Изменение полей версора на константные / Making versor's fields constant
This commit is contained in:
parent
e7616ae80c
commit
23fcdc2c28
10 changed files with 423 additions and 425 deletions
|
|
@ -2,5 +2,4 @@
|
|||
<CodeBlocks_workspace_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveProject path="dev/geometry-dev.cbp" />
|
||||
<PreferredTarget name="Release" />
|
||||
</CodeBlocks_workspace_layout_file>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# depslib dependency file v1.0
|
||||
1731995770 source:/home/andrey/Projects/Private/C/Geometry/dev/main.c
|
||||
1732169779 source:/home/andrey/Projects/Private/C/Geometry/dev/main.c
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
<math.h>
|
||||
|
|
@ -21,18 +21,18 @@
|
|||
"quaternion.h"
|
||||
"versor.h"
|
||||
|
||||
1730476002 /home/andrey/Projects/Private/C/Geometry/src/basis.h
|
||||
1732094620 /home/andrey/Projects/Private/C/Geometry/src/basis.h
|
||||
|
||||
1730392488 /home/andrey/Projects/Private/C/Geometry/src/angle.h
|
||||
1732096335 /home/andrey/Projects/Private/C/Geometry/src/angle.h
|
||||
<math.h>
|
||||
"basis.h"
|
||||
|
||||
1731673023 /home/andrey/Projects/Private/C/Geometry/src/vector2.h
|
||||
1732095049 /home/andrey/Projects/Private/C/Geometry/src/vector2.h
|
||||
"basis.h"
|
||||
"angle.h"
|
||||
<math.h>
|
||||
|
||||
1731673331 /home/andrey/Projects/Private/C/Geometry/src/vector3.h
|
||||
1732095097 /home/andrey/Projects/Private/C/Geometry/src/vector3.h
|
||||
"basis.h"
|
||||
"angle.h"
|
||||
<math.h>
|
||||
|
|
@ -42,12 +42,12 @@
|
|||
"angle.h"
|
||||
<math.h>
|
||||
|
||||
1731673308 /home/andrey/Projects/Private/C/Geometry/src/matrix2x2.h
|
||||
1732095748 /home/andrey/Projects/Private/C/Geometry/src/matrix2x2.h
|
||||
"angle.h"
|
||||
"vector2.h"
|
||||
"matrixes.h"
|
||||
|
||||
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrix3x3.h
|
||||
1732095414 /home/andrey/Projects/Private/C/Geometry/src/matrix3x3.h
|
||||
"vector3.h"
|
||||
"matrixes.h"
|
||||
|
||||
|
|
@ -61,12 +61,12 @@
|
|||
"vector2.h"
|
||||
"matrix2x2.h"
|
||||
|
||||
1730355414 /home/andrey/Projects/Private/C/Geometry/src/rotation3.h
|
||||
1732095748 /home/andrey/Projects/Private/C/Geometry/src/rotation3.h
|
||||
"basis.h"
|
||||
"angle.h"
|
||||
"vector3.h"
|
||||
|
||||
1731995858 /home/andrey/Projects/Private/C/Geometry/src/versor.h
|
||||
1732169837 /home/andrey/Projects/Private/C/Geometry/src/versor.h
|
||||
<stdint.h>
|
||||
"basis.h"
|
||||
"vector3.h"
|
||||
|
|
@ -107,19 +107,19 @@
|
|||
"versor.h"
|
||||
"affine_map3.h"
|
||||
|
||||
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrixes.h
|
||||
1732094620 /home/andrey/Projects/Private/C/Geometry/src/matrixes.h
|
||||
|
||||
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrix2x3.h
|
||||
1732095530 /home/andrey/Projects/Private/C/Geometry/src/matrix2x3.h
|
||||
"vector2.h"
|
||||
"vector3.h"
|
||||
"matrixes.h"
|
||||
|
||||
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrix3x2.h
|
||||
1732095530 /home/andrey/Projects/Private/C/Geometry/src/matrix3x2.h
|
||||
"vector2.h"
|
||||
"vector3.h"
|
||||
"matrixes.h"
|
||||
|
||||
1731407834 /home/andrey/Projects/Private/C/Geometry/src/quaternion.h
|
||||
1732095234 /home/andrey/Projects/Private/C/Geometry/src/quaternion.h
|
||||
<math.h>
|
||||
"basis.h"
|
||||
"matrix3x3.h"
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Release" />
|
||||
<File name="main.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3793" topLine="116" />
|
||||
<Cursor1 position="1168" topLine="46" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ BgFP32Versor * make_random_versors(const unsigned int amount)
|
|||
|
||||
void print_versor(const BgFP32Versor* versor)
|
||||
{
|
||||
printf("(%f, %f, %f, %f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
|
||||
printf("(%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
||||
}
|
||||
|
||||
void print_vector(const BgFP32Vector3* vector)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,29 @@
|
|||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="matrix2x3.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="geometry.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1596" topLine="0" />
|
||||
<Cursor1 position="316" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="128" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1765" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix2x2.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2008" topLine="63" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix3x3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4343" topLine="67" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="angle.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
|
|
@ -12,49 +32,9 @@
|
|||
<Cursor1 position="0" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="quaternion.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="matrixes.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1849" topLine="187" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix2x2.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="24" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix2x2.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="13404" topLine="440" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector2.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="556" topLine="12" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector2.c" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="24" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="versor.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="504" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="154" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="versor.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="27" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="basis.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="103" topLine="0" />
|
||||
<Cursor1 position="4418" topLine="54" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="basis.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
|
|
@ -62,49 +42,79 @@
|
|||
<Cursor1 position="20" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector3.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="quaternion.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4195" topLine="122" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector2.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1765" topLine="17" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="angle.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1082" topLine="0" />
|
||||
<Cursor1 position="12295" topLine="509" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix3x2.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="897" topLine="52" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="quaternion.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6789" topLine="145" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix3x3.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="17612" topLine="537" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="geometry.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="316" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector3.h" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="15169" topLine="102" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="305" topLine="29" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix3x3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="23" topLine="72" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector3.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="matrix2x2.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="24" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="versor.h" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3483" topLine="119" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix3x2.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2291" topLine="280" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="vector2.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2044" topLine="216" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="versor.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1316" topLine="90" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix3x3.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="99" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2552" topLine="44" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="basis.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1382" topLine="6" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrix2x3.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2817" topLine="324" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="quaternion.c" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1596" topLine="2" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="matrixes.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="11981" topLine="205" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// ============ Make Rotation Matrix ============ //
|
||||
|
||||
void bg_fp32_quaternion_make_rotation_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix)
|
||||
void bg_fp32_quaternion_get_rotation_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix)
|
||||
{
|
||||
const float s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const float x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -40,7 +40,7 @@ void bg_fp32_quaternion_make_rotation_matrix(const BgFP32Quaternion* quaternion,
|
|||
matrix->r1c3 = corrector2 * (x1x3 + s0x2);
|
||||
}
|
||||
|
||||
void bg_fp64_quaternion_make_rotation_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix)
|
||||
void bg_fp64_quaternion_get_rotation_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix)
|
||||
{
|
||||
const double s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const double x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -80,7 +80,7 @@ void bg_fp64_quaternion_make_rotation_matrix(const BgFP64Quaternion* quaternion,
|
|||
|
||||
// ============ Make Reverse Matrix ============= //
|
||||
|
||||
void bg_fp32_quaternion_make_reverse_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix)
|
||||
void bg_fp32_quaternion_get_reverse_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix)
|
||||
{
|
||||
const float s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const float x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -118,7 +118,7 @@ void bg_fp32_quaternion_make_reverse_matrix(const BgFP32Quaternion* quaternion,
|
|||
matrix->r1c3 = corrector2 * (x1x3 - s0x2);
|
||||
}
|
||||
|
||||
void bg_fp64_quaternion_make_reverse_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix)
|
||||
void bg_fp64_quaternion_get_reverse_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix)
|
||||
{
|
||||
const double s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const double x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
|
|||
|
|
@ -158,15 +158,15 @@ static inline void bg_fp64_quaternion_set_conjugate_fp32(const BgFP32Quaternion*
|
|||
|
||||
// ============ Make Rotation Matrix ============ //
|
||||
|
||||
void bg_fp32_quaternion_make_rotation_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix);
|
||||
void bg_fp32_quaternion_get_rotation_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix);
|
||||
|
||||
void bg_fp64_quaternion_make_rotation_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix);
|
||||
void bg_fp64_quaternion_get_rotation_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix);
|
||||
|
||||
// ============ Make Reverse Matrix ============= //
|
||||
|
||||
void bg_fp32_quaternion_make_reverse_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix);
|
||||
void bg_fp32_quaternion_get_reverse_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix);
|
||||
|
||||
void bg_fp64_quaternion_make_reverse_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix);
|
||||
void bg_fp64_quaternion_get_reverse_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix);
|
||||
|
||||
// ==================== Add ===================== //
|
||||
|
||||
|
|
|
|||
92
src/versor.c
92
src/versor.c
|
|
@ -7,51 +7,45 @@ const BgFP32Versor BG_FP32_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|||
|
||||
const BgFP64Versor BG_FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 };
|
||||
|
||||
void __bg_fp32_versor_normalize(const float square_module, BgFP32Versor* versor)
|
||||
void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwin* twin)
|
||||
{
|
||||
if (square_module <= BG_FP32_SQUARE_EPSYLON) {
|
||||
bg_fp32_versor_reset(versor);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3) <= BG_FP32_SQUARE_EPSYLON * square_module) {
|
||||
bg_fp32_versor_reset(versor);
|
||||