Небольшие исправления, а также добавление гомогенного трёхмерного вектора
This commit is contained in:
parent
03627f4401
commit
043cc72c81
25 changed files with 1686 additions and 1644 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<CodeBlocks_workspace_file>
|
<CodeBlocks_workspace_file>
|
||||||
<Workspace title="Workspace">
|
<Workspace title="Workspace">
|
||||||
|
<Project filename="basic-geometry/basic-geometry.cbp" />
|
||||||
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
|
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
|
||||||
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
||||||
</Project>
|
</Project>
|
||||||
<Project filename="basic-geometry-test/basic-geometry-test.cbp">
|
<Project filename="basic-geometry-test/basic-geometry-test.cbp">
|
||||||
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
||||||
</Project>
|
</Project>
|
||||||
<Project filename="basic-geometry/basic-geometry.cbp" />
|
|
||||||
</Workspace>
|
</Workspace>
|
||||||
</CodeBlocks_workspace_file>
|
</CodeBlocks_workspace_file>
|
||||||
|
|
|
||||||
|
|
@ -51,186 +51,6 @@
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="main.h" />
|
<Unit filename="main.h" />
|
||||||
<Unit filename="test_utilities.h" />
|
<Unit filename="test_utilities.h" />
|
||||||
<Unit filename="tests/complex.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex.h" />
|
|
||||||
<Unit filename="tests/complex/complex_copy.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_copy.h" />
|
|
||||||
<Unit filename="tests/complex/complex_is_unit.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_is_unit.h" />
|
|
||||||
<Unit filename="tests/complex/complex_is_zero.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_is_zero.h" />
|
|
||||||
<Unit filename="tests/complex/complex_modulus.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_modulus.h" />
|
|
||||||
<Unit filename="tests/complex/complex_reset.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_reset.h" />
|
|
||||||
<Unit filename="tests/complex/complex_set_values.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_set_values.h" />
|
|
||||||
<Unit filename="tests/complex/complex_swap.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_swap.h" />
|
|
||||||
<Unit filename="tests/quaternion.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_copy.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_copy.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_is_unit.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_is_unit.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_is_zero.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_is_zero.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_modulus.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_modulus.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_reset.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_reset.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_set_to_identity.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_set_to_identity.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_set_values.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_set_values.h" />
|
|
||||||
<Unit filename="tests/quaternion/quaternion_swap.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/quaternion/quaternion_swap.h" />
|
|
||||||
<Unit filename="tests/utilities.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/utilities.h" />
|
|
||||||
<Unit filename="tests/utilities/are_close.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/utilities/are_close.h" />
|
|
||||||
<Unit filename="tests/utilities/is_unit.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/utilities/is_unit.h" />
|
|
||||||
<Unit filename="tests/utilities/is_zero.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/utilities/is_zero.h" />
|
|
||||||
<Unit filename="tests/vector2.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2.h" />
|
|
||||||
<Unit filename="tests/vector2/vector2_copy.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2/vector2_copy.h" />
|
|
||||||
<Unit filename="tests/vector2/vector2_is_unit.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2/vector2_is_unit.h" />
|
|
||||||
<Unit filename="tests/vector2/vector2_is_zero.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2/vector2_is_zero.h" />
|
|
||||||
<Unit filename="tests/vector2/vector2_modulus.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2/vector2_modulus.h" />
|
|
||||||
<Unit filename="tests/vector2/vector2_reset.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2/vector2_reset.h" />
|
|
||||||
<Unit filename="tests/vector2/vector2_set_values.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2/vector2_set_values.h" />
|
|
||||||
<Unit filename="tests/vector2/vector2_swap.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector2/vector2_swap.h" />
|
|
||||||
<Unit filename="tests/vector3.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3.h" />
|
|
||||||
<Unit filename="tests/vector3/vector3_copy.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3/vector3_copy.h" />
|
|
||||||
<Unit filename="tests/vector3/vector3_is_unit.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3/vector3_is_unit.h" />
|
|
||||||
<Unit filename="tests/vector3/vector3_is_zero.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3/vector3_is_zero.h" />
|
|
||||||
<Unit filename="tests/vector3/vector3_modulus.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3/vector3_modulus.h" />
|
|
||||||
<Unit filename="tests/vector3/vector3_reset.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3/vector3_reset.h" />
|
|
||||||
<Unit filename="tests/vector3/vector3_set_values.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3/vector3_set_values.h" />
|
|
||||||
<Unit filename="tests/vector3/vector3_swap.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/vector3/vector3_swap.h" />
|
|
||||||
<Unit filename="tests/versor.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor.h" />
|
|
||||||
<Unit filename="tests/versor/versor_are_close.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor/versor_are_close.h" />
|
|
||||||
<Unit filename="tests/versor/versor_combine.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor/versor_combine.h" />
|
|
||||||
<Unit filename="tests/versor/versor_copy.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor/versor_copy.h" />
|
|
||||||
<Unit filename="tests/versor/versor_is_identity.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor/versor_is_identity.h" />
|
|
||||||
<Unit filename="tests/versor/versor_reset.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor/versor_reset.h" />
|
|
||||||
<Unit filename="tests/versor/versor_set_values.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor/versor_set_values.h" />
|
|
||||||
<Unit filename="tests/versor/versor_swap.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/versor/versor_swap.h" />
|
|
||||||
<Unit filename="unity/unity.c">
|
<Unit filename="unity/unity.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,14 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="cotes-number.h" />
|
<Unit filename="cotes-number.h" />
|
||||||
|
<Unit filename="hg-vector3.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="hg-vector3.h" />
|
||||||
|
<Unit filename="matrices.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="matrices.h" />
|
||||||
<Unit filename="matrix2x2.c">
|
<Unit filename="matrix2x2.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
@ -80,10 +88,6 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="matrix3x3.h" />
|
<Unit filename="matrix3x3.h" />
|
||||||
<Unit filename="matrixes.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="matrixes.h" />
|
|
||||||
<Unit filename="position2.c">
|
<Unit filename="position2.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ void bgc_fp32_complex_get_exponation(BGC_FP32_Complex* power, const BGC_FP32_Com
|
||||||
{
|
{
|
||||||
const float square_modulus = bgc_fp32_complex_get_square_modulus(base);
|
const float square_modulus = bgc_fp32_complex_get_square_modulus(base);
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
|
if (square_modulus <= BGC_FP32_SQUARE_EPSILON) {
|
||||||
power->real = 0.0f;
|
power->real = 0.0f;
|
||||||
power->imaginary = 0.0f;
|
power->imaginary = 0.0f;
|
||||||
return;
|
return;
|
||||||
|
|
@ -110,7 +110,7 @@ void bgc_fp64_complex_get_exponation(BGC_FP64_Complex* power, const BGC_FP64_Com
|
||||||
{
|
{
|
||||||
const double square_modulus = bgc_fp64_complex_get_square_modulus(base);
|
const double square_modulus = bgc_fp64_complex_get_square_modulus(base);
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
|
if (square_modulus <= BGC_FP64_SQUARE_EPSILON) {
|
||||||
power->real = 0.0;
|
power->real = 0.0;
|
||||||
power->imaginary = 0.0;
|
power->imaginary = 0.0;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,12 @@ inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number)
|
||||||
|
|
||||||
inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number)
|
inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number)
|
||||||
{
|
{
|
||||||
return bgc_fp32_complex_get_square_modulus(number) <= BGC_FP32_SQUARE_EPSYLON;
|
return bgc_fp32_complex_get_square_modulus(number) <= BGC_FP32_SQUARE_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number)
|
inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number)
|
||||||
{
|
{
|
||||||
return bgc_fp64_complex_get_square_modulus(number) <= BGC_FP64_SQUARE_EPSYLON;
|
return bgc_fp64_complex_get_square_modulus(number) <= BGC_FP64_SQUARE_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number)
|
inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number)
|
||||||
|
|
@ -178,7 +178,7 @@ inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,7 +220,7 @@ inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const B
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
normalized->real = 0.0f;
|
normalized->real = 0.0f;
|
||||||
normalized->imaginary = 0.0f;
|
normalized->imaginary = 0.0f;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -244,7 +244,7 @@ inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const B
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
normalized->real = 0.0;
|
normalized->real = 0.0;
|
||||||
normalized->imaginary = 0.0;
|
normalized->imaginary = 0.0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -288,7 +288,7 @@ inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP3
|
||||||
{
|
{
|
||||||
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
|
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -304,7 +304,7 @@ inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP6
|
||||||
{
|
{
|
||||||
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
|
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,7 +368,7 @@ inline void bgc_fp32_complex_subtract(BGC_FP32_Complex* difference, const BGC_FP
|
||||||
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
|
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference)
|
inline void bgc_fp64_complex_subtract(BGC_FP64_Complex* difference, const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend)
|
||||||
{
|
{
|
||||||
difference->real = minuend->real - subtrahend->real;
|
difference->real = minuend->real - subtrahend->real;
|
||||||
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
|
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
|
||||||
|
|
@ -414,7 +414,7 @@ inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32
|
||||||
{
|
{
|
||||||
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
|
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
|
if (square_modulus <= BGC_FP32_SQUARE_EPSILON) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -433,7 +433,7 @@ inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64
|
||||||
{
|
{
|
||||||
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
|
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
|
if (square_modulus <= BGC_FP64_SQUARE_EPSILON) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -518,11 +518,11 @@ inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC
|
||||||
|
|
||||||
const float square_distance = d_real * d_real + d_imaginary * d_imaginary;
|
const float square_distance = d_real * d_real + d_imaginary * d_imaginary;
|
||||||
|
|
||||||
if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
|
if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) {
|
||||||
return square_distance <= BGC_FP32_SQUARE_EPSYLON;
|
return square_distance <= BGC_FP32_SQUARE_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
|
return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
|
inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
|
||||||
|
|
@ -535,11 +535,11 @@ inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC
|
||||||
|
|
||||||
const double square_distance = d_real * d_real + d_imaginary * d_imaginary;
|
const double square_distance = d_real * d_real + d_imaginary * d_imaginary;
|
||||||
|
|
||||||
if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
|
if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) {
|
||||||
return square_distance <= BGC_FP64_SQUARE_EPSYLON;
|
return square_distance <= BGC_FP64_SQUARE_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
|
return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ void _bgc_fp32_cotes_number_normalize(BGC_FP32_CotesNumber* number)
|
||||||
{
|
{
|
||||||
const float square_modulus = number->_cos * number->_cos + number->_sin * number->_sin;
|
const float square_modulus = number->_cos * number->_cos + number->_sin * number->_sin;
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
number->_cos = 1.0f;
|
number->_cos = 1.0f;
|
||||||
number->_sin = 0.0f;
|
number->_sin = 0.0f;
|
||||||
return;
|
return;
|
||||||
|
|
@ -78,7 +78,7 @@ void _bgc_fp64_cotes_number_normalize(BGC_FP64_CotesNumber* number)
|
||||||
{
|
{
|
||||||
const double square_modulus = number->_cos * number->_cos + number->_sin * number->_sin;
|
const double square_modulus = number->_cos * number->_cos + number->_sin * number->_sin;
|
||||||
|
|
||||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||||
number->_cos = 1.0;
|
number->_cos = 1.0;
|
||||||
number->_sin = 0.0;
|
number->_sin = 0.0;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -250,36 +250,36 @@ inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, cons
|
||||||
|
|
||||||
inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = number->_cos;
|
matrix->row1_col1 = number->_cos;
|
||||||
matrix->r1c2 = -number->_sin;
|
matrix->row1_col2 = -number->_sin;
|
||||||
matrix->r2c1 = number->_sin;
|
matrix->row2_col1 = number->_sin;
|
||||||
matrix->r2c2 = number->_cos;
|
matrix->row2_col2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = number->_cos;
|
matrix->row1_col1 = number->_cos;
|
||||||
matrix->r1c2 = -number->_sin;
|
matrix->row1_col2 = -number->_sin;
|
||||||
matrix->r2c1 = number->_sin;
|
matrix->row2_col1 = number->_sin;
|
||||||
matrix->r2c2 = number->_cos;
|
matrix->row2_col2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============== Reverse Matrix ================ //
|
// ============== Reverse Matrix ================ //
|
||||||
|
|
||||||
inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = number->_cos;
|
matrix->row1_col1 = number->_cos;
|
||||||
matrix->r1c2 = number->_sin;
|
matrix->row1_col2 = number->_sin;
|
||||||
matrix->r2c1 = -number->_sin;
|
matrix->row2_col1 = -number->_sin;
|
||||||
matrix->r2c2 = number->_cos;
|
matrix->row2_col2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = number->_cos;
|
matrix->row1_col1 = number->_cos;
|
||||||
matrix->r1c2 = number->_sin;
|
matrix->row1_col2 = number->_sin;
|
||||||
matrix->r2c1 = -number->_sin;
|
matrix->row2_col1 = -number->_sin;
|
||||||
matrix->r2c2 = number->_cos;
|
matrix->row2_col2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Turn Vector ================= //
|
// ================ Turn Vector ================= //
|
||||||
|
|
@ -329,7 +329,7 @@ inline int bgc_fp32_cotes_number_are_close(const BGC_FP32_CotesNumber* number1,
|
||||||
const float d_cos = number1->_cos - number2->_cos;
|
const float d_cos = number1->_cos - number2->_cos;
|
||||||
const float d_sin = number1->_sin - number2->_sin;
|
const float d_sin = number1->_sin - number2->_sin;
|
||||||
|
|
||||||
return d_cos * d_cos + d_sin * d_sin <= BGC_FP32_SQUARE_EPSYLON;
|
return d_cos * d_cos + d_sin * d_sin <= BGC_FP32_SQUARE_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2)
|
inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2)
|
||||||
|
|
@ -337,7 +337,7 @@ inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1,
|
||||||
const double d_cos = number1->_cos - number2->_cos;
|
const double d_cos = number1->_cos - number2->_cos;
|
||||||
const double d_sin = number1->_sin - number2->_sin;
|
const double d_sin = number1->_sin - number2->_sin;
|
||||||
|
|
||||||
return d_cos * d_cos + d_sin * d_sin <= BGC_FP64_SQUARE_EPSYLON;
|
return d_cos * d_cos + d_sin * d_sin <= BGC_FP64_SQUARE_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
28
basic-geometry/hg-vector3.c
Normal file
28
basic-geometry/hg-vector3.c
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "./hg-vector3.h"
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_hg_vector3_reset_point(BGC_FP32_HgVector3* homogeneous_vector);
|
||||||
|
extern inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vector);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_hg_vector3_reset_vector(BGC_FP32_HgVector3* homogeneous_vector);
|
||||||
|
extern inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vector);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float ratio);
|
||||||
|
extern inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double ratio);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_hg_vector3_make_point(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector);
|
||||||
|
extern inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_hg_vector3_make_vector(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector);
|
||||||
|
extern inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector);
|
||||||
|
|
||||||
|
extern inline int bgc_fp32_hg_vector3_is_point(const BGC_FP32_HgVector3* homogeneous_vector);
|
||||||
|
extern inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector);
|
||||||
|
|
||||||
|
extern inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector);
|
||||||
|
extern inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_hg_vector3_copy(BGC_FP32_HgVector3* destination, const BGC_FP32_HgVector3* source);
|
||||||
|
extern inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_FP64_HgVector3* source);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_hg_vector3_swap(BGC_FP32_HgVector3* first, BGC_FP32_HgVector3* second);
|
||||||
|
extern inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVector3* second);
|
||||||
190
basic-geometry/hg-vector3.h
Normal file
190
basic-geometry/hg-vector3.h
Normal file
|
|
@ -0,0 +1,190 @@
|
||||||
|
#ifndef _BGC_HG_VECTOR3_H_INCLUDED_
|
||||||
|
#define _BGC_HG_VECTOR3_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "./vector3.h"
|
||||||
|
|
||||||
|
// ================== Vector3 =================== //
|
||||||
|
|
||||||
|
// Homogeneous 3D Vector
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
float x1, x2, x3, ratio;
|
||||||
|
} BGC_FP32_HgVector3;
|
||||||
|
|
||||||
|
// Homogeneous 3D Vector
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
double x1, x2, x3, ratio;
|
||||||
|
} BGC_FP64_HgVector3;
|
||||||
|
|
||||||
|
// ================ Reset Point ================= //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_vector3_reset_point(BGC_FP32_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = 0.0f;
|
||||||
|
homogeneous_vector->x2 = 0.0f;
|
||||||
|
homogeneous_vector->x3 = 0.0f;
|
||||||
|
homogeneous_vector->ratio = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = 0.0;
|
||||||
|
homogeneous_vector->x2 = 0.0;
|
||||||
|
homogeneous_vector->x3 = 0.0;
|
||||||
|
homogeneous_vector->ratio = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Reset Point ================= //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_vector3_reset_vector(BGC_FP32_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = 0.0f;
|
||||||
|
homogeneous_vector->x2 = 0.0f;
|
||||||
|
homogeneous_vector->x3 = 0.0f;
|
||||||
|
homogeneous_vector->ratio = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = 0.0;
|
||||||
|
homogeneous_vector->x2 = 0.0;
|
||||||
|
homogeneous_vector->x3 = 0.0;
|
||||||
|
homogeneous_vector->ratio = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Make ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float ratio)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = x1;
|
||||||
|
homogeneous_vector->x2 = x2;
|
||||||
|
homogeneous_vector->x3 = x3;
|
||||||
|
homogeneous_vector->ratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double ratio)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = x1;
|
||||||
|
homogeneous_vector->x2 = x2;
|
||||||
|
homogeneous_vector->x3 = x3;
|
||||||
|
homogeneous_vector->ratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Make Point ================= //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_vector3_make_point(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
|
homogeneous_vector->ratio = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
|
homogeneous_vector->ratio = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Make Vector ================= //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_vector3_make_vector(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
|
homogeneous_vector->ratio = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
|
||||||
|
{
|
||||||
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
|
homogeneous_vector->ratio = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Is Point ================== //
|
||||||
|
|
||||||
|
inline int bgc_fp32_hg_vector3_is_point(const BGC_FP32_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
return !bgc_fp32_is_zero(homogeneous_vector->ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
return !bgc_fp64_is_zero(homogeneous_vector->ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Is Vector ================== //
|
||||||
|
|
||||||
|
inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
return bgc_fp32_is_zero(homogeneous_vector->ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
|
{
|
||||||
|
return bgc_fp64_is_zero(homogeneous_vector->ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_vector3_copy(BGC_FP32_HgVector3* destination, const BGC_FP32_HgVector3* source)
|
||||||
|
{
|
||||||
|
destination->x1 = source->x1;
|
||||||
|
destination->x2 = source->x2;
|
||||||
|
destination->x3 = source->x3;
|
||||||
|
destination->ratio = source->ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_FP64_HgVector3* source)
|
||||||
|
{
|
||||||
|
destination->x1 = source->x1;
|
||||||
|
destination->x2 = source->x2;
|
||||||
|
destination->x3 = source->x3;
|
||||||
|
destination->ratio = source->ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_vector3_swap(BGC_FP32_HgVector3* first, BGC_FP32_HgVector3* second)
|
||||||
|
{
|
||||||
|
const float x1 = first->x1;
|
||||||
|
const float x2 = first->x2;
|
||||||
|
const float x3 = first->x3;
|
||||||
|
const float ratio = first->ratio;
|
||||||
|
|
||||||
|
first->x1 = second->x1;
|
||||||
|
first->x2 = second->x2;
|
||||||
|
first->x3 = second->x3;
|
||||||
|
first->ratio = second->ratio;
|
||||||
|
|
||||||
|
second->x1 = x1;
|
||||||
|
second->x2 = x2;
|
||||||
|
second->x3 = x3;
|
||||||
|
second->ratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVector3* second)
|
||||||
|
{
|
||||||
|
const double x1 = first->x1;
|
||||||
|
const double x2 = first->x2;
|
||||||
|
const double x3 = first->x3;
|
||||||
|
const double ratio = first->ratio;
|
||||||
|
|
||||||
|
first->x1 = second->x1;
|
||||||
|
first->x2 = second->x2;
|
||||||
|
first->x3 = second->x3;
|
||||||
|
first->ratio = second->ratio;
|
||||||
|
|
||||||
|
second->x1 = x1;
|
||||||
|
second->x2 = x2;
|
||||||
|
second->x3 = x3;
|
||||||
|
second->ratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -4,361 +4,361 @@
|
||||||
// ================== Matrix2x2 ================= //
|
// ================== Matrix2x2 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float r1c1, r1c2;
|
float row1_col1, row1_col2;
|
||||||
float r2c1, r2c2;
|
float row2_col1, row2_col2;
|
||||||
} BGC_FP32_Matrix2x2;
|
} BGC_FP32_Matrix2x2;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2;
|
double row1_col1, row1_col2;
|
||||||
double r2c1, r2c2;
|
double row2_col1, row2_col2;
|
||||||
} BGC_FP64_Matrix2x2;
|
} BGC_FP64_Matrix2x2;
|
||||||
|
|
||||||
// ================== Matrix2x3 ================= //
|
// ================== Matrix2x3 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float r1c1, r1c2;
|
float row1_col1, row1_col2;
|
||||||
float r2c1, r2c2;
|
float row2_col1, row2_col2;
|
||||||
float r3c1, r3c2;
|
float row3_col1, row3_col2;
|
||||||
} BGC_FP32_Matrix2x3;
|
} BGC_FP32_Matrix2x3;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2;
|
double row1_col1, row1_col2;
|
||||||
double r2c1, r2c2;
|
double row2_col1, row2_col2;
|
||||||
double r3c1, r3c2;
|
double row3_col1, row3_col2;
|
||||||
} BGC_FP64_Matrix2x3;
|
} BGC_FP64_Matrix2x3;
|
||||||
|
|
||||||
// ================== Matrix3x2 ================= //
|
// ================== Matrix3x2 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float r1c1, r1c2, r1c3;
|
float row1_col1, row1_col2, row1_col3;
|
||||||
float r2c1, r2c2, r2c3;
|
float row2_col1, row2_col2, row2_col3;
|
||||||
} BGC_FP32_Matrix3x2;
|
} BGC_FP32_Matrix3x2;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2, r1c3;
|
double row1_col1, row1_col2, row1_col3;
|
||||||
double r2c1, r2c2, r2c3;
|
double row2_col1, row2_col2, row2_col3;
|
||||||
} BGC_FP64_Matrix3x2;
|
} BGC_FP64_Matrix3x2;
|
||||||
|
|
||||||
// ================== Matrix3x3 ================= //
|
// ================== Matrix3x3 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float r1c1, r1c2, r1c3;
|
float row1_col1, row1_col2, row1_col3;
|
||||||
float r2c1, r2c2, r2c3;
|
float row2_col1, row2_col2, row2_col3;
|
||||||
float r3c1, r3c2, r3c3;
|
float row3_col1, row3_col2, row3_col3;
|
||||||
} BGC_FP32_Matrix3x3;
|
} BGC_FP32_Matrix3x3;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2, r1c3;
|
double row1_col1, row1_col2, row1_col3;
|
||||||
double r2c1, r2c2, r2c3;
|
double row2_col1, row2_col2, row2_col3;
|
||||||
double r3c1, r3c2, r3c3;
|
double row3_col1, row3_col2, row3_col3;
|
||||||
} BGC_FP64_Matrix3x3;
|
} BGC_FP64_Matrix3x3;
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 2x2 ========= //
|
// ========== Matrix Product 2x2 at 2x2 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->row1_col1 = row1_col1;
|
||||||
product->r1c2 = r1c2;
|
product->row1_col2 = row1_col2;
|
||||||
|
|
||||||
product->r2c1 = r2c1;
|
product->row2_col1 = row2_col1;
|
||||||
product->r2c2 = r2c2;
|
product->row2_col2 = row2_col2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->row1_col1 = row1_col1;
|
||||||
product->r1c2 = r1c2;
|
product->row1_col2 = row1_col2;
|
||||||
|
|
||||||
product->r2c1 = r2c1;
|
product->row2_col1 = row2_col1;
|
||||||
product->r2c2 = r2c2;
|
product->row2_col2 = row2_col2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 3x2 ========= //
|
// ========== Matrix Product 2x2 at 3x2 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
||||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
||||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->row1_col1 = row1_col1;
|
||||||
product->r1c2 = r1c2;
|
product->row1_col2 = row1_col2;
|
||||||
product->r1c3 = r1c3;
|
product->row1_col3 = row1_col3;
|
||||||
|
|
||||||
product->r2c1 = r2c1;
|
product->row2_col1 = row2_col1;
|
||||||
product->r2c2 = r2c2;
|
product->row2_col2 = row2_col2;
|
||||||
product->r2c3 = r2c3;
|
product->row2_col3 = row2_col3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
||||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
||||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->row1_col1 = row1_col1;
|
||||||
product->r1c2 = r1c2;
|
product->row1_col2 = row1_col2;
|
||||||
product->r1c3 = r1c3;
|
product->row1_col3 = row1_col3;
|
||||||
|
|
||||||
product->r2c1 = r2c1;
|
product->row2_col1 = row2_col1;
|
||||||
product->r2c2 = r2c2;
|
product->row2_col2 = row2_col2;
|
||||||
product->r2c3 = r2c3;
|
product->row2_col3 = row2_col3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 2x2 ========= //
|
// ========== Matrix Product 2x3 at 2x2 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
||||||
|
|
||||||