Добавление функций восстановления позиции в трёхмерном пространстве (position3) по аффинному преобрезованию (affine3); небольшие исправления в документации, а также переименование некоторых переменных
This commit is contained in:
parent
39352af3f9
commit
178e004e3f
5 changed files with 122 additions and 68 deletions
|
|
@ -303,64 +303,64 @@ int bgc_fp32_quaternion_set_rotation_matrix(BGC_FP32_Quaternion* const quaternio
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
const float ss_4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
||||
const float xx_4 = (1 + matrix->r1c1) - (matrix->r2c2 + matrix->r3c3);
|
||||
const float yy_4 = (1 + matrix->r2c2) - (matrix->r1c1 + matrix->r3c3);
|
||||
const float zz_4 = (1 + matrix->r3c3) - (matrix->r1c1 + matrix->r2c2);
|
||||
const float ss4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
||||
const float xx4 = (1 + matrix->r1c1) - (matrix->r2c2 + matrix->r3c3);
|
||||
const float yy4 = (1 + matrix->r2c2) - (matrix->r1c1 + matrix->r3c3);
|
||||
const float zz4 = (1 + matrix->r3c3) - (matrix->r1c1 + matrix->r2c2);
|
||||
|
||||
const float sx_4 = matrix->r3c2 - matrix->r2c3;
|
||||
const float sy_4 = matrix->r1c3 - matrix->r3c1;
|
||||
const float sz_4 = matrix->r2c1 - matrix->r1c2;
|
||||
const float sx4 = matrix->r3c2 - matrix->r2c3;
|
||||
const float sy4 = matrix->r1c3 - matrix->r3c1;
|
||||
const float sz4 = matrix->r2c1 - matrix->r1c2;
|
||||
|
||||
const float yz_4 = matrix->r3c2 + matrix->r2c3;
|
||||
const float xz_4 = matrix->r1c3 + matrix->r3c1;
|
||||
const float xy_4 = matrix->r2c1 + matrix->r1c2;
|
||||
const float yz4 = matrix->r3c2 + matrix->r2c3;
|
||||
const float xz4 = matrix->r1c3 + matrix->r3c1;
|
||||
const float xy4 = matrix->r2c1 + matrix->r1c2;
|
||||
|
||||
float max = ss_4;
|
||||
float max = ss4;
|
||||
int index = 0;
|
||||
|
||||
if (xx_4 > max) {
|
||||
max = xx_4;
|
||||
if (xx4 > max) {
|
||||
max = xx4;
|
||||
index = 1;
|
||||
}
|
||||
|
||||
if (yy_4 > max) {
|
||||
max = yy_4;
|
||||
if (yy4 > max) {
|
||||
max = yy4;
|
||||
index = 2;
|
||||
}
|
||||
|
||||
if (zz_4 > max) {
|
||||
max = zz_4;
|
||||
if (zz4 > max) {
|
||||
max = zz4;
|
||||
index = 3;
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
quaternion->s = ss_4;
|
||||
quaternion->x = sx_4;
|
||||
quaternion->y = sy_4;
|
||||
quaternion->z = sz_4;
|
||||
quaternion->s = ss4;
|
||||
quaternion->x = sx4;
|
||||
quaternion->y = sy4;
|
||||
quaternion->z = sz4;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
quaternion->s = sx_4;
|
||||
quaternion->x = xx_4;
|
||||
quaternion->y = xy_4;
|
||||
quaternion->z = xz_4;
|
||||
quaternion->s = sx4;
|
||||
quaternion->x = xx4;
|
||||
quaternion->y = xy4;
|
||||
quaternion->z = xz4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
quaternion->s = sy_4;
|
||||
quaternion->x = xy_4;
|
||||
quaternion->y = yy_4;
|
||||
quaternion->z = yz_4;
|
||||
quaternion->s = sy4;
|
||||
quaternion->x = xy4;
|
||||
quaternion->y = yy4;
|
||||
quaternion->z = yz4;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
quaternion->s = sz_4;
|
||||
quaternion->x = xz_4;
|
||||
quaternion->y = yz_4;
|
||||
quaternion->z = zz_4;
|
||||
quaternion->s = sz4;
|
||||
quaternion->x = xz4;
|
||||
quaternion->y = yz4;
|
||||
quaternion->z = zz4;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -387,64 +387,64 @@ int bgc_fp64_quaternion_set_rotation_matrix(BGC_FP64_Quaternion* const quaternio
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
const double ss_4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
||||
const double xx_4 = (1 + matrix->r1c1) - (matrix->r2c2 - matrix->r3c3);
|
||||
const double yy_4 = (1 + matrix->r2c2) - (matrix->r1c1 - matrix->r3c3);
|
||||
const double zz_4 = (1 + matrix->r3c3) - (matrix->r1c1 - matrix->r2c2);
|
||||
const double ss4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
||||
const double xx4 = (1 + matrix->r1c1) - (matrix->r2c2 - matrix->r3c3);
|
||||
const double yy4 = (1 + matrix->r2c2) - (matrix->r1c1 - matrix->r3c3);
|
||||
const double zz4 = (1 + matrix->r3c3) - (matrix->r1c1 - matrix->r2c2);
|
||||
|
||||
const double sx_4 = matrix->r3c2 - matrix->r2c3;
|
||||
const double sy_4 = matrix->r1c3 - matrix->r3c1;
|
||||
const double sz_4 = matrix->r2c1 - matrix->r1c2;
|
||||
const double sx4 = matrix->r3c2 - matrix->r2c3;
|
||||
const double sy4 = matrix->r1c3 - matrix->r3c1;
|
||||
const double sz4 = matrix->r2c1 - matrix->r1c2;
|
||||
|
||||
const double yz_4 = matrix->r3c2 + matrix->r2c3;
|
||||
const double xz_4 = matrix->r1c3 + matrix->r3c1;
|
||||
const double xy_4 = matrix->r2c1 + matrix->r1c2;
|
||||
const double yz4 = matrix->r3c2 + matrix->r2c3;
|
||||
const double xz4 = matrix->r1c3 + matrix->r3c1;
|
||||
const double xy4 = matrix->r2c1 + matrix->r1c2;
|
||||
|
||||
double max = ss_4;
|
||||
double max = ss4;
|
||||
int index = 0;
|
||||
|
||||
if (xx_4 > max) {
|
||||
max = xx_4;
|
||||
if (xx4 > max) {
|
||||
max = xx4;
|
||||
index = 1;
|
||||
}
|
||||
|
||||
if (yy_4 > max) {
|
||||
max = yy_4;
|
||||
if (yy4 > max) {
|
||||
max = yy4;
|
||||
index = 2;
|
||||
}
|
||||
|
||||
if (zz_4 > max) {
|
||||
max = zz_4;
|
||||
if (zz4 > max) {
|
||||
max = zz4;
|
||||
index = 3;
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
quaternion->s = ss_4;
|
||||
quaternion->x = sx_4;
|
||||
quaternion->y = sy_4;
|
||||
quaternion->z = sz_4;
|
||||
quaternion->s = ss4;
|
||||
quaternion->x = sx4;
|
||||
quaternion->y = sy4;
|
||||
quaternion->z = sz4;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
quaternion->s = sx_4;
|
||||
quaternion->x = xx_4;
|
||||
quaternion->y = xy_4;
|
||||
quaternion->z = xz_4;
|
||||
quaternion->s = sx4;
|
||||
quaternion->x = xx4;
|
||||
quaternion->y = xy4;
|
||||
quaternion->z = xz4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
quaternion->s = sy_4;
|
||||
quaternion->x = xy_4;
|
||||
quaternion->y = yy_4;
|
||||
quaternion->z = yz_4;
|
||||
quaternion->s = sy4;
|
||||
quaternion->x = xy4;
|
||||
quaternion->y = yy4;
|
||||
quaternion->z = yz4;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
quaternion->s = sz_4;
|
||||
quaternion->x = xz_4;
|
||||
quaternion->y = yz_4;
|
||||
quaternion->z = zz_4;
|
||||
quaternion->s = sz4;
|
||||
quaternion->x = xz4;
|
||||
quaternion->y = yz4;
|
||||
quaternion->z = zz4;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue