Отказ от функций GetWeightedSum в пользу AppendScaled; оптимизация версоров / Replacing of GetWeightedSum onto AppendScaled; versor optimization

This commit is contained in:
Andrey Pokidov 2024-11-20 01:33:05 +07:00
parent c3dc0b2ecd
commit c66edd3432
14 changed files with 142 additions and 548 deletions

View file

@ -278,14 +278,24 @@ namespace BGC
public static void Combine(in F64Versor second, in F64Versor first, out F64Versor result)
{
LoadValues(
(second.s0 * first.s0 - second.x1 * first.x1) - (second.x2 * first.x2 + second.x3 * first.x3),
(second.x1 * first.s0 + second.s0 * first.x1) - (second.x3 * first.x2 - second.x2 * first.x3),
(second.x2 * first.s0 + second.s0 * first.x2) - (second.x1 * first.x3 - second.x3 * first.x1),
(second.x3 * first.s0 + second.s0 * first.x3) - (second.x2 * first.x1 - second.x1 * first.x2),
out result);
double s0 = (second.s0 * first.s0 - second.x1 * first.x1) - (second.x2 * first.x2 + second.x3 * first.x3);
double x1 = (second.x1 * first.s0 + second.s0 * first.x1) - (second.x3 * first.x2 - second.x2 * first.x3);
double x2 = (second.x2 * first.s0 + second.s0 * first.x2) - (second.x1 * first.x3 - second.x3 * first.x1);
double x3 = (second.x3 * first.s0 + second.s0 * first.x3) - (second.x2 * first.x1 - second.x1 * first.x2);
double squareModule = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
result.s0 = s0;
result.x1 = x1;
result.x2 = x2;
result.x3 = x3;
if (squareModule < 1.0 - F64Utility.TWO_EPSYLON || 1.0 + F64Utility.TWO_EPSYLON < squareModule)
{
result.Normalize(squareModule);
}
}
public static void LoadIdle(out F64Versor versor)
{
versor.s0 = 1.0;