Compare commits

..

9 commits

Author SHA1 Message Date
57280ac3f3 Добавление арифметических операций для дуальных чисел, векторов и кватернионов 2026-02-05 01:58:09 +07:00
b0b064de5a Добавление арифметических операций для дуальных кватернионов 2026-02-05 01:47:52 +07:00
b470a3194b Отказ от терминов Versor и Cotes Number в пользу Turn3 и Turn2, использование кватернионов внутри Turn3 2026-02-04 21:02:15 +07:00
38cff7e27d Добавление арифметических операций для дуальных кватернионов 2026-02-04 03:44:09 +07:00
b87518cd3f Развитие дуальный чисел, векторов и кватернионов, а также гомогенных векторов и матриц 2026-02-03 19:56:56 +07:00
3f96b661a9 Добавление дуальных чисел, дуальных векторов (3D) и дуальных версоров 2026-02-03 03:33:53 +07:00
043cc72c81 Небольшие исправления, а также добавление гомогенного трёхмерного вектора 2026-02-02 20:44:10 +07:00
03627f4401 Переход на парадигму Destination first в порядке параметров функий 2026-02-01 23:42:51 +07:00
f7e41645fe Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций 2026-01-30 19:37:49 +07:00
110 changed files with 7242 additions and 6325 deletions

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_workspace_file>
<Workspace title="Workspace">
<Project filename="basic-geometry/basic-geometry.cbp" />
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
<Depends filename="basic-geometry/basic-geometry.cbp" />
</Project>
<Project filename="basic-geometry/basic-geometry.cbp" />
<Project filename="basic-geometry-test/basic-geometry-test.cbp">
<Depends filename="basic-geometry/basic-geometry.cbp" />
</Project>

View file

@ -8,7 +8,7 @@
Programming language: C (C99)
Version: 0.2.0-dev
Version: 0.3.0-dev
License: Apache-2.0

View file

@ -10,7 +10,7 @@
Язык программирования: Си (C99)
Версия: 0.2.0-dev
Версия: 0.3.0-dev
Лицензия: Apache-2.0

View file

@ -9,16 +9,16 @@
#include <time.h>
#endif // _WINDOWS_
BgcAffine3FP32* _create_bgc_affine3_list(int affine_amount)
BGC_FP32_Affine3* _create_bgc_affine3_list(int affine_amount)
{
BgcAffine3FP32* affines = malloc(affine_amount * sizeof(BgcAffine3FP32));
BGC_FP32_Affine3* affines = malloc(affine_amount * sizeof(BGC_FP32_Affine3));
if (affines == 0) {
return 0;
}
for (int i = 0; i < affine_amount; i++) {
bgc_affine3_reset_fp32(&affines[i]);
bgc_fp32_affine3_reset(&affines[i]);
}
return affines;
@ -29,43 +29,43 @@ float get_random_value_fp32()
return rand() * (2.0f / RAND_MAX) - 1.0f;
}
BgcAffine3FP32* _create_bgc_affine3_random_list(int affine_amount)
BGC_FP32_Affine3* _create_bgc_affine3_random_list(int affine_amount)
{
BgcAffine3FP32* affines = malloc(affine_amount * sizeof(BgcAffine3FP32));
BGC_FP32_Affine3* affines = malloc(affine_amount * sizeof(BGC_FP32_Affine3));
if (affines == 0) {
return 0;
}
BgcPosition3FP32 position;
BGC_FP32_Position3 position;
for (int i = 0; i < affine_amount; i++) {
bgc_versor_set_values_fp32(
bgc_fp32_turn3_set_raw_values(
&position.turn,
get_random_value_fp32(),
get_random_value_fp32(),
get_random_value_fp32(),
get_random_value_fp32(),
&position.turn
get_random_value_fp32()
);
position.shift.x1 = get_random_value_fp32();
position.shift.x2 = get_random_value_fp32();
position.shift.x3 = get_random_value_fp32();
bgc_position3_get_outward_affine_fp32(&position, &affines[i]);
bgc_fp32_position3_get_outward_affine(&affines[i], &position);
}
return affines;
}
BgcVector3FP32* _create_bgc_vector3_list(int amount)
BGC_FP32_Vector3* _create_bgc_vector3_list(int amount)
{
return malloc(amount * sizeof(BgcVector3FP32));
return malloc(amount * sizeof(BGC_FP32_Vector3));
}
BgcVector3FP32* _create_bgc_vector3_random_list(int amount)
BGC_FP32_Vector3* _create_bgc_vector3_random_list(int amount)
{
BgcVector3FP32* vectors = _create_bgc_vector3_list(amount);
BGC_FP32_Vector3* vectors = _create_bgc_vector3_list(amount);
if (vectors == 0) {
return 0;
@ -82,9 +82,9 @@ BgcVector3FP32* _create_bgc_vector3_random_list(int amount)
float test_bgc_affine3_performance(int affine_amount, int vector_per_affine)
{
BgcAffine3FP32* affines;
BgcVector3FP32* source_vectors;
BgcVector3FP32* result_vectors;
BGC_FP32_Affine3* affines;
BGC_FP32_Vector3* source_vectors;
BGC_FP32_Vector3* result_vectors;
int vector_index = 0;
float time = -1.0f;
@ -131,7 +131,7 @@ float test_bgc_affine3_performance(int affine_amount, int vector_per_affine)
for (int i = 0; i < affine_amount; i++)
{
for (int j = 0; j < vector_per_affine; j++) {
bgc_affine3_transform_point_fp32(&affines[i], &source_vectors[vector_index], &result_vectors[vector_index]);
bgc_fp32_affine3_transform_point(&result_vectors[vector_index], &affines[i], &source_vectors[vector_index]);
vector_index++;
}
}

View file

@ -10,7 +10,7 @@
#endif // _WINDOWS_
typedef struct {
BgcVersorFP32 versor1, versor2, result;
BGC_FP32_Turn3 versor1, versor2, result;
} structure_fp32_t;
structure_fp32_t* allocate_structures(const unsigned int amount)
@ -29,57 +29,57 @@ structure_fp32_t* make_structures(const unsigned int amount)
const float multiplier = 2.0f / RAND_MAX;
for (unsigned int i = 0; i < amount; i++) {
bgc_versor_set_values_fp32(
bgc_fp32_turn3_set_raw_values(
&list[i].versor1,
rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f,
&list[i].versor1
rand() * multiplier - 1.0f
);
bgc_versor_set_values_fp32(
bgc_fp32_turn3_set_raw_values(
&list[i].versor2,
rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f,
&list[i].versor2
rand() * multiplier - 1.0f
);
bgc_versor_reset_fp32(&list[i].result);
bgc_fp32_turn3_reset(&list[i].result);
}
return list;
}
void print_versor_fp32(const BgcVersorFP32* versor)
void print_quaternion_fp32(const BGC_FP32_Quaternion* quaternion)
{
printf("Versor (s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
printf("Quaternion FP32(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3);
}
void print_versor_fp64(const BgcVersorFP64* versor)
void print_quaternion_fp64(const BGC_FP64_Quaternion* quaternion)
{
printf("Versor (s0 = %0.20f, x1 = %0.20f, x2 = %0.20f, x3 = %0.20f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
printf("Quaternion FP64(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3);
}
void print_vector_fp32(const BgcVector3FP32* vector)
void print_vector_fp32(const BGC_FP32_Vector3* vector)
{
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp32(vector));
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_fp32_vector3_get_modulus(vector));
}
void print_vector_fp64(const BgcVector3FP64* vector)
void print_vector_fp64(const BGC_FP64_Vector3* vector)
{
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp64(vector));
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_fp64_vector3_get_modulus(vector));
}
void list_work(const uint_fast32_t amount, structure_fp32_t* list)
{
for (uint_fast32_t j = 0; j < 1000; j++) {
for (uint_fast32_t i = 0; i < amount; i++) {
bgc_versor_combine_fp32(&list[i].versor1, &list[i].versor1, &list[i].result);
bgc_fp32_turn3_combine(&list[i].result, &list[i].versor1, &list[i].versor2);
}
}
}
/*
int main()
{
const unsigned int amount = 1000000;
@ -113,25 +113,25 @@ int main()
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
#endif // _WIN64
print_versor_fp32(&list[10].versor1);
print_versor_fp32(&list[10].versor2);
print_versor_fp32(&list[10].result);
print_quaternion_fp32(&list[10].versor1._versor);
print_quaternion_fp32(&list[10].versor2._versor);
print_quaternion_fp32(&list[10].result._versor);
free(list);
return 0;
}
*/
/*
int main() {
BgcComplexFP32 complex, exponent, result;
BGC_FP32_Complex complex, exponent, result;
bgc_complex_set_values_fp32(0, 1, &complex);
bgc_fp32_complex_make(0, 1, &complex);
bgc_complex_set_values_fp32(4, 0, &exponent);
bgc_fp32_complex_make(4, 0, &exponent);
bgc_complex_get_exponation_fp32(&complex, exponent.real, exponent.imaginary, &result);
bgc_fp32_complex_get_exponation(&complex, exponent.real, exponent.imaginary, &result);
printf("(%f, %f) ^ (%f, %f) = (%f, %f)\n", complex.real, complex.imaginary, exponent.real, exponent.imaginary, result.real, result.imaginary);
@ -140,10 +140,10 @@ int main() {
*/
/*
int main() {
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f };
BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f };
BgcVersorFP32 result;
bgc_versor_spherical_interpolation_fp32(&start, &end, 0.5f, &result);
BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f };
BGC_FP32_Turn3 end = { 0.0f, 1.0f, 0.0f, 0.0f };
BGC_FP32_Turn3 result;
bgc_fp32_turn3_spherical_interpolation(&start, &end, 0.5f, &result);
printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3);
return 0;
}
@ -152,346 +152,347 @@ int main() {
void test_basis_difference_fp32()
{
BgcVector3FP32 initial_primary, initial_auxiliary;
BgcVector3FP32 final_primary, final_auxiliary;
BgcVersorFP32 turn;
BGC_FP32_Vector3 initial_primary, initial_auxiliary;
BGC_FP32_Vector3 final_primary, final_auxiliary;
BGC_FP32_Turn3 turn;
// No turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nNo turn:\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// Turn around (1, 1, 0) axis on 180 degrees
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 1.0f, 0.0f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// 180 degree turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, -1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// 90 degree turn around x3 axis
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 3.1f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 2.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 3.1f, 0.0f);
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, 0.0f, 10.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary,-1.0f, 0.0f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(-2.0f, 3.1f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 2.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, -2.0f, 3.1f, 0.0f);
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 5.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, 0.0f, 10.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, -1.0f, 5.0f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// Zero vectors
bgc_vector3_set_values_fp32(0.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 0.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
int code;
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
code = bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) {
printf("\nZero vectors: this cannot be!\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
}
else {
printf("\nZero vector validation works fine\n");
}
// Parallel vectors
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 2.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
code = bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
}
else {
printf("\nParallelism validation works fine\n");
}
// Small angle turn (about 1 degree):
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-0.017452f, 0.999848f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, 0.999848f, 0.017452f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, -0.017452f, 0.999848f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn , &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// About 179 degrees turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_vector3_set_values_fp32(-0.999848f, -0.017452f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.017452f, -0.999848f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, -0.999848f, -0.017452f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 0.017452f, -0.999848f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 179 degrees turn:\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// 120 degrees around (-1, -1, 1)
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 0.0f, -1.0f, &final_auxiliary);
bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 0.0f, -1.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n120 degees turn:\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 0.999848f, 0.017452f, 0.0f);
bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, -1.0f, 0.0f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
// About 0.01 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(1.0f, 0.000001f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, -1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(&initial_auxiliary, 1.0f, 0.000001f, 0.0f);
bgc_fp32_vector3_make(&final_primary, 0.0f, -1.0f, 0.0f);
bgc_fp32_vector3_make(&final_auxiliary, 1.0f, 0.0f, 0.0f);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn);
print_quaternion_fp32(&turn._versor);
}
void test_basis_difference_fp64()
{
BgcVector3FP64 initial_primary, initial_auxiliary;
BgcVector3FP64 final_primary, final_auxiliary;
BgcVersorFP64 turn;
BGC_FP64_Vector3 initial_primary, initial_auxiliary;
BGC_FP64_Vector3 final_primary, final_auxiliary;
BGC_FP64_Turn3 turn;
// No turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nNo turn:\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// Turn around (1, 1, 0) axis on 180 degrees
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 1.0, 0.0, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// 180 degree turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&initial_auxiliary, -1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// 90 degree turn around x3 axis
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 3.1, 0.0, &initial_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 2.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 3.1, 0.0);
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&final_primary, 0.0, 10.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, -1.0, 0.0, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(-2.0, 3.1, 0.0, &initial_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 2.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, -2.0, 3.1, 0.0);
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 5.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&final_primary, 0.0, 10.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, -1.0, 5.0, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// Zero vectors
bgc_vector3_set_values_fp64(0.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 0.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
int code;
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
code = bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) {
printf("\nZero vectors: this cannot be!\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
}
else {
printf("\nZero vector validation works fine\n");
}
// Parallel vectors
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 2.0, 0.0, 0.0);
bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
code = bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
}
else {
printf("\nParallelism validation works fine\n");
}
// Small angle turn (about 1 degree):
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-0.017452, 0.999848, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&final_primary, 0.999848, 0.017452, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, -0.017452, 0.999848, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// About 179 degrees turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_vector3_set_values_fp64(-0.999848, -0.017452, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.017452, -0.999848, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&final_primary, -0.999848, -0.017452, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 0.017452, -0.999848, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 179 degrees turn:\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// 120 degrees around (-1, -1, 1)
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 0.0, -1.0, &final_auxiliary);
bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 0.0, 0.0, -1.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n120 degees turn:\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 0.999848, 0.017452, 0.0);
bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, -1.0, 0.0, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
// About 0.001 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(1.0, 0.000001, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, -1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary);
bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(&initial_auxiliary, 1.0, 0.000001, 0.0);
bgc_fp64_vector3_make(&final_primary, 0.0, -1.0, 0.0);
bgc_fp64_vector3_make(&final_auxiliary, 1.0, 0.0, 0.0);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn);
print_quaternion_fp64(&turn._versor);
}
/*
#include "affine3.h"
int main()
{
//BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f };
//BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f };
/*
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f };
BgcVersorFP32 end = { 0.9999f, 0.01414f, 0.0f, 0.0f };
BgcSlerpFP32 slerp;
BgcVersorFP32 result;
bgc_slerp_make_full_fp32(&start, &end, &slerp);
bgc_slerp_get_turn_for_phase_fp32(&slerp, 0.5f, &result);
//BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f };
//BGC_FP32_Turn3 end = { 0.0f, 1.0f, 0.0f, 0.0f };
print_versor_fp32(&result);
*/
//test_basis_difference_fp64();
BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f };
BGC_FP32_Turn3 end = { 0.9999f, 0.01414f, 0.0f, 0.0f };
BGC_FP32_Slerp slerp;
BGC_FP32_Turn3 result;
bgc_fp32_slerp_make_full(&slerp, &start, &end);
bgc_fp32_slerp_get_phase_versor(&result, &slerp, 0.5f);
printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10));
//print_quaternion_fp32(&result);
printf("sizeof(BgcAffine3FP32) = %zu\n", sizeof(BgcAffine3FP32));
//printf("offsetof(shift) = %zu\n", offsetof(BgcAffine3FP32, shift));
printf("sizeof(BgcMatrix3x3FP32) = %zu\n", sizeof(BgcMatrix3x3FP32));
test_basis_difference_fp64();
//printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10));
//printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3));
//printf("offsetof(shift) = %zu\n", offsetof(BGC_FP32_Affine3, shift));
//printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3));
return 0;
}
*/

View file

@ -51,186 +51,6 @@
</Unit>
<Unit filename="main.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">
<Option compilerVar="CC" />
</Unit>

View file

@ -150,105 +150,9 @@
<ItemGroup>
<ClCompile Include="helpers.c" />
<ClCompile Include="main.c" />
<ClCompile Include="tests\complex.c" />
<ClCompile Include="tests\complex\complex_copy.c" />
<ClCompile Include="tests\complex\complex_is_unit.c" />
<ClCompile Include="tests\complex\complex_is_zero.c" />
<ClCompile Include="tests\complex\complex_modulus.c" />
<ClCompile Include="tests\complex\complex_reset.c" />
<ClCompile Include="tests\complex\complex_set_values.c" />
<ClCompile Include="tests\complex\complex_swap.c" />
<ClCompile Include="tests\complex\complex_arithmetics.c" />
<ClCompile Include="tests\quaternion.c" />
<ClCompile Include="tests\quaternion\quaternion_copy.c" />
<ClCompile Include="tests\quaternion\quaternion_is_unit.c" />
<ClCompile Include="tests\quaternion\quaternion_is_zero.c" />
<ClCompile Include="tests\quaternion\quaternion_modulus.c" />
<ClCompile Include="tests\quaternion\quaternion_reset.c" />
<ClCompile Include="tests\quaternion\quaternion_set_to_identity.c" />
<ClCompile Include="tests\quaternion\quaternion_set_values.c" />
<ClCompile Include="tests\quaternion\quaternion_swap.c" />
<ClCompile Include="tests\utilities.c" />
<ClCompile Include="tests\utilities\are_close.c" />
<ClCompile Include="tests\utilities\is_unit.c" />
<ClCompile Include="tests\utilities\is_zero.c" />
<ClCompile Include="tests\vector2.c" />
<ClCompile Include="tests\vector2\vector2_arithmetics.c" />
<ClCompile Include="tests\vector2\vector2_is_unit.c" />
<ClCompile Include="tests\vector2\vector2_is_zero.c" />
<ClCompile Include="tests\vector2\vector2_copy.c" />
<ClCompile Include="tests\vector2\vector2_modulus.c" />
<ClCompile Include="tests\vector2\vector2_reset.c" />
<ClCompile Include="tests\vector2\vector2_set_values.c" />
<ClCompile Include="tests\vector2\vector2_swap.c" />
<ClCompile Include="tests\vector3.c" />
<ClCompile Include="tests\vector3\vector3_arithmetics.c" />
<ClCompile Include="tests\vector3\vector3_is_unit.c" />
<ClCompile Include="tests\vector3\vector3_is_zero.c" />
<ClCompile Include="tests\vector3\vector3_copy.c" />
<ClCompile Include="tests\vector3\vector3_modulus.c" />
<ClCompile Include="tests\vector3\vector3_swap.c" />
<ClCompile Include="tests\vector3\vector3_reset.c" />
<ClCompile Include="tests\vector3\vector3_set_values.c" />
<ClCompile Include="tests\versor.c" />
<ClCompile Include="tests\versor\versor_copy.c" />
<ClCompile Include="tests\versor\versor_is_identity.c" />
<ClCompile Include="tests\versor\versor_swap.c" />
<ClCompile Include="tests\versor\versor_combine.c" />
<ClCompile Include="tests\versor\versor_reset.c" />
<ClCompile Include="tests\versor\versor_set_values.c" />
<ClCompile Include="tests\versor\versor_are_close.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="helpers.h" />
<ClInclude Include="tests\complex.h" />
<ClInclude Include="tests\complex\complex_copy.h" />
<ClInclude Include="tests\complex\complex_is_unit.h" />
<ClInclude Include="tests\complex\complex_is_zero.h" />
<ClInclude Include="tests\complex\complex_modulus.h" />
<ClInclude Include="tests\complex\complex_reset.h" />
<ClInclude Include="tests\complex\complex_set_values.h" />
<ClInclude Include="tests\complex\complex_swap.h" />
<ClInclude Include="tests\complex\complex_arithmetics.h" />
<ClInclude Include="tests\quaternion.h" />
<ClInclude Include="tests\quaternion\quaternion_copy.h" />
<ClInclude Include="tests\quaternion\quaternion_is_unit.h" />
<ClInclude Include="tests\quaternion\quaternion_is_zero.h" />
<ClInclude Include="tests\quaternion\quaternion_modulus.h" />
<ClInclude Include="tests\quaternion\quaternion_reset.h" />
<ClInclude Include="tests\quaternion\quaternion_set_to_identity.h" />
<ClInclude Include="tests\quaternion\quaternion_set_values.h" />
<ClInclude Include="tests\quaternion\quaternion_swap.h" />
<ClInclude Include="tests\utilities.h" />
<ClInclude Include="tests\utilities\are_close.h" />
<ClInclude Include="tests\utilities\is_unit.h" />
<ClInclude Include="tests\utilities\is_zero.h" />
<ClInclude Include="tests\vector2.h" />
<ClInclude Include="tests\vector2\vector2_arithmetics.h" />
<ClInclude Include="tests\vector2\vector2_is_unit.h" />
<ClInclude Include="tests\vector2\vector2_is_zero.h" />
<ClInclude Include="tests\vector2\vector2_copy.h" />
<ClInclude Include="tests\vector2\vector2_modulus.h" />
<ClInclude Include="tests\vector2\vector2_reset.h" />
<ClInclude Include="tests\vector2\vector2_set_values.h" />
<ClInclude Include="tests\vector2\vector2_swap.h" />
<ClInclude Include="tests\vector3.h" />
<ClInclude Include="tests\vector3\vector3_arithmetics.h" />
<ClInclude Include="tests\vector3\vector3_is_unit.h" />
<ClInclude Include="tests\vector3\vector3_is_zero.h" />
<ClInclude Include="tests\vector3\vector3_copy.h" />
<ClInclude Include="tests\vector3\vector3_modulus.h" />
<ClInclude Include="tests\vector3\vector3_swap.h" />
<ClInclude Include="tests\vector3\vector3_reset.h" />
<ClInclude Include="tests\vector3\vector3_set_values.h" />
<ClInclude Include="tests\versor.h" />
<ClInclude Include="tests\versor\versor_copy.h" />
<ClInclude Include="tests\versor\versor_is_identity.h" />
<ClInclude Include="tests\versor\versor_swap.h" />
<ClInclude Include="tests\versor\versor_combine.h" />
<ClInclude Include="tests\versor\versor_reset.h" />
<ClInclude Include="tests\versor\versor_set_values.h" />
<ClInclude Include="tests\versor\versor_are_close.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -3,319 +3,8 @@
<ItemGroup>
<ClCompile Include="main.c" />
<ClCompile Include="helpers.c" />
<ClCompile Include="tests\utilities.c">
<Filter>tests</Filter>
</ClCompile>
<ClCompile Include="tests\vector2.c">
<Filter>tests</Filter>
</ClCompile>
<ClCompile Include="tests\vector3.c">
<Filter>tests</Filter>
</ClCompile>
<ClCompile Include="tests\versor.c">
<Filter>tests</Filter>
</ClCompile>
<ClCompile Include="tests\utilities\is_zero.c">
<Filter>tests\utilities</Filter>
</ClCompile>
<ClCompile Include="tests\utilities\is_unit.c">
<Filter>tests\utilities</Filter>
</ClCompile>
<ClCompile Include="tests\utilities\are_close.c">
<Filter>tests\utilities</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_are_close.c">
<Filter>tests\versor</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_set_values.c">
<Filter>tests\versor</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_combine.c">
<Filter>tests\versor</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_reset.c">
<Filter>tests\versor</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_reset.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_set_values.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_reset.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_set_values.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_copy.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_swap.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_copy.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_swap.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_copy.c">
<Filter>tests\versor</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_swap.c">
<Filter>tests\versor</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_copy.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_reset.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_set_values.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_swap.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion.c">
<Filter>tests</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_set_to_identity.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_is_zero.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_is_zero.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_is_zero.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_is_unit.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_is_unit.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_is_unit.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_is_identity.c">
<Filter>tests\versor</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_modulus.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_modulus.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_modulus.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_copy.c">
<Filter>tests\complex</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_is_unit.c">
<Filter>tests\complex</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_is_zero.c">
<Filter>tests\complex</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_modulus.c">
<Filter>tests\complex</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_reset.c">
<Filter>tests\complex</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_set_values.c">
<Filter>tests\complex</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_swap.c">
<Filter>tests\complex</Filter>
</ClCompile>
<ClCompile Include="tests\complex.c">
<Filter>tests</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_arithmetics.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_arithmetics.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\complex\complex_arithmetics.c">
<Filter>tests\complex</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="helpers.h" />
<ClInclude Include="tests\utilities.h">
<Filter>tests</Filter>
</ClInclude>
<ClInclude Include="tests\vector2.h">
<Filter>tests</Filter>
</ClInclude>
<ClInclude Include="tests\vector3.h">
<Filter>tests</Filter>
</ClInclude>
<ClInclude Include="tests\versor.h">
<Filter>tests</Filter>
</ClInclude>
<ClInclude Include="tests\utilities\is_zero.h">
<Filter>tests\utilities</Filter>
</ClInclude>
<ClInclude Include="tests\utilities\is_unit.h">
<Filter>tests\utilities</Filter>
</ClInclude>
<ClInclude Include="tests\utilities\are_close.h">
<Filter>tests\utilities</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_are_close.h">
<Filter>tests\versor</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_set_values.h">
<Filter>tests\versor</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_combine.h">
<Filter>tests\versor</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_reset.h">
<Filter>tests\versor</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_reset.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_set_values.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_reset.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_set_values.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_copy.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_swap.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_copy.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_swap.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_copy.h">
<Filter>tests\versor</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_swap.h">
<Filter>tests\versor</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_copy.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_reset.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_set_values.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_swap.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion.h">
<Filter>tests</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_set_to_identity.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_is_zero.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_is_zero.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_is_zero.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_is_unit.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_is_unit.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_is_unit.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_is_identity.h">
<Filter>tests\versor</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_modulus.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_modulus.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_modulus.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_copy.h">
<Filter>tests\complex</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_is_unit.h">
<Filter>tests\complex</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_is_zero.h">
<Filter>tests\complex</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_modulus.h">
<Filter>tests\complex</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_reset.h">
<Filter>tests\complex</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_set_values.h">
<Filter>tests\complex</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_swap.h">
<Filter>tests\complex</Filter>
</ClInclude>
<ClInclude Include="tests\complex.h">
<Filter>tests</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_arithmetics.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_arithmetics.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\complex\complex_arithmetics.h">
<Filter>tests\complex</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="tests">
<UniqueIdentifier>{10db9024-67b8-4555-80a9-48b54ae0dec9}</UniqueIdentifier>
</Filter>
<Filter Include="tests\utilities">
<UniqueIdentifier>{392bc542-f334-4132-a22b-b5b440c77897}</UniqueIdentifier>
</Filter>
<Filter Include="tests\vector2">
<UniqueIdentifier>{d9f520e0-1b2d-4379-8887-1b5728763129}</UniqueIdentifier>
</Filter>
<Filter Include="tests\vector3">
<UniqueIdentifier>{dbf2eefa-8f1f-4447-b3d4-d17dee049580}</UniqueIdentifier>
</Filter>
<Filter Include="tests\versor">
<UniqueIdentifier>{d6f82407-8310-4b32-b153-aa67e766c72a}</UniqueIdentifier>
</Filter>
<Filter Include="tests\quaternion">
<UniqueIdentifier>{e8bafdb8-66e5-4393-bc89-8bff83bcccd6}</UniqueIdentifier>
</Filter>
<Filter Include="tests\complex">
<UniqueIdentifier>{e025e123-45aa-44f9-aab4-f1705844b211}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View file

@ -25,19 +25,19 @@ typedef struct {
// =================== Versor =================== //
typedef struct {
BgcVersorFP32 first, second;
BGC_FP32_Turn3 first, second;
} TestVersorPairFP32;
typedef struct {
BgcVersorFP64 first, second;
BGC_FP64_Turn3 first, second;
} TestVersorPairFP64;
typedef struct {
BgcVersorFP32 first, second, result;
BGC_FP32_Turn3 first, second, result;
} TestVersorTripletFP32;
typedef struct {
BgcVersorFP64 first, second, result;
BGC_FP64_Turn3 first, second, result;
} TestVersorTripletFP64;
// ================= Functions ================== //

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST[] = {
{ 1.0f, 2.0f },
{ -4.0f, -3.0f },
{ -0.001f, 100.0f },
@ -16,13 +16,13 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
void test_complex_copy_fp32()
{
BgcComplexFP32 vector;
BGC_FP32_Complex vector;
print_testing_name("bgc_complex_copy_fp32");
print_testing_name("bgc_fp32_complex_copy");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST[i], &vector);
bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP32_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) {
@ -37,7 +37,7 @@ void test_complex_copy_fp32()
// ==================== FP64 ==================== //
static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST[] = {
{ 1.0, 2.0 },
{ -4.0, -3.0 },
{ -0.001, 100.0 },
@ -46,13 +46,13 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
void test_complex_copy_fp64()
{
BgcComplexFP64 vector;
BGC_FP64_Complex vector;
print_testing_name("bgc_complex_copy_fp64");
print_testing_name("bgc_fp64_complex_copy");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST[i], &vector);
bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP64_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) {

View file

@ -7,35 +7,35 @@
static const int _TEST_FP32_UNIT_COMPLEX_AMOUNT = 10;
static const int _TEST_FP32_NONUNIT_COMPLEX_AMOUNT = 6;
static const BgcComplexFP32 _TEST_FP32_UNIT_COMPLEX_LIST[] = {
static const BGC_FP32_Complex _TEST_FP32_UNIT_COMPLEX_LIST[] = {
{ 1.0f, 0.0f },
{ -1.0f, 0.0f },
{ 0.6f, -0.8f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 },
{ 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON },
{ 0.7071067812f, 0.7071067812f },
{ 0.7071067812f + 0.75f * BGC_EPSYLON_FP32, 0.7071067812f },
{ 0.7071067812f, 0.7071067812f - 0.75f * BGC_EPSYLON_FP32 }
{ 0.7071067812f + 0.75f * BGC_FP32_EPSYLON, 0.7071067812f },
{ 0.7071067812f, 0.7071067812f - 0.75f * BGC_FP32_EPSYLON }
};
static const BgcComplexFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
{ 0.7071067812f + 1.25f * BGC_EPSYLON_FP32, 0.7071067812f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.7071067812f - 1.25f * BGC_EPSYLON_FP32, 0.7071067812f - 1.25f * BGC_EPSYLON_FP32 }
static const BGC_FP32_Complex _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.7071067812f + 1.25f * BGC_FP32_EPSYLON, 0.7071067812f + 1.25f * BGC_FP32_EPSYLON },
{ 0.7071067812f - 1.25f * BGC_FP32_EPSYLON, 0.7071067812f - 1.25f * BGC_FP32_EPSYLON }
};
void test_complex_is_unit_fp32()
{
print_testing_name("bgc_complex_is_unit_fp32");
print_testing_name("bgc_fp32_complex_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_unit_fp32(&_TEST_FP32_UNIT_COMPLEX_LIST[i])) {
if (!bgc_fp32_complex_is_unit(&_TEST_FP32_UNIT_COMPLEX_LIST[i])) {
print_testing_error("A unit complex number was not recognized");
return;
}
@ -43,7 +43,7 @@ void test_complex_is_unit_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
if (bgc_fp32_complex_is_unit(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit complex number was recognized a unit complex number");
return;
}
@ -57,35 +57,35 @@ void test_complex_is_unit_fp32()
static const int _TEST_FP64_UNIT_COMPLEX_AMOUNT = 10;
static const int _TEST_FP64_NONUNIT_COMPLEX_AMOUNT = 6;
static const BgcComplexFP64 _TEST_FP64_UNIT_COMPLEX_LIST[] = {
static const BGC_FP64_Complex _TEST_FP64_UNIT_COMPLEX_LIST[] = {
{ 1.0, 0.0 },
{ -1.0, 0.0 },
{ -0.6, 0.8 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 },
{ 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244, 0.7071067811865475244 },
{ 0.7071067811865475244 + 0.75 * BGC_EPSYLON_FP64, 0.7071067811865475244 },
{ 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_EPSYLON_FP64 }
{ 0.7071067811865475244 + 0.75 * BGC_FP64_EPSYLON, 0.7071067811865475244 },
{ 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_FP64_EPSYLON }
};
static const BgcComplexFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
{ 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64 }
static const BGC_FP64_Complex _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON }
};
void test_complex_is_unit_fp64()
{
print_testing_name("bgc_complex_is_unit_fp64");
print_testing_name("bgc_fp64_complex_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_unit_fp64(&_TEST_FP64_UNIT_COMPLEX_LIST[i])) {
if (!bgc_fp64_complex_is_unit(&_TEST_FP64_UNIT_COMPLEX_LIST[i])) {
print_testing_error("A unit complex number was not recognized");
return;
}
@ -93,7 +93,7 @@ void test_complex_is_unit_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
if (bgc_fp64_complex_is_unit(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit complex number was recognized a unit complex number");
return;
}

View file

@ -7,31 +7,31 @@
static const int _TEST_FP32_ZERO_COMPLEX_AMOUNT = 4;
static const int _TEST_FP32_NONZERO_COMPLEX_AMOUNT = 7;
static const BgcComplexFP32 _TEST_FP32_ZERO_COMPLEX_LIST[] = {
static const BGC_FP32_Complex _TEST_FP32_ZERO_COMPLEX_LIST[] = {
{ 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32 }
{ 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, -0.75f * BGC_FP32_EPSYLON }
};
static const BgcComplexFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = {
static const BGC_FP32_Complex _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 0.0f, 1.0f },
{ 1.25f * BGC_EPSYLON_FP32 },
{ -1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 }
{ 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON }
};
void test_complex_is_zero_fp32()
{
print_testing_name("bgc_complex_is_zero_fp32");
print_testing_name("bgc_fp32_complex_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_zero_fp32(&_TEST_FP32_ZERO_COMPLEX_LIST[i])) {
if (!bgc_fp32_complex_is_zero(&_TEST_FP32_ZERO_COMPLEX_LIST[i])) {
print_testing_error("A zero complex number was not recognized");
return;
}
@ -39,7 +39,7 @@ void test_complex_is_zero_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
if (bgc_fp32_complex_is_zero(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero complex number was recognized as a zero complex number");
return;
}
@ -53,31 +53,31 @@ void test_complex_is_zero_fp32()
static const int _TEST_FP64_ZERO_COMPLEX_AMOUNT = 4;
static const int _TEST_FP64_NONZERO_COMPLEX_AMOUNT = 7;
static const BgcComplexFP64 _TEST_FP64_ZERO_COMPLEX_LIST[] = {
static const BGC_FP64_Complex _TEST_FP64_ZERO_COMPLEX_LIST[] = {
{ 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64 }
{ 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, -0.75 * BGC_FP64_EPSYLON }
};
static const BgcComplexFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = {
static const BGC_FP64_Complex _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 0.0, 1.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64 },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 }
{ 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON },
{ -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON }
};
void test_complex_is_zero_fp64()
{
print_testing_name("bgc_complex_is_zero_fp64");
print_testing_name("bgc_fp64_complex_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_zero_fp64(&_TEST_FP64_ZERO_COMPLEX_LIST[i])) {
if (!bgc_fp64_complex_is_zero(&_TEST_FP64_ZERO_COMPLEX_LIST[i])) {
print_testing_error("A zero complex number was not recognized");
return;
}
@ -85,7 +85,7 @@ void test_complex_is_zero_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
if (bgc_fp64_complex_is_zero(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero complex number was recognized as a zero complex number");
return;
}

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST[] = {
{ 4.0f, 3.0f },
{ -1.0f, 1.0f },
{ 100.0f, -100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_complex_square_modulus_fp32()
{
print_testing_name("bgc_complex_get_square_modulus_fp32");
print_testing_name("bgc_fp32_complex_get_square_modulus");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_complex_get_square_modulus_fp32(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_complex_get_square_modulus(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -43,10 +43,10 @@ void test_complex_square_modulus_fp32()
void test_complex_modulus_fp32()
{
print_testing_name("bgc_complex_get_modulus_fp32");
print_testing_name("bgc_fp32_complex_get_modulus");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_complex_get_modulus_fp32(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_complex_get_modulus(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -59,7 +59,7 @@ void test_complex_modulus_fp32()
static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST[] = {
{ 4.0, 3.0 },
{ -1.0, -1.0 },
{ -100.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_complex_square_modulus_fp64()
{
print_testing_name("bgc_complex_get_square_modulus_fp64");
print_testing_name("bgc_fp64_complex_get_square_modulus");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_complex_get_square_modulus_fp64(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_complex_get_square_modulus(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -96,10 +96,10 @@ void test_complex_square_modulus_fp64()
void test_complex_modulus_fp64()
{
print_testing_name("bgc_complex_get_modulus_fp64");
print_testing_name("bgc_fp64_complex_get_modulus");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_complex_get_modulus_fp64(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_complex_get_modulus(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed();
return;
}

View file

@ -4,11 +4,11 @@
void test_complex_reset_fp32()
{
BgcComplexFP32 vector;
BGC_FP32_Complex vector;
print_testing_name("bgc_complex_reset_fp32");
print_testing_name("bgc_fp32_complex_reset");
bgc_complex_reset_fp32(&vector);
bgc_fp32_complex_reset(&vector);
if (vector.real != 0.0f || vector.imaginary != 0.0f) {
print_testing_failed();
@ -20,11 +20,11 @@ void test_complex_reset_fp32()
void test_complex_reset_fp64()
{
BgcComplexFP64 vector;
BGC_FP64_Complex vector;
print_testing_name("bgc_complex_reset_fp64");
print_testing_name("bgc_fp64_complex_reset");
bgc_complex_reset_fp64(&vector);
bgc_fp64_complex_reset(&vector);
if (vector.real != 0.0 || vector.imaginary != 0.0) {
print_testing_failed();

View file

@ -8,25 +8,25 @@
void test_complex_set_values_fp32()
{
BgcComplexFP32 vector;
BGC_FP32_Complex vector;
print_testing_name("bgc_complex_set_values_fp32");
print_testing_name("bgc_fp32_complex_make");
bgc_complex_set_values_fp32(1.0f, 2.0f, &vector);
bgc_fp32_complex_make(1.0f, 2.0f, &vector);
if (vector.real != 1.0f || vector.imaginary != 2.0f) {
print_testing_error("First step failed");
return;
}
bgc_complex_set_values_fp32(-1.0f, -3.0f, &vector);
bgc_fp32_complex_make(-1.0f, -3.0f, &vector);
if (vector.real != -1.0f || vector.imaginary != -3.0f) {
print_testing_error("Second step failed");
return;
}
bgc_complex_set_values_fp32(-8.0f, -2.0f, &vector);
bgc_fp32_complex_make(-8.0f, -2.0f, &vector);
if (vector.real != -8.0f || vector.imaginary != -2.0f) {
print_testing_error("Third step failed");
@ -40,25 +40,25 @@ void test_complex_set_values_fp32()
void test_complex_set_values_fp64()
{
BgcComplexFP64 vector;
BGC_FP64_Complex vector;
print_testing_name("bgc_complex_set_values_fp64");
print_testing_name("bgc_fp64_complex_make");
bgc_complex_set_values_fp64(1.0, 2.0, &vector);
bgc_fp64_complex_make(1.0, 2.0, &vector);
if (vector.real != 1.0 || vector.imaginary != 2.0) {
print_testing_error("First step failed");
return;
}
bgc_complex_set_values_fp64(-1.0, -3.0, &vector);
bgc_fp64_complex_make(-1.0, -3.0, &vector);
if (vector.real != -1.0 || vector.imaginary != -3.0) {
print_testing_error("Second step failed");
return;
}
bgc_complex_set_values_fp64(-8.0, -2.0, &vector);
bgc_fp64_complex_make(-8.0, -2.0, &vector);
if (vector.real != -8.0 || vector.imaginary != -2.0) {
print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST1[] = {
static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST1[] = {
{ 3.0f, 4.0f },
{ -2.0f, -1.0f },
{ -244.8f, 100.0f },
{ 1000.32f, -100.1f }
};
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = {
static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST2[] = {
{ 5.3f, 1003.28f },
{ -0.0032f, 891.3f },
{ 5.322f, 0.9275f },
@ -24,15 +24,15 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = {
void test_complex_swap_fp32()
{
BgcComplexFP32 compleimaginary, complex2;
BGC_FP32_Complex compleimaginary, complex2;
print_testing_name("bgc_complex_swap_fp32");
print_testing_name("bgc_fp32_complex_swap");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary);
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST2[i], &complex2);
bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary);
bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST2[i], &complex2);
bgc_complex_swap_fp32(&compleimaginary, &complex2);
bgc_fp32_complex_swap(&compleimaginary, &complex2);
if (compleimaginary.real != _TEST_FP32_COMPLEX_LIST2[i].real ||
compleimaginary.imaginary != _TEST_FP32_COMPLEX_LIST2[i].imaginary ||
@ -50,14 +50,14 @@ void test_complex_swap_fp32()
static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST1[] = {
static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST1[] = {
{ 1.0, 4.0 },
{ -4.0, -3.0 },
{ -244.8, 344.7 },
{ 1000.32, -271.3 }
};
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = {
static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST2[] = {
{ -0.123, 1003.28 },
{ 204.07, -781.89 },
{ 5.322, 0.9275 },
@ -66,15 +66,15 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = {
void test_complex_swap_fp64()
{
BgcComplexFP64 compleimaginary, complex2;
BGC_FP64_Complex compleimaginary, complex2;
print_testing_name("bgc_complex_swap_fp64");
print_testing_name("bgc_fp64_complex_swap");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary);
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST2[i], &complex2);
bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary);
bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST2[i], &complex2);
bgc_complex_swap_fp64(&compleimaginary, &complex2);
bgc_fp64_complex_swap(&compleimaginary, &complex2);
if (compleimaginary.real != _TEST_FP64_COMPLEX_LIST2[i].real ||
compleimaginary.imaginary != _TEST_FP64_COMPLEX_LIST2[i].imaginary ||

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f },
{ -0.001f, 100.0f, -100.0f, 0.001f },
@ -16,13 +16,13 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
void test_quaternion_copy_fp32()
{
BgcQuaternionFP32 vector;
BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_copy_fp32");
print_testing_name("bgc_fp32_quaternion_copy");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST[i], &vector);
bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST[i], &vector);
if (vector.s0 != _TEST_FP32_QUATERNION_LIST[i].s0 ||
vector.x1 != _TEST_FP32_QUATERNION_LIST[i].x1 ||
@ -39,7 +39,7 @@ void test_quaternion_copy_fp32()
// ==================== FP64 ==================== //
static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = {
static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST[] = {
{ 1.0, 2.0, 3.0, 4.0 },
{ -4.0, -3.0, -2.0, -1.0 },
{ -0.001, 100.0, -100.0, 0.001 },
@ -48,13 +48,13 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = {
void test_quaternion_copy_fp64()
{
BgcQuaternionFP64 vector;
BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_copy_fp64");
print_testing_name("bgc_fp64_quaternion_copy");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST[i], &vector);
bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST[i], &vector);
if (vector.s0 != _TEST_FP64_QUATERNION_LIST[i].s0 ||
vector.x1 != _TEST_FP64_QUATERNION_LIST[i].x1 ||

View file

@ -7,45 +7,45 @@
static const int _TEST_FP32_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP32_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP32 _TEST_FP32_UNIT_QUATERNION_LIST[] = {
static const BGC_FP32_Quaternion _TEST_FP32_UNIT_QUATERNION_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, -0.8f, 0.6f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 },
{ 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON },
{ 0.5f, 0.5f, 0.5f, 0.5f },
{ 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f, 0.5f },
{ 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f },
{ 0.5f, 0.5f, 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f },
{ 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32 }
{ 0.5f + 0.75f * BGC_FP32_EPSYLON, 0.5f, 0.5f, 0.5f },
{ 0.5f, 0.5f - 0.75f * BGC_FP32_EPSYLON, 0.5f, 0.5f },
{ 0.5f, 0.5f, 0.5f + 0.75f * BGC_FP32_EPSYLON, 0.5f },
{ 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_FP32_EPSYLON }
};
static const BgcQuaternionFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
{ 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f, 0.5f },
{ 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.5f }
static const BGC_FP32_Quaternion _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f, 0.5f },
{ 0.5f - 1.25f * BGC_FP32_EPSYLON, 0.5f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.5f }
};
void test_quaternion_is_unit_fp32()
{
print_testing_name("bgc_quaternion_is_unit_fp32");
print_testing_name("bgc_fp32_quaternion_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp32(&_TEST_FP32_UNIT_QUATERNION_LIST[i])) {
if (!bgc_fp32_quaternion_is_unit(&_TEST_FP32_UNIT_QUATERNION_LIST[i])) {
print_testing_error("A unit quaternion was not recognized");
return;
}
@ -53,7 +53,7 @@ void test_quaternion_is_unit_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
if (bgc_fp32_quaternion_is_unit(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit quaternion was recognized a unit quaternion");
return;
}
@ -67,45 +67,45 @@ void test_quaternion_is_unit_fp32()
static const int _TEST_FP64_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP64_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP64 _TEST_FP64_UNIT_QUATERNION_LIST[] = {
static const BGC_FP64_Quaternion _TEST_FP64_UNIT_QUATERNION_LIST[] = {
{ 1.0, 0.0, 0.0, 0.0 },
{ -1.0, 0.0, 0.0, 0.0 },
{ 0.0, -0.6, 0.8, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 },
{ 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON },
{ 0.5, 0.5, 0.5, 0.5 },
{ 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5, 0.5 },
{ 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5 },
{ 0.5, 0.5, 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5 },
{ 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64 }
{ 0.5 + 0.75 * BGC_FP64_EPSYLON, 0.5, 0.5, 0.5 },
{ 0.5, 0.5 - 0.75 * BGC_FP64_EPSYLON, 0.5, 0.5 },
{ 0.5, 0.5, 0.5 + 0.75 * BGC_FP64_EPSYLON, 0.5 },
{ 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_FP64_EPSYLON }
};
static const BgcQuaternionFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
{ 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5, 0.5 },
{ 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.5 }
static const BGC_FP64_Quaternion _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5, 0.5 },
{ 0.5 - 1.25 * BGC_FP64_EPSYLON, 0.5 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.5 }
};
void test_quaternion_is_unit_fp64()
{
print_testing_name("bgc_quaternion_is_unit_fp64");
print_testing_name("bgc_fp64_quaternion_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp64(&_TEST_FP64_UNIT_QUATERNION_LIST[i])) {
if (!bgc_fp64_quaternion_is_unit(&_TEST_FP64_UNIT_QUATERNION_LIST[i])) {
print_testing_error("A unit quaternion was not recognized");
return;
}
@ -113,7 +113,7 @@ void test_quaternion_is_unit_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
if (bgc_fp64_quaternion_is_unit(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit quaternion was recognized a unit quaternion");
return;
}

View file

@ -7,39 +7,39 @@
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 9;
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = {
static const BGC_FP32_Quaternion _TEST_FP32_ZERO_QUATERNION_LIST[] = {
{ 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 }
{ 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON }
};
static const BgcQuaternionFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = {
static const BGC_FP32_Quaternion _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }
{ 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
};
void test_quaternion_is_zero_fp32()
{
print_testing_name("bgc_quaternion_is_zero_fp32");
print_testing_name("bgc_fp32_quaternion_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_zero_fp32(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) {
if (!bgc_fp32_quaternion_is_zero(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) {
print_testing_error("A zero quaternion was not recognized");
return;
}
@ -47,7 +47,7 @@ void test_quaternion_is_zero_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
if (bgc_fp32_quaternion_is_zero(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero quaternion was recognized as a zero quaternion");
return;
}
@ -61,39 +61,39 @@ void test_quaternion_is_zero_fp32()
static const int _TEST_FP64_ZERO_QUATERNION_AMOUNT = 9;
static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = {
static const BGC_FP64_Quaternion _TEST_FP64_ZERO_QUATERNION_LIST[] = {
{ 0.0, 0.0, 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 }
{ 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON }
};
static const BgcQuaternionFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = {
static const BGC_FP64_Quaternion _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 0.0, 1.0, 0.0, 0.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }
{ 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }
};
void test_quaternion_is_zero_fp64()
{
print_testing_name("bgc_quaternion_is_zero_fp64");
print_testing_name("bgc_fp64_quaternion_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_zero_fp64(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) {
if (!bgc_fp64_quaternion_is_zero(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) {
print_testing_error("A zero quaternion was not recognized");
return;
}
@ -101,7 +101,7 @@ void test_quaternion_is_zero_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
if (bgc_fp64_quaternion_is_zero(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero quaternion was recognized as a zero quaternion");
return;
}

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST[] = {
{ 0.0f, 4.0f, 3.0f, 0.0f },
{ -1.0f, 1.0f, -1.0f, 1.0f },
{ 100.0f, -100.0f, 0.0f, 100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_quaternion_square_modulus_fp32()
{
print_testing_name("bgc_quaternion_get_square_modulus_fp32");
print_testing_name("bgc_fp32_quaternion_get_square_modulus");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_quaternion_get_square_modulus_fp32(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_quaternion_get_square_modulus(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -43,10 +43,10 @@ void test_quaternion_square_modulus_fp32()
void test_quaternion_modulus_fp32()
{
print_testing_name("bgc_quaternion_get_modulus_fp32");
print_testing_name("bgc_fp32_quaternion_get_modulus");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_quaternion_get_modulus_fp32(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_quaternion_get_modulus(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -59,7 +59,7 @@ void test_quaternion_modulus_fp32()
static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = {
static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST[] = {
{ 0.0, 4.0, 3.0, 0.0 },
{ -1.0, 1.0, -1.0, 1.0 },
{ 100.0, -100.0, 0.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_quaternion_square_modulus_fp64()
{
print_testing_name("bgc_quaternion_get_square_modulus_fp64");
print_testing_name("bgc_fp64_quaternion_get_square_modulus");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_quaternion_get_square_modulus_fp64(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_quaternion_get_square_modulus(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -96,10 +96,10 @@ void test_quaternion_square_modulus_fp64()
void test_quaternion_modulus_fp64()
{
print_testing_name("bgc_quaternion_get_modulus_fp64");
print_testing_name("bgc_fp64_quaternion_get_modulus");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_quaternion_get_modulus_fp64(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_quaternion_get_modulus(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed();
return;
}

View file

@ -4,11 +4,11 @@
void test_quaternion_reset_fp32()
{
BgcQuaternionFP32 vector;
BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_reset_fp32");
print_testing_name("bgc_fp32_quaternion_reset");
bgc_quaternion_reset_fp32(&vector);
bgc_fp32_quaternion_reset(&vector);
if (vector.s0 != 0.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
print_testing_failed();
@ -20,11 +20,11 @@ void test_quaternion_reset_fp32()
void test_quaternion_reset_fp64()
{
BgcQuaternionFP64 vector;
BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_reset_fp64");
print_testing_name("bgc_fp64_quaternion_reset");
bgc_quaternion_reset_fp64(&vector);
bgc_fp64_quaternion_reset(&vector);
if (vector.s0 != 0.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
print_testing_failed();

View file

@ -2,13 +2,13 @@
#include "./../../helpers.h"
void test_quaternion_set_to_identity_fp32()
void test_quaternion_make_unit_fp32()
{
BgcQuaternionFP32 vector;
BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_set_to_identity_fp32");
print_testing_name("bgc_fp32_quaternion_make_unit");
bgc_quaternion_make_unit_fp32(&vector);
bgc_fp32_quaternion_make_unit(&vector);
if (vector.s0 != 1.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
print_testing_failed();
@ -18,13 +18,13 @@ void test_quaternion_set_to_identity_fp32()
print_testing_success();
}
void test_quaternion_set_to_identity_fp64()
void test_quaternion_make_unit_fp64()
{
BgcQuaternionFP64 vector;
BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_set_to_identity_fp64");
print_testing_name("bgc_fp64_quaternion_make_unit");
bgc_quaternion_make_unit_fp64(&vector);
bgc_fp64_quaternion_make_unit(&vector);
if (vector.s0 != 1.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
print_testing_failed();
@ -36,6 +36,6 @@ void test_quaternion_set_to_identity_fp64()
void test_quaternion_set_to_identity()
{
test_quaternion_set_to_identity_fp32();
test_quaternion_set_to_identity_fp64();
test_quaternion_make_unit_fp32();
test_quaternion_make_unit_fp64();
}

View file

@ -1,9 +1,9 @@
#ifndef _TEST_QUATERNION_SET_TO_IDENTITY_H_
#define _TEST_QUATERNION_SET_TO_IDENTITY_H_
void test_quaternion_set_to_identity_fp32();
void test_quaternion_make_unit_fp32();
void test_quaternion_set_to_identity_fp64();
void test_quaternion_make_unit_fp64();
void test_quaternion_set_to_identity();

View file

@ -8,25 +8,25 @@
void test_quaternion_set_values_fp32()
{
BgcQuaternionFP32 vector;
BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_set_values_fp32");
print_testing_name("bgc_fp32_quaternion_make");
bgc_quaternion_set_values_fp32(1.0f, 2.0f, 3.0f, 4.0f, &vector);
bgc_fp32_quaternion_make(1.0f, 2.0f, 3.0f, 4.0f, &vector);
if (vector.s0 != 1.0f || vector.x1 != 2.0f || vector.x2 != 3.0f || vector.x3 != 4.0f) {
print_testing_error("First step failed");
return;
}
bgc_quaternion_set_values_fp32(-1.0f, -3.0f, -5.0f, -7.0f, &vector);
bgc_fp32_quaternion_make(-1.0f, -3.0f, -5.0f, -7.0f, &vector);
if (vector.s0 != -1.0f || vector.x1 != -3.0f || vector.x2 != -5.0f || vector.x3 != -7.0f) {
print_testing_error("Second step failed");
return;
}
bgc_quaternion_set_values_fp32(-8.0f, -2.0f, 2.0f, 4.0f, &vector);
bgc_fp32_quaternion_make(-8.0f, -2.0f, 2.0f, 4.0f, &vector);
if (vector.s0 != -8.0f || vector.x1 != -2.0f || vector.x2 != 2.0f || vector.x3 != 4.0f) {
print_testing_error("Third step failed");
@ -40,25 +40,25 @@ void test_quaternion_set_values_fp32()
void test_quaternion_set_values_fp64()
{
BgcQuaternionFP64 vector;
BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_set_values_fp64");
print_testing_name("bgc_fp64_quaternion_make");
bgc_quaternion_set_values_fp64(1.0, 2.0, 3.0, 4.0, &vector);
bgc_fp64_quaternion_make(1.0, 2.0, 3.0, 4.0, &vector);
if (vector.s0 != 1.0 || vector.x1 != 2.0 || vector.x2 != 3.0 || vector.x3 != 4.0) {
print_testing_error("First step failed");
return;
}
bgc_quaternion_set_values_fp64(-1.0, -3.0, -5.0, -7.0, &vector);
bgc_fp64_quaternion_make(-1.0, -3.0, -5.0, -7.0, &vector);
if (vector.s0 != -1.0 || vector.x1 != -3.0 || vector.x2 != -5.0 || vector.x3 != -7.0) {
print_testing_error("Second step failed");
return;
}
bgc_quaternion_set_values_fp64(-8.0, -2.0, 2.0, 4.0, &vector);
bgc_fp64_quaternion_make(-8.0, -2.0, 2.0, 4.0, &vector);
if (vector.s0 != -8.0 || vector.x1 != -2.0 || vector.x2 != 2.0 || vector.x3 != 4.0) {
print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST1[] = {
static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST1[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f },
{ -244.8f, 100.0f, -100.0f, 344.7f },
{ 1000.32f, -100.1f, 100.2f, -271.3f }
};
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST2[] = {
static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST2[] = {
{ 3.6f, -0.123f, 5.3f, 1003.28f },
{ 204.07f, -781.89f, -0.0032f, 891.3f },
{ -20.02f, -1.0003f, 5.322f, 0.9275f },
@ -24,15 +24,15 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST2[] = {
void test_quaternion_swap_fp32()
{
BgcQuaternionFP32 quaternion1, quaternion2;
BGC_FP32_Quaternion quaternion1, quaternion2;
print_testing_name("bgc_quaternion_swap_fp32");
print_testing_name("bgc_fp32_quaternion_swap");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST1[i], &quaternion1);
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST2[i], &quaternion2);
bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST1[i], &quaternion1);
bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST2[i], &quaternion2);
bgc_quaternion_swap_fp32(&quaternion1, &quaternion2);
bgc_fp32_quaternion_swap(&quaternion1, &quaternion2);
if (quaternion1.s0 != _TEST_FP32_QUATERNION_LIST2[i].s0 ||
quaternion1.x1 != _TEST_FP32_QUATERNION_LIST2[i].x1 ||
@ -54,14 +54,14 @@ void test_quaternion_swap_fp32()
static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST1[] = {
static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST1[] = {
{ 1.0, 2.0, 3.0, 4.0 },
{ -4.0, -3.0, -2.0, -1.0 },
{ -244.8, 100.0, -100.0, 344.7 },
{ 1000.32, -100.1, 100.2, -271.3 }
};
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST2[] = {
static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST2[] = {
{ 3.6, -0.123, 5.3, 1003.28 },
{ 204.07, -781.89, -0.0032, 891.3 },
{ -20.02, -1.0003, 5.322, 0.9275 },
@ -70,15 +70,15 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST2[] = {
void test_quaternion_swap_fp64()
{
BgcQuaternionFP64 quaternion1, quaternion2;
BGC_FP64_Quaternion quaternion1, quaternion2;
print_testing_name("bgc_quaternion_swap_fp64");
print_testing_name("bgc_fp64_quaternion_swap");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST1[i], &quaternion1);
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST2[i], &quaternion2);
bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST1[i], &quaternion1);
bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST2[i], &quaternion2);
bgc_quaternion_swap_fp64(&quaternion1, &quaternion2);
bgc_fp64_quaternion_swap(&quaternion1, &quaternion2);
if (quaternion1.s0 != _TEST_FP64_QUATERNION_LIST2[i].s0 ||
quaternion1.x1 != _TEST_FP64_QUATERNION_LIST2[i].x1 ||

View file

@ -12,22 +12,22 @@ static const TestNumberPairFP32 _TEST_FP32_DATA_CLOSE[] = {
{1.0f, 1.0f},
{-1.0f, -1.0f},
{-0.4f * BGC_EPSYLON_FP32, 0.4f * BGC_EPSYLON_FP32},
{-0.4f * BGC_FP32_EPSYLON, 0.4f * BGC_FP32_EPSYLON},
{1.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32},
{1.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32},
{1.0f + 0.75f * BGC_EPSYLON_FP32, 1.0f},
{1.0f - 0.75f * BGC_EPSYLON_FP32, 1.0f},
{1.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON},
{1.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON},
{1.0f + 0.75f * BGC_FP32_EPSYLON, 1.0f},
{1.0f - 0.75f * BGC_FP32_EPSYLON, 1.0f},
{-1.0f, -1.0f + 0.75f * BGC_EPSYLON_FP32},
{-1.0f, -1.0f - 0.75f * BGC_EPSYLON_FP32},
{-1.0f + 0.75f * BGC_EPSYLON_FP32, -1.0f},
{-1.0f - 0.75f * BGC_EPSYLON_FP32, -1.0f},
{-1.0f, -1.0f + 0.75f * BGC_FP32_EPSYLON},
{-1.0f, -1.0f - 0.75f * BGC_FP32_EPSYLON},
{-1.0f + 0.75f * BGC_FP32_EPSYLON, -1.0f},
{-1.0f - 0.75f * BGC_FP32_EPSYLON, -1.0f},
{100.0f, 100.0f * (1.0f + 0.75f * BGC_EPSYLON_FP32)},
{100.0f, 100.0f * (1.0f - 0.75f * BGC_EPSYLON_FP32)},
{-100.0f, -100.0f * (1.0f + 0.75f * BGC_EPSYLON_FP32)},
{-100.0f, -100.0f * (1.0f - 0.75f * BGC_EPSYLON_FP32)}
{100.0f, 100.0f * (1.0f + 0.75f * BGC_FP32_EPSYLON)},
{100.0f, 100.0f * (1.0f - 0.75f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f + 0.75f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f - 0.75f * BGC_FP32_EPSYLON)}
};
static const TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
@ -35,31 +35,31 @@ static const TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
{1.0f, 0.999f},
{-1.0f, -0.999f},
{-0.6f * BGC_EPSYLON_FP32, 0.6f * BGC_EPSYLON_FP32},
{-0.6f * BGC_FP32_EPSYLON, 0.6f * BGC_FP32_EPSYLON},
{1.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32},
{1.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32},
{1.0f + 1.25f * BGC_EPSYLON_FP32, 1.0f},
{1.0f - 1.25f * BGC_EPSYLON_FP32, 1.0f},
{1.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON},
{1.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON},
{1.0f + 1.25f * BGC_FP32_EPSYLON, 1.0f},
{1.0f - 1.25f * BGC_FP32_EPSYLON, 1.0f},
{-1.0f, -1.0f + 1.25f * BGC_EPSYLON_FP32},
{-1.0f, -1.0f - 1.25f * BGC_EPSYLON_FP32},
{-1.0f + 1.25f * BGC_EPSYLON_FP32, -1.0f},
{-1.0f - 1.25f * BGC_EPSYLON_FP32, -1.0f},
{-1.0f, -1.0f + 1.25f * BGC_FP32_EPSYLON},
{-1.0f, -1.0f - 1.25f * BGC_FP32_EPSYLON},
{-1.0f + 1.25f * BGC_FP32_EPSYLON, -1.0f},
{-1.0f - 1.25f * BGC_FP32_EPSYLON, -1.0f},
{100.0f, 100.0f * (1.0f + 1.25f * BGC_EPSYLON_FP32)},
{100.0f, 100.0f * (1.0f - 1.25f * BGC_EPSYLON_FP32)},
{-100.0f, -100.0f * (1.0f + 1.25f * BGC_EPSYLON_FP32)},
{-100.0f, -100.0f * (1.0f - 1.25f * BGC_EPSYLON_FP32)}
{100.0f, 100.0f * (1.0f + 1.25f * BGC_FP32_EPSYLON)},
{100.0f, 100.0f * (1.0f - 1.25f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f + 1.25f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f - 1.25f * BGC_FP32_EPSYLON)}
};
void test_are_close_fp32()
{
print_testing_name("bgc_are_close_fp32");
print_testing_name("bgc_fp32_are_close");
// Testing close pairs of values:
for (int i = 0; i < _TEST_FP32_CLOSE_NUMBERS_AMOUNT; i++) {
if (!bgc_are_close_fp32(_TEST_FP32_DATA_CLOSE[i].number1, _TEST_FP32_DATA_CLOSE[i].number2)) {
if (!bgc_fp32_are_close(_TEST_FP32_DATA_CLOSE[i].number1, _TEST_FP32_DATA_CLOSE[i].number2)) {
print_testing_error("A pair of close numbers was not recognized");
return;
}
@ -67,7 +67,7 @@ void test_are_close_fp32()
// Testing different pairs of values:
for (int i = 0; i < _TEST_FP32_DIFFERENT_NUMBERS_AMOUNT; i++) {
if (bgc_are_close_fp32(_TEST_FP32_DATA_DIFFERENT[i].number1, _TEST_FP32_DATA_DIFFERENT[i].number2)) {
if (bgc_fp32_are_close(_TEST_FP32_DATA_DIFFERENT[i].number1, _TEST_FP32_DATA_DIFFERENT[i].number2)) {
print_testing_error("A pair of close numbers was not recognized");
return;
}
@ -86,22 +86,22 @@ static const TestNumberPairFP64 _TEST_FP64_DATA_CLOSE[] = {
{1.0, 1.0},
{-1.0, -1.0},
{-0.4 * BGC_EPSYLON_FP64, 0.4 * BGC_EPSYLON_FP64},
{-0.4 * BGC_FP64_EPSYLON, 0.4 * BGC_FP64_EPSYLON},
{1.0, 1.0 + 0.75 * BGC_EPSYLON_FP64},
{1.0, 1.0 - 0.75 * BGC_EPSYLON_FP64},
{1.0 + 0.75 * BGC_EPSYLON_FP64, 1.0},
{1.0 - 0.75 * BGC_EPSYLON_FP64, 1.0},
{1.0, 1.0 + 0.75 * BGC_FP64_EPSYLON},
{1.0, 1.0 - 0.75 * BGC_FP64_EPSYLON},
{1.0 + 0.75 * BGC_FP64_EPSYLON, 1.0},
{1.0 - 0.75 * BGC_FP64_EPSYLON, 1.0},
{-1.0, -1.0 + 0.75 * BGC_EPSYLON_FP64},
{-1.0, -1.0 - 0.75 * BGC_EPSYLON_FP64},
{-1.0 + 0.75 * BGC_EPSYLON_FP64, -1.0},
{-1.0 - 0.75 * BGC_EPSYLON_FP64, -1.0},
{-1.0, -1.0 + 0.75 * BGC_FP64_EPSYLON},
{-1.0, -1.0 - 0.75 * BGC_FP64_EPSYLON},
{-1.0 + 0.75 * BGC_FP64_EPSYLON, -1.0},
{-1.0 - 0.75 * BGC_FP64_EPSYLON, -1.0},
{100.0, 100.0 * (1.0 + 0.75 * BGC_EPSYLON_FP64)},
{100.0, 100.0 * (1.0 - 0.75 * BGC_EPSYLON_FP64)},
{-100.0, -100.0 * (1.0 + 0.75 * BGC_EPSYLON_FP64)},
{-100.0, -100.0 * (1.0 - 0.75 * BGC_EPSYLON_FP64)}
{100.0, 100.0 * (1.0 + 0.75 * BGC_FP64_EPSYLON)},
{100.0, 100.0 * (1.0 - 0.75 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 + 0.75 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 - 0.75 * BGC_FP64_EPSYLON)}
};
static const TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
@ -109,31 +109,31 @@ static const TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
{1.0, 0.999999},
{-1.0, -0.999999},
{-0.6 * BGC_EPSYLON_FP64, 0.6 * BGC_EPSYLON_FP64},
{-0.6 * BGC_FP64_EPSYLON, 0.6 * BGC_FP64_EPSYLON},
{1.0, 1.0 + 1.25 * BGC_EPSYLON_FP64},
{1.0, 1.0 - 1.25 * BGC_EPSYLON_FP64},
{1.0 + 1.25 * BGC_EPSYLON_FP64, 1.0},
{1.0 - 1.25 * BGC_EPSYLON_FP64, 1.0},
{1.0, 1.0 + 1.25 * BGC_FP64_EPSYLON},
{1.0, 1.0 - 1.25 * BGC_FP64_EPSYLON},
{1.0 + 1.25 * BGC_FP64_EPSYLON, 1.0},
{1.0 - 1.25 * BGC_FP64_EPSYLON, 1.0},
{-1.0, -1.0 + 1.25 * BGC_EPSYLON_FP64},
{-1.0, -1.0 - 1.25 * BGC_EPSYLON_FP64},
{-1.0 + 1.25 * BGC_EPSYLON_FP64, -1.0},
{-1.0 - 1.25 * BGC_EPSYLON_FP64, -1.0},
{-1.0, -1.0 + 1.25 * BGC_FP64_EPSYLON},
{-1.0, -1.0 - 1.25 * BGC_FP64_EPSYLON},
{-1.0 + 1.25 * BGC_FP64_EPSYLON, -1.0},
{-1.0 - 1.25 * BGC_FP64_EPSYLON, -1.0},
{100.0, 100.0 * (1.0 + 1.25 * BGC_EPSYLON_FP64)},
{100.0, 100.0 * (1.0 - 1.25 * BGC_EPSYLON_FP64)},
{-100.0, -100.0 * (1.0 + 1.25 * BGC_EPSYLON_FP64)},
{-100.0, -100.0 * (1.0 - 1.25 * BGC_EPSYLON_FP64)}
{100.0, 100.0 * (1.0 + 1.25 * BGC_FP64_EPSYLON)},
{100.0, 100.0 * (1.0 - 1.25 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 + 1.25 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 - 1.25 * BGC_FP64_EPSYLON)}
};
void test_are_close_fp64()
{
print_testing_name("bgc_are_close_fp64");
print_testing_name("bgc_fp64_are_close");
// Testing close pairs of values:
for (int i = 0; i < _TEST_FP64_CLOSE_NUMBERS_AMOUNT; i++) {
if (!bgc_are_close_fp64(_TEST_FP64_DATA_CLOSE[i].number1, _TEST_FP64_DATA_CLOSE[i].number2)) {
if (!bgc_fp64_are_close(_TEST_FP64_DATA_CLOSE[i].number1, _TEST_FP64_DATA_CLOSE[i].number2)) {
print_testing_error("A pair of close numbers was not recognized");
return;
}
@ -141,7 +141,7 @@ void test_are_close_fp64()
// Testing different pairs of values:
for (int i = 0; i < _TEST_FP64_DIFFERENT_NUMBERS_AMOUNT; i++) {
if (bgc_are_close_fp64(_TEST_FP64_DATA_DIFFERENT[i].number1, _TEST_FP64_DATA_DIFFERENT[i].number2)) {
if (bgc_fp64_are_close(_TEST_FP64_DATA_DIFFERENT[i].number1, _TEST_FP64_DATA_DIFFERENT[i].number2)) {
print_testing_error("A pair of different numbers was recognized as close numbers");
return;
}

View file

@ -9,24 +9,24 @@ static const int _TEST_FP32_NONUNIT_NUMBERS_AMOUNT = 4;
static const float _TEST_FP32_UNIT_NUMBERS[] = {
1.0f,
1.0f + 0.75f * BGC_EPSYLON_FP32,
1.0f - 0.75f * BGC_EPSYLON_FP32
1.0f + 0.75f * BGC_FP32_EPSYLON,
1.0f - 0.75f * BGC_FP32_EPSYLON
};
static const float _TEST_FP32_NONUNIT_NUMBERS[] = {
0.0f,
-1.0f,
1.0f + 1.25f * BGC_EPSYLON_FP32,
1.0f - 1.25f * BGC_EPSYLON_FP32
1.0f + 1.25f * BGC_FP32_EPSYLON,
1.0f - 1.25f * BGC_FP32_EPSYLON
};
void test_is_unit_fp32()
{
print_testing_name("bgc_is_unit_fp32");
print_testing_name("bgc_fp32_is_unit");
// Testing unit values:
for (int i = 0; i < _TEST_FP32_UNIT_NUMBERS_AMOUNT; i++) {
if (!bgc_is_unit_fp32(_TEST_FP32_UNIT_NUMBERS[i])) {
if (!bgc_fp32_is_unit(_TEST_FP32_UNIT_NUMBERS[i])) {
print_testing_error("A unit value was not recognized");
return;
}
@ -34,7 +34,7 @@ void test_is_unit_fp32()
// Testing non-unit values:
for (int i = 0; i < _TEST_FP32_NONUNIT_NUMBERS_AMOUNT; i++) {
if (bgc_is_unit_fp32(_TEST_FP32_NONUNIT_NUMBERS[i])) {
if (bgc_fp32_is_unit(_TEST_FP32_NONUNIT_NUMBERS[i])) {
print_testing_error("A non-unit value was recognized as a unit value");
return;
}
@ -50,24 +50,24 @@ static const int _TEST_FP64_NONUNIT_NUMBERS_AMOUNT = 4;
static const double _TEST_FP64_UNIT_NUMBERS[] = {
1.0,
1.0 + 0.75 * BGC_EPSYLON_FP64,
1.0 - 0.75 * BGC_EPSYLON_FP64
1.0 + 0.75 * BGC_FP64_EPSYLON,
1.0 - 0.75 * BGC_FP64_EPSYLON
};
static const double _TEST_FP64_NONUNIT_NUMBERS[] = {
0.0,
-1.0,
1.0 + 1.25 * BGC_EPSYLON_FP64,
1.0 - 1.25 * BGC_EPSYLON_FP64
1.0 + 1.25 * BGC_FP64_EPSYLON,
1.0 - 1.25 * BGC_FP64_EPSYLON
};
void test_is_unit_fp64()
{
print_testing_name("bgc_is_unit_fp64");
print_testing_name("bgc_fp64_is_unit");
// Testing unit values:
for (int i = 0; i < _TEST_FP64_UNIT_NUMBERS_AMOUNT; i++) {
if (!bgc_is_unit_fp64(_TEST_FP64_UNIT_NUMBERS[i])) {
if (!bgc_fp64_is_unit(_TEST_FP64_UNIT_NUMBERS[i])) {
print_testing_error("A unit value was not recognized");
return;
}
@ -75,7 +75,7 @@ void test_is_unit_fp64()
// Testing non-unit values:
for (int i = 0; i < _TEST_FP64_NONUNIT_NUMBERS_AMOUNT; i++) {
if (bgc_is_unit_fp64(_TEST_FP64_NONUNIT_NUMBERS[i])) {
if (bgc_fp64_is_unit(_TEST_FP64_NONUNIT_NUMBERS[i])) {
print_testing_error("A non-unit value was recognized as a unit value");
return;
}
@ -91,24 +91,24 @@ static const int _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT = 4;
static const float _TEST_FP32_DATA_SQUARE_UNIT[] = {
1.0f,
1.0f + 1.75f * BGC_EPSYLON_FP32,
1.0f - 1.75f * BGC_EPSYLON_FP32
1.0f + 1.75f * BGC_FP32_EPSYLON,
1.0f - 1.75f * BGC_FP32_EPSYLON
};
static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = {
0.0f,
-1.0f,
1.0f + 2.25f * BGC_EPSYLON_FP32,
1.0f - 2.25f * BGC_EPSYLON_FP32
1.0f + 2.25f * BGC_FP32_EPSYLON,
1.0f - 2.25f * BGC_FP32_EPSYLON
};
void test_is_sqare_unit_fp32()
void test_is_square_unit_fp32()
{
print_testing_name("bgc_is_sqare_unit_fp32");
print_testing_name("bgc_fp32_is_square_unit");
// Testing unit values:
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT; i++) {
if (!bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_UNIT[i])) {
if (!bgc_fp32_is_square_unit(_TEST_FP32_DATA_SQUARE_UNIT[i])) {
print_testing_error("A square unit value was not recognized");
return;
}
@ -116,7 +116,7 @@ void test_is_sqare_unit_fp32()
// Testing non-unit values:
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
if (bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) {
if (bgc_fp32_is_square_unit(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) {
print_testing_error("A non-unit value was recognized as a square unit value");
return;
}
@ -132,24 +132,24 @@ static const int _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT = 4;
static const double _TEST_FP64_DATA_SQUARE_UNIT[] = {
1.0,
1.0 + 1.75 * BGC_EPSYLON_FP64,
1.0 - 1.75 * BGC_EPSYLON_FP64
1.0 + 1.75 * BGC_FP64_EPSYLON,
1.0 - 1.75 * BGC_FP64_EPSYLON
};
static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = {
0.0,
-1.0,
1.0 + 2.25 * BGC_EPSYLON_FP64,
1.0 - 2.25 * BGC_EPSYLON_FP64
1.0 + 2.25 * BGC_FP64_EPSYLON,
1.0 - 2.25 * BGC_FP64_EPSYLON
};
void test_is_sqare_unit_fp64()
void test_is_square_unit_fp64()
{
print_testing_name("bgc_is_sqare_unit_fp64");
print_testing_name("bgc_fp64_is_square_unit");
// Testing unit values:
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT; i++) {
if (!bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_UNIT[i])) {
if (!bgc_fp64_is_square_unit(_TEST_FP64_DATA_SQUARE_UNIT[i])) {
print_testing_error("A square unit value was not recognized");
return;
}
@ -157,7 +157,7 @@ void test_is_sqare_unit_fp64()
// Testing non-unit values:
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
if (bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) {
if (bgc_fp64_is_square_unit(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) {
print_testing_error("A non-unit value was recognized as a square unit value");
return;
}
@ -171,6 +171,6 @@ void test_is_unit()
test_is_unit_fp32();
test_is_unit_fp64();
test_is_sqare_unit_fp32();
test_is_sqare_unit_fp64();
test_is_square_unit_fp32();
test_is_square_unit_fp64();
}

View file

@ -5,9 +5,9 @@ void test_is_unit_fp32();
void test_is_unit_fp64();
void test_is_sqare_unit_fp32();
void test_is_square_unit_fp32();
void test_is_sqare_unit_fp64();
void test_is_square_unit_fp64();
void test_is_unit();

View file

@ -9,24 +9,24 @@ static const int _TEST_FP32_NONZERO_NUMBERS_AMOUNT = 4;
static const float _TEST_FP32_ZERO_NUMBERS[] = {
0.0f,
0.75f * BGC_EPSYLON_FP32,
-0.75f * BGC_EPSYLON_FP32
0.75f * BGC_FP32_EPSYLON,
-0.75f * BGC_FP32_EPSYLON
};
static const float _TEST_FP32_NONZERO_NUMBERS[] = {
1.0f,
-1.0f,
1.25f * BGC_EPSYLON_FP32,
-1.25f * BGC_EPSYLON_FP32
1.25f * BGC_FP32_EPSYLON,
-1.25f * BGC_FP32_EPSYLON
};
void test_is_zero_fp32()
{
print_testing_name("bgc_is_zero_fp32");
print_testing_name("bgc_fp32_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_NUMBERS_AMOUNT; i++) {
if (!bgc_is_zero_fp32(_TEST_FP32_ZERO_NUMBERS[i])) {
if (!bgc_fp32_is_zero(_TEST_FP32_ZERO_NUMBERS[i])) {
print_testing_error("A zero value was not recognized");
return;
}
@ -34,7 +34,7 @@ void test_is_zero_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_NUMBERS_AMOUNT; i++) {
if (bgc_is_zero_fp32(_TEST_FP32_NONZERO_NUMBERS[i])) {
if (bgc_fp32_is_zero(_TEST_FP32_NONZERO_NUMBERS[i])) {
print_testing_error("A non-zero value was recognized as a zero value");
return;
}
@ -50,24 +50,24 @@ static const int _TEST_FP64_NONZERO_NUMBERS_AMOUNT = 4;
static const double _TEST_FP64_ZERO_NUMBERS[] = {
0.0,
0.75 * BGC_EPSYLON_FP64,
-0.75 * BGC_EPSYLON_FP64
0.75 * BGC_FP64_EPSYLON,
-0.75 * BGC_FP64_EPSYLON
};
static const double _TEST_FP64_NONZERO_NUMBERS[] = {
1.0,
-1.0,
1.25 * BGC_EPSYLON_FP64,
-1.25 * BGC_EPSYLON_FP64
1.25 * BGC_FP64_EPSYLON,
-1.25 * BGC_FP64_EPSYLON
};
void test_is_zero_fp64()
{
print_testing_name("bgc_is_zero_fp64");
print_testing_name("bgc_fp64_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_NUMBERS_AMOUNT; i++) {
if (!bgc_is_zero_fp64(_TEST_FP64_ZERO_NUMBERS[i])) {
if (!bgc_fp64_is_zero(_TEST_FP64_ZERO_NUMBERS[i])) {
print_testing_error("A zero value was not recognized");
return;
}
@ -75,7 +75,7 @@ void test_is_zero_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_NUMBERS_AMOUNT; i++) {
if (bgc_is_zero_fp64(_TEST_FP64_NONZERO_NUMBERS[i])) {
if (bgc_fp64_is_zero(_TEST_FP64_NONZERO_NUMBERS[i])) {
print_testing_error("A non-zero value was recognized as a zero value");
return;
}

View file

@ -22,7 +22,7 @@ void test_vector2()
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1[] = {
const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_1[] = {
{ 3.0f, 4.0f },
{ -3.0f, -4.0f },
{ 10000.0f, -20000.0f },
@ -30,7 +30,7 @@ const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1[] = {
{ -123.5f, 3.7283f }
};
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_2[] = {
const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_2[] = {
{ -3.0f, -4.0f },
{ -3.0f, -4.0f },
{ 0.002f, -0.05f },
@ -49,7 +49,7 @@ int test_vector2_fp32_square_modulus()
float square_modulus;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
square_modulus = bgc_vector2_get_square_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
square_modulus = bgc_fp32_vector2_get_square_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i])) {
print_testing_failed();
@ -72,7 +72,7 @@ int test_vector2_fp32_modulus()
float square_modulus;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
square_modulus = bgc_vector2_get_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
square_modulus = bgc_fp32_vector2_get_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_MODULUS_1[i])) {
print_testing_failed();
@ -86,7 +86,7 @@ int test_vector2_fp32_modulus()
// ===================== Add ==================== //
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
{ 0.0f, 0.0f },
{ -6.0f, -8.0f },
{ 10000.002f, -20000.05f },
@ -98,10 +98,10 @@ int test_vector2_add_fp32()
{
print_testing_name("vector2_fp32_t add");
BgcVector2FP32 vector;
BGC_FP32_Vector2 vector;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
bgc_vector2_add_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
bgc_fp32_vector2_add(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1) ||
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2)) {
@ -116,7 +116,7 @@ int test_vector2_add_fp32()
// ================== Subtract ================== //
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
{ 6.0f, 8.0f },
{ 0.0f, 0.0f },
{ 9999.998f, -19999.95f },
@ -128,10 +128,10 @@ int test_vector2_subtract_fp32()
{
print_testing_name("vector2_fp32_t subtract");
BgcVector2FP32 vector;
BGC_FP32_Vector2 vector;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
bgc_vector2_subtract_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
bgc_fp32_vector2_subtract(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1) ||
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2)) {

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = {
static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST[] = {
{ 1.0f, 2.0f },
{ -2.0f, -1.0f },
{ 100.0f, -100.0f },
@ -16,13 +16,13 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = {
void test_vector2_copy_fp32()
{
BgcVector2FP32 vector;
BGC_FP32_Vector2 vector;
print_testing_name("bgc_vector2_copy_fp32");
print_testing_name("bgc_fp32_vector2_copy");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST[i], &vector);
bgc_fp32_vector2_copy(&_TEST_FP32_VECTOR2_LIST[i], &vector);
if (vector.x1 != _TEST_FP32_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP32_VECTOR2_LIST[i].x2) {
print_testing_failed();
@ -36,7 +36,7 @@ void test_vector2_copy_fp32()
// ==================== FP64 ==================== //
static const int _TEST_FP64_VECTOR2_AMOUNT = 4;
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = {
static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST[] = {
{ 1.0, 2.0 },
{ -2.0, -1.0 },
{ 100.0, -100.0 },
@ -45,13 +45,13 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = {
void test_vector2_copy_fp64()
{
BgcVector2FP64 vector;
BGC_FP64_Vector2 vector;
print_testing_name("bgc_vector2_copy_fp64");
print_testing_name("bgc_fp64_vector2_copy");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST[i], &vector);
bgc_fp64_vector2_copy(&_TEST_FP64_VECTOR2_LIST[i], &vector);
if (vector.x1 != _TEST_FP64_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP64_VECTOR2_LIST[i].x2) {
print_testing_failed();

View file

@ -7,32 +7,32 @@
static const int _TEST_FP32_UNIT_VECTOR2_AMOUNT = 6;
static const int _TEST_FP32_NONUNIT_VECTOR2_AMOUNT = 7;
static const BgcVector2FP32 _TEST_FP32_UNIT_VECTOR2_LIST[] = {
static const BGC_FP32_Vector2 _TEST_FP32_UNIT_VECTOR2_LIST[] = {
{ 1.0f, 0.0f },
{ 0.0f, -1.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }
{ 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON }
};
static const BgcVector2FP32 _TEST_FP32_NONUNIT_VECTOR2_LIST[] = {
static const BGC_FP32_Vector2 _TEST_FP32_NONUNIT_VECTOR2_LIST[] = {
{ 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
{ 0.8f + 1.25f * BGC_EPSYLON_FP32, 0.6f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.6f - 1.25f * BGC_EPSYLON_FP32, 0.8f - 1.25f * BGC_EPSYLON_FP32 }
{ 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.8f + 1.25f * BGC_FP32_EPSYLON, 0.6f + 1.25f * BGC_FP32_EPSYLON },
{ 0.6f - 1.25f * BGC_FP32_EPSYLON, 0.8f - 1.25f * BGC_FP32_EPSYLON }
};
void test_vector2_is_unit_fp32()
{
print_testing_name("bgc_vector2_is_unit_fp32");
print_testing_name("bgc_fp32_vector2_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_unit_fp32(&_TEST_FP32_UNIT_VECTOR2_LIST[i])) {
if (!bgc_fp32_vector2_is_unit(&_TEST_FP32_UNIT_VECTOR2_LIST[i])) {
print_testing_error("A unit vector was not recognized");
return;
}
@ -40,7 +40,7 @@ void test_vector2_is_unit_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_unit_fp32(&_TEST_FP32_NONUNIT_VECTOR2_LIST[i])) {
if (bgc_fp32_vector2_is_unit(&_TEST_FP32_NONUNIT_VECTOR2_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector");
return;
}
@ -54,32 +54,32 @@ void test_vector2_is_unit_fp32()
static const int _TEST_FP64_UNIT_VECTOR2_AMOUNT = 6;
static const int _TEST_FP64_NONUNIT_VECTOR2_AMOUNT = 7;
static const BgcVector2FP64 _TEST_FP64_UNIT_VECTOR2_LIST[] = {
static const BGC_FP64_Vector2 _TEST_FP64_UNIT_VECTOR2_LIST[] = {
{ -1.0, 0.0 },
{ 0.0, 1.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }
{ 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON }
};
static const BgcVector2FP64 _TEST_FP64_NONUNIT_VECTOR2_LIST[] = {
static const BGC_FP64_Vector2 _TEST_FP64_NONUNIT_VECTOR2_LIST[] = {
{ 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
{ 0.6 + 1.25 * BGC_EPSYLON_FP64, 0.8 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.8 - 1.25 * BGC_EPSYLON_FP64, 0.6 - 1.25 * BGC_EPSYLON_FP64 }
{ 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.6 + 1.25 * BGC_FP64_EPSYLON, 0.8 + 1.25 * BGC_FP64_EPSYLON },
{ 0.8 - 1.25 * BGC_FP64_EPSYLON, 0.6 - 1.25 * BGC_FP64_EPSYLON }
};
void test_vector2_is_unit_fp64()
{
print_testing_name("bgc_vector2_is_unit_fp64");
print_testing_name("bgc_fp64_vector2_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_unit_fp64(&_TEST_FP64_UNIT_VECTOR2_LIST[i])) {
if (!bgc_fp64_vector2_is_unit(&_TEST_FP64_UNIT_VECTOR2_LIST[i])) {
print_testing_error("A unit vector was not recognized");
return;
}
@ -87,7 +87,7 @@ void test_vector2_is_unit_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_unit_fp64(&_TEST_FP64_NONUNIT_VECTOR2_LIST[i])) {
if (bgc_fp64_vector2_is_unit(&_TEST_FP64_NONUNIT_VECTOR2_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector");
return;
}

View file

@ -7,31 +7,31 @@
static const int _TEST_FP32_ZERO_VECTOR2_AMOUNT = 5;
static const int _TEST_FP32_NONZERO_VECTOR2_AMOUNT = 7;
static const BgcVector2FP32 _TEST_FP32_ZERO_VECTOR2_LIST[] = {
static const BGC_FP32_Vector2 _TEST_FP32_ZERO_VECTOR2_LIST[] = {
{ 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32 }
{ 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, -0.75f * BGC_FP32_EPSYLON }
};
static const BgcVector2FP32 _TEST_FP32_NONZERO_VECTOR2_LIST[] = {
static const BGC_FP32_Vector2 _TEST_FP32_NONZERO_VECTOR2_LIST[] = {
{ 0.0f, 1.0f },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 }
{ 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ -1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON }
};
void test_vector2_is_zero_fp32()
{
print_testing_name("bgc_vector2_is_zero_fp32");
print_testing_name("bgc_fp32_vector2_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp32(&_TEST_FP32_ZERO_VECTOR2_LIST[i])) {
if (!bgc_fp32_vector2_is_zero(&_TEST_FP32_ZERO_VECTOR2_LIST[i])) {
print_testing_error("A zero vector was not recongized");
return;
}
@ -39,7 +39,7 @@ void test_vector2_is_zero_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp32(&_TEST_FP32_NONZERO_VECTOR2_LIST[i])) {
if (bgc_fp32_vector2_is_zero(&_TEST_FP32_NONZERO_VECTOR2_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector");
return;
}
@ -53,31 +53,31 @@ void test_vector2_is_zero_fp32()
static const int _TEST_FP64_ZERO_VECTOR2_AMOUNT = 5;
static const int _TEST_FP64_NONZERO_VECTOR2_AMOUNT = 7;
static const BgcVector2FP64 _TEST_FP64_ZERO_VECTOR2_LIST[] = {
static const BGC_FP64_Vector2 _TEST_FP64_ZERO_VECTOR2_LIST[] = {
{ 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64 }
{ 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, -0.75 * BGC_FP64_EPSYLON }
};
static const BgcVector2FP64 _TEST_FP64_NONZERO_VECTOR2_LIST[] = {
static const BGC_FP64_Vector2 _TEST_FP64_NONZERO_VECTOR2_LIST[] = {
{ 0.0, 1.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64 },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 }
{ 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON },
{ -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON }
};
void test_vector2_is_zero_fp64()
{
print_testing_name("bgc_vector2_is_zero_fp64");
print_testing_name("bgc_fp64_vector2_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp64(&_TEST_FP64_ZERO_VECTOR2_LIST[i])) {
if (!bgc_fp64_vector2_is_zero(&_TEST_FP64_ZERO_VECTOR2_LIST[i])) {
print_testing_error("A zero vector was not recongized");
return;
}
@ -85,7 +85,7 @@ void test_vector2_is_zero_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_VECTOR2_LIST[i])) {
if (bgc_fp64_vector2_is_zero(&_TEST_FP64_NONZERO_VECTOR2_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector");
return;
}

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = {
static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST[] = {
{ 4.0f, 3.0f },
{ -3.0f, -4.0f },
{ 100.0f, -100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_vector2_square_modulus_fp32()
{
print_testing_name("bgc_vector2_get_square_modulus_fp32");
print_testing_name("bgc_fp32_vector2_get_square_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector2_get_square_modulus_fp32(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_vector2_get_square_modulus(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -43,10 +43,10 @@ void test_vector2_square_modulus_fp32()
void test_vector2_modulus_fp32()
{
print_testing_name("bgc_vector2_get_modulus_fp32");
print_testing_name("bgc_fp32_vector2_get_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector2_get_modulus_fp32(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_vector2_get_modulus(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -59,7 +59,7 @@ void test_vector2_modulus_fp32()
static const int _TEST_FP64_VECTOR2_AMOUNT = 4;
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = {
static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST[] = {
{ 4.0, 3.0 },
{ -3.0, -4.0 },
{ 100.0, -100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_vector2_square_modulus_fp64()
{
print_testing_name("bgc_vector2_get_square_modulus_fp64");
print_testing_name("bgc_fp64_vector2_get_square_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector2_get_square_modulus_fp64(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_vector2_get_square_modulus(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -96,10 +96,10 @@ void test_vector2_square_modulus_fp64()
void test_vector2_modulus_fp64()
{
print_testing_name("bgc_vector2_get_modulus_fp64");
print_testing_name("bgc_fp64_vector2_get_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector2_get_modulus_fp64(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_vector2_get_modulus(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed();
return;
}

View file

@ -4,11 +4,11 @@
void test_vector2_reset_fp32()
{
BgcVector2FP32 vector;
BGC_FP32_Vector2 vector;
print_testing_name("bgc_vector2_reset_fp32");
print_testing_name("bgc_fp32_vector2_reset");
bgc_vector2_reset_fp32(&vector);
bgc_fp32_vector2_reset(&vector);
if (vector.x1 != 0.0f || vector.x2 != 0.0f) {
print_testing_failed();
@ -20,11 +20,11 @@ void test_vector2_reset_fp32()
void test_vector2_reset_fp64()
{
BgcVector2FP64 vector;
BGC_FP64_Vector2 vector;
print_testing_name("bgc_vector2_reset_fp64");
print_testing_name("bgc_fp64_vector2_reset");
bgc_vector2_reset_fp64(&vector);
bgc_fp64_vector2_reset(&vector);
if (vector.x1 != 0.0 || vector.x2 != 0.0) {
print_testing_failed();

View file

@ -8,25 +8,25 @@
void test_vector2_set_values_fp32()
{
BgcVector2FP32 vector;
BGC_FP32_Vector2 vector;
print_testing_name("bgc_vector2_set_values_fp32");
print_testing_name("bgc_fp32_vector2_make");
bgc_vector2_set_values_fp32(1.0f, 2.0f, &vector);
bgc_fp32_vector2_make(1.0f, 2.0f, &vector);
if (vector.x1 != 1.0f || vector.x2 != 2.0f) {
print_testing_error("First step failed");
return;
}
bgc_vector2_set_values_fp32(-3.0f, -5.0f, &vector);
bgc_fp32_vector2_make(-3.0f, -5.0f, &vector);
if (vector.x1 != -3.0f || vector.x2 != -5.0f) {
print_testing_error("Second step failed");
return;
}
bgc_vector2_set_values_fp32(-2.0f, 2.0f, &vector);
bgc_fp32_vector2_make(-2.0f, 2.0f, &vector);
if (vector.x1 != -2.0f || vector.x2 != 2.0f) {
print_testing_error("Third step failed");
@ -40,26 +40,26 @@ void test_vector2_set_values_fp32()
void test_vector2_set_values_fp64()
{
BgcVector2FP64 vector;
BGC_FP64_Vector2 vector;
print_testing_name("bgc_vector2_set_values_fp64");
print_testing_name("bgc_fp64_vector2_make");
bgc_vector2_set_values_fp64(1.0, 2.0, &vector);
bgc_fp64_vector2_make(1.0, 2.0, &vector);
if (vector.x1 != 1.0 || vector.x2 != 2.0) {
print_testing_error("First step failed");
return;
}
bgc_vector2_set_values_fp64(-3.0, -5.0, &vector);
bgc_fp64_vector2_make(-3.0, -5.0, &vector);
if (vector.x1 != -3.0 || vector.x2 != -5.0) {
print_testing_error("Second step failed");
return;
}
bgc_vector2_set_values_fp64(-2.0, 2.0, &vector);
bgc_fp64_vector2_make(-2.0, 2.0, &vector);
if (vector.x1 != -2.0 || vector.x2 != 2.0) {
print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST1[] = {
static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST1[] = {
{ 1.0f, 2.0f },
{ -2.0f, -1.0f },
{ 100.0f, -100.0f },
{ -100.1f, 100.2f }
};
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = {
static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST2[] = {
{ 3.6f, 5.3f },
{ 204.07f, -781.89f },
{ -20.02f, -1.0003f },
@ -24,15 +24,15 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = {
void test_vector2_swap_fp32()
{
BgcVector2FP32 vector1, vector2;
BGC_FP32_Vector2 vector1, vector2;
print_testing_name("bgc_vector2_swap_fp32");
print_testing_name("bgc_fp32_vector2_swap");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST1[i], &vector1);
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST2[i], &vector2);
bgc_fp32_vector2_copy(&_TEST_FP32_VECTOR2_LIST1[i], &vector1);
bgc_fp32_vector2_copy(&_TEST_FP32_VECTOR2_LIST2[i], &vector2);
bgc_vector2_swap_fp32(&vector1, &vector2);
bgc_fp32_vector2_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP32_VECTOR2_LIST2[i].x1 ||
vector1.x2 != _TEST_FP32_VECTOR2_LIST2[i].x2 ||
@ -50,14 +50,14 @@ void test_vector2_swap_fp32()
static const int _TEST_FP64_VECTOR2_AMOUNT = 4;
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST1[] = {
static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST1[] = {
{ 1.0, 2.0 },
{ -2.0, -1.0 },
{ 100.0, -100.0 },
{ -100.1, 100.2 }
};
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = {
static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST2[] = {
{ 3.6, 5.3 },
{ 204.07, -781.89 },
{ -20.02, -1.0003 },
@ -66,15 +66,15 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = {
void test_vector2_swap_fp64()
{
BgcVector2FP64 vector1, vector2;
BGC_FP64_Vector2 vector1, vector2;
print_testing_name("bgc_vector2_swap_fp64");
print_testing_name("bgc_fp64_vector2_swap");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST1[i], &vector1);
bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST2[i], &vector2);
bgc_fp64_vector2_copy(&_TEST_FP64_VECTOR2_LIST1[i], &vector1);
bgc_fp64_vector2_copy(&_TEST_FP64_VECTOR2_LIST2[i], &vector2);
bgc_vector2_swap_fp64(&vector1, &vector2);
bgc_fp64_vector2_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP64_VECTOR2_LIST2[i].x1 ||
vector1.x2 != _TEST_FP64_VECTOR2_LIST2[i].x2 ||

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = {
static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST[] = {
{ 1.0f, 2.0f, 3.0f },
{ -3.0f, -2.0f, -1.0f },
{ 100.0f, -100.0f, 0.001f },
@ -16,13 +16,13 @@ static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = {
void test_vector3_copy_fp32()
{
BgcVector3FP32 vector;
BGC_FP32_Vector3 vector;
print_testing_name("bgc_vector3_copy_fp32");
print_testing_name("bgc_fp32_vector3_copy");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST[i], &vector);
bgc_fp32_vector3_copy(&_TEST_FP32_VECTOR3_LIST[i], &vector);
if (vector.x1 != _TEST_FP32_VECTOR3_LIST[i].x1 ||
vector.x2 != _TEST_FP32_VECTOR3_LIST[i].x2 ||
@ -38,7 +38,7 @@ void test_vector3_copy_fp32()
// ==================== FP64 ==================== //
static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = {
static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST[] = {
{ 1.0, 2.0, 3.0 },
{ -3.0, -2.0, -1.0 },
{ 100.0, -100.0, 0.001 },
@ -47,13 +47,13 @@ static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = {
void test_vector3_copy_fp64()
{
BgcVector3FP64 vector;
BGC_FP64_Vector3 vector;
print_testing_name("bgc_vector3_copy_fp64");
print_testing_name("bgc_fp64_vector3_copy");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST[i], &vector);
bgc_fp64_vector3_copy(&_TEST_FP64_VECTOR3_LIST[i], &vector);
if (vector.x1 != _TEST_FP64_VECTOR3_LIST[i].x1 ||
vector.x2 != _TEST_FP64_VECTOR3_LIST[i].x2 ||

View file

@ -7,38 +7,38 @@
static const int _TEST_FP32_UNIT_VECTOR3_AMOUNT = 10;
static const int _TEST_FP32_NONUNIT_VECTOR3_AMOUNT = 9;
static const BgcVector3FP32 _TEST_FP32_UNIT_VECTOR3_LIST[] = {
static const BGC_FP32_Vector3 _TEST_FP32_UNIT_VECTOR3_LIST[] = {
{ 1.0f, 0.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f },
{ 0.0f, -0.8f, 0.6f },
{ -0.6f, 0.0f, 0.8f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, -1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, -1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }
{ 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, -1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON }
};
static const BgcVector3FP32 _TEST_FP32_NONUNIT_VECTOR3_LIST[] = {
static const BGC_FP32_Vector3 _TEST_FP32_NONUNIT_VECTOR3_LIST[] = {
{ 0.0f, 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
{ 0.8f + 1.25f * BGC_EPSYLON_FP32, -0.6f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.6f - 1.25f * BGC_EPSYLON_FP32, -0.8f + 1.25f * BGC_EPSYLON_FP32, 0.0f }
{ 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.8f + 1.25f * BGC_FP32_EPSYLON, -0.6f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.6f - 1.25f * BGC_FP32_EPSYLON, -0.8f + 1.25f * BGC_FP32_EPSYLON, 0.0f }
};
void test_vector3_is_unit_fp32()
{
print_testing_name("bgc_vector3_is_unit_fp32");
print_testing_name("bgc_fp32_vector3_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_unit_fp32(&_TEST_FP32_UNIT_VECTOR3_LIST[i])) {
if (!bgc_fp32_vector3_is_unit(&_TEST_FP32_UNIT_VECTOR3_LIST[i])) {
print_testing_error("A unit vector was not recognized");
return;
}
@ -46,7 +46,7 @@ void test_vector3_is_unit_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_unit_fp32(&_TEST_FP32_NONUNIT_VECTOR3_LIST[i])) {
if (bgc_fp32_vector3_is_unit(&_TEST_FP32_NONUNIT_VECTOR3_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector");
return;
}
@ -60,38 +60,38 @@ void test_vector3_is_unit_fp32()
static const int _TEST_FP64_UNIT_VECTOR3_AMOUNT = 10;
static const int _TEST_FP64_NONUNIT_VECTOR3_AMOUNT = 9;
static const BgcVector3FP64 _TEST_FP64_UNIT_VECTOR3_LIST[] = {
static const BGC_FP64_Vector3 _TEST_FP64_UNIT_VECTOR3_LIST[] = {
{ 1.0, 0.0, 0.0 },
{ 0.0, -1.0, 0.0 },
{ 0.0, -0.8, 0.6 },
{ -0.6, 0.0, 0.8 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, -1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, -1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }
{ 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, -1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON }
};
static const BgcVector3FP64 _TEST_FP64_NONUNIT_VECTOR3_LIST[] = {
static const BGC_FP64_Vector3 _TEST_FP64_NONUNIT_VECTOR3_LIST[] = {
{ 0.0, 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
{ 0.8 + 1.25 * BGC_EPSYLON_FP64, -0.6 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.6 - 1.25 * BGC_EPSYLON_FP64, -0.8 + 1.25 * BGC_EPSYLON_FP64, 0.0 }
{ 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.8 + 1.25 * BGC_FP64_EPSYLON, -0.6 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.6 - 1.25 * BGC_FP64_EPSYLON, -0.8 + 1.25 * BGC_FP64_EPSYLON, 0.0 }
};
void test_vector3_is_unit_fp64()
{
print_testing_name("bgc_vector3_is_unit_fp64");
print_testing_name("bgc_fp64_vector3_is_unit");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_unit_fp64(&_TEST_FP64_UNIT_VECTOR3_LIST[i])) {
if (!bgc_fp64_vector3_is_unit(&_TEST_FP64_UNIT_VECTOR3_LIST[i])) {
print_testing_error("A unit vector was not recognized");
return;
}
@ -99,7 +99,7 @@ void test_vector3_is_unit_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_unit_fp64(&_TEST_FP64_NONUNIT_VECTOR3_LIST[i])) {
if (bgc_fp64_vector3_is_unit(&_TEST_FP64_NONUNIT_VECTOR3_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector");
return;
}

View file

@ -7,35 +7,35 @@
static const int _TEST_FP32_ZERO_VECTOR3_AMOUNT = 7;
static const int _TEST_FP32_NONZERO_VECTOR3_AMOUNT = 9;
static const BgcVector3FP32 _TEST_FP32_ZERO_VECTOR3_LIST[] = {
static const BGC_FP32_Vector3 _TEST_FP32_ZERO_VECTOR3_LIST[] = {
{ 0.0f, 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 }
{ 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON }
};
static const BgcVector3FP32 _TEST_FP32_NONZERO_VECTOR3_LIST[] = {
static const BGC_FP32_Vector3 _TEST_FP32_NONZERO_VECTOR3_LIST[] = {
{ 0.0f, 1.0f, 0.0f },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f }
{ 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON, 0.0f }
};
void test_vector3_is_zero_fp32()
{
print_testing_name("bgc_vector3_is_zero_fp32");
print_testing_name("bgc_fp32_vector3_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_zero_fp32(&_TEST_FP32_ZERO_VECTOR3_LIST[i])) {
if (!bgc_fp32_vector3_is_zero(&_TEST_FP32_ZERO_VECTOR3_LIST[i])) {
print_testing_error("A zero vector was not recongized");
return;
}
@ -43,7 +43,7 @@ void test_vector3_is_zero_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_zero_fp32(&_TEST_FP32_NONZERO_VECTOR3_LIST[i])) {
if (bgc_fp32_vector3_is_zero(&_TEST_FP32_NONZERO_VECTOR3_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector");
return;
}
@ -57,35 +57,35 @@ void test_vector3_is_zero_fp32()
static const int _TEST_FP64_ZERO_VECTOR3_AMOUNT = 7;
static const int _TEST_FP64_NONZERO_VECTOR3_AMOUNT = 9;
static const BgcVector3FP64 _TEST_FP64_ZERO_VECTOR3_LIST[] = {
static const BGC_FP64_Vector3 _TEST_FP64_ZERO_VECTOR3_LIST[] = {
{ 0.0, 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 }
{ 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON }
};
static const BgcVector3FP64 _TEST_FP64_NONZERO_VECTOR3_LIST[] = {
static const BGC_FP64_Vector3 _TEST_FP64_NONZERO_VECTOR3_LIST[] = {
{ 0.0, 1.0, 0.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64, 0.0 }
{ 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ -BGC_FP64_EPSYLON, -BGC_FP64_EPSYLON, 0.0 }
};
void test_vector3_is_zero_fp64()
{
print_testing_name("bgc_vector3_is_zero_fp64");
print_testing_name("bgc_fp64_vector3_is_zero");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_zero_fp64(&_TEST_FP64_ZERO_VECTOR3_LIST[i])) {
if (!bgc_fp64_vector3_is_zero(&_TEST_FP64_ZERO_VECTOR3_LIST[i])) {
print_testing_error("A zero vector was not recongized");
return;
}
@ -93,7 +93,7 @@ void test_vector3_is_zero_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_zero_fp64(&_TEST_FP64_NONZERO_VECTOR3_LIST[i])) {
if (bgc_fp64_vector3_is_zero(&_TEST_FP64_NONZERO_VECTOR3_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector");
return;
}

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = {
static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST[] = {
{ 4.0f, 3.0f, 0.0f },
{ 0.0f, -3.0f, -4.0f },
{ 100.0f, -100.0f, 100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_vector3_square_modulus_fp32()
{
print_testing_name("bgc_vector3_get_square_modulus_fp32");
print_testing_name("bgc_fp32_vector3_get_square_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector3_get_square_modulus_fp32(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_vector3_get_square_modulus(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -43,10 +43,10 @@ void test_vector3_square_modulus_fp32()
void test_vector3_modulus_fp32()
{
print_testing_name("bgc_vector3_get_modulus_fp32");
print_testing_name("bgc_fp32_vector3_get_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector3_get_modulus_fp32(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
if (!bgc_fp32_are_close(bgc_fp32_vector3_get_modulus(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -59,7 +59,7 @@ void test_vector3_modulus_fp32()
static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = {
static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST[] = {
{ 0.0, 4.0, 3.0 },
{ -3.0, 0.0, -4.0 },
{ 100.0, -100.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_vector3_square_modulus_fp64()
{
print_testing_name("bgc_vector3_get_square_modulus_fp64");
print_testing_name("bgc_fp64_vector3_get_square_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector3_get_square_modulus_fp64(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_vector3_get_square_modulus(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
@ -96,10 +96,10 @@ void test_vector3_square_modulus_fp64()
void test_vector3_modulus_fp64()
{
print_testing_name("bgc_vector3_get_modulus_fp64");
print_testing_name("bgc_fp64_vector3_get_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector3_get_modulus_fp64(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
if (!bgc_fp64_are_close(bgc_fp64_vector3_get_modulus(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed();
return;
}

View file

@ -4,11 +4,11 @@
void test_vector3_reset_fp32()
{
BgcVector3FP32 vector;
BGC_FP32_Vector3 vector;
print_testing_name("bgc_vector3_reset_fp32");
print_testing_name("bgc_fp32_vector3_reset");
bgc_vector3_reset_fp32(&vector);
bgc_fp32_vector3_reset(&vector);
if (vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
print_testing_failed();
@ -20,11 +20,11 @@ void test_vector3_reset_fp32()
void test_vector3_reset_fp64()
{
BgcVector3FP64 vector;
BGC_FP64_Vector3 vector;
print_testing_name("bgc_vector3_reset_fp64");
print_testing_name("bgc_fp64_vector3_reset");
bgc_vector3_reset_fp64(&vector);
bgc_fp64_vector3_reset(&vector);
if (vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
print_testing_failed();

View file

@ -8,25 +8,25 @@
void test_vector3_set_values_fp32()
{
BgcVector3FP32 vector;
BGC_FP32_Vector3 vector;
print_testing_name("bgc_vector3_set_values_fp32");
print_testing_name("bgc_fp32_vector3_make");
bgc_vector3_set_values_fp32(1.0f, 2.0f, 3.0f, &vector);
bgc_fp32_vector3_make(1.0f, 2.0f, 3.0f, &vector);
if (vector.x1 != 1.0f || vector.x2 != 2.0f || vector.x3 != 3.0f) {
print_testing_error("First step failed");
return;
}
bgc_vector3_set_values_fp32(-3.0f, -5.0f, -7.0f, &vector);
bgc_fp32_vector3_make(-3.0f, -5.0f, -7.0f, &vector);
if (vector.x1 != -3.0f || vector.x2 != -5.0f || vector.x3 != -7.0f) {
print_testing_error("Second step failed");
return;
}
bgc_vector3_set_values_fp32(-2.0f, 2.0f, 4.0f, &vector);
bgc_fp32_vector3_make(-2.0f, 2.0f, 4.0f, &vector);
if (vector.x1 != -2.0f || vector.x2 != 2.0f || vector.x3 != 4.0f) {
print_testing_error("Third step failed");
@ -40,26 +40,26 @@ void test_vector3_set_values_fp32()
void test_vector3_set_values_fp64()
{
BgcVector3FP64 vector;
BGC_FP64_Vector3 vector;
print_testing_name("bgc_vector3_set_values_fp64");
print_testing_name("bgc_fp64_vector3_make");
bgc_vector3_set_values_fp64(1.0, 2.0, 3.0, &vector);
bgc_fp64_vector3_make(1.0, 2.0, 3.0, &vector);
if (vector.x1 != 1.0 || vector.x2 != 2.0 || vector.x3 != 3.0) {
print_testing_error("First step failed");
return;
}
bgc_vector3_set_values_fp64(-3.0, -5.0, -7.0, &vector);
bgc_fp64_vector3_make(-3.0, -5.0, -7.0, &vector);
if (vector.x1 != -3.0 || vector.x2 != -5.0 || vector.x3 != -7.0) {
print_testing_error("Second step failed");
return;
}
bgc_vector3_set_values_fp64(-2.0, 2.0, 4.0, &vector);
bgc_fp64_vector3_make(-2.0, 2.0, 4.0, &vector);
if (vector.x1 != -2.0 || vector.x2 != 2.0 || vector.x3 != 4.0) {
print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST1[] = {
static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST1[] = {
{ 1.0f, 2.0f, 3.0f },
{ -3.0f, -2.0f, -1.0f },
{ 100.0f, -100.0f, 344.7f },
{ -100.1f, 100.2f, -271.3f }
};
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST2[] = {
static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST2[] = {
{ 3.6f, 5.3f, -0.123f },
{ 204.07f, -781.89f, 891.3f },
{ -20.02f, -1.0003f, 0.9275f },
@ -24,15 +24,15 @@ static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST2[] = {
void test_vector3_swap_fp32()
{
BgcVector3FP32 vector1, vector2;
BGC_FP32_Vector3 vector1, vector2;
print_testing_name("bgc_vector3_swap_fp32");
print_testing_name("bgc_fp32_vector3_swap");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST1[i], &vector1);
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST2[i], &vector2);
bgc_fp32_vector3_copy(&_TEST_FP32_VECTOR3_LIST1[i], &vector1);
bgc_fp32_vector3_copy(&_TEST_FP32_VECTOR3_LIST2[i], &vector2);
bgc_vector3_swap_fp32(&vector1, &vector2);
bgc_fp32_vector3_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP32_VECTOR3_LIST2[i].x1 ||
vector1.x2 != _TEST_FP32_VECTOR3_LIST2[i].x2 ||
@ -52,14 +52,14 @@ void test_vector3_swap_fp32()
static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST1[] = {
static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST1[] = {
{ 1.0, 2.0, 3.0 },
{ -3.0, -2.0, -1.0 },
{ 100.0, -100.0, 344.7 },
{ -100.1, 100.2, -271.3 }
};
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST2[] = {
static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST2[] = {
{ 3.6, 5.3, -0.123 },
{ 204.07, -781.89, 891.3 },
{ -20.02, -1.0003, 0.9275 },
@ -68,15 +68,15 @@ static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST2[] = {
void test_vector3_swap_fp64()
{
BgcVector3FP64 vector1, vector2;
BGC_FP64_Vector3 vector1, vector2;
print_testing_name("bgc_vector3_swap_fp64");
print_testing_name("bgc_fp64_vector3_swap");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST1[i], &vector1);
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST2[i], &vector2);
bgc_fp64_vector3_copy(&_TEST_FP64_VECTOR3_LIST1[i], &vector1);
bgc_fp64_vector3_copy(&_TEST_FP64_VECTOR3_LIST2[i], &vector2);
bgc_vector3_swap_fp64(&vector1, &vector2);
bgc_fp64_vector3_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP64_VECTOR3_LIST2[i].x1 ||
vector1.x2 != _TEST_FP64_VECTOR3_LIST2[i].x2 ||

View file

@ -9,35 +9,35 @@ static const int _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP32 _TEST_FP32_CLOSE_VERSOR_PAIR_LIST[] = {
{
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }
{ 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
},
{
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }
{ 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
},
{
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }
{ 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
},
{
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }
{ 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
},
{
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f }
},
{
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f }
},
{
{ 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON }
},
{
{ 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON }
},
{
{ 0.70710678f, 0.0f, 0.70710675f, 0.0f },
@ -54,35 +54,35 @@ static const int _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = {
{
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }
{ 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
},
{
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }
{ 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
},
{
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }
{ 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
},
{
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }
{ 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
},
{
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f }
},
{
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f }
},
{
{ 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON }
},
{
{ 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON }
},
{
{ 0.707106f, 0.0f, 0.707107f, 0.0f },
@ -96,11 +96,11 @@ static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = {
void test_versor_are_close_fp32()
{
print_testing_name("bgc_versor_are_close_fp32");
print_testing_name("bgc_fp32_versor_are_close");
// Testing close pairs of versors:
for (int i = 0; i < _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT; i++) {
if (!bgc_versor_are_close_fp32(&_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].second)) {
if (!bgc_fp32_versor_are_close(&_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of close versors was not recognized");
return;
}
@ -108,7 +108,7 @@ void test_versor_are_close_fp32()
// Testing different pairs of versors:
for (int i = 0; i < _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) {
if (bgc_versor_are_close_fp32(&_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
if (bgc_fp32_versor_are_close(&_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of different versors was recognized as close versors");
return;
}
@ -125,35 +125,35 @@ static const int _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP64 _TEST_FP64_CLOSE_VERSOR_PAIR_LIST[] = {
{
{ 1.0, 0.0, 0.0, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }
{ 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
},
{
{ 1.0, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }
{ 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
},
{
{ 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }
{ 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }
},
{
{ 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }
{ 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }
},
{
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }
{ 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 }
},
{
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }
{ 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 }
},
{
{ 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON }
},
{
{ 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON }
},
{
{ 0.7071067811865475244, 0.0, 0.7071067811865465244, 0.0 },
@ -170,35 +170,35 @@ static const int _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = {
{
{ 1.0, 0.0, 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }
{ 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
},
{
{ 1.0, 0.0, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }
{ 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
},
{
{ 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }
{ 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }
},
{
{ 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }
{ 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }
},
{
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }
{ 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 }
},
{
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }
{ 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 }
},
{
{ 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON }
},
{
{ 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON }
},
{
{ 0.7071067811866, 0.0, 0.7071067811865, 0.0 },
@ -212,11 +212,11 @@ static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = {
void test_versor_are_close_fp64()
{
print_testing_name("bgc_versor_are_close_fp64");
print_testing_name("bgc_fp64_versor_are_close");
// Testing close pairs of versors:
for (int i = 0; i < _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT; i++) {
if (!bgc_versor_are_close_fp64(&_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].second)) {
if (!bgc_fp64_versor_are_close(&_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of close versors was not recognized");
return;
}
@ -224,7 +224,7 @@ void test_versor_are_close_fp64()
// Testing different pairs of versors:
for (int i = 0; i < _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) {
if (bgc_versor_are_close_fp64(&_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
if (bgc_fp64_versor_are_close(&_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of different versors was recognized as close versors");
return;
}

View file

@ -38,14 +38,14 @@ static const TestVersorTripletFP32 _TEST_FP32_VERSOR_TRIPLET_LIST[] = {
void test_versor_combine_fp32()
{
BgcVersorFP32 versor;
BGC_FP32_Versor versor;
print_testing_name("bgc_versor_combine_fp32");
print_testing_name("bgc_fp32_versor_combine");
for (int i = 0; i < _TEST_FP32_VERSOR_TRIPLET_AMOUNT; i++) {
bgc_versor_combine_fp32(&_TEST_FP32_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].second, &versor);
bgc_fp32_versor_combine(&_TEST_FP32_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].second, &versor);
if (!bgc_versor_are_close_fp32(&versor, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].result)) {
if (!bgc_fp32_versor_are_close(&versor, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].result)) {
print_testing_failed();
return;
}
@ -88,14 +88,14 @@ static const TestVersorTripletFP64 _TEST_FP64_VERSOR_TRIPLET_LIST[] = {
void test_versor_combine_fp64()
{
BgcVersorFP64 versor;
BGC_FP64_Versor versor;
print_testing_name("bgc_versor_combine_fp64");
print_testing_name("bgc_fp64_versor_combine");
for (int i = 0; i < _TEST_FP64_VERSOR_TRIPLET_AMOUNT; i++) {
bgc_versor_combine_fp64(&_TEST_FP64_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].second, &versor);
bgc_fp64_versor_combine(&_TEST_FP64_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].second, &versor);
if (!bgc_versor_are_close_fp64(&versor, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].result)) {
if (!bgc_fp64_versor_are_close(&versor, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].result)) {
print_testing_failed();
return;
}

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_VERSOR_AMOUNT = 8;
static const BgcVersorFP32 _TEST_FP32_VERSOR_LIST[] = {
static const BGC_FP32_Versor _TEST_FP32_VERSOR_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.182574185835f, 0.36514837167f, 0.54772255751f, 0.73029674334f },
@ -20,13 +20,13 @@ static const BgcVersorFP32 _TEST_FP32_VERSOR_LIST[] = {
void test_versor_copy_fp32()
{
BgcVersorFP32 versor;
BGC_FP32_Versor versor;
print_testing_name("bgc_versor_copy_fp32");
print_testing_name("bgc_fp32_versor_copy");
for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) {
bgc_versor_copy_fp32(&_TEST_FP32_VERSOR_LIST[i], &versor);
bgc_fp32_versor_copy(&_TEST_FP32_VERSOR_LIST[i], &versor);
if (versor._s0 != _TEST_FP32_VERSOR_LIST[i]._s0 ||
versor._x1 != _TEST_FP32_VERSOR_LIST[i]._x1 ||
@ -43,7 +43,7 @@ void test_versor_copy_fp32()
// ==================== FP64 ==================== //
static const int _TEST_FP64_VERSOR_AMOUNT = 8;
static const BgcVersorFP64 _TEST_FP64_VERSOR_LIST[] = {
static const BGC_FP64_Versor _TEST_FP64_VERSOR_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.1825741858350553712, 0.3651483716701107423, 0.5477225575051661135, 0.7302967433402214846 },
@ -56,13 +56,13 @@ static const BgcVersorFP64 _TEST_FP64_VERSOR_LIST[] = {
void test_versor_copy_fp64()
{
BgcVersorFP64 versor;
BGC_FP64_Versor versor;
print_testing_name("bgc_versor_copy_fp64");
print_testing_name("bgc_fp64_versor_copy");
for (int i = 0; i < _TEST_FP64_VERSOR_AMOUNT; i++) {
bgc_versor_copy_fp64(&_TEST_FP64_VERSOR_LIST[i], &versor);
bgc_fp64_versor_copy(&_TEST_FP64_VERSOR_LIST[i], &versor);
if (versor._s0 != _TEST_FP64_VERSOR_LIST[i]._s0 ||
versor._x1 != _TEST_FP64_VERSOR_LIST[i]._x1 ||

View file

@ -7,33 +7,33 @@
static const int _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT = 9;
static const int _TEST_FP32_NON_IDENTIYTY_VERSOR_AMOUNT = 5;
static const BgcVersorFP32 _TEST_FP32_IDENTIYTY_VERSOR_LIST[] = {
static const BGC_FP32_Versor _TEST_FP32_IDENTIYTY_VERSOR_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 1.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 },
{ 1.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 }
{ 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f, 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 1.0f, 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON }
};
static const BgcVersorFP32 _TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[] = {
static const BGC_FP32_Versor _TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[] = {
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.5f, 0.5f, 0.5f, 0.5f },
{ 1.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }
{ 1.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
};
void test_versor_is_identity_fp32()
{
print_testing_name("bgc_versor_is_identity_fp32");
print_testing_name("bgc_fp32_versor_is_idle");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (!bgc_versor_is_identity_fp32(&_TEST_FP32_IDENTIYTY_VERSOR_LIST[i])) {
if (!bgc_fp32_versor_is_idle(&_TEST_FP32_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("An identity versor was not recognized");
return;
}
@ -41,7 +41,7 @@ void test_versor_is_identity_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NON_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (bgc_versor_is_identity_fp32(&_TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[i])) {
if (bgc_fp32_versor_is_idle(&_TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("A non-identity versor was recognized as an identity versor");
return;
}
@ -55,33 +55,33 @@ void test_versor_is_identity_fp32()
static const int _TEST_FP64_IDENTIYTY_VERSOR_AMOUNT = 9;
static const int _TEST_FP64_NON_IDENTIYTY_VERSOR_AMOUNT = 5;
static const BgcVersorFP64 _TEST_FP64_IDENTIYTY_VERSOR_LIST[] = {
static const BGC_FP64_Versor _TEST_FP64_IDENTIYTY_VERSOR_LIST[] = {
{ 1.0, 0.0, 0.0, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 1.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 1.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 1.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 },
{ 1.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 }
{ 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0, -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0, 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0, 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0, 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0, 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 1.0, 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON }
};
static const BgcVersorFP64 _TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[] = {
static const BGC_FP64_Versor _TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[] = {
{ 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 },
{ 0.5, 0.5, 0.5, 0.5 },
{ 1.0, 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 }
{ 1.0, 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 }
};
void test_versor_is_identity_fp64()
{
print_testing_name("bgc_versor_is_identity_fp64");
print_testing_name("bgc_fp64_versor_is_idle");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (!bgc_versor_is_identity_fp64(&_TEST_FP64_IDENTIYTY_VERSOR_LIST[i])) {
if (!bgc_fp64_versor_is_idle(&_TEST_FP64_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("An identity versor was not recognized");
return;
}
@ -89,7 +89,7 @@ void test_versor_is_identity_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NON_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (bgc_versor_is_identity_fp64(&_TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[i])) {
if (bgc_fp64_versor_is_idle(&_TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("A non-identity versor was recognized as an identity versor");
return;
}

View file

@ -4,11 +4,11 @@
void test_versor_reset_fp32()
{
BgcVersorFP32 versor;
BGC_FP32_Versor versor;
print_testing_name("bgc_versor_reset_fp32");
print_testing_name("bgc_fp32_versor_reset");
bgc_versor_reset_fp32(&versor);
bgc_fp32_versor_reset(&versor);
if (versor._s0 != 1.0f || versor._x1 != 0.0f || versor._x2 != 0.0f || versor._x3 != 0.0f) {
print_testing_failed();
@ -20,11 +20,11 @@ void test_versor_reset_fp32()
void test_versor_reset_fp64()
{
BgcVersorFP64 versor;
BGC_FP64_Versor versor;
print_testing_name("bgc_versor_reset_fp64");
print_testing_name("bgc_fp64_versor_reset");
bgc_versor_reset_fp64(&versor);
bgc_fp64_versor_reset(&versor);
if (versor._s0 != 1.0 || versor._x1 != 0.0 || versor._x2 != 0.0 || versor._x3 != 0.0) {
print_testing_failed();

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_VERSOR_DATA_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_DATA_LIST[] = {
static const BGC_FP32_Quaternion _TEST_FP32_VERSOR_DATA_LIST[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f },
{ 4.0f, 3.0f, 2.0f, 1.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f },
@ -17,12 +17,12 @@ static const BgcQuaternionFP32 _TEST_FP32_VERSOR_DATA_LIST[] = {
void test_versor_set_values_fp32()
{
float versor_module, ratio;
BgcVersorFP32 versor;
BGC_FP32_Versor versor;
print_testing_name("bgc_versor_set_values_fp32");
print_testing_name("bgc_fp32_versor_make");
for (int i = 0; i < _TEST_FP32_VERSOR_DATA_AMOUNT; i++) {
bgc_versor_set_values_fp32(
bgc_fp32_versor_make(
_TEST_FP32_VERSOR_DATA_LIST[i].s0,
_TEST_FP32_VERSOR_DATA_LIST[i].x1,
_TEST_FP32_VERSOR_DATA_LIST[i].x2,
@ -32,28 +32,28 @@ void test_versor_set_values_fp32()
versor_module = sqrtf(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3);
if (!bgc_is_unit_fp32(versor_module)) {
if (!bgc_fp32_is_unit(versor_module)) {
print_testing_error("Versor module is not equal to one.");
return;
}
if (bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].s0)) {
if (bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].s0)) {
continue;
}
ratio = _TEST_FP32_VERSOR_DATA_LIST[i].s0 / versor._s0;
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
if (!bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].x1) && !bgc_fp32_are_close(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
print_testing_error("Versor was not normalized proportionally (x1).");
return;
}
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
if (!bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].x2) && !bgc_fp32_are_close(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
print_testing_error("Versor was not normalized proportionally (x2).");
return;
}
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
if (!bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].x3) && !bgc_fp32_are_close(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
print_testing_error("Versor was not normalized proportionally (x3).");
return;
}
@ -65,7 +65,7 @@ void test_versor_set_values_fp32()
// ==================== FP64 ==================== //
static const int _TEST_FP64_VERSOR_DATA_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_VERSOR_DATA_LIST[] = {
static const BGC_FP64_Quaternion _TEST_FP64_VERSOR_DATA_LIST[] = {
{ 1.0, 2.0, 3.0, 4.0 },
{ 4.0, 3.0, 2.0, 1.0 },
{ -1.0, 0.0, 0.0, 0.0 },
@ -75,12 +75,12 @@ static const BgcQuaternionFP64 _TEST_FP64_VERSOR_DATA_LIST[] = {
void test_versor_set_values_fp64()
{
double versor_module, ratio;
BgcVersorFP64 versor;
BGC_FP64_Versor versor;
print_testing_name("bgc_versor_set_values_fp64");
print_testing_name("bgc_fp64_versor_make");
for (int i = 0; i < _TEST_FP64_VERSOR_DATA_AMOUNT; i++) {
bgc_versor_set_values_fp64(
bgc_fp64_versor_make(
_TEST_FP64_VERSOR_DATA_LIST[i].s0,
_TEST_FP64_VERSOR_DATA_LIST[i].x1,
_TEST_FP64_VERSOR_DATA_LIST[i].x2,
@ -90,28 +90,28 @@ void test_versor_set_values_fp64()
versor_module = sqrt(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3);
if (!bgc_is_unit_fp64(versor_module)) {
if (!bgc_fp64_is_unit(versor_module)) {
print_testing_error("Versor module is not equal to one.");
return;
}
if (bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].s0)) {
if (bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].s0)) {
continue;
}
ratio = _TEST_FP64_VERSOR_DATA_LIST[i].s0 / versor._s0;
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
if (!bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].x1) && !bgc_fp64_are_close(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
print_testing_error("Versor was not normalized proportionally (x1).");
return;
}
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
if (!bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].x2) && !bgc_fp64_are_close(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
print_testing_error("Versor was not normalized proportionally (x2).");
return;
}
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
if (!bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].x3) && !bgc_fp64_are_close(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
print_testing_error("Versor was not normalized proportionally (x3).");
return;
}

View file

@ -8,13 +8,13 @@
static const int _TEST_FP32_VERSOR_AMOUNT = 3;
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST1[] = {
static const BGC_FP32_Quaternion _TEST_FP32_VERSOR_LIST1[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f },
{ 0.5f, -0.5f, -0.5f, -0.5f }
};
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST2[] = {
static const BGC_FP32_Quaternion _TEST_FP32_VERSOR_LIST2[] = {
{ -0.5f, 0.5f, 0.5f, 0.5f },
{ -1.0f, -2.0f, -3.0f, -4.0f },
{ 4.0f, 3.0f, 2.0f, 1.0f }
@ -22,12 +22,12 @@ static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST2[] = {
void test_versor_swap_fp32()
{
BgcVersorFP32 versor1a, versor2a, versor1b, versor2b;
BGC_FP32_Versor versor1a, versor2a, versor1b, versor2b;
print_testing_name("bgc_versor_swap_fp32");
print_testing_name("bgc_fp32_versor_swap");
for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) {
bgc_versor_set_values_fp32(
bgc_fp32_versor_make(
_TEST_FP32_VERSOR_LIST1[i].s0,
_TEST_FP32_VERSOR_LIST1[i].x1,
_TEST_FP32_VERSOR_LIST1[i].x2,
@ -35,7 +35,7 @@ void test_versor_swap_fp32()
&versor1a
);
bgc_versor_set_values_fp32(
bgc_fp32_versor_make(
_TEST_FP32_VERSOR_LIST2[i].s0,
_TEST_FP32_VERSOR_LIST2[i].x1,
_TEST_FP32_VERSOR_LIST2[i].x2,
@ -43,10 +43,10 @@ void test_versor_swap_fp32()
&versor2a
);
bgc_versor_copy_fp32(&versor1a, &versor1b);
bgc_versor_copy_fp32(&versor2a, &versor2b);
bgc_fp32_versor_copy(&versor1a, &versor1b);
bgc_fp32_versor_copy(&versor2a, &versor2b);
bgc_versor_swap_fp32(&versor1b, &versor2b);
bgc_fp32_versor_swap(&versor1b, &versor2b);
if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 ||
versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) {
@ -62,12 +62,12 @@ void test_versor_swap_fp32()
void test_versor_swap_fp64()
{
BgcVersorFP64 versor1a, versor2a, versor1b, versor2b;
BGC_FP64_Versor versor1a, versor2a, versor1b, versor2b;
print_testing_name("bgc_versor_swap_fp64");
print_testing_name("bgc_fp64_versor_swap");
for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) {
bgc_versor_set_values_fp64(
bgc_fp64_versor_make(
_TEST_FP32_VERSOR_LIST1[i].s0,
_TEST_FP32_VERSOR_LIST1[i].x1,
_TEST_FP32_VERSOR_LIST1[i].x2,
@ -75,7 +75,7 @@ void test_versor_swap_fp64()
&versor1a
);
bgc_versor_set_values_fp64(
bgc_fp64_versor_make(
_TEST_FP32_VERSOR_LIST2[i].s0,
_TEST_FP32_VERSOR_LIST2[i].x1,
_TEST_FP32_VERSOR_LIST2[i].x2,
@ -83,10 +83,10 @@ void test_versor_swap_fp64()
&versor2a
);
bgc_versor_copy_fp64(&versor1a, &versor1b);
bgc_versor_copy_fp64(&versor2a, &versor2b);
bgc_fp64_versor_copy(&versor1a, &versor1b);
bgc_fp64_versor_copy(&versor2a, &versor2b);
bgc_versor_swap_fp64(&versor1b, &versor2b);
bgc_fp64_versor_swap(&versor1b, &versor2b);
if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 ||
versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) {

View file

@ -1,28 +1,31 @@
#include "affine2.h"
extern inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine);
extern inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine);
extern inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2* affine);
extern inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2* affine);
extern inline void bgc_affine2_make_fp32(const BgcMatrix2x2FP32 * distortion, const BgcVector2FP32 * shift, BgcAffine2FP32 * affine);
extern inline void bgc_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * affine);
extern inline void bgc_fp32_affine2_make(BGC_FP32_Affine2* affine, const BGC_FP32_Matrix2x2* distortion, const BGC_FP32_Vector2* shift);
extern inline void bgc_fp64_affine2_make(BGC_FP64_Affine2* affine, const BGC_FP64_Matrix2x2* distortion, const BGC_FP64_Vector2* shift);
extern inline void bgc_affine2_copy_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination);
extern inline void bgc_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination);
extern inline void bgc_fp32_affine2_copy(BGC_FP32_Affine2* destination, const BGC_FP32_Affine2* source);
extern inline void bgc_fp64_affine2_copy(BGC_FP64_Affine2* destination, const BGC_FP64_Affine2* source);
extern inline void bgc_affine2_convert_fp64_to_fp32(const BgcAffine2FP64 * source, BgcAffine2FP32 * destination);
extern inline void bgc_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination);
extern inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2* first, BGC_FP32_Affine2* second);
extern inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2* first, BGC_FP64_Affine2* second);
extern inline int bgc_affine2_invert_fp32(BgcAffine2FP32 * affine);
extern inline int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine);
extern inline void bgc_fp32_affine2_convert_to_fp64(BGC_FP64_Affine2* destination, const BGC_FP32_Affine2* source);
extern inline void bgc_fp64_affine2_convert_to_fp32(BGC_FP32_Affine2* destination, const BGC_FP64_Affine2* source);
extern inline int bgc_affine2_get_inverse_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination);
extern inline int bgc_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination);
extern inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2* affine);
extern inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2* affine);
extern inline void bgc_affine2_combine_fp32(const BgcAffine2FP32 * first, const BgcAffine2FP32 * second, BgcAffine2FP32 * combination);
extern inline void bgc_affine2_combine_fp64(const BgcAffine2FP64 * first, const BgcAffine2FP64 * second, BgcAffine2FP64 * combination);
extern inline int bgc_fp32_affine2_get_inverse(BGC_FP32_Affine2* inverse, const BGC_FP32_Affine2* affine);
extern inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP64_Affine2* affine);
extern inline void bgc_affine2_transform_point_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_point, BgcVector2FP32 * transformed_point);
extern inline void bgc_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * transformed_point);
extern inline void bgc_fp32_affine2_combine(BGC_FP32_Affine2* combination, const BGC_FP32_Affine2* first, const BGC_FP32_Affine2* second);
extern inline void bgc_fp64_affine2_combine(BGC_FP64_Affine2* combination, const BGC_FP64_Affine2* first, const BGC_FP64_Affine2* second);
extern inline void bgc_affine2_transform_vector_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_vector, BgcVector2FP32 * transformed_vector);
extern inline void bgc_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * transformed_vector);
extern inline void bgc_fp32_affine2_transform_point(BGC_FP32_Vector2* transformed_point, const BGC_FP32_Affine2* affine, const BGC_FP32_Vector2* initial_point);
extern inline void bgc_fp64_affine2_transform_point(BGC_FP64_Vector2* transformed_point, const BGC_FP64_Affine2* affine, const BGC_FP64_Vector2* initial_point);
extern inline void bgc_fp32_affine2_transform_vector(BGC_FP32_Vector2* transformed_vector, const BGC_FP32_Affine2* affine, const BGC_FP32_Vector2* initial_vector);
extern inline void bgc_fp64_affine2_transform_vector(BGC_FP64_Vector2* transformed_vector, const BGC_FP64_Affine2* affine, const BGC_FP64_Vector2* initial_vector);

View file

@ -2,174 +2,188 @@
#define _BGC_AFFINE2_H_INCLUDED_
#include "vector2.h"
#include "matrixes.h"
#include "matrices.h"
#include "matrix2x2.h"
// ==================== Types ==================== //
typedef struct {
BgcMatrix2x2FP32 distortion;
BgcVector2FP32 shift;
} BgcAffine2FP32;
BGC_FP32_Matrix2x2 distortion;
BGC_FP32_Vector2 shift;
} BGC_FP32_Affine2;
typedef struct {
BgcMatrix2x2FP64 distortion;
BgcVector2FP64 shift;
} BgcAffine2FP64;
BGC_FP64_Matrix2x2 distortion;
BGC_FP64_Vector2 shift;
} BGC_FP64_Affine2;
// ==================== Reset ==================== //
inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine)
inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2* affine)
{
bgc_matrix2x2_set_to_identity_fp32(&affine->distortion);
bgc_vector2_reset_fp32(&affine->shift);
bgc_fp32_matrix2x2_make_identity(&affine->distortion);
bgc_fp32_vector2_reset(&affine->shift);
}
inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine)
inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2* affine)
{
bgc_matrix2x2_set_to_identity_fp64(&affine->distortion);
bgc_vector2_reset_fp64(&affine->shift);
bgc_fp64_matrix2x2_make_identity(&affine->distortion);
bgc_fp64_vector2_reset(&affine->shift);
}
// ==================== Make ===================== //
inline void bgc_affine2_make_fp32(const BgcMatrix2x2FP32 * distortion, const BgcVector2FP32 * shift, BgcAffine2FP32 * affine)
inline void bgc_fp32_affine2_make(BGC_FP32_Affine2* affine, const BGC_FP32_Matrix2x2* distortion, const BGC_FP32_Vector2* shift)
{
bgc_matrix2x2_copy_fp32(distortion, &affine->distortion);
bgc_vector2_copy_fp32(shift, &affine->shift);
bgc_fp32_matrix2x2_copy(&affine->distortion, distortion);
bgc_fp32_vector2_copy(&affine->shift, shift);
}
inline void bgc_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * affine)
inline void bgc_fp64_affine2_make(BGC_FP64_Affine2* affine, const BGC_FP64_Matrix2x2* distortion, const BGC_FP64_Vector2* shift)
{
bgc_matrix2x2_copy_fp64(distortion, &affine->distortion);
bgc_vector2_copy_fp64(shift, &affine->shift);
bgc_fp64_matrix2x2_copy(&affine->distortion, distortion);
bgc_fp64_vector2_copy(&affine->shift, shift);
}
// ==================== Copy ===================== //
inline void bgc_affine2_copy_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination)
inline void bgc_fp32_affine2_copy(BGC_FP32_Affine2* destination, const BGC_FP32_Affine2* source)
{
bgc_matrix2x2_copy_fp32(&source->distortion, &destination->distortion);
bgc_vector2_copy_fp32(&source->shift, &destination->shift);
bgc_fp32_matrix2x2_copy(&destination->distortion, &source->distortion);
bgc_fp32_vector2_copy(&destination->shift, &source->shift);
}
inline void bgc_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination)
inline void bgc_fp64_affine2_copy(BGC_FP64_Affine2* destination, const BGC_FP64_Affine2* source)
{
bgc_matrix2x2_copy_fp64(&source->distortion, &destination->distortion);
bgc_vector2_copy_fp64(&source->shift, &destination->shift);
bgc_fp64_matrix2x2_copy(&destination->distortion, &source->distortion);
bgc_fp64_vector2_copy(&destination->shift, &source->shift);
}
// ==================== Swap ===================== //
inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2 * first, BGC_FP32_Affine2 * second)
{
bgc_fp32_matrix2x2_swap(&first->distortion, &second->distortion);
bgc_fp32_vector2_swap(&first->shift, &second->shift);
}
inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2 * first, BGC_FP64_Affine2 * second)
{
bgc_fp64_matrix2x2_swap(&first->distortion, &second->distortion);
bgc_fp64_vector2_swap(&first->shift, &second->shift);
}
// =================== Convert =================== //
inline void bgc_affine2_convert_fp64_to_fp32(const BgcAffine2FP64 * source, BgcAffine2FP32 * destination)
inline void bgc_fp32_affine2_convert_to_fp64(BGC_FP64_Affine2* destination, const BGC_FP32_Affine2* source)
{
bgc_matrix2x2_convert_fp64_to_fp32(&source->distortion, &destination->distortion);
bgc_vector2_convert_fp64_to_fp32(&source->shift, &destination->shift);
bgc_fp32_matrix2x2_convert_to_fp64(&destination->distortion, &source->distortion);
bgc_fp32_vector2_convert_to_fp64(&destination->shift, &source->shift);
}
inline void bgc_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination)
inline void bgc_fp64_affine2_convert_to_fp32(BGC_FP32_Affine2* destination, const BGC_FP64_Affine2 * source)
{
bgc_matrix2x2_convert_fp32_to_fp64(&source->distortion, &destination->distortion);
bgc_vector2_convert_fp32_to_fp64(&source->shift, &destination->shift);
bgc_fp64_matrix2x2_convert_to_fp32(&destination->distortion, &source->distortion);
bgc_fp64_vector2_convert_to_fp32(&destination->shift, &source->shift);
}
// =================== Invert ==================== //
inline int bgc_affine2_invert_fp32(BgcAffine2FP32 * affine)
inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine)
{
if (!bgc_matrix2x2_invert_fp32(&affine->distortion, &affine->distortion)) {
if (!bgc_fp32_matrix2x2_invert(&affine->distortion)) {
return 0;
}
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector2_make_opposite_fp32(&affine->shift);
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp32_vector2_revert(&affine->shift);
return 1;
}
inline int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine)
inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine)
{
if (!bgc_matrix2x2_invert_fp64(&affine->distortion, &affine->distortion)) {
if (!bgc_fp64_matrix2x2_invert(&affine->distortion)) {
return 0;
}
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector2_make_opposite_fp64(&affine->shift);
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp64_vector2_revert(&affine->shift);
return 1;
}
// ================= Get Inverse ================= //
inline int bgc_affine2_get_inverse_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination)
inline int bgc_fp32_affine2_get_inverse(BGC_FP32_Affine2* inverse, const BGC_FP32_Affine2 * affine)
{
if (!bgc_matrix2x2_invert_fp32(&source->distortion, &destination->distortion)) {
if (!bgc_fp32_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) {
return 0;
}
bgc_matrix2x2_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift);
bgc_vector2_make_opposite_fp32(&destination->shift);
bgc_fp32_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
bgc_fp32_vector2_revert(&inverse->shift);
return 1;
}
inline int bgc_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination)
inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP64_Affine2 * affine)
{
if (!bgc_matrix2x2_invert_fp64(&source->distortion, &destination->distortion)) {
if (!bgc_fp64_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) {
return 0;
}
bgc_matrix2x2_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift);
bgc_vector2_make_opposite_fp64(&destination->shift);
bgc_fp64_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
bgc_fp64_vector2_revert(&inverse->shift);
return 1;
}
// =================== Combine =================== //
inline void bgc_affine2_combine_fp32(const BgcAffine2FP32 * first, const BgcAffine2FP32 * second, BgcAffine2FP32 * combination)
inline void bgc_fp32_affine2_combine(BGC_FP32_Affine2* combination, const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second)
{
BgcVector2FP32 first_shift;
bgc_matrix2x2_get_right_product_fp32(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_2x2_at_2x2_fp32(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector2_add_fp32(&first_shift, &second->shift, &combination->shift);
BGC_FP32_Vector2 first_shift;
bgc_fp32_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift);
bgc_fp32_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp32_vector2_add(&combination->shift, &second->shift, &first_shift);
}
inline void bgc_affine2_combine_fp64(const BgcAffine2FP64 * first, const BgcAffine2FP64 * second, BgcAffine2FP64 * combination)
inline void bgc_fp64_affine2_combine(BGC_FP64_Affine2* combination, const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second)
{
BgcVector2FP64 first_shift;
bgc_matrix2x2_get_right_product_fp64(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_2x2_at_2x2_fp64(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector2_add_fp64(&first_shift, &second->shift, &combination->shift);
BGC_FP64_Vector2 first_shift;
bgc_fp64_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift);
bgc_fp64_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp64_vector2_add(&combination->shift, &second->shift, &first_shift);
}
// =============== Transform Point =============== //
inline void bgc_affine2_transform_point_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_point, BgcVector2FP32 * transformed_point)
inline void bgc_fp32_affine2_transform_point(BGC_FP32_Vector2* transformed_point, const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point)
{
BgcVector2FP32 distorted;
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_point, &distorted);
bgc_vector2_add_fp32(&affine->shift, &distorted, transformed_point);
BGC_FP32_Vector2 distorted;
bgc_fp32_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point);
bgc_fp32_vector2_add(transformed_point, &affine->shift, &distorted);
}
inline void bgc_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * transformed_point)
inline void bgc_fp64_affine2_transform_point(BGC_FP64_Vector2* transformed_point, const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point)
{
BgcVector2FP64 distorted;
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_point, &distorted);
bgc_vector2_add_fp64(&affine->shift, &distorted, transformed_point);
BGC_FP64_Vector2 distorted;
bgc_fp64_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point);
bgc_fp64_vector2_add(transformed_point, &affine->shift, &distorted);
}
// ============== Transform Vector =============== //
inline void bgc_affine2_transform_vector_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_vector, BgcVector2FP32 * transformed_vector)
inline void bgc_fp32_affine2_transform_vector(BGC_FP32_Vector2* transformed_vector, const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector)
{
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector);
bgc_fp32_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector);
}
inline void bgc_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * transformed_vector)
inline void bgc_fp64_affine2_transform_vector(BGC_FP64_Vector2* transformed_vector, const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector)
{
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector);
bgc_fp64_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector);
}
#endif

View file

@ -1,28 +1,31 @@
#include "affine3.h"
extern inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine);
extern inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine);
extern inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3* affine);
extern inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3* affine);
extern inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine);
extern inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine);
extern inline void bgc_fp32_affine3_make(BGC_FP32_Affine3* affine, const BGC_FP32_Matrix3x3* distortion, const BGC_FP32_Vector3* shift);
extern inline void bgc_fp64_affine3_make(BGC_FP64_Affine3* affine, const BGC_FP64_Matrix3x3* distortion, const BGC_FP64_Vector3* shift);
extern inline void bgc_affine3_copy_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination);
extern inline void bgc_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination);
extern inline void bgc_fp32_affine3_copy(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3* source);
extern inline void bgc_fp64_affine3_copy(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3* source);
extern inline void bgc_affine3_convert_fp64_to_fp32(const BgcAffine3FP64 * source, BgcAffine3FP32 * destination);
extern inline void bgc_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination);
extern inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3* first, BGC_FP32_Affine3* second);
extern inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3* first, BGC_FP64_Affine3* second);
extern inline int bgc_affine3_invert_fp32(BgcAffine3FP32 * affine);
extern inline int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine);
extern inline void bgc_fp32_affine3_convert_to_fp64(BGC_FP64_Affine3* destination, const BGC_FP32_Affine3* source);
extern inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, const BGC_FP64_Affine3* source);
extern inline int bgc_affine3_get_inverse_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination);
extern inline int bgc_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination);
extern inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3* affine);
extern inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3* affine);
extern inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * first, const BgcAffine3FP32 * second, BgcAffine3FP32 * combination);
extern inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * first, const BgcAffine3FP64 * second, BgcAffine3FP64 * combination);
extern inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* inverse, const BGC_FP32_Affine3* affine);
extern inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* inverse, const BGC_FP64_Affine3* affine);
extern inline void bgc_affine3_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point);
extern inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point);
extern inline void bgc_fp32_affine3_combine(BGC_FP32_Affine3* combination, const BGC_FP32_Affine3* first, const BGC_FP32_Affine3* second);
extern inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP64_Affine3* first, const BGC_FP64_Affine3* second);
extern inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector);
extern inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector);
extern inline void bgc_fp32_affine3_transform_point(BGC_FP32_Vector3* transformed_point, const BGC_FP32_Affine3* affine, const BGC_FP32_Vector3* initial_point);
extern inline void bgc_fp64_affine3_transform_point(BGC_FP64_Vector3* transformed_point, const BGC_FP64_Affine3* affine, const BGC_FP64_Vector3* initial_point);
extern inline void bgc_fp32_affine3_transform_vector(BGC_FP32_Vector3* transformed_vector, const BGC_FP32_Affine3* affine, const BGC_FP32_Vector3* initial_vector);
extern inline void bgc_fp64_affine3_transform_vector(BGC_FP64_Vector3* transformed_vector, const BGC_FP64_Affine3* affine, const BGC_FP64_Vector3* initial_vector);

View file

@ -2,173 +2,187 @@
#define _BGC_AFFINE3_H_INCLUDED_
#include "vector3.h"
#include "matrixes.h"
#include "matrices.h"
#include "matrix3x3.h"
// ==================== Types ==================== //
typedef struct {
BgcMatrix3x3FP32 distortion;
BgcVector3FP32 shift;
} BgcAffine3FP32;
BGC_FP32_Matrix3x3 distortion;
BGC_FP32_Vector3 shift;
} BGC_FP32_Affine3;
typedef struct {
BgcMatrix3x3FP64 distortion;
BgcVector3FP64 shift;
} BgcAffine3FP64;
BGC_FP64_Matrix3x3 distortion;
BGC_FP64_Vector3 shift;
} BGC_FP64_Affine3;
// ==================== Reset ==================== //
inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine)
inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3 * affine)
{
bgc_matrix3x3_set_to_identity_fp32(&affine->distortion);
bgc_vector3_reset_fp32(&affine->shift);
bgc_fp32_matrix3x3_make_identity(&affine->distortion);
bgc_fp32_vector3_reset(&affine->shift);
}
inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine)
inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine)
{
bgc_matrix3x3_set_to_identity_fp64(&affine->distortion);
bgc_vector3_reset_fp64(&affine->shift);
bgc_fp64_matrix3x3_make_identity(&affine->distortion);
bgc_fp64_vector3_reset(&affine->shift);
}
// ==================== Make ===================== //
inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine)
inline void bgc_fp32_affine3_make(BGC_FP32_Affine3* affine, const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift)
{
bgc_matrix3x3_copy_fp32(distortion, &affine->distortion);
bgc_vector3_copy_fp32(shift, &affine->shift);
bgc_fp32_matrix3x3_copy(&affine->distortion, distortion);
bgc_fp32_vector3_copy(&affine->shift, shift);
}
inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine)
inline void bgc_fp64_affine3_make(BGC_FP64_Affine3* affine, const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift)
{
bgc_matrix3x3_copy_fp64(distortion, &affine->distortion);
bgc_vector3_copy_fp64(shift, &affine->shift);
bgc_fp64_matrix3x3_copy(&affine->distortion, distortion);
bgc_fp64_vector3_copy(&affine->shift, shift);
}
// ==================== Copy ===================== //
inline void bgc_affine3_copy_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination)
inline void bgc_fp32_affine3_copy(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source)
{
bgc_matrix3x3_copy_fp32(&source->distortion, &destination->distortion);
bgc_vector3_copy_fp32(&source->shift, &destination->shift);
bgc_fp32_matrix3x3_copy(&destination->distortion, &source->distortion);
bgc_fp32_vector3_copy(&destination->shift, &source->shift);
}
inline void bgc_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination)
inline void bgc_fp64_affine3_copy(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source)
{
bgc_matrix3x3_copy_fp64(&source->distortion, &destination->distortion);
bgc_vector3_copy_fp64(&source->shift, &destination->shift);
bgc_fp64_matrix3x3_copy(&destination->distortion, &source->distortion);
bgc_fp64_vector3_copy(&destination->shift, &source->shift);
}
// ==================== Swap ===================== //
inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second)
{
bgc_fp32_matrix3x3_swap(&first->distortion, &second->distortion);
bgc_fp32_vector3_swap(&first->shift, &second->shift);
}
inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3 * first, BGC_FP64_Affine3 * second)
{
bgc_fp64_matrix3x3_swap(&first->distortion, &second->distortion);
bgc_fp64_vector3_swap(&first->shift, &second->shift);
}
// =================== Convert =================== //
inline void bgc_affine3_convert_fp64_to_fp32(const BgcAffine3FP64 * source, BgcAffine3FP32 * destination)
inline void bgc_fp32_affine3_convert_to_fp64(BGC_FP64_Affine3* destination, const BGC_FP32_Affine3 * source)
{
bgc_matrix3x3_convert_fp64_to_fp32(&source->distortion, &destination->distortion);
bgc_vector3_convert_fp64_to_fp32(&source->shift, &destination->shift);
bgc_fp32_matrix3x3_convert_to_fp64(&destination->distortion, &source->distortion);
bgc_fp32_vector3_convert_to_fp64(&destination->shift, &source->shift);
}
inline void bgc_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination)
inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, const BGC_FP64_Affine3* source)
{
bgc_matrix3x3_convert_fp32_to_fp64(&source->distortion, &destination->distortion);
bgc_vector3_convert_fp32_to_fp64(&source->shift, &destination->shift);
bgc_fp64_matrix3x3_convert_to_fp32(&destination->distortion, &source->distortion);
bgc_fp64_vector3_convert_to_fp32(&destination->shift, &source->shift);
}
// =================== Invert ==================== //
inline int bgc_affine3_invert_fp32(BgcAffine3FP32 * affine)
inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine)
{
if (!bgc_matrix3x3_invert_fp32(&affine->distortion, &affine->distortion)) {
if (!bgc_fp32_matrix3x3_invert(&affine->distortion)) {
return 0;
}
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector3_make_opposite_fp32(&affine->shift);
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp32_vector3_revert(&affine->shift);
return 1;
}
inline int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine)
inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
{
if (!bgc_matrix3x3_invert_fp64(&affine->distortion, &affine->distortion)) {
if (!bgc_fp64_matrix3x3_invert(&affine->distortion)) {
return 0;
}
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector3_make_opposite_fp64(&affine->shift);
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp64_vector3_revert(&affine->shift);
return 1;
}
// ================= Get Inverse ================= //
inline int bgc_affine3_get_inverse_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination)
inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source)
{
if (!bgc_matrix3x3_invert_fp32(&source->distortion, &destination->distortion)) {
if (!bgc_fp32_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
return 0;
}
bgc_matrix3x3_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift);
bgc_vector3_make_opposite_fp32(&destination->shift);
bgc_fp32_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
bgc_fp32_vector3_revert(&destination->shift);
return 1;
}
inline int bgc_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination)
inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source)
{
if (!bgc_matrix3x3_invert_fp64(&source->distortion, &destination->distortion)) {
if (!bgc_fp64_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
return 0;
}
bgc_matrix3x3_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift);
bgc_vector3_make_opposite_fp64(&destination->shift);
bgc_fp64_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
bgc_fp64_vector3_revert(&destination->shift);
return 1;
}
// =================== Combine =================== //
inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * first, const BgcAffine3FP32 * second, BgcAffine3FP32 * combination)
inline void bgc_fp32_affine3_combine(BGC_FP32_Affine3* combination, const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second)
{
BgcVector3FP32 first_shift;
bgc_matrix3x3_get_right_product_fp32(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_3x3_at_3x3_fp32(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector3_add_fp32(&first_shift, &second->shift, &combination->shift);
BGC_FP32_Vector3 first_shift;
bgc_fp32_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
bgc_fp32_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp32_vector3_add(&combination->shift, &first_shift, &second->shift);
}
inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * first, const BgcAffine3FP64 * second, BgcAffine3FP64 * combination)
inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second)
{
BgcVector3FP64 first_shift;
bgc_matrix3x3_get_right_product_fp64(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_3x3_at_3x3_fp64(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector3_add_fp64(&first_shift, &second->shift, &combination->shift);
BGC_FP64_Vector3 first_shift;
bgc_fp64_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
bgc_fp64_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp64_vector3_add(&combination->shift, &first_shift, &second->shift);
}
// =============== Transform Point =============== //
inline void bgc_affine3_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point)
inline void bgc_fp32_affine3_transform_point(BGC_FP32_Vector3* transformed_point, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point)
{
BgcVector3FP32 distorted;
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_point, &distorted);
bgc_vector3_add_fp32(&affine->shift, &distorted, transformed_point);
BGC_FP32_Vector3 distorted;
bgc_fp32_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
bgc_fp32_vector3_add(transformed_point, &affine->shift, &distorted);
}
inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point)
inline void bgc_fp64_affine3_transform_point(BGC_FP64_Vector3* transformed_point, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point)
{
BgcVector3FP64 distorted;
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_point, &distorted);
bgc_vector3_add_fp64(&affine->shift, &distorted, transformed_point);
BGC_FP64_Vector3 distorted;
bgc_fp64_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
bgc_fp64_vector3_add(transformed_point, &affine->shift, &distorted);
}
// ============== Transform Vector =============== //
inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector)
inline void bgc_fp32_affine3_transform_vector(BGC_FP32_Vector3* transformed_vector, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector)
{
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector);
bgc_fp32_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
}
inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector)
inline void bgc_fp64_affine3_transform_vector(BGC_FP64_Vector3* transformed_vector, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector)
{
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector);
bgc_fp64_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
}
#endif

View file

@ -3,65 +3,59 @@
// !================= Radians ==================! //
extern inline float bgc_radians_to_degrees_fp32(const float radians);
extern inline double bgc_radians_to_degrees_fp64(const double radians);
extern inline float bgc_fp32_radians_to_degrees(const float radians);
extern inline double bgc_fp64_radians_to_degrees(const double radians);
extern inline float bgc_radians_to_turns_fp32(const float radians);
extern inline double bgc_radians_to_turns_fp64(const double radians);
extern inline float bgc_fp32_radians_to_turns(const float radians);
extern inline double bgc_fp64_radians_to_turns(const double radians);
extern inline float bgc_radians_to_units_fp32(const float radians, const BgcAngleUnitEnum to_unit);
extern inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnitEnum to_unit);
extern inline float bgc_fp32_radians_to_units(const float radians, const int angle_unit);
extern inline double bgc_fp64_radians_to_units(const double radians, const int angle_unit);
extern inline float bgc_radians_normalize_fp32(const float radians, const BgcAngleRangeEnum range);
extern inline double bgc_radians_normalize_fp64(const double radians, const BgcAngleRangeEnum range);
extern inline float bgc_fp32_normalize_radians(const float radians, const int angle_range);
extern inline double bgc_fp64_normalize_radians(const double radians, const int angle_range);
// !================= Degrees ==================! //
extern inline float bgc_degrees_to_radians_fp32(const float degrees);
extern inline double bgc_degrees_to_radians_fp64(const double degrees);
extern inline float bgc_fp32_degrees_to_radians(const float degrees);
extern inline double bgc_fp64_degrees_to_radians(const double degrees);
extern inline float bgc_degrees_to_turns_fp32(const float radians);
extern inline double bgc_degrees_to_turns_fp64(const double radians);
extern inline float bgc_fp32_degrees_to_turns(const float radians);
extern inline double bgc_fp64_degrees_to_turns(const double radians);
extern inline float bgc_degrees_to_units_fp32(const float degrees, const BgcAngleUnitEnum to_unit);
extern inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnitEnum to_unit);
extern inline float bgc_fp32_degrees_to_units(const float degrees, const int angle_unit);
extern inline double bgc_fp64_degrees_to_units(const double degrees, const int angle_unit);
extern inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRangeEnum range);
extern inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRangeEnum range);
extern inline float bgc_fp32_normalize_degrees(const float degrees, const int angle_range);
extern inline double bgc_fp64_degrees_normalize(const double degrees, const int angle_range);
// !================== Turns ===================! //
extern inline float bgc_turns_to_radians_fp32(const float turns);
extern inline double bgc_turns_to_radians_fp64(const double turns);
extern inline float bgc_fp32_turns_to_radians(const float turns);
extern inline double bgc_fp64_turns_to_radians(const double turns);
extern inline float bgc_turns_to_degrees_fp32(const float turns);
extern inline double bgc_turns_to_degrees_fp64(const double turns);
extern inline float bgc_fp32_turns_to_degrees(const float turns);
extern inline double bgc_fp64_turns_to_degrees(const double turns);
extern inline float bgc_turns_to_units_fp32(const float turns, const BgcAngleUnitEnum to_unit);
extern inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum to_unit);
extern inline float bgc_fp32_turns_to_units(const float turns, const int angle_unit);
extern inline double bgc_fp64_turns_to_units(const double turns, const int angle_unit);
extern inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum range);
extern inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEnum range);
extern inline float bgc_fp32_normalize_turns(const float turns, const int angle_range);
extern inline double bgc_fp64_normalize_turns(const double turns, const int angle_range);
// !================== Angle ===================! //
extern inline float bgc_angle_to_radians_fp32(const float angle, const BgcAngleUnitEnum unit);
extern inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEnum unit);
extern inline float bgc_fp32_angle_to_radians(const float angle, const int angle_unit);
extern inline double bgc_fp64_angle_to_radians(const double angle, const int angle_unit);
extern inline float bgc_angle_to_degrees_fp32(const float angle, const BgcAngleUnitEnum unit);
extern inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEnum unit);
extern inline float bgc_fp32_angle_to_degrees(const float angle, const int angle_unit);
extern inline double bgc_fp64_angle_to_degrees(const double angle, const int angle_unit);
extern inline float bgc_angle_to_turns_fp32(const float angle, const BgcAngleUnitEnum unit);
extern inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum unit);
extern inline float bgc_fp32_angle_to_turns(const float angle, const int angle_unit);
extern inline double bgc_fp64_angle_to_turns(const double angle, const int angle_unit);
extern inline float bgc_angle_get_full_circle_fp32(const BgcAngleUnitEnum unit);
extern inline double bgc_angle_get_full_circle_fp64(const BgcAngleUnitEnum unit);
extern inline float bgc_fp32_full_circle(const int angle_unit);
extern inline double bgc_fp64_full_circle(const int angle_unit);
extern inline float bgc_angle_get_half_circle_fp32(const BgcAngleUnitEnum unit);
extern inline double bgc_angle_get_half_circle_fp64(const BgcAngleUnitEnum unit);
extern inline float bgc_angle_get_quater_circle_fp32(const BgcAngleUnitEnum unit);
extern inline double bgc_angle_get_quater_circle_fp64(const BgcAngleUnitEnum unit);
extern inline float bgc_angle_normalize_fp32(const float angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range);
extern inline double bgc_angle_normalize_fp64(const double angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range);
extern inline float bgc_fp32_normalize_angle(const float angle, const int angle_unit, const int angle_range);
extern inline double bgc_fp64_normalize_angle(const double angle, const int angle_unit, const int angle_range);

View file

@ -1,102 +1,98 @@
#ifndef _BGC_ANGLE_H_
#define _BGC_ANGLE_H_
#ifndef _BGC_ANGLE_H_INCLUDED_
#define _BGC_ANGLE_H_INCLUDED_
#include <math.h>
#include "utilities.h"
#define BGC_PI_FP32 3.1415926536f
#define BGC_TWO_PI_FP32 6.2831853072f
#define BGC_HALF_OF_PI_FP32 1.5707963268f
#define BGC_THIRD_OF_PI_FP32 1.0471975512f
#define BGC_FOURTH_OF_PI_FP32 0.7853981634f
#define BGC_SIXTH_OF_PI_FP32 0.5235987756f
#define BGC_FP32_PI 3.1415926536f
#define BGC_FP32_TWO_PI 6.2831853072f
#define BGC_FP32_HALF_OF_PI 1.5707963268f
#define BGC_FP32_ONE_THIRD_OF_PI 1.0471975512f
#define BGC_FP32_ONE_FOURTH_OF_PI 0.7853981634f
#define BGC_FP32_ONE_SIXTH_OF_PI 0.5235987756f
#define BGC_DEGREES_IN_RADIAN_FP32 57.295779513f
#define BGC_TURNS_IN_RADIAN_FP32 0.1591549431f
#define BGC_RADIANS_IN_DEGREE_FP32 1.745329252E-2f
#define BGC_TURNS_IN_DEGREE_FP32 2.7777777778E-3f
#define BGC_FP32_DEGREES_IN_RADIAN 57.295779513f
#define BGC_FP32_TURNS_IN_RADIAN 0.1591549431f
#define BGC_FP32_RADIANS_IN_DEGREE 1.745329252E-2f
#define BGC_FP32_TURNS_IN_DEGREE 2.7777777778E-3f
#define BGC_PI_FP64 3.14159265358979324
#define BGC_TWO_PI_FP64 6.28318530717958648
#define BGC_HALF_OF_PI_FP64 1.57079632679489662
#define BGC_THIRD_OF_PI_FP64 1.04719755119659775
#define BGC_FOURTH_OF_PI_FP64 0.78539816339744831
#define BGC_SIXTH_OF_PI_FP64 0.523598775598298873
#define BGC_FP64_PI 3.14159265358979324
#define BGC_FP64_TWO_PI 6.28318530717958648
#define BGC_FP64_HALF_OF_PI 1.57079632679489662
#define BGC_FP64_ONE_THIRD_OF_PI 1.04719755119659775
#define BGC_FP64_ONE_FOURTH_OF_PI 0.78539816339744831
#define BGC_FP64_ONE_SIXTH_OF_PI 0.523598775598298873
#define BGC_DEGREES_IN_RADIAN_FP64 57.2957795130823209
#define BGC_TURNS_IN_RADIAN_FP64 0.159154943091895336
#define BGC_RADIANS_IN_DEGREE_FP64 1.74532925199432958E-2
#define BGC_TURNS_IN_DEGREE_FP64 2.77777777777777778E-3
#define BGC_FP64_DEGREES_IN_RADIAN 57.2957795130823209
#define BGC_FP64_TURNS_IN_RADIAN 0.159154943091895336
#define BGC_FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2
#define BGC_FP64_TURNS_IN_DEGREE 2.77777777777777778E-3
typedef enum {
BGC_ANGLE_UNIT_RADIANS = 1,
BGC_ANGLE_UNIT_DEGREES = 2,
BGC_ANGLE_UNIT_TURNS = 3
} BgcAngleUnitEnum;
#define BGC_ANGLE_UNIT_RADIANS 1
#define BGC_ANGLE_UNIT_DEGREES 2
#define BGC_ANGLE_UNIT_TURNS 3
typedef enum {
/**
* The measure of an angle with a range of:
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
*/
BGC_ANGLE_RANGE_UNSIGNED = 1,
#define BGC_ANGLE_RANGE_UNSIGNED 1
/**
* The measure of an angle with a range of:
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
*/
BGC_ANGLE_RANGE_SIGNED = 2
} BgcAngleRangeEnum;
#define BGC_ANGLE_RANGE_SIGNED 2
// !================= Radians ==================! //
// ========= Convert radians to degrees ========= //
inline float bgc_radians_to_degrees_fp32(const float radians)
inline float bgc_fp32_radians_to_degrees(const float radians)
{
return radians * BGC_DEGREES_IN_RADIAN_FP32;
return radians * BGC_FP32_DEGREES_IN_RADIAN;
}
inline double bgc_radians_to_degrees_fp64(const double radians)
inline double bgc_fp64_radians_to_degrees(const double radians)
{
return radians * BGC_DEGREES_IN_RADIAN_FP64;
return radians * BGC_FP64_DEGREES_IN_RADIAN;
}
// ========== Convert radians to turns ========== //
inline float bgc_radians_to_turns_fp32(const float radians)
inline float bgc_fp32_radians_to_turns(const float radians)
{
return radians * BGC_TURNS_IN_RADIAN_FP32;
return radians * BGC_FP32_TURNS_IN_RADIAN;
}
inline double bgc_radians_to_turns_fp64(const double radians)
inline double bgc_fp64_radians_to_turns(const double radians)
{
return radians * BGC_TURNS_IN_RADIAN_FP64;
return radians * BGC_FP64_TURNS_IN_RADIAN;
}
// ========= Convert radians to any unit ======== //
inline float bgc_radians_to_units_fp32(const float radians, const BgcAngleUnitEnum to_unit)
inline float bgc_fp32_radians_to_units(const float radians, const int angle_unit)
{
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_DEGREES_IN_RADIAN_FP32;
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_FP32_DEGREES_IN_RADIAN;
}
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
return radians * BGC_TURNS_IN_RADIAN_FP32;
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return radians * BGC_FP32_TURNS_IN_RADIAN;
}
return radians;
}
inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnitEnum to_unit)
inline double bgc_fp64_radians_to_units(const double radians, const int angle_unit)
{
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_DEGREES_IN_RADIAN_FP64;
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_FP64_DEGREES_IN_RADIAN;
}
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
return radians * BGC_TURNS_IN_RADIAN_FP64;
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return radians * BGC_FP64_TURNS_IN_RADIAN;
}
return radians;
@ -104,103 +100,103 @@ inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnit
// ============ Normalize radians ============= //
inline float bgc_radians_normalize_fp32(const float radians, const BgcAngleRangeEnum range)
inline float bgc_fp32_normalize_radians(const float radians, const int angle_range)
{
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= radians && radians < BGC_TWO_PI_FP32) {
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= radians && radians < BGC_FP32_TWO_PI) {
return radians;
}
}
else {
if (-BGC_PI_FP32 < radians && radians <= BGC_PI_FP32) {
if (-BGC_FP32_PI < radians && radians <= BGC_FP32_PI) {
return radians;
}
}
float turns = radians * BGC_TURNS_IN_RADIAN_FP32;
float turns = radians * BGC_FP32_TURNS_IN_RADIAN;
turns -= floorf(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
turns -= 1.0f;
}
return turns * BGC_TWO_PI_FP32;
return turns * BGC_FP32_TWO_PI;
}
inline double bgc_radians_normalize_fp64(const double radians, const BgcAngleRangeEnum range)
inline double bgc_fp64_normalize_radians(const double radians, const int angle_range)
{
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= radians && radians < BGC_TWO_PI_FP64) {
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= radians && radians < BGC_FP64_TWO_PI) {
return radians;
}
}
else {
if (-BGC_PI_FP64 < radians && radians <= BGC_PI_FP64) {
if (-BGC_FP64_PI < radians && radians <= BGC_FP64_PI) {
return radians;
}
}
double turns = radians * BGC_TURNS_IN_RADIAN_FP64;
double turns = radians * BGC_FP64_TURNS_IN_RADIAN;
turns -= floor(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
turns -= 1.0;
}
return turns * BGC_TWO_PI_FP64;
return turns * BGC_FP64_TWO_PI;
}
// !================= Degrees ==================! //
// ========= Convert degrees to radians ========= //
inline float bgc_degrees_to_radians_fp32(const float degrees)
inline float bgc_fp32_degrees_to_radians(const float degrees)
{
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
return degrees * BGC_FP32_RADIANS_IN_DEGREE;
}
inline double bgc_degrees_to_radians_fp64(const double degrees)
inline double bgc_fp64_degrees_to_radians(const double degrees)
{
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
return degrees * BGC_FP64_RADIANS_IN_DEGREE;
}
// ========== Convert degrees to turns ========== //
inline float bgc_degrees_to_turns_fp32(const float radians)
inline float bgc_fp32_degrees_to_turns(const float radians)
{
return radians * BGC_TURNS_IN_DEGREE_FP32;
return radians * BGC_FP32_TURNS_IN_DEGREE;
}
inline double bgc_degrees_to_turns_fp64(const double radians)
inline double bgc_fp64_degrees_to_turns(const double radians)
{
return radians * BGC_TURNS_IN_DEGREE_FP64;
return radians * BGC_FP64_TURNS_IN_DEGREE;
}
// ========= Convert degreess to any unit ======== //
inline float bgc_degrees_to_units_fp32(const float degrees, const BgcAngleUnitEnum to_unit)
inline float bgc_fp32_degrees_to_units(const float degrees, const int angle_unit)
{
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_FP32_RADIANS_IN_DEGREE;
}
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
return degrees * BGC_TURNS_IN_DEGREE_FP32;
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return degrees * BGC_FP32_TURNS_IN_DEGREE;
}
return degrees;
}
inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnitEnum to_unit)
inline double bgc_fp64_degrees_to_units(const double degrees, const int angle_unit)
{
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_FP64_RADIANS_IN_DEGREE;
}
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
return degrees * BGC_TURNS_IN_DEGREE_FP64;
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return degrees * BGC_FP64_TURNS_IN_DEGREE;
}
return degrees;
@ -208,9 +204,9 @@ inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnit
// ============ Normalize degrees ============= //
inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRangeEnum range)
inline float bgc_fp32_normalize_degrees(const float degrees, const int angle_range)
{
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= degrees && degrees < 360.0f) {
return degrees;
}
@ -221,20 +217,20 @@ inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRange
}
}
float turns = degrees * BGC_TURNS_IN_DEGREE_FP32;
float turns = degrees * BGC_FP32_TURNS_IN_DEGREE;
turns -= floorf(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
turns -= 1.0f;
}
return turns * 360.0f;
}
inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRangeEnum range)
inline double bgc_fp64_degrees_normalize(const double degrees, const int angle_range)
{
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= degrees && degrees < 360.0) {
return degrees;
}
@ -245,11 +241,11 @@ inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRan
}
}
double turns = degrees * BGC_TURNS_IN_DEGREE_FP64;
double turns = degrees * BGC_FP64_TURNS_IN_DEGREE;
turns -= floor(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
turns -= 1.0;
}
@ -260,50 +256,50 @@ inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRan
// ========== Convert turns to radians ========== //
inline float bgc_turns_to_radians_fp32(const float turns)
inline float bgc_fp32_turns_to_radians(const float turns)
{
return turns * BGC_TWO_PI_FP32;
return turns * BGC_FP32_TWO_PI;
}
inline double bgc_turns_to_radians_fp64(const double turns)
inline double bgc_fp64_turns_to_radians(const double turns)
{
return turns * BGC_TWO_PI_FP64;
return turns * BGC_FP64_TWO_PI;
}
// ========== Convert turns to degrees ========== //
inline float bgc_turns_to_degrees_fp32(const float turns)
inline float bgc_fp32_turns_to_degrees(const float turns)
{
return turns * 360.0f;
}
inline double bgc_turns_to_degrees_fp64(const double turns)
inline double bgc_fp64_turns_to_degrees(const double turns)
{
return turns * 360.0;
}
// ========= Convert turns to any unit ======== //
inline float bgc_turns_to_units_fp32(const float turns, const BgcAngleUnitEnum to_unit)
inline float bgc_fp32_turns_to_units(const float turns, const int angle_unit)
{
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_TWO_PI_FP32;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_FP32_TWO_PI;
}
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return turns * 360.0f;
}
return turns;
}
inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum to_unit)
inline double bgc_fp64_turns_to_units(const double turns, const int angle_unit)
{
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_TWO_PI_FP64;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_FP64_TWO_PI;
}
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return turns * 360.0;
}
@ -312,9 +308,9 @@ inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum
// ============= Normalize turns ============== //
inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum range)
inline float bgc_fp32_normalize_turns(const float turns, const int angle_range)
{
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= turns && turns < 1.0f) {
return turns;
}
@ -327,16 +323,16 @@ inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum
float rest = turns - floorf(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) {
if (angle_range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) {
return rest - 1.0f;
}
return rest;
}
inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEnum range)
inline double bgc_fp64_normalize_turns(const double turns, const int angle_range)
{
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= turns && turns < 1.0) {
return turns;
}
@ -349,7 +345,7 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn
double rest = turns - floor(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) {
if (angle_range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) {
return rest - 1.0;
}
@ -360,27 +356,27 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn
// ========= Convert any unit to radians ======== //
inline float bgc_angle_to_radians_fp32(const float angle, const BgcAngleUnitEnum unit)
inline float bgc_fp32_angle_to_radians(const float angle, const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_RADIANS_IN_DEGREE_FP32;
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_FP32_RADIANS_IN_DEGREE;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return angle * BGC_TWO_PI_FP32;
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * BGC_FP32_TWO_PI;
}
return angle;
}
inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEnum unit)
inline double bgc_fp64_angle_to_radians(const double angle, const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_RADIANS_IN_DEGREE_FP64;
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_FP64_RADIANS_IN_DEGREE;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return angle * BGC_TWO_PI_FP64;
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * BGC_FP64_TWO_PI;
}
return angle;
@ -388,26 +384,26 @@ inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEn
// ========= Convert any unit to degreess ======== //
inline float bgc_angle_to_degrees_fp32(const float angle, const BgcAngleUnitEnum unit)
inline float bgc_fp32_angle_to_degrees(const float angle, const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_DEGREES_IN_RADIAN_FP32;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_FP32_DEGREES_IN_RADIAN;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * 360.0f;
}
return angle;
}
inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEnum unit)
inline double bgc_fp64_angle_to_degrees(const double angle, const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_DEGREES_IN_RADIAN_FP64;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_FP64_DEGREES_IN_RADIAN;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * 360.0;
}
@ -416,27 +412,27 @@ inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEn
// ========= Convert any unit to turns ======== //
inline float bgc_angle_to_turns_fp32(const float angle, const BgcAngleUnitEnum unit)
inline float bgc_fp32_angle_to_turns(const float angle, const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_TURNS_IN_RADIAN_FP32;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_FP32_TURNS_IN_RADIAN;
}
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_TURNS_IN_DEGREE_FP32;
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_FP32_TURNS_IN_DEGREE;
}
return angle;
}
inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum unit)
inline double bgc_fp64_angle_to_turns(const double angle, const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_TURNS_IN_RADIAN_FP64;
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_FP64_TURNS_IN_RADIAN;
}
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_TURNS_IN_DEGREE_FP64;
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_FP64_TURNS_IN_DEGREE;
}
return angle;
@ -444,114 +440,58 @@ inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum
// ============= Get Full Circle ============== //
inline float bgc_angle_get_full_circle_fp32(const BgcAngleUnitEnum unit)
inline float bgc_fp32_full_circle(const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return 360.0f;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return 1.0f;
}
return BGC_TWO_PI_FP32;
return BGC_FP32_TWO_PI;
}
inline double bgc_angle_get_full_circle_fp64(const BgcAngleUnitEnum unit)
inline double bgc_fp64_full_circle(const int angle_unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return 360.0;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return 1.0;
}
return BGC_TWO_PI_FP64;
}
// ============= Get Half Circle ============== //
inline float bgc_angle_get_half_circle_fp32(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 180.0f;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.5f;
}
return BGC_PI_FP32;
}
inline double bgc_angle_get_half_circle_fp64(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 180.0;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.5;
}
return BGC_PI_FP64;
}
// ============= Get Half Circle ============== //
inline float bgc_angle_get_quater_circle_fp32(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 90.0f;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.25f;
}
return BGC_HALF_OF_PI_FP32;
}
inline double bgc_angle_get_quater_circle_fp64(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 90.0;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.25;
}
return BGC_HALF_OF_PI_FP64;
return BGC_FP64_TWO_PI;
}
// ================ Normalize ================= //
inline float bgc_angle_normalize_fp32(const float angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range)
inline float bgc_fp32_normalize_angle(const float angle, const int angle_unit, const int angle_range)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return bgc_degrees_normalize_fp32(angle, range);
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return bgc_fp32_normalize_degrees(angle, angle_range);
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return bgc_turns_normalize_fp32(angle, range);
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return bgc_fp32_normalize_turns(angle, angle_range);
}
return bgc_radians_normalize_fp32(angle, range);
return bgc_fp32_normalize_radians(angle, angle_range);
}
inline double bgc_angle_normalize_fp64(const double angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range)
inline double bgc_fp64_normalize_angle(const double angle, const int angle_unit, const int angle_range)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return bgc_degrees_normalize_fp64(angle, range);
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return bgc_fp64_degrees_normalize(angle, angle_range);
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return bgc_turns_normalize_fp64(angle, range);
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return bgc_fp64_normalize_turns(angle, angle_range);
}
return bgc_radians_normalize_fp64(angle, range);
return bgc_fp64_normalize_radians(angle, angle_range);
}
#endif

View file

@ -60,10 +60,30 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="complex.h" />
<Unit filename="cotes-number.c">
<Unit filename="dual-number.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="cotes-number.h" />
<Unit filename="dual-number.h" />
<Unit filename="dual-quaternion.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="dual-quaternion.h" />
<Unit filename="dual-vector3.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="dual-vector3.h" />
<Unit filename="hg-matrix3x3.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="hg-matrix3x3.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">
<Option compilerVar="CC" />
</Unit>
@ -80,10 +100,6 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="matrix3x3.h" />
<Unit filename="matrixes.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="matrixes.h" />
<Unit filename="position2.c">
<Option compilerVar="CC" />
</Unit>
@ -96,10 +112,18 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="quaternion.h" />
<Unit filename="rotation3.c">
<Unit filename="slerp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="rotation3.h" />
<Unit filename="slerp.h" />
<Unit filename="turn2.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="turn2.h" />
<Unit filename="turn3.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="turn3.h" />
<Unit filename="utilities.c">
<Option compilerVar="CC" />
</Unit>
@ -112,10 +136,6 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="vector3.h" />
<Unit filename="versor.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="versor.h" />
<Extensions />
</Project>
</CodeBlocks_project_file>

View file

@ -1,5 +1,5 @@
#ifndef _BGC_H_
#define _BGC_H_
#ifndef _BGC_H_INCLUDED_
#define _BGC_H_INCLUDED_
#include "./utilities.h"
@ -8,7 +8,7 @@
#include "./vector2.h"
#include "./vector3.h"
#include "./matrixes.h"
#include "./matrices.h"
#include "./matrix2x2.h"
#include "./matrix2x3.h"
#include "./matrix3x2.h"
@ -18,15 +18,14 @@
#include "./affine3.h"
#include "./complex.h"
#include "./cotes-number.h"
#include "./rotation3.h"
#include "./quaternion.h"
#include "./versor.h"
#include "./slerp.h"
#include "./turn2.h"
#include "./turn3.h"
#include "./position2.h"
#include "./position3.h"
#include "./slerp.h"
#endif

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -24,20 +24,23 @@
<ClInclude Include="angle.h" />
<ClInclude Include="basic-geometry.h" />
<ClInclude Include="complex.h" />
<ClInclude Include="cotes-number.h" />
<ClInclude Include="dual-number.h" />
<ClInclude Include="dual-quaternion.h" />
<ClInclude Include="dual-vector3.h" />
<ClInclude Include="hg-matrix3x3.h" />
<ClInclude Include="hg-vector3.h" />
<ClInclude Include="matrix2x2.h" />
<ClInclude Include="matrix2x3.h" />
<ClInclude Include="matrix3x2.h" />
<ClInclude Include="matrix3x3.h" />
<ClInclude Include="matrixes.h" />
<ClInclude Include="matrices.h" />
<ClInclude Include="position2.h" />
<ClInclude Include="position3.h" />
<ClInclude Include="quaternion.h" />
<ClInclude Include="rotation3.h" />
<ClInclude Include="types.h" />
<ClInclude Include="turn2.h" />
<ClInclude Include="turn3.h" />
<ClInclude Include="utilities.h" />
<ClInclude Include="slerp.h" />
<ClInclude Include="versor.h" />
<ClInclude Include="vector2.h" />
<ClInclude Include="vector3.h" />
</ItemGroup>
@ -46,19 +49,23 @@
<ClCompile Include="affine3.c" />
<ClCompile Include="angle.c" />
<ClInclude Include="complex.c" />
<ClInclude Include="cotes-number.c" />
<ClCompile Include="dual-number.c" />
<ClCompile Include="dual-quaternion.c" />
<ClCompile Include="dual-vector3.c" />
<ClCompile Include="hg-matrix3x3.c" />
<ClCompile Include="hg-vector3.c" />
<ClCompile Include="position2.c" />
<ClCompile Include="position3.c" />
<ClCompile Include="turn2.c" />
<ClCompile Include="turn3.c" />
<ClCompile Include="utilities.c" />
<ClCompile Include="matrix2x2.c" />
<ClCompile Include="matrix2x3.c" />
<ClCompile Include="matrix3x2.c" />
<ClCompile Include="matrix3x3.c" />
<ClCompile Include="matrixes.c" />
<ClCompile Include="matrices.c" />
<ClCompile Include="quaternion.c" />
<ClCompile Include="rotation3.c" />
<ClCompile Include="slerp.c" />
<ClCompile Include="versor.c" />
<ClCompile Include="vector2.c" />
<ClCompile Include="vector3.c" />
</ItemGroup>

View file

@ -21,9 +21,6 @@
<ClInclude Include="complex.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="cotes-number.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="utilities.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
@ -36,12 +33,6 @@
<ClInclude Include="matrix3x3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="rotation3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="versor.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="vector2.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
@ -57,21 +48,15 @@
<ClInclude Include="matrix3x2.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="matrixes.h">
<ClInclude Include="matrices.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="complex.c">
<Filter>Исходные файлы</Filter>
</ClInclude>
<ClInclude Include="cotes-number.c">
<Filter>Исходные файлы</Filter>
</ClInclude>
<ClInclude Include="slerp.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="types.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="affine3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
@ -84,6 +69,27 @@
<ClInclude Include="position3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="hg-vector3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="dual-number.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="dual-vector3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="dual-quaternion.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="hg-matrix3x3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="turn2.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="turn3.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="angle.c">
@ -98,22 +104,16 @@
<ClCompile Include="matrix3x3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="versor.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="vector2.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="vector3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="rotation3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="quaternion.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="matrixes.c">
<ClCompile Include="matrices.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="matrix2x3.c">
@ -137,5 +137,26 @@
<ClCompile Include="position3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="hg-vector3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="dual-number.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="dual-vector3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="dual-quaternion.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="hg-matrix3x3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="turn2.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="turn3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,96 +1,96 @@
#include "./complex.h"
extern inline void bgc_complex_reset_fp32(BgcComplexFP32* complex);
extern inline void bgc_complex_reset_fp64(BgcComplexFP64* complex);
extern inline void bgc_fp32_complex_reset(BGC_FP32_Complex* complex);
extern inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex);
extern inline void bgc_complex_set_values_fp32(const float real, const float imaginary, BgcComplexFP32* destination);
extern inline void bgc_complex_set_values_fp64(const double real, const double imaginary, BgcComplexFP64* destination);
extern inline void bgc_fp32_complex_make(BGC_FP32_Complex* complex, const float real, const float imaginary);
extern inline void bgc_fp64_complex_make(BGC_FP64_Complex* complex, const double real, const double imaginary);
extern inline float bgc_complex_get_square_modulus_fp32(const BgcComplexFP32* number);
extern inline double bgc_complex_get_square_modulus_fp64(const BgcComplexFP64* number);
extern inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* number);
extern inline double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number);
extern inline float bgc_complex_get_modulus_fp32(const BgcComplexFP32* number);
extern inline double bgc_complex_get_modulus_fp64(const BgcComplexFP64* number);
extern inline float bgc_fp32_complex_get_modulus(const BGC_FP32_Complex* number);
extern inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number);
extern inline int bgc_complex_is_zero_fp32(const BgcComplexFP32* number);
extern inline int bgc_complex_is_zero_fp64(const BgcComplexFP64* number);
extern inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number);
extern inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number);
extern inline int bgc_complex_is_unit_fp32(const BgcComplexFP32* number);
extern inline int bgc_complex_is_unit_fp64(const BgcComplexFP64* number);
extern inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number);
extern inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number);
extern inline void bgc_complex_copy_fp32(const BgcComplexFP32* source, BgcComplexFP32* destination);
extern inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64* destination);
extern inline void bgc_fp32_complex_copy(BGC_FP32_Complex* destination, const BGC_FP32_Complex* source);
extern inline void bgc_fp64_complex_copy(BGC_FP64_Complex* destination, const BGC_FP64_Complex* source);
extern inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* number2);
extern inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* number2);
extern inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* number2);
extern inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2);
extern inline void bgc_complex_convert_fp64_to_fp32(const BgcComplexFP64* source, BgcComplexFP32* destination);
extern inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcComplexFP64* destination);
extern inline void bgc_fp64_complex_convert_to_fp32(BGC_FP32_Complex* destination, const BGC_FP64_Complex* source);
extern inline void bgc_fp32_complex_convert_to_fp64(BGC_FP64_Complex* destination, const BGC_FP32_Complex* source);
extern inline void bgc_complex_make_opposite_fp32(BgcComplexFP32* number);
extern inline void bgc_complex_make_opposite_fp64(BgcComplexFP64* number);
extern inline void bgc_fp32_complex_revert(BGC_FP32_Complex* number);
extern inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number);
extern inline void bgc_complex_get_opposite_fp32(const BgcComplexFP32* number, BgcComplexFP32* opposite);
extern inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcComplexFP64* opposite);
extern inline void bgc_fp32_complex_get_reverse(BGC_FP32_Complex* reverse, const BGC_FP32_Complex* number);
extern inline void bgc_fp64_complex_get_reverse(BGC_FP64_Complex* reverse, const BGC_FP64_Complex* number);
extern inline int bgc_complex_normalize_fp32(BgcComplexFP32* number);
extern inline int bgc_complex_normalize_fp64(BgcComplexFP64* number);
extern inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number);
extern inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number);
extern inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized);
extern inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized);
extern inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const BGC_FP32_Complex* number);
extern inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const BGC_FP64_Complex* number);
extern inline void bgc_complex_conjugate_fp32(BgcComplexFP32* number);
extern inline void bgc_complex_conjugate_fp64(BgcComplexFP64* number);
extern inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* number);
extern inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number);
extern inline void bgc_complex_get_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate);
extern inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate);
extern inline void bgc_fp32_complex_get_conjugate(BGC_FP32_Complex* conjugate, const BGC_FP32_Complex* number);
extern inline void bgc_fp64_complex_get_conjugate(BGC_FP64_Complex* conjugate, const BGC_FP64_Complex* number);
extern inline int bgc_complex_invert_fp32(BgcComplexFP32* number);
extern inline int bgc_complex_invert_fp64(BgcComplexFP64* number);
extern inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number);
extern inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number);
extern inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverse);
extern inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverse);
extern inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP32_Complex* number);
extern inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number);
extern inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* result);
extern inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* result);
extern inline void bgc_fp32_complex_get_product(BGC_FP32_Complex* product, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline void bgc_fp64_complex_get_product(BGC_FP64_Complex* product, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
extern inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient);
extern inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient);
extern inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor);
extern inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor);
extern inline void bgc_complex_add_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* sum);
extern inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* sum);
extern inline void bgc_fp32_complex_add(BGC_FP32_Complex* sum, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline void bgc_fp64_complex_add(BGC_FP64_Complex* sum, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
extern inline void bgc_complex_add_scaled_fp32(const BgcComplexFP32* basic_number, const BgcComplexFP32* scalable_number, const float scale, BgcComplexFP32* sum);
extern inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, const BgcComplexFP64* scalable_number, const double scale, BgcComplexFP64* sum);
extern inline void bgc_fp32_complex_add_scaled(BGC_FP32_Complex* sum, const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale);
extern inline void bgc_fp64_complex_add_scaled(BGC_FP64_Complex* sum, const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale);
extern inline void bgc_complex_subtract_fp32(const BgcComplexFP32* minuend, const BgcComplexFP32* subtrahend, BgcComplexFP32* difference);
extern inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcComplexFP64* subtrahend, BgcComplexFP64* difference);
extern inline void bgc_fp32_complex_subtract(BGC_FP32_Complex* difference, const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend);
extern inline void bgc_fp64_complex_subtract(BGC_FP64_Complex* difference, const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend);
extern inline void bgc_complex_multiply_by_number_fp32(const BgcComplexFP32* multiplicand, const float multiplier, BgcComplexFP32* product);
extern inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplicand, const double multiplier, BgcComplexFP64* product);
extern inline void bgc_fp32_complex_multiply(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier);
extern inline void bgc_fp64_complex_multiply(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier);
extern inline void bgc_complex_divide_by_number_fp32(const BgcComplexFP32* dividend, const float divisor, BgcComplexFP32* quotient);
extern inline void bgc_complex_divide_by_number_fp64(const BgcComplexFP64* dividend, const double divisor, BgcComplexFP64* quotient);
extern inline void bgc_fp32_complex_divide(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor);
extern inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor);
extern inline void bgc_complex_get_mean_of_two_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* mean);
extern inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* mean);
extern inline void bgc_fp32_complex_get_mean2(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline void bgc_fp64_complex_get_mean2(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
extern inline void bgc_complex_get_mean_of_three_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const BgcComplexFP32* number3, BgcComplexFP32* mean);
extern inline void bgc_complex_get_mean_of_three_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const BgcComplexFP64* number3, BgcComplexFP64* mean);
extern inline void bgc_fp32_complex_get_mean3(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3);
extern inline void bgc_fp64_complex_get_mean3(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3);
extern inline void bgc_complex_interpolate_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const float phase, BgcComplexFP32* interpolation);
extern inline void bgc_complex_interpolate_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const double phase, BgcComplexFP64* interpolation);
extern inline void bgc_fp32_complex_interpolate(BGC_FP32_Complex* interpolation, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase);
extern inline void bgc_fp64_complex_interpolate(BGC_FP64_Complex* interpolation, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase);
extern inline int bgc_complex_are_close_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2);
extern inline int bgc_complex_are_close_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2);
extern inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
// =============== Get Exponation =============== //
void bgc_complex_get_exponation_fp32(const BgcComplexFP32* base, const float real_exponent, const float imaginary_exponent, BgcComplexFP32* power)
void bgc_fp32_complex_get_exponation(BGC_FP32_Complex* power, const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(base);
const float square_modulus = bgc_fp32_complex_get_square_modulus(base);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
if (square_modulus <= BGC_FP32_SQUARE_EPSILON) {
power->real = 0.0f;
power->imaginary = 0.0f;
return;
@ -106,11 +106,11 @@ void bgc_complex_get_exponation_fp32(const BgcComplexFP32* base, const float rea
power->imaginary = power_modulus * sinf(power_angle);
}
void bgc_complex_get_exponation_fp64(const BgcComplexFP64* base, const double real_exponent, const double imaginary_exponent, BgcComplexFP64* power)
void bgc_fp64_complex_get_exponation(BGC_FP64_Complex* power, const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(base);
const double square_modulus = bgc_fp64_complex_get_square_modulus(base);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
if (square_modulus <= BGC_FP64_SQUARE_EPSILON) {
power->real = 0.0;
power->imaginary = 0.0;
return;

View file

@ -1,5 +1,5 @@
#ifndef _BGC_COMPLEX_H_
#define _BGC_COMPLEX_H_
#ifndef _BGC_COMPLEX_H_INCLUDED_
#define _BGC_COMPLEX_H_INCLUDED_
#include "utilities.h"
#include "angle.h"
@ -9,22 +9,22 @@
typedef struct
{
float real, imaginary;
} BgcComplexFP32;
} BGC_FP32_Complex;
typedef struct
{
double real, imaginary;
} BgcComplexFP64;
} BGC_FP64_Complex;
// =================== Reset ==================== //
inline void bgc_complex_reset_fp32(BgcComplexFP32* complex)
inline void bgc_fp32_complex_reset(BGC_FP32_Complex* complex)
{
complex->real = 0.0f;
complex->imaginary = 0.0f;
}
inline void bgc_complex_reset_fp64(BgcComplexFP64* complex)
inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex)
{
complex->real = 0.0;
complex->imaginary = 0.0;
@ -32,71 +32,71 @@ inline void bgc_complex_reset_fp64(BgcComplexFP64* complex)
// ==================== Set ===================== //
inline void bgc_complex_set_values_fp32(const float real, const float imaginary, BgcComplexFP32* destination)
inline void bgc_fp32_complex_make(BGC_FP32_Complex* complex, const float real, const float imaginary)
{
destination->real = real;
destination->imaginary = imaginary;
complex->real = real;
complex->imaginary = imaginary;
}
inline void bgc_complex_set_values_fp64(const double real, const double imaginary, BgcComplexFP64* destination)
inline void bgc_fp64_complex_make(BGC_FP64_Complex* complex, const double real, const double imaginary)
{
destination->real = real;
destination->imaginary = imaginary;
complex->real = real;
complex->imaginary = imaginary;
}
// ================== Modulus =================== //
inline float bgc_complex_get_square_modulus_fp32(const BgcComplexFP32* number)
inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* number)
{
return number->real * number->real + number->imaginary * number->imaginary;
}
inline double bgc_complex_get_square_modulus_fp64(const BgcComplexFP64* number)
inline double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number)
{
return number->real * number->real + number->imaginary * number->imaginary;
}
inline float bgc_complex_get_modulus_fp32(const BgcComplexFP32* number)
inline float bgc_fp32_complex_get_modulus(const BGC_FP32_Complex* number)
{
return sqrtf(bgc_complex_get_square_modulus_fp32(number));
return sqrtf(bgc_fp32_complex_get_square_modulus(number));
}
inline double bgc_complex_get_modulus_fp64(const BgcComplexFP64* number)
inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number)
{
return sqrt(bgc_complex_get_square_modulus_fp64(number));
return sqrt(bgc_fp64_complex_get_square_modulus(number));
}
// ================= Comparison ================= //
inline int bgc_complex_is_zero_fp32(const BgcComplexFP32* number)
inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number)
{
return bgc_complex_get_square_modulus_fp32(number) <= BGC_SQUARE_EPSYLON_FP32;
return bgc_fp32_complex_get_square_modulus(number) <= BGC_FP32_SQUARE_EPSILON;
}
inline int bgc_complex_is_zero_fp64(const BgcComplexFP64* number)
inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number)
{
return bgc_complex_get_square_modulus_fp64(number) <= BGC_SQUARE_EPSYLON_FP64;
return bgc_fp64_complex_get_square_modulus(number) <= BGC_FP64_SQUARE_EPSILON;
}
inline int bgc_complex_is_unit_fp32(const BgcComplexFP32* number)
inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number)
{
return bgc_is_sqare_unit_fp32(bgc_complex_get_square_modulus_fp32(number));
return bgc_fp32_is_square_unit(bgc_fp32_complex_get_square_modulus(number));
}
inline int bgc_complex_is_unit_fp64(const BgcComplexFP64* number)
inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number)
{
return bgc_is_sqare_unit_fp64(bgc_complex_get_square_modulus_fp64(number));
return bgc_fp64_is_square_unit(bgc_fp64_complex_get_square_modulus(number));
}
// ==================== Copy ==================== //
inline void bgc_complex_copy_fp32(const BgcComplexFP32* source, BgcComplexFP32* destination)
inline void bgc_fp32_complex_copy(BGC_FP32_Complex* destination, const BGC_FP32_Complex* source)
{
destination->real = source->real;
destination->imaginary = source->imaginary;
}
inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64* destination)
inline void bgc_fp64_complex_copy(BGC_FP64_Complex* destination, const BGC_FP64_Complex* source)
{
destination->real = source->real;
destination->imaginary = source->imaginary;
@ -104,7 +104,7 @@ inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64*
// ==================== Swap ==================== //
inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* number2)
inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* number2)
{
const float real = number2->real;
const float imaginary = number2->imaginary;
@ -116,7 +116,7 @@ inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* numbe
number1->imaginary = imaginary;
}
inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* number2)
inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2)
{
const double real = number2->real;
const double imaginary = number2->imaginary;
@ -130,13 +130,13 @@ inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* numbe
// ================== Convert =================== //
inline void bgc_complex_convert_fp64_to_fp32(const BgcComplexFP64* source, BgcComplexFP32* destination)
inline void bgc_fp64_complex_convert_to_fp32(BGC_FP32_Complex* destination, const BGC_FP64_Complex* source)
{
destination->real = (float)source->real;
destination->imaginary = (float)source->imaginary;
}
inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcComplexFP64* destination)
inline void bgc_fp32_complex_convert_to_fp64(BGC_FP64_Complex* destination, const BGC_FP32_Complex* source)
{
destination->real = source->real;
destination->imaginary = source->imaginary;
@ -144,41 +144,41 @@ inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcCo
// ================== Negative ================== //
inline void bgc_complex_make_opposite_fp32(BgcComplexFP32* number)
inline void bgc_fp32_complex_revert(BGC_FP32_Complex* number)
{
number->real = -number->real;
number->imaginary = -number->imaginary;
}
inline void bgc_complex_make_opposite_fp64(BgcComplexFP64* number)
inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number)
{
number->real = -number->real;
number->imaginary = -number->imaginary;
}
inline void bgc_complex_get_opposite_fp32(const BgcComplexFP32* number, BgcComplexFP32* opposite)
inline void bgc_fp32_complex_get_reverse(BGC_FP32_Complex* reverse, const BGC_FP32_Complex* number)
{
opposite->real = -number->real;
opposite->imaginary = -number->imaginary;
reverse->real = -number->real;
reverse->imaginary = -number->imaginary;
}
inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcComplexFP64* opposite)
inline void bgc_fp64_complex_get_reverse(BGC_FP64_Complex* reverse, const BGC_FP64_Complex* number)
{
opposite->real = -number->real;
opposite->imaginary = -number->imaginary;
reverse->real = -number->real;
reverse->imaginary = -number->imaginary;
}
// ================= Normalize ================== //
inline int bgc_complex_normalize_fp32(BgcComplexFP32* number)
inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp32(square_modulus)) {
if (bgc_fp32_is_square_unit(square_modulus)) {
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
}
@ -190,15 +190,15 @@ inline int bgc_complex_normalize_fp32(BgcComplexFP32* number)
return 1;
}
inline int bgc_complex_normalize_fp64(BgcComplexFP64* number)
inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp64(square_modulus)) {
if (bgc_fp64_is_square_unit(square_modulus)) {
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
}
@ -210,17 +210,17 @@ inline int bgc_complex_normalize_fp64(BgcComplexFP64* number)
return 1;
}
inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized)
inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const BGC_FP32_Complex* number)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp32(square_modulus)) {
if (bgc_fp32_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
normalized->real = 0.0f;
normalized->imaginary = 0.0f;
return 0;
@ -234,17 +234,17 @@ inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComp
return 1;
}
inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized)
inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const BGC_FP64_Complex* number)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp64(square_modulus)) {
if (bgc_fp64_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
normalized->real = 0.0;
normalized->imaginary = 0.0;
return 0;
@ -260,23 +260,23 @@ inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComp
// ================= Conjugate ================== //
inline void bgc_complex_conjugate_fp32(BgcComplexFP32* number)
inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* number)
{
number->imaginary = -number->imaginary;
}
inline void bgc_complex_conjugate_fp64(BgcComplexFP64* number)
inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number)
{
number->imaginary = -number->imaginary;
}
inline void bgc_complex_get_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate)
inline void bgc_fp32_complex_get_conjugate(BGC_FP32_Complex* conjugate, const BGC_FP32_Complex* number)
{
conjugate->real = number->real;
conjugate->imaginary = -number->imaginary;
}
inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate)
inline void bgc_fp64_complex_get_conjugate(BGC_FP64_Complex* conjugate, const BGC_FP64_Complex* number)
{
conjugate->real = number->real;
conjugate->imaginary = -number->imaginary;
@ -284,11 +284,11 @@ inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComp
// =================== Invert =================== //
inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverse)
inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP32_Complex* number)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
}
@ -300,11 +300,11 @@ inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplex
return 1;
}
inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverse)
inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
}
@ -316,31 +316,31 @@ inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplex
return 1;
}
inline int bgc_complex_invert_fp32(BgcComplexFP32* number)
inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number)
{
return bgc_complex_get_inverse_fp32(number, number);
return bgc_fp32_complex_get_inverse(number, number);
}
inline int bgc_complex_invert_fp64(BgcComplexFP64* number)
inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number)
{
return bgc_complex_get_inverse_fp64(number, number);
return bgc_fp64_complex_get_inverse(number, number);
}
// =============== Get Exponation =============== //
void bgc_complex_get_exponation_fp32(const BgcComplexFP32* base, const float real_exponent, const float imaginary_exponent, BgcComplexFP32* power);
void bgc_fp32_complex_get_exponation(BGC_FP32_Complex* power, const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent);
void bgc_complex_get_exponation_fp64(const BgcComplexFP64* base, const double real_exponent, const double imaginary_exponent, BgcComplexFP64* power);
void bgc_fp64_complex_get_exponation(BGC_FP64_Complex* power, const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent);
// ==================== Add ===================== //
inline void bgc_complex_add_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* sum)
inline void bgc_fp32_complex_add(BGC_FP32_Complex* sum, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2)
{
sum->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary;
}
inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* sum)
inline void bgc_fp64_complex_add(BGC_FP64_Complex* sum, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
{
sum->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary;
@ -348,13 +348,13 @@ inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplex
// ================= Add scaled ================= //
inline void bgc_complex_add_scaled_fp32(const BgcComplexFP32* basic_number, const BgcComplexFP32* scalable_number, const float scale, BgcComplexFP32* sum)
inline void bgc_fp32_complex_add_scaled(BGC_FP32_Complex* sum, const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale)
{
sum->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
}
inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, const BgcComplexFP64* scalable_number, const double scale, BgcComplexFP64* sum)
inline void bgc_fp64_complex_add_scaled(BGC_FP64_Complex* sum, const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale)
{
sum->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
@ -362,13 +362,13 @@ inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, cons
// ================== Subtract ================== //
inline void bgc_complex_subtract_fp32(const BgcComplexFP32* minuend, const BgcComplexFP32* subtrahend, BgcComplexFP32* difference)
inline void bgc_fp32_complex_subtract(BGC_FP32_Complex* difference, const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend)
{
difference->real = minuend->real - subtrahend->real;
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
}
inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcComplexFP64* subtrahend, BgcComplexFP64* 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->imaginary = minuend->imaginary - subtrahend->imaginary;
@ -376,7 +376,7 @@ inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcCo
// ================== Multiply ================== //
inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* product)
inline void bgc_fp32_complex_get_product(BGC_FP32_Complex* product, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2)
{
const float real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -385,7 +385,7 @@ inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcCo
product->imaginary = imaginary;
}
inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* product)
inline void bgc_fp64_complex_get_product(BGC_FP64_Complex* product, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
{
const double real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -396,13 +396,13 @@ inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcCo
// ============= Multiply By Number ============= //
inline void bgc_complex_multiply_by_number_fp32(const BgcComplexFP32* multiplicand, const float multiplier, BgcComplexFP32* product)
inline void bgc_fp32_complex_multiply(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier)
{
product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier;
}
inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplicand, const double multiplier, BgcComplexFP64* product)
inline void bgc_fp64_complex_multiply(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier)
{
product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier;
@ -410,11 +410,11 @@ inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplica
// =================== Divide =================== //
inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient)
inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(divisor);
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
if (square_modulus <= BGC_FP32_SQUARE_EPSILON) {
return 0;
}
@ -429,11 +429,11 @@ inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComp
return 1;
}
inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient)
inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(divisor);
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
if (square_modulus <= BGC_FP64_SQUARE_EPSILON) {
return 0;
}
@ -450,25 +450,25 @@ inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComp
// ============== Divide By Number ============== //
inline void bgc_complex_divide_by_number_fp32(const BgcComplexFP32* dividend, const float divisor, BgcComplexFP32* quotient)
inline void bgc_fp32_complex_divide(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor)
{
bgc_complex_multiply_by_number_fp32(dividend, 1.0f / divisor, quotient);
bgc_fp32_complex_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_complex_divide_by_number_fp64(const BgcComplexFP64* dividend, const double divisor, BgcComplexFP64* quotient)
inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor)
{
bgc_complex_multiply_by_number_fp64(dividend, 1.0 / divisor, quotient);
bgc_fp64_complex_multiply(quotient, dividend, 1.0 / divisor);
}
// ================== Average2 ================== //
inline void bgc_complex_get_mean_of_two_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* mean)
inline void bgc_fp32_complex_get_mean2(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2)
{
mean->real = (number1->real + number2->real) * 0.5f;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5f;
}
inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* mean)
inline void bgc_fp64_complex_get_mean2(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
{
mean->real = (number1->real + number2->real) * 0.5;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5;
@ -476,70 +476,70 @@ inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, cons
// ================== Average3 ================== //
inline void bgc_complex_get_mean_of_three_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const BgcComplexFP32* number3, BgcComplexFP32* mean)
inline void bgc_fp32_complex_get_mean3(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3)
{
mean->real = (number1->real + number2->real + number3->real) * BGC_ONE_THIRD_FP32;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_ONE_THIRD_FP32;
mean->real = (number1->real + number2->real + number3->real) * BGC_FP32_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP32_ONE_THIRD;
}
inline void bgc_complex_get_mean_of_three_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const BgcComplexFP64* number3, BgcComplexFP64* mean)
inline void bgc_fp64_complex_get_mean3(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3)
{
mean->real = (number1->real + number2->real + number3->real) * BGC_ONE_THIRD_FP64;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_ONE_THIRD_FP64;
mean->real = (number1->real + number2->real + number3->real) * BGC_FP64_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP64_ONE_THIRD;
}
// =================== Linear =================== //
inline void bgc_complex_interpolate_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const float phase, BgcComplexFP32* interpolation)
inline void bgc_fp32_complex_interpolate(BGC_FP32_Complex* interpolation, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase)
{
const float counterphase = 1.0f - phase;
const float counter_phase = 1.0f - phase;
interpolation->real = number1->real * counterphase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counterphase + number2->imaginary * phase;
interpolation->real = number1->real * counter_phase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase;
}
inline void bgc_complex_interpolate_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const double phase, BgcComplexFP64* interpolation)
inline void bgc_fp64_complex_interpolate(BGC_FP64_Complex* interpolation, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase)
{
const double counterphase = 1.0 - phase;
const double counter_phase = 1.0 - phase;
interpolation->real = number1->real * counterphase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counterphase + number2->imaginary * phase;
interpolation->real = number1->real * counter_phase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase;
}
// ================== Are Close ================= //
inline int bgc_complex_are_close_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2)
inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2)
{
const float square_modulus1 = bgc_complex_get_square_modulus_fp32(number1);
const float square_modulus2 = bgc_complex_get_square_modulus_fp32(number2);
const float square_modulus1 = bgc_fp32_complex_get_square_modulus(number1);
const float square_modulus2 = bgc_fp32_complex_get_square_modulus(number2);
const float d_real = number1->real - number2->real;
const float d_imaginary = number1->imaginary - number2->imaginary;
const float square_distance = d_real * d_real + d_imaginary * d_imaginary;
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) {
return square_distance <= BGC_SQUARE_EPSYLON_FP32;
if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP32_SQUARE_EPSILON;
}
return square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus2;
return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2;
}
inline int bgc_complex_are_close_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2)
inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
{
const double square_modulus1 = bgc_complex_get_square_modulus_fp64(number1);
const double square_modulus2 = bgc_complex_get_square_modulus_fp64(number2);
const double square_modulus1 = bgc_fp64_complex_get_square_modulus(number1);
const double square_modulus2 = bgc_fp64_complex_get_square_modulus(number2);
const double d_real = number1->real - number2->real;
const double d_imaginary = number1->imaginary - number2->imaginary;
const double square_distance = d_real * d_real + d_imaginary * d_imaginary;
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) {
return square_distance <= BGC_SQUARE_EPSYLON_FP64;
if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP64_SQUARE_EPSILON;
}
return square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus2;
return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2;
}
#endif

View file

@ -1,94 +0,0 @@
#include "./cotes-number.h"
const BgcCotesNumberFP32 BGC_IDLE_COTES_NUMBER_FP32 = { 1.0f, 0.0f };
const BgcCotesNumberFP64 BGC_IDLE_COTES_NUMBER_FP64 = { 1.0, 0.0 };
extern inline void bgc_cotes_number_reset_fp32(BgcCotesNumberFP32* number);
extern inline void bgc_cotes_number_reset_fp64(BgcCotesNumberFP64* number);
extern inline void bgc_cotes_number_set_values_fp32(const float x1, const float x2, BgcCotesNumberFP32* number);
extern inline void bgc_cotes_number_set_values_fp64(const double x1, const double x2, BgcCotesNumberFP64* number);
extern inline void bgc_cotes_number_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP32* number);
extern inline void bgc_cotes_number_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP64* number);
extern inline float bgc_cotes_number_get_angle_fp32(const BgcCotesNumberFP32* number, const BgcAngleUnitEnum unit);
extern inline double bgc_cotes_number_get_angle_fp64(const BgcCotesNumberFP64* number, const BgcAngleUnitEnum unit);
extern inline void bgc_cotes_number_copy_fp32(const BgcCotesNumberFP32* source, BgcCotesNumberFP32* destination);
extern inline void bgc_cotes_number_copy_fp64(const BgcCotesNumberFP64* source, BgcCotesNumberFP64* destination);
extern inline void bgc_cotes_number_swap_fp32(BgcCotesNumberFP32* number1, BgcCotesNumberFP32* number2);
extern inline void bgc_cotes_number_swap_fp64(BgcCotesNumberFP64* number1, BgcCotesNumberFP64* number2);
extern inline void bgc_cotes_number_convert_fp64_to_fp32(const BgcCotesNumberFP64* source, BgcCotesNumberFP32* destination);
extern inline void bgc_cotes_number_convert_fp32_to_fp64(const BgcCotesNumberFP32* source, BgcCotesNumberFP64* destination);
extern inline void bgc_cotes_number_make_opposite_fp32(BgcCotesNumberFP32* number);
extern inline void bgc_cotes_number_make_opposite_fp64(BgcCotesNumberFP64* number);
extern inline void bgc_cotes_number_get_opposite_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* opposite);
extern inline void bgc_cotes_number_get_opposite_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* opposite);
extern inline void bgc_cotes_number_invert_fp32(BgcCotesNumberFP32* number);
extern inline void bgc_cotes_number_invert_fp64(BgcCotesNumberFP64* number);
extern inline void bgc_cotes_number_get_inverse_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* inverse);
extern inline void bgc_cotes_number_get_inverse_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* inverse);
extern inline void bgc_cotes_number_get_exponation_fp32(const BgcCotesNumberFP32* base, const float exponent, BgcCotesNumberFP32* power);
extern inline void bgc_cotes_number_get_exponation_fp64(const BgcCotesNumberFP64* base, const double exponent, BgcCotesNumberFP64* power);
extern inline void bgc_cotes_number_combine_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2, BgcCotesNumberFP32* result);
extern inline void bgc_cotes_number_combine_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2, BgcCotesNumberFP64* result);
extern inline void bgc_cotes_number_exclude_fp32(const BgcCotesNumberFP32* base, const BgcCotesNumberFP32* excludant, BgcCotesNumberFP32* difference);
extern inline void bgc_cotes_number_exclude_fp64(const BgcCotesNumberFP64* base, const BgcCotesNumberFP64* excludant, BgcCotesNumberFP64* difference);
extern inline void bgc_cotes_number_get_rotation_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix);
extern inline void bgc_cotes_number_get_rotation_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix);
extern inline void bgc_cotes_number_get_reverse_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix);
extern inline void bgc_cotes_number_get_reverse_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix);
extern inline void bgc_cotes_number_turn_vector_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result);
extern inline void bgc_cotes_number_turn_vector_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result);
extern inline void bgc_cotes_number_turn_vector_back_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result);
extern inline void bgc_cotes_number_turn_vector_back_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result);
extern inline int bgc_cotes_number_are_close_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2);
extern inline int bgc_cotes_number_are_close_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2);
void _bgc_cotes_number_normalize_fp32(const float square_modulus, BgcCotesNumberFP32* number)
{
// (square_modulus != square_modulus) is true when square_modulus is NaN
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
number->_cos = 1.0f;
number->_sin = 0.0f;
return;
}
const float multiplier = sqrtf(1.0f / square_modulus);
number->_cos *= multiplier;
number->_sin *= multiplier;
}
void _bgc_cotes_number_normalize_fp64(const double square_modulus, BgcCotesNumberFP64* number)
{
// (square_modulus != square_modulus) is true when square_modulus is NaN
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
number->_cos = 1.0;
number->_sin = 0.0;
return;
}
const double multiplier = sqrt(1.0 / square_modulus);
number->_cos *= multiplier;
number->_sin *= multiplier;
}

View file

@ -1,356 +0,0 @@
#ifndef _BGC_COTES_NUMBER_H_
#define _BGC_COTES_NUMBER_H_
#include <math.h>
#include "utilities.h"
#include "angle.h"
#include "vector2.h"
#include "matrix2x2.h"
// =================== Types ==================== //
typedef struct
{
float _cos, _sin;
} BgcCotesNumberFP32;
typedef struct
{
double _cos, _sin;
} BgcCotesNumberFP64;
// ================= Constants ================== //
extern const BgcCotesNumberFP32 BGC_IDLE_COTES_NUMBER_FP32;
extern const BgcCotesNumberFP64 BGC_IDLE_COTES_NUMBER_FP64;
// =================== Reset ==================== //
inline void bgc_cotes_number_reset_fp32(BgcCotesNumberFP32* number)
{
number->_cos = 1.0f;
number->_sin = 0.0f;
}
inline void bgc_cotes_number_reset_fp64(BgcCotesNumberFP64* number)
{
number->_cos = 1.0;
number->_sin = 0.0;
}
// ==================== Set ===================== //
void _bgc_cotes_number_normalize_fp32(const float square_modulus, BgcCotesNumberFP32* twin);
void _bgc_cotes_number_normalize_fp64(const double square_modulus, BgcCotesNumberFP64* twin);
inline void bgc_cotes_number_set_values_fp32(const float x1, const float x2, BgcCotesNumberFP32* number)
{
const float square_modulus = x1 * x1 + x2 * x2;
number->_cos = x1;
number->_sin = x2;
if (!bgc_is_sqare_unit_fp32(square_modulus)) {
_bgc_cotes_number_normalize_fp32(square_modulus, number);
}
}
inline void bgc_cotes_number_set_values_fp64(const double x1, const double x2, BgcCotesNumberFP64* number)
{
const double square_modulus = x1 * x1 + x2 * x2;
number->_cos = x1;
number->_sin = x2;
if (!bgc_is_sqare_unit_fp64(square_modulus)) {
_bgc_cotes_number_normalize_fp64(square_modulus, number);
}
}
// ================== Set Turn ================== //
inline void bgc_cotes_number_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP32* number)
{
const float radians = bgc_angle_to_radians_fp32(angle, unit);
number->_cos = cosf(radians);
number->_sin = sinf(radians);
}
inline void bgc_cotes_number_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP64* number)
{
const double radians = bgc_angle_to_radians_fp64(angle, unit);
number->_cos = cos(radians);
number->_sin = sin(radians);
}
// =================== Angle =================== //
inline float bgc_cotes_number_get_angle_fp32(const BgcCotesNumberFP32* number, const BgcAngleUnitEnum unit)
{
return bgc_radians_to_units_fp32(atan2f(number->_sin, number->_cos), unit);
}
inline double bgc_cotes_number_get_angle_fp64(const BgcCotesNumberFP64* number, const BgcAngleUnitEnum unit)
{
return bgc_radians_to_units_fp64(atan2(number->_sin, number->_cos), unit);
}
// ==================== Copy ==================== //
inline void bgc_cotes_number_copy_fp32(const BgcCotesNumberFP32* source, BgcCotesNumberFP32* destination)
{
destination->_cos = source->_cos;
destination->_sin = source->_sin;
}
inline void bgc_cotes_number_copy_fp64(const BgcCotesNumberFP64* source, BgcCotesNumberFP64* destination)
{
destination->_cos = source->_cos;
destination->_sin = source->_sin;
}
// ==================== Swap ==================== //
inline void bgc_cotes_number_swap_fp32(BgcCotesNumberFP32* number1, BgcCotesNumberFP32* number2)
{
const float cos = number1->_cos;
const float sin = number1->_sin;
number1->_cos = number2->_cos;
number1->_sin = number2->_sin;
number2->_cos = cos;
number2->_sin = sin;
}
inline void bgc_cotes_number_swap_fp64(BgcCotesNumberFP64* number1, BgcCotesNumberFP64* number2)
{
const double cos = number1->_cos;
const double sin = number1->_sin;
number1->_cos = number2->_cos;
number1->_sin = number2->_sin;
number2->_cos = cos;
number2->_sin = sin;
}
// ================== Convert =================== //
inline void bgc_cotes_number_convert_fp64_to_fp32(const BgcCotesNumberFP64* source, BgcCotesNumberFP32* destination)
{
bgc_cotes_number_set_values_fp32((float)source->_cos, (float)source->_sin, destination);
}
inline void bgc_cotes_number_convert_fp32_to_fp64(const BgcCotesNumberFP32* source, BgcCotesNumberFP64* destination)
{
bgc_cotes_number_set_values_fp64((double)source->_cos, (double)source->_sin, destination);
}
// ================== Negative ================== //
inline void bgc_cotes_number_make_opposite_fp32(BgcCotesNumberFP32* number)
{
number->_cos = -number->_cos;
number->_sin = -number->_sin;
}
inline void bgc_cotes_number_make_opposite_fp64(BgcCotesNumberFP64* number)
{
number->_cos = -number->_cos;
number->_sin = -number->_sin;
}
inline void bgc_cotes_number_get_opposite_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* opposite)
{
opposite->_cos = -number->_cos;
opposite->_sin = -number->_sin;
}
inline void bgc_cotes_number_get_opposite_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* opposite)
{
opposite->_cos = -number->_cos;
opposite->_sin = -number->_sin;
}
// =================== Invert =================== //
inline void bgc_cotes_number_invert_fp32(BgcCotesNumberFP32* number)
{
number->_sin = -number->_sin;
}
inline void bgc_cotes_number_invert_fp64(BgcCotesNumberFP64* number)
{
number->_sin = -number->_sin;
}
inline void bgc_cotes_number_get_inverse_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* inverse)
{
inverse->_cos = number->_cos;
inverse->_sin = -number->_sin;
}
inline void bgc_cotes_number_get_inverse_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* inverse)
{
inverse->_cos = number->_cos;
inverse->_sin = -number->_sin;
}
// ================= Exponation ================= //
inline void bgc_cotes_number_get_exponation_fp32(const BgcCotesNumberFP32* base, const float exponent, BgcCotesNumberFP32* power)
{
const float power_angle = exponent * atan2f(base->_sin, base->_cos);
power->_cos = cosf(power_angle);
power->_sin = sinf(power_angle);
}
inline void bgc_cotes_number_get_exponation_fp64(const BgcCotesNumberFP64* base, const double exponent, BgcCotesNumberFP64* power)
{
const double power_angle = exponent * atan2(base->_sin, base->_cos);
power->_cos = cos(power_angle);
power->_sin = sin(power_angle);
}
// ================ Combination ================= //
inline void bgc_cotes_number_combine_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2, BgcCotesNumberFP32* result)
{
bgc_cotes_number_set_values_fp32(
number1->_cos * number2->_cos - number1->_sin * number2->_sin,
number1->_cos * number2->_sin + number1->_sin * number2->_cos,
result
);
}
inline void bgc_cotes_number_combine_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2, BgcCotesNumberFP64* result)
{
bgc_cotes_number_set_values_fp64(
number1->_cos * number2->_cos - number1->_sin * number2->_sin,
number1->_cos * number2->_sin + number1->_sin * number2->_cos,
result
);
}
// ================= Exclusion ================== //
inline void bgc_cotes_number_exclude_fp32(const BgcCotesNumberFP32* base, const BgcCotesNumberFP32* excludant, BgcCotesNumberFP32* difference)
{
bgc_cotes_number_set_values_fp32(
base->_cos * excludant->_cos + base->_sin * excludant->_sin,
base->_sin * excludant->_cos - base->_cos * excludant->_sin,
difference
);
}
inline void bgc_cotes_number_exclude_fp64(const BgcCotesNumberFP64* base, const BgcCotesNumberFP64* excludant, BgcCotesNumberFP64* difference)
{
bgc_cotes_number_set_values_fp64(
base->_cos * excludant->_cos + base->_sin * excludant->_sin,
base->_sin * excludant->_cos - base->_cos * excludant->_sin,
difference
);
}
// ============== Rotation Matrix =============== //
inline void bgc_cotes_number_get_rotation_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix)
{
matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin;
matrix->r2c1 = number->_sin;
matrix->r2c2 = number->_cos;
}
inline void bgc_cotes_number_get_rotation_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix)
{
matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin;
matrix->r2c1 = number->_sin;
matrix->r2c2 = number->_cos;
}
// ============== Reverse Matrix ================ //
inline void bgc_cotes_number_get_reverse_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix)
{
matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin;
matrix->r2c1 = -number->_sin;
matrix->r2c2 = number->_cos;
}
inline void bgc_cotes_number_get_reverse_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix)
{
matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin;
matrix->r2c1 = -number->_sin;
matrix->r2c2 = number->_cos;
}
// ================ Turn Vector ================= //
inline void bgc_cotes_number_turn_vector_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result)
{
const float x1 = number->_cos * vector->x1 - number->_sin * vector->x2;
const float x2 = number->_sin * vector->x1 + number->_cos * vector->x2;
result->x1 = x1;
result->x2 = x2;
}
inline void bgc_cotes_number_turn_vector_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result)
{
const double x1 = number->_cos * vector->x1 - number->_sin * vector->x2;
const double x2 = number->_sin * vector->x1 + number->_cos * vector->x2;
result->x1 = x1;
result->x2 = x2;
}
// ============ Turn Vector Backward ============ //
inline void bgc_cotes_number_turn_vector_back_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result)
{
const float x1 = number->_sin * vector->x2 + number->_cos * vector->x1;
const float x2 = number->_cos * vector->x2 - number->_sin * vector->x1;
result->x1 = x1;
result->x2 = x2;
}
inline void bgc_cotes_number_turn_vector_back_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result)
{
const double x1 = number->_sin * vector->x2 + number->_cos * vector->x1;
const double x2 = number->_cos * vector->x2 - number->_sin * vector->x1;
result->x1 = x1;
result->x2 = x2;
}
// ================== Are Close ================= //
inline int bgc_cotes_number_are_close_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2)
{
const float d_cos = number1->_cos - number2->_cos;
const float d_sin = number1->_sin - number2->_sin;
return d_cos * d_cos + d_sin * d_sin <= BGC_SQUARE_EPSYLON_FP32;
}
inline int bgc_cotes_number_are_close_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2)
{
const double d_cos = number1->_cos - number2->_cos;
const double d_sin = number1->_sin - number2->_sin;
return d_cos * d_cos + d_sin * d_sin <= BGC_SQUARE_EPSYLON_FP64;
}
#endif

View file

@ -0,0 +1,43 @@
#include "dual-number.h"
extern inline void bgc_fp32_dual_number_reset(BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_dual_number_reset(BGC_FP64_DualNumber* number);
extern inline void bgc_fp32_dual_number_make(BGC_FP32_DualNumber* number, const float real, const float dual);
extern inline void bgc_fp64_dual_number_make(BGC_FP64_DualNumber* number, const double real, const double dual);
extern inline void bgc_fp32_dual_number_copy(BGC_FP32_DualNumber* destination, const BGC_FP32_DualNumber* source);
extern inline void bgc_fp64_dual_number_copy(BGC_FP64_DualNumber* destination, const BGC_FP64_DualNumber* source);
extern inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second);
extern inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second);
extern inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second);
extern inline void bgc_fp64_dual_number_add(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second);
extern inline void bgc_fp32_dual_number_add_scaled(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* base_number, const BGC_FP32_DualNumber* scalable_number, const float scale);
extern inline void bgc_fp64_dual_number_add_scaled(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* base_number, const BGC_FP64_DualNumber* scalable_number, const double scale);
extern inline void bgc_fp32_dual_number_subtract(BGC_FP32_DualNumber* difference, const BGC_FP32_DualNumber* minuend, const BGC_FP32_DualNumber* subtrahend);
extern inline void bgc_fp64_dual_number_subtract(BGC_FP64_DualNumber* difference, const BGC_FP64_DualNumber* minuend, const BGC_FP64_DualNumber* subtrahend);
extern inline void bgc_fp32_dual_number_multiply(BGC_FP32_DualNumber* product, const BGC_FP32_DualNumber* multiplicand, const float multiplier);
extern inline void bgc_fp64_dual_number_multiply(BGC_FP64_DualNumber* product, const BGC_FP64_DualNumber* multiplicand, const double multiplier);
extern inline void bgc_fp32_dual_number_divide(BGC_FP32_DualNumber* quotient, const BGC_FP32_DualNumber* dividend, const float divisor);
extern inline void bgc_fp64_dual_number_divide(BGC_FP64_DualNumber* quotient, const BGC_FP64_DualNumber* dividend, const double divisor);
extern inline void bgc_fp32_dual_number_get_mean2(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second);
extern inline void bgc_fp64_dual_number_get_mean2(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second);
extern inline void bgc_fp32_dual_number_get_mean3(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const BGC_FP32_DualNumber* third);
extern inline void bgc_fp64_dual_number_get_mean3(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const BGC_FP64_DualNumber* third);
extern inline void bgc_fp32_dual_number_interpolate(BGC_FP32_DualNumber* interpolation, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const float phase);
extern inline void bgc_fp64_dual_number_interpolate(BGC_FP64_DualNumber* interpolation, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const double phase);
extern inline void bgc_fp32_dual_number_revert(BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_dual_number_revert(BGC_FP64_DualNumber* number);
extern inline void bgc_fp32_number_get_reverse(BGC_FP32_DualNumber* reverse, const BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_number_get_reverse(BGC_FP64_DualNumber* reverse, const BGC_FP64_DualNumber* number);

View file

@ -0,0 +1,214 @@
#ifndef _BGC_DUAL_NUMBER_H_INCLUDED_
#define _BGC_DUAL_NUMBER_H_INCLUDED_
#include "utilities.h"
// =================== Types ==================== //
typedef struct {
float real, dual;
} BGC_FP32_DualNumber;
typedef struct {
double real, dual;
} BGC_FP64_DualNumber;
// =================== Reset ==================== //
inline void bgc_fp32_dual_number_reset(BGC_FP32_DualNumber* number)
{
number->real = 0.0f;
number->dual = 0.0f;
}
inline void bgc_fp64_dual_number_reset(BGC_FP64_DualNumber* number)
{
number->real = 0.0;
number->dual = 0.0;
}
// ==================== Make ==================== //
inline void bgc_fp32_dual_number_make(BGC_FP32_DualNumber* number, const float real, const float dual)
{
number->real = real;
number->dual = dual;
}
inline void bgc_fp64_dual_number_make(BGC_FP64_DualNumber* number, const double real, const double dual)
{
number->real = real;
number->dual = dual;
}
// ==================== Copy ==================== //
inline void bgc_fp32_dual_number_copy(BGC_FP32_DualNumber* destination, const BGC_FP32_DualNumber* source)
{
destination->real = source->real;
destination->dual = source->dual;
}
inline void bgc_fp64_dual_number_copy(BGC_FP64_DualNumber* destination, const BGC_FP64_DualNumber* source)
{
destination->real = source->real;
destination->dual = source->dual;
}
// ==================== Swap ==================== //
inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second)
{
first->real = second->real;
first->dual = second->dual;
}
inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second)
{
first->real = second->real;
first->dual = second->dual;
}
// ==================== Add ===================== //
inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second)
{
sum->real = first->real + second->real;
sum->dual = first->dual + second->dual;
}
inline void bgc_fp64_dual_number_add(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second)
{
sum->real = first->real + second->real;
sum->dual = first->dual + second->dual;
}
// ================= Add Scaled ================= //
inline void bgc_fp32_dual_number_add_scaled(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* base_number, const BGC_FP32_DualNumber* scalable_number, const float scale)
{
sum->real = base_number->real + scalable_number->real * scale;
sum->dual = base_number->dual + scalable_number->dual * scale;
}
inline void bgc_fp64_dual_number_add_scaled(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* base_number, const BGC_FP64_DualNumber* scalable_number, const double scale)
{
sum->real = base_number->real + scalable_number->real * scale;
sum->dual = base_number->dual + scalable_number->dual * scale;
}
// ================== Subtract ================== //
inline void bgc_fp32_dual_number_subtract(BGC_FP32_DualNumber* difference, const BGC_FP32_DualNumber* minuend, const BGC_FP32_DualNumber* subtrahend)
{
difference->real = minuend->real - subtrahend->real;
difference->dual = minuend->dual - subtrahend->dual;
}
inline void bgc_fp64_dual_number_subtract(BGC_FP64_DualNumber* difference, const BGC_FP64_DualNumber* minuend, const BGC_FP64_DualNumber* subtrahend)
{
difference->real = minuend->real - subtrahend->real;
difference->dual = minuend->dual - subtrahend->dual;
}
// ================== Multiply ================== //
inline void bgc_fp32_dual_number_multiply(BGC_FP32_DualNumber* product, const BGC_FP32_DualNumber* multiplicand, const float multiplier)
{
product->real = multiplicand->real * multiplier;
product->dual = multiplicand->dual * multiplier;
}
inline void bgc_fp64_dual_number_multiply(BGC_FP64_DualNumber* product, const BGC_FP64_DualNumber* multiplicand, const double multiplier)
{
product->real = multiplicand->real * multiplier;
product->dual = multiplicand->dual * multiplier;
}
// =================== Divide =================== //
inline void bgc_fp32_dual_number_divide(BGC_FP32_DualNumber* quotient, const BGC_FP32_DualNumber* dividend, const float divisor)
{
bgc_fp32_dual_number_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_fp64_dual_number_divide(BGC_FP64_DualNumber* quotient, const BGC_FP64_DualNumber* dividend, const double divisor)
{
bgc_fp64_dual_number_multiply(quotient, dividend, 1.0 / divisor);
}
// ================ Mean of Two ================= //
inline void bgc_fp32_dual_number_get_mean2(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second)
{
mean->real = (first->real + second->real) * 0.5f;
mean->dual = (first->dual + second->dual) * 0.5f;
}
inline void bgc_fp64_dual_number_get_mean2(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second)
{
mean->real = (first->real + second->real) * 0.5;
mean->dual = (first->dual + second->dual) * 0.5;
}
// =============== Mean of Three ================ //
inline void bgc_fp32_dual_number_get_mean3(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const BGC_FP32_DualNumber* third)
{
mean->real = (first->real + second->real + third->real) * BGC_FP32_ONE_THIRD;
mean->dual = (first->dual + second->dual + third->dual) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_dual_number_get_mean3(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const BGC_FP64_DualNumber* third)
{
mean->real = (first->real + second->real + third->real) * BGC_FP64_ONE_THIRD;
mean->dual = (first->dual + second->dual + third->dual) * BGC_FP64_ONE_THIRD;
}
// ============ Linear Interpolation ============ //
inline void bgc_fp32_dual_number_interpolate(BGC_FP32_DualNumber* interpolation, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const float phase)
{
const float counter_phase = 1.0f - phase;
interpolation->real = first->real *counter_phase + second->real * phase;
interpolation->dual = first->dual *counter_phase + second->dual * phase;
}
inline void bgc_fp64_dual_number_interpolate(BGC_FP64_DualNumber* interpolation, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const double phase)
{
const double counter_phase = 1.0 - phase;
interpolation->real = first->real * counter_phase + second->real * phase;
interpolation->dual = first->dual * counter_phase + second->dual * phase;
}
// =================== Revert =================== //
inline void bgc_fp32_dual_number_revert(BGC_FP32_DualNumber* number)
{
number->real = -number->real;
number->dual = -number->dual;
}
inline void bgc_fp64_dual_number_revert(BGC_FP64_DualNumber* number)
{
number->real = -number->real;
number->dual = -number->dual;
}
// ================ Get Reverse ================= //
inline void bgc_fp32_number_get_reverse(BGC_FP32_DualNumber* reverse, const BGC_FP32_DualNumber* number)
{
reverse->real = -number->real;
reverse->dual = -number->dual;
}
inline void bgc_fp64_number_get_reverse(BGC_FP64_DualNumber* reverse, const BGC_FP64_DualNumber* number)
{
reverse->real = -number->real;
reverse->dual = -number->dual;
}
#endif

View file

@ -0,0 +1,43 @@
#include "dual-quaternion.h"
extern inline void bgc_fp32_dual_quaternion_reset(BGC_FP32_DualQuaternion* quaternion);
extern inline void bgc_fp64_dual_quaternion_reset(BGC_FP64_DualQuaternion* quaternion);
extern inline void bgc_fp32_dual_quaternion_copy(BGC_FP32_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source);
extern inline void bgc_fp64_dual_quaternion_copy(BGC_FP64_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source);
extern inline void bgc_fp32_dual_quaternion_swap(BGC_FP32_DualQuaternion* first, BGC_FP32_DualQuaternion* second);
extern inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP64_DualQuaternion* second);
extern inline void bgc_fp32_dual_quaternion_convert_to_fp64(BGC_FP64_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source);
extern inline void bgc_fp64_dual_quaternion_convert_to_fp32(BGC_FP32_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source);
extern inline void bgc_fp32_dual_quaternion_add(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* first, const BGC_FP32_DualQuaternion* second);
extern inline void bgc_fp64_dual_quaternion_add(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* first, const BGC_FP64_DualQuaternion* second);
extern inline void bgc_fp32_dual_quaternion_add_scaled(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* base_quaternion, const BGC_FP32_DualQuaternion* scalable_quaternion, const float scale);
extern inline void bgc_fp64_dual_quaternion_add_scaled(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* base_quaternion, const BGC_FP64_DualQuaternion* scalable_quaternion, const double scale);
extern inline void bgc_fp32_dual_quaternion_subtract(BGC_FP32_DualQuaternion* difference, const BGC_FP32_DualQuaternion* minuend, const BGC_FP32_DualQuaternion* subtrahend);
extern inline void bgc_fp64_dual_quaternion_subtract(BGC_FP64_DualQuaternion* difference, const BGC_FP64_DualQuaternion* minuend, const BGC_FP64_DualQuaternion* subtrahend);
extern inline void bgc_fp32_dual_quaternion_multiply(BGC_FP32_DualQuaternion* product, const BGC_FP32_DualQuaternion* multiplicand, const float multipier);
extern inline void bgc_fp64_dual_quaternion_multiply(BGC_FP64_DualQuaternion* product, const BGC_FP64_DualQuaternion* multiplicand, const double multipier);
extern inline void bgc_fp32_dual_quaternion_divide(BGC_FP32_DualQuaternion* quotient, const BGC_FP32_DualQuaternion* divident, const float divisor);
extern inline void bgc_fp64_dual_quaternion_divide(BGC_FP64_DualQuaternion* quotient, const BGC_FP64_DualQuaternion* divident, const double divisor);
extern inline void bgc_fp32_dual_quaternion_get_mean2(BGC_FP32_DualQuaternion* mean, const BGC_FP32_DualQuaternion* quaternion1, const BGC_FP32_DualQuaternion* quaternion2);
extern inline void bgc_fp64_dual_quaternion_get_mean2(BGC_FP64_DualQuaternion* mean, const BGC_FP64_DualQuaternion* quaternion1, const BGC_FP64_DualQuaternion* quaternion2);
extern inline void bgc_fp32_dual_quaternion_get_mean3(BGC_FP32_DualQuaternion* mean, const BGC_FP32_DualQuaternion* quaternion1, const BGC_FP32_DualQuaternion* quaternion2, const BGC_FP32_DualQuaternion* quaternion3);
extern inline void bgc_fp64_dual_quaternion_get_mean3(BGC_FP64_DualQuaternion* mean, const BGC_FP64_DualQuaternion* quaternion1, const BGC_FP64_DualQuaternion* quaternion2, const BGC_FP64_DualQuaternion* quaternion3);
extern inline void bgc_fp32_dual_quaternion_interpolate(BGC_FP32_DualQuaternion* interpolation, const BGC_FP32_DualQuaternion* first, const BGC_FP32_DualQuaternion* second, const float phase);
extern inline void bgc_fp64_dual_quaternion_interpolate(BGC_FP64_DualQuaternion* interpolation, const BGC_FP64_DualQuaternion* first, const BGC_FP64_DualQuaternion* second, const double phase);
extern inline void bgc_fp32_dual_quaternion_revert(BGC_FP32_DualQuaternion* quaternion);
extern inline void bgc_fp64_dual_quaternion_revert(BGC_FP64_DualQuaternion* quaternion);
extern inline void bgc_fp32_dual_quaternion_get_reverse(BGC_FP32_DualQuaternion* reverse, const BGC_FP32_DualQuaternion* quaternion);
extern inline void bgc_fp64_dual_quaternion_get_reverse(BGC_FP64_DualQuaternion* reverse, const BGC_FP64_DualQuaternion* quaternion);

View file

@ -0,0 +1,210 @@
#ifndef _BGC_DUAL_QUATERNION_H_INCLUDED_
#define _BGC_DUAL_QUATERNION_H_INCLUDED_
#include "quaternion.h"
// =================== Types ==================== //
typedef struct {
BGC_FP32_Quaternion real, dual;
} BGC_FP32_DualQuaternion;
typedef struct {
BGC_FP64_Quaternion real, dual;
} BGC_FP64_DualQuaternion;
// =================== Reset ==================== //
inline void bgc_fp32_dual_quaternion_reset(BGC_FP32_DualQuaternion* quaternion)
{
bgc_fp32_quaternion_reset(&quaternion->real);
bgc_fp32_quaternion_reset(&quaternion->dual);
}
inline void bgc_fp64_dual_quaternion_reset(BGC_FP64_DualQuaternion* quaternion)
{
bgc_fp64_quaternion_reset(&quaternion->real);
bgc_fp64_quaternion_reset(&quaternion->dual);
}
// ==================== Copy ==================== //
inline void bgc_fp32_dual_quaternion_copy(BGC_FP32_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source)
{
bgc_fp32_quaternion_copy(&destination->real, &source->real);
bgc_fp32_quaternion_copy(&destination->dual, &source->dual);
}
inline void bgc_fp64_dual_quaternion_copy(BGC_FP64_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source)
{
bgc_fp64_quaternion_copy(&destination->real, &source->real);
bgc_fp64_quaternion_copy(&destination->dual, &source->dual);
}
// ==================== Swap ==================== //
inline void bgc_fp32_dual_quaternion_swap(BGC_FP32_DualQuaternion* first, BGC_FP32_DualQuaternion* second)
{
bgc_fp32_quaternion_swap(&first->real, &second->real);
bgc_fp32_quaternion_swap(&first->dual, &second->dual);
}
inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP64_DualQuaternion* second)
{
bgc_fp64_quaternion_swap(&first->real, &second->real);
bgc_fp64_quaternion_swap(&first->dual, &second->dual);
}
// ================== Convert =================== //
inline void bgc_fp32_dual_quaternion_convert_to_fp64(BGC_FP64_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source)
{
bgc_fp32_quaternion_convert_to_fp64(&destination->real, &source->real);
bgc_fp32_quaternion_convert_to_fp64(&destination->dual, &source->dual);
}
inline void bgc_fp64_dual_quaternion_convert_to_fp32(BGC_FP32_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source)
{
bgc_fp64_quaternion_convert_to_fp32(&destination->real, &source->real);
bgc_fp64_quaternion_convert_to_fp32(&destination->dual, &source->dual);
}
// ==================== Add ===================== //
inline void bgc_fp32_dual_quaternion_add(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* first, const BGC_FP32_DualQuaternion* second)
{
bgc_fp32_quaternion_add(&sum->real, &first->real, &second->real);
bgc_fp32_quaternion_add(&sum->dual, &first->dual, &second->dual);
}
inline void bgc_fp64_dual_quaternion_add(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* first, const BGC_FP64_DualQuaternion* second)
{
bgc_fp64_quaternion_add(&sum->real, &first->real, &second->real);
bgc_fp64_quaternion_add(&sum->dual, &first->dual, &second->dual);
}
// ================= Add Scaled ================= //
inline void bgc_fp32_dual_quaternion_add_scaled(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* base_quaternion, const BGC_FP32_DualQuaternion* scalable_quaternion, const float scale)
{
bgc_fp32_quaternion_add_scaled(&sum->real, &base_quaternion->real, &scalable_quaternion->real, scale);
bgc_fp32_quaternion_add_scaled(&sum->dual, &base_quaternion->dual, &scalable_quaternion->dual, scale);
}
inline void bgc_fp64_dual_quaternion_add_scaled(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* base_quaternion, const BGC_FP64_DualQuaternion* scalable_quaternion, const double scale)
{
bgc_fp64_quaternion_add_scaled(&sum->real, &base_quaternion->real, &scalable_quaternion->real, scale);
bgc_fp64_quaternion_add_scaled(&sum->dual, &base_quaternion->dual, &scalable_quaternion->dual, scale);
}
// ================== Subtract ================== //
inline void bgc_fp32_dual_quaternion_subtract(BGC_FP32_DualQuaternion* difference, const BGC_FP32_DualQuaternion* minuend, const BGC_FP32_DualQuaternion* subtrahend)
{
bgc_fp32_quaternion_subtract(&difference->real, &minuend->real, &subtrahend->real);
bgc_fp32_quaternion_subtract(&difference->dual, &minuend->dual, &subtrahend->dual);
}
inline void bgc_fp64_dual_quaternion_subtract(BGC_FP64_DualQuaternion* difference, const BGC_FP64_DualQuaternion* minuend, const BGC_FP64_DualQuaternion* subtrahend)
{
bgc_fp64_quaternion_subtract(&difference->real, &minuend->real, &subtrahend->real);
bgc_fp64_quaternion_subtract(&difference->dual, &minuend->dual, &subtrahend->dual);
}
// ================== Multiply ================== //
inline void bgc_fp32_dual_quaternion_multiply(BGC_FP32_DualQuaternion* product, const BGC_FP32_DualQuaternion* multiplicand, const float multipier)
{
bgc_fp32_quaternion_multiply(&product->real, &multiplicand->real, multipier);
bgc_fp32_quaternion_multiply(&product->dual, &multiplicand->dual, multipier);
}
inline void bgc_fp64_dual_quaternion_multiply(BGC_FP64_DualQuaternion* product, const BGC_FP64_DualQuaternion* multiplicand, const double multipier)
{
bgc_fp64_quaternion_multiply(&product->real, &multiplicand->real, multipier);
bgc_fp64_quaternion_multiply(&product->dual, &multiplicand->dual, multipier);
}
// =================== Divide =================== //
inline void bgc_fp32_dual_quaternion_divide(BGC_FP32_DualQuaternion* quotient, const BGC_FP32_DualQuaternion* divident, const float divisor)
{
bgc_fp32_dual_quaternion_multiply(quotient, divident, 1.0f / divisor);
}
inline void bgc_fp64_dual_quaternion_divide(BGC_FP64_DualQuaternion* quotient, const BGC_FP64_DualQuaternion* divident, const double divisor)
{
bgc_fp64_dual_quaternion_multiply(quotient, divident, 1.0 / divisor);
}
// ================ Mean of Two ================= //
inline void bgc_fp32_dual_quaternion_get_mean2(BGC_FP32_DualQuaternion* mean, const BGC_FP32_DualQuaternion* quaternion1, const BGC_FP32_DualQuaternion* quaternion2)
{
bgc_fp32_quaternion_get_mean2(&mean->real, &quaternion1->real, &quaternion2->real);
bgc_fp32_quaternion_get_mean2(&mean->dual, &quaternion1->dual, &quaternion2->dual);
}
inline void bgc_fp64_dual_quaternion_get_mean2(BGC_FP64_DualQuaternion* mean, const BGC_FP64_DualQuaternion* quaternion1, const BGC_FP64_DualQuaternion* quaternion2)
{
bgc_fp64_quaternion_get_mean2(&mean->real, &quaternion1->real, &quaternion2->real);
bgc_fp64_quaternion_get_mean2(&mean->dual, &quaternion1->dual, &quaternion2->dual);
}
// =============== Mean of Three ================ //
inline void bgc_fp32_dual_quaternion_get_mean3(BGC_FP32_DualQuaternion* mean, const BGC_FP32_DualQuaternion* quaternion1, const BGC_FP32_DualQuaternion* quaternion2, const BGC_FP32_DualQuaternion* quaternion3)
{
bgc_fp32_quaternion_get_mean3(&mean->real, &quaternion1->real, &quaternion2->real, &quaternion3->real);
bgc_fp32_quaternion_get_mean3(&mean->dual, &quaternion1->dual, &quaternion2->dual, &quaternion3->dual);
}
inline void bgc_fp64_dual_quaternion_get_mean3(BGC_FP64_DualQuaternion* mean, const BGC_FP64_DualQuaternion* quaternion1, const BGC_FP64_DualQuaternion* quaternion2, const BGC_FP64_DualQuaternion* quaternion3)
{
bgc_fp64_quaternion_get_mean3(&mean->real, &quaternion1->real, &quaternion2->real, &quaternion3->real);
bgc_fp64_quaternion_get_mean3(&mean->dual, &quaternion1->dual, &quaternion2->dual, &quaternion3->dual);
}
// ============ Linear Interpolation ============ //
inline void bgc_fp32_dual_quaternion_interpolate(BGC_FP32_DualQuaternion* interpolation, const BGC_FP32_DualQuaternion* first, const BGC_FP32_DualQuaternion* second, const float phase)
{
bgc_fp32_quaternion_interpolate(&interpolation->real, &first->real, &second->real, phase);
bgc_fp32_quaternion_interpolate(&interpolation->dual, &first->dual, &second->dual, phase);
}
inline void bgc_fp64_dual_quaternion_interpolate(BGC_FP64_DualQuaternion* interpolation, const BGC_FP64_DualQuaternion* first, const BGC_FP64_DualQuaternion* second, const double phase)
{
bgc_fp64_quaternion_interpolate(&interpolation->real, &first->real, &second->real, phase);
bgc_fp64_quaternion_interpolate(&interpolation->dual, &first->dual, &second->dual, phase);
}
// =================== Revert =================== //
inline void bgc_fp32_dual_quaternion_revert(BGC_FP32_DualQuaternion* quaternion)
{
bgc_fp32_quaternion_revert(&quaternion->real);
bgc_fp32_quaternion_revert(&quaternion->dual);
}
inline void bgc_fp64_dual_quaternion_revert(BGC_FP64_DualQuaternion* quaternion)
{
bgc_fp64_quaternion_revert(&quaternion->real);
bgc_fp64_quaternion_revert(&quaternion->dual);
}
// ================ Get Reverse ================= //
inline void bgc_fp32_dual_quaternion_get_reverse(BGC_FP32_DualQuaternion* reverse, const BGC_FP32_DualQuaternion* quaternion)
{
bgc_fp32_quaternion_get_reverse(&reverse->real, &quaternion->real);
bgc_fp32_quaternion_get_reverse(&reverse->dual, &quaternion->dual);
}
inline void bgc_fp64_dual_quaternion_get_reverse(BGC_FP64_DualQuaternion* reverse, const BGC_FP64_DualQuaternion* quaternion)
{
bgc_fp64_quaternion_get_reverse(&reverse->real, &quaternion->real);
bgc_fp64_quaternion_get_reverse(&reverse->dual, &quaternion->dual);
}
#endif

View file

@ -0,0 +1,49 @@
#include "./dual-vector3.h"
extern inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector);
extern inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector);
extern inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual);
extern inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual);
extern inline void bgc_fp32_dual_vector3_copy(BGC_FP32_DualVector3* destination, const BGC_FP32_DualVector3* source);
extern inline void bgc_fp64_dual_vector3_copy(BGC_FP64_DualVector3* destination, const BGC_FP64_DualVector3* source);
extern inline void bgc_fp32_dual_vector3_swap(BGC_FP32_DualVector3* first, BGC_FP32_DualVector3* second);
extern inline void bgc_fp64_dual_vector3_swap(BGC_FP64_DualVector3* first, BGC_FP64_DualVector3* second);
extern inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
extern inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
extern inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
extern inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
extern inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second);
extern inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second);
extern inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale);
extern inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale);
extern inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend);
extern inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend);
extern inline void bgc_fp32_dual_vector3_multiply(BGC_FP32_DualVector3* product, const BGC_FP32_DualVector3* multiplicand, const float multiplier);
extern inline void bgc_fp64_dual_vector3_multiply(BGC_FP64_DualVector3* product, const BGC_FP64_DualVector3* multiplicand, const double multiplier);
extern inline void bgc_fp32_dual_vector3_divide(BGC_FP32_DualVector3* quotient, const BGC_FP32_DualVector3* dividend, const float divisor);
extern inline void bgc_fp64_dual_vector3_divide(BGC_FP64_DualVector3* quotient, const BGC_FP64_DualVector3* dividend, const double divisor);
extern inline void bgc_fp32_dual_vector3_get_mean2(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2);
extern inline void bgc_fp64_dual_vector3_get_mean2(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2);
extern inline void bgc_fp32_dual_vector3_get_mean3(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2, const BGC_FP32_DualVector3* vector3);
extern inline void bgc_fp64_dual_vector3_get_mean3(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2, const BGC_FP64_DualVector3* vector3);
extern inline void bgc_fp32_dual_vector3_interpolate(BGC_FP32_DualVector3* interpolation, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second, const float phase);
extern inline void bgc_fp64_dual_vector3_interpolate(BGC_FP64_DualVector3* interpolation, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second, const double phase);
extern inline void bgc_fp32_dual_vector3_revert(BGC_FP32_DualVector3* vector);
extern inline void bgc_fp64_dual_vector3_revert(BGC_FP64_DualVector3* vector);
extern inline void bgc_fp32_dual_vector3_get_reverse(BGC_FP32_DualVector3* reverse, const BGC_FP32_DualVector3* vector);
extern inline void bgc_fp64_dual_vector3_get_reverse(BGC_FP64_DualVector3* reverse, const BGC_FP64_DualVector3* vector);

View file

@ -0,0 +1,242 @@
#ifndef _BGC_DUAL_VECTOR3_H_INCLUDED_
#define _BGC_DUAL_VECTOR3_H_INCLUDED_
#include "./vector3.h"
// =================== Types ==================== //
typedef struct {
BGC_FP32_Vector3 real, dual;
} BGC_FP32_DualVector3;
typedef struct {
BGC_FP64_Vector3 real, dual;
} BGC_FP64_DualVector3;
// =================== Reset ==================== //
inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector)
{
bgc_fp32_vector3_reset(&vector->real);
bgc_fp32_vector3_reset(&vector->dual);
}
inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector)
{
bgc_fp64_vector3_reset(&vector->real);
bgc_fp64_vector3_reset(&vector->dual);
}
// ==================== Make ==================== //
inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual)
{
bgc_fp32_vector3_copy(&vector->real, real);
bgc_fp32_vector3_copy(&vector->dual, dual);
}
inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual)
{
bgc_fp64_vector3_copy(&vector->real, real);
bgc_fp64_vector3_copy(&vector->dual, dual);
}
// ==================== Copy ==================== //
inline void bgc_fp32_dual_vector3_copy(BGC_FP32_DualVector3* destination, const BGC_FP32_DualVector3* source)
{
bgc_fp32_vector3_copy(&destination->real, &source->real);
bgc_fp32_vector3_copy(&destination->dual, &source->dual);
}
inline void bgc_fp64_dual_vector3_copy(BGC_FP64_DualVector3* destination, const BGC_FP64_DualVector3* source)
{
bgc_fp64_vector3_copy(&destination->real, &source->real);
bgc_fp64_vector3_copy(&destination->dual, &source->dual);
}
// ==================== Swap ==================== //
inline void bgc_fp32_dual_vector3_swap(BGC_FP32_DualVector3* first, BGC_FP32_DualVector3* second)
{
bgc_fp32_vector3_swap(&first->real, &second->real);
bgc_fp32_vector3_swap(&first->dual, &second->dual);
}
inline void bgc_fp64_dual_vector3_swap(BGC_FP64_DualVector3* first, BGC_FP64_DualVector3* second)
{
bgc_fp64_vector3_swap(&first->real, &second->real);
bgc_fp64_vector3_swap(&first->dual, &second->dual);
}
// ================== Set Real ================== //
inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3)
{
vector->real.x1 = x1;
vector->real.x2 = x2;
vector->real.x3 = x3;
}
inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3)
{
vector->real.x1 = x1;
vector->real.x2 = x2;
vector->real.x3 = x3;
}
// ================== Set Dual ================== //
inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3)
{
vector->dual.x1 = x1;
vector->dual.x2 = x2;
vector->dual.x3 = x3;
}
inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3)
{
vector->dual.x1 = x1;
vector->dual.x2 = x2;
vector->dual.x3 = x3;
}
// ==================== Add ===================== //
inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second)
{
bgc_fp32_vector3_add(&sum->real, &first->real, &second->real);
bgc_fp32_vector3_add(&sum->dual, &first->dual, &second->dual);
}
inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second)
{
bgc_fp64_vector3_add(&sum->real, &first->real, &second->real);
bgc_fp64_vector3_add(&sum->dual, &first->dual, &second->dual);
}
// ================= Add Scaled ================= //
inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale)
{
bgc_fp32_vector3_add_scaled(&sum->real, &base_vector->real, &scalable_vector->real, scale);
bgc_fp32_vector3_add_scaled(&sum->dual, &base_vector->dual, &scalable_vector->dual, scale);
}
inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale)
{
bgc_fp64_vector3_add_scaled(&sum->real, &base_vector->real, &scalable_vector->real, scale);
bgc_fp64_vector3_add_scaled(&sum->dual, &base_vector->dual, &scalable_vector->dual, scale);
}
// ================== Subtract ================== //
inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend)
{
bgc_fp32_vector3_subtract(&difference->real, &minuend->real, &subtrahend->real);
bgc_fp32_vector3_subtract(&difference->dual, &minuend->dual, &subtrahend->dual);
}
inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend)
{
bgc_fp64_vector3_subtract(&difference->real, &minuend->real, &subtrahend->real);
bgc_fp64_vector3_subtract(&difference->dual, &minuend->dual, &subtrahend->dual);
}
// ================== Multiply ================== //
inline void bgc_fp32_dual_vector3_multiply(BGC_FP32_DualVector3* product, const BGC_FP32_DualVector3* multiplicand, const float multiplier)
{
bgc_fp32_vector3_multiply(&product->real, &multiplicand->real, multiplier);
bgc_fp32_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
}
inline void bgc_fp64_dual_vector3_multiply(BGC_FP64_DualVector3* product, const BGC_FP64_DualVector3* multiplicand, const double multiplier)
{
bgc_fp64_vector3_multiply(&product->real, &multiplicand->real, multiplier);
bgc_fp64_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
}
// =================== Divide =================== //
inline void bgc_fp32_dual_vector3_divide(BGC_FP32_DualVector3* quotient, const BGC_FP32_DualVector3* dividend, const float divisor)
{
bgc_fp32_dual_vector3_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_fp64_dual_vector3_divide(BGC_FP64_DualVector3* quotient, const BGC_FP64_DualVector3* dividend, const double divisor)
{
bgc_fp64_dual_vector3_multiply(quotient, dividend, 1.0 / divisor);
}
// ================ Mean of Two ================= //
inline void bgc_fp32_dual_vector3_get_mean2(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2)
{
bgc_fp32_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real);
bgc_fp32_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual);
}
inline void bgc_fp64_dual_vector3_get_mean2(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2)
{
bgc_fp64_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real);
bgc_fp64_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual);
}
// =============== Mean of Three ================ //
inline void bgc_fp32_dual_vector3_get_mean3(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2, const BGC_FP32_DualVector3* vector3)
{
bgc_fp32_vector3_get_mean3(&mean->real, &vector1->real, &vector2->real, &vector3->real);
bgc_fp32_vector3_get_mean3(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
}
inline void bgc_fp64_dual_vector3_get_mean3(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2, const BGC_FP64_DualVector3* vector3)
{
bgc_fp64_vector3_get_mean3(&mean->real, &vector1->real, &vector2->real, &vector3->real);
bgc_fp64_vector3_get_mean3(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
}
// ============ Linear Interpolation ============ //
inline void bgc_fp32_dual_vector3_interpolate(BGC_FP32_DualVector3* interpolation, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second, const float phase)
{
bgc_fp32_vector3_interpolate(&interpolation->real, &first->real, &second->real, phase);
bgc_fp32_vector3_interpolate(&interpolation->dual, &first->dual, &second->dual, phase);
}
inline void bgc_fp64_dual_vector3_interpolate(BGC_FP64_DualVector3* interpolation, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second, const double phase)
{
bgc_fp64_vector3_interpolate(&interpolation->real, &first->real, &second->real, phase);
bgc_fp64_vector3_interpolate(&interpolation->dual, &first->dual, &second->dual, phase);
}
// =================== Revert =================== //
inline void bgc_fp32_dual_vector3_revert(BGC_FP32_DualVector3* vector)
{
bgc_fp32_vector3_revert(&vector->real);
bgc_fp32_vector3_revert(&vector->dual);
}
inline void bgc_fp64_dual_vector3_revert(BGC_FP64_DualVector3* vector)
{
bgc_fp64_vector3_revert(&vector->real);
bgc_fp64_vector3_revert(&vector->dual);
}
// ================ Get Reverse ================= //
inline void bgc_fp32_dual_vector3_get_reverse(BGC_FP32_DualVector3* reverse, const BGC_FP32_DualVector3* vector)
{
bgc_fp32_vector3_get_reverse(&reverse->real, &vector->real);
bgc_fp32_vector3_get_reverse(&reverse->dual, &vector->dual);
}
inline void bgc_fp64_dual_vector3_get_reverse(BGC_FP64_DualVector3* reverse, const BGC_FP64_DualVector3* vector)
{
bgc_fp64_vector3_get_reverse(&reverse->real, &vector->real);
bgc_fp64_vector3_get_reverse(&reverse->dual, &vector->dual);
}
#endif

View file

@ -0,0 +1,7 @@
#include "hg-matrix3x3.h"
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix);
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix);
inline void bgc_fp32_hg_matrix3x3_make(BGC_FP32_HgMatrix3x3* homogeneous_matrix, const BGC_FP32_Matrix3x3* linear_matrix, const BGC_FP32_Vector3* shift);
inline void bgc_fp64_hg_matrix3x3_make(BGC_FP64_HgMatrix3x3* homogeneous_matrix, const BGC_FP64_Matrix3x3* linear_matrix, const BGC_FP64_Vector3* shift);

View file

@ -0,0 +1,123 @@
#ifndef _BGC_HG_MATRIX3X3_H_INCLUDED_
#define _BGC_HG_MATRIX3X3_H_INCLUDED_
#include "vector3.h"
#include "matrices.h"
#include "hg-vector3.h"
// =================== Types ==================== //
typedef struct
{
float r1c1, r1c2, r1c3, r1d0;
float r2c1, r2c2, r2c3, r2d0;
float r3c1, r3c2, r3c3, r3d0;
float d0c1, d0c2, d0c3, d0d0;
} BGC_FP32_HgMatrix3x3;
typedef struct
{
double r1c1, r1c2, r1c3, r1d0;
double r2c1, r2c2, r2c3, r2d0;
double r3c1, r3c2, r3c3, r3d0;
double d0c1, d0c2, d0c3, d0d0;
} BGC_FP64_HgMatrix3x3;
// =================== Reset ==================== //
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix)
{
homogeneous_matrix->r1c1 = 1.0f;
homogeneous_matrix->r1c2 = 0.0f;
homogeneous_matrix->r1c2 = 0.0f;
homogeneous_matrix->r1d0 = 0.0f;
homogeneous_matrix->r2c1 = 0.0f;
homogeneous_matrix->r2c2 = 1.0f;
homogeneous_matrix->r2c2 = 0.0f;
homogeneous_matrix->r2d0 = 0.0f;
homogeneous_matrix->r3c1 = 0.0f;
homogeneous_matrix->r3c2 = 0.0f;
homogeneous_matrix->r3c2 = 1.0f;
homogeneous_matrix->r3d0 = 0.0f;
homogeneous_matrix->d0c1 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0d0 = 1.0f;
}
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix)
{
homogeneous_matrix->r1c1 = 1.0;
homogeneous_matrix->r1c2 = 0.0;
homogeneous_matrix->r1c2 = 0.0;
homogeneous_matrix->r1d0 = 0.0;
homogeneous_matrix->r2c1 = 0.0;
homogeneous_matrix->r2c2 = 1.0;
homogeneous_matrix->r2c2 = 0.0;
homogeneous_matrix->r2d0 = 0.0;
homogeneous_matrix->r3c1 = 0.0;
homogeneous_matrix->r3c2 = 0.0;
homogeneous_matrix->r3c2 = 1.0;
homogeneous_matrix->r3d0 = 0.0;
homogeneous_matrix->d0c1 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0d0 = 1.0;
}
// ==================== Make ==================== //
inline void bgc_fp32_hg_matrix3x3_make(BGC_FP32_HgMatrix3x3* homogeneous_matrix, const BGC_FP32_Matrix3x3* linear_matrix, const BGC_FP32_Vector3* shift)
{
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
homogeneous_matrix->r1d0 = shift->x1;
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
homogeneous_matrix->r2d0 = shift->x2;
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
homogeneous_matrix->r3d0 = shift->x3;
homogeneous_matrix->d0c1 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0d0 = 1.0f;
}
inline void bgc_fp64_hg_matrix3x3_make(BGC_FP64_HgMatrix3x3* homogeneous_matrix, const BGC_FP64_Matrix3x3* linear_matrix, const BGC_FP64_Vector3* shift)
{
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
homogeneous_matrix->r1d0 = shift->x1;
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
homogeneous_matrix->r2d0 = shift->x2;
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
homogeneous_matrix->r3d0 = shift->x3;
homogeneous_matrix->d0c1 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0d0 = 1.0;
}
#endif

View 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);

224
basic-geometry/hg-vector3.h Normal file
View file

@ -0,0 +1,224 @@
#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, d0;
} BGC_FP32_HgVector3;
// Homogeneous 3D Vector
typedef struct
{
double x1, x2, x3, d0;
} 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->d0 = 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->d0 = 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->d0 = 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->d0 = 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 d0)
{
homogeneous_vector->x1 = x1;
homogeneous_vector->x2 = x2;
homogeneous_vector->x3 = x3;
homogeneous_vector->d0 = d0;
}
inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double d0)
{
homogeneous_vector->x1 = x1;
homogeneous_vector->x2 = x2;
homogeneous_vector->x3 = x3;
homogeneous_vector->d0 = d0;
}
// ================= 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->d0 = 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->d0 = 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->d0 = 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->d0 = 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->d0);
}
inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector)
{
return !bgc_fp64_is_zero(homogeneous_vector->d0);
}
// ================= Is Vector ================== //
inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector)
{
return bgc_fp32_is_zero(homogeneous_vector->d0);
}
inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector)
{
return bgc_fp64_is_zero(homogeneous_vector->d0);
}
// ==================== 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->d0 = source->d0;
}
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->d0 = source->d0;
}
// ==================== 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 d0 = first->d0;
first->x1 = second->x1;
first->x2 = second->x2;
first->x3 = second->x3;
first->d0 = second->d0;
second->x1 = x1;
second->x2 = x2;
second->x3 = x3;
second->d0 = d0;
}
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 d0 = first->d0;
first->x1 = second->x1;
first->x2 = second->x2;
first->x3 = second->x3;
first->d0 = second->d0;
second->x1 = x1;
second->x2 = x2;
second->x3 = x3;
second->d0 = d0;
}
// ================== Rescale =================== //
inline int bgc_fp32_hg_vector3_rescale(BGC_FP32_HgVector3* homogeneous_vector, const float new_ratio)
{
if (bgc_fp32_is_zero(homogeneous_vector->d0)) {
return 0;
}
const float multiplier = new_ratio / homogeneous_vector->d0;
homogeneous_vector->x1 *= multiplier;
homogeneous_vector->x2 *= multiplier;
homogeneous_vector->x3 *= multiplier;
homogeneous_vector->d0 = new_ratio;
return 1;
}
inline int bgc_fp64_hg_vector3_rescale(BGC_FP64_HgVector3* homogeneous_vector, const double new_ratio)
{
if (bgc_fp64_is_zero(homogeneous_vector->d0)) {
return 0;
}
const double multiplier = new_ratio / homogeneous_vector->d0;
homogeneous_vector->x1 *= multiplier;
homogeneous_vector->x2 *= multiplier;
homogeneous_vector->x3 *= multiplier;
homogeneous_vector->d0 = new_ratio;
return 1;
}
#endif

25
basic-geometry/matrices.c Normal file
View file

@ -0,0 +1,25 @@
#include "matrices.h"
extern inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2);
extern inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2);
extern inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2);
extern inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2);
extern inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2);
extern inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2);
extern inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2);
extern inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2);
extern inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2);
extern inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2);
extern inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2);
extern inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2);
extern inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2);
extern inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2);
extern inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2);
extern inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2);

364
basic-geometry/matrices.h Normal file
View file

@ -0,0 +1,364 @@
#ifndef _BGC_MATRICES_H_INCLUDED_
#define _BGC_MATRICES_H_INCLUDED_
// ================== Matrix2x2 ================= //
typedef struct {
float r1c1, r1c2;
float r2c1, r2c2;
} BGC_FP32_Matrix2x2;
typedef struct {
double r1c1, r1c2;
double r2c1, r2c2;
} BGC_FP64_Matrix2x2;
// ================== Matrix2x3 ================= //
typedef struct {
float r1c1, r1c2;
float r2c1, r2c2;
float r3c1, r3c2;
} BGC_FP32_Matrix2x3;
typedef struct {
double r1c1, r1c2;
double r2c1, r2c2;
double r3c1, r3c2;
} BGC_FP64_Matrix2x3;
// ================== Matrix3x2 ================= //
typedef struct {
float r1c1, r1c2, r1c3;
float r2c1, r2c2, r2c3;
} BGC_FP32_Matrix3x2;
typedef struct {
double r1c1, r1c2, r1c3;
double r2c1, r2c2, r2c3;
} BGC_FP64_Matrix3x2;
// ================== Matrix3x3 ================= //
typedef struct {
float r1c1, r1c2, r1c3;
float r2c1, r2c2, r2c3;
float r3c1, r3c2, r3c3;
} BGC_FP32_Matrix3x3;
typedef struct {
double r1c1, r1c2, r1c3;
double r2c1, r2c2, r2c3;
double r3c1, r3c2, r3c3;
} BGC_FP64_Matrix3x3;
// ========== 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)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
}
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 r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
}
// ========== 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)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
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 r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
// ========== 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)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
// ========== Matrix Product 2x3 at 3x2 ========= //
inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
}
inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
}
// ========== Matrix Product 3x2 at 2x3 ========= //
inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
}
inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
}
// ========== Matrix Product 3x2 at 3x3 ========= //
inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
// ========== Matrix Product 3x3 at 2x3 ========= //
inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
// ========== Matrix Product 3x3 at 3x3 ========= //
inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
product->r3c3 = r3c3;
}
inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
product->r3c3 = r3c3;
}
#endif // _BGC_MATRIX_TYPES_H_

View file

@ -1,73 +1,82 @@
#include "matrix2x2.h"
extern inline void bgc_matrix2x2_reset_fp32(BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_reset_fp64(BgcMatrix2x2FP64* matrix);
extern inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_to_identity_fp32(BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix);
extern inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, BgcMatrix2x2FP64* matrix);
extern inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2);
extern inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2);
extern inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix);
extern inline void bgc_fp32_matrix2x2_set_turn(BGC_FP32_Matrix2x2* matrix, const float angle, const int angle_unit);
extern inline void bgc_fp64_matrix2x2_set_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit);
extern inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix);
extern inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix);
extern inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix);
extern inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix);
extern inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix);
extern inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix);
extern inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* matrix);
extern inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* matrix);
extern inline int bgc_matrix2x2_is_rotation_fp32(const BgcMatrix2x2FP32* matrix);
extern inline int bgc_matrix2x2_is_rotation_fp64(const BgcMatrix2x2FP64* matrix);
extern inline int bgc_fp32_matrix2x2_is_singular(const BGC_FP32_Matrix2x2* matrix);
extern inline int bgc_fp64_matrix2x2_is_singular(const BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination);
extern inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP64* destination);
extern inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix);
extern inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32* matrix2);
extern inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64* matrix2);
extern inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source);
extern inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source);
extern inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP32* destination);
extern inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP64* destination);
extern inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2);
extern inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2);
extern inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted);
extern inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted);
extern inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source);
extern inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source);
extern inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed);
extern inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed);
extern inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC_FP32_Matrix2x2* matrix);
extern inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix);
extern inline int bgc_fp32_matrix2x2_invert(BGC_FP32_Matrix2x2* matrix);
extern inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix);
extern inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix);
extern inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix);
extern inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix);
extern inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number);
extern inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number);
extern inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum);
extern inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum);
extern inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row);
extern inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row);
extern inline void bgc_matrix2x2_add_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* sum);
extern inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* sum);
extern inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number);
extern inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number);
extern inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference);
extern inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const BgcMatrix2x2FP64* subtrahend, BgcMatrix2x2FP64* difference);
extern inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column);
extern inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column);
extern inline void bgc_matrix2x2_subtract_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* difference);
extern inline void bgc_matrix2x2_subtract_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* difference);
extern inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2);
extern inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2);
extern inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product);
extern inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, const double multiplier, BgcMatrix2x2FP64* product);
extern inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale);
extern inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient);
extern inline void bgc_matrix2x2_divide_fp64(const BgcMatrix2x2FP64* dividend, const double divisor, BgcMatrix2x2FP64* quotient);
extern inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend);
extern inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend);
extern inline void bgc_matrix2x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* product);
extern inline void bgc_matrix2x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* product);
extern inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier);
extern inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier);
extern inline void bgc_matrix2x2_get_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* product);
extern inline void bgc_matrix2x2_get_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* product);
extern inline void bgc_fp32_matrix2x2_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor);
extern inline void bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor);
extern inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase);
extern inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase);
extern inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector);
extern inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector);
extern inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix);

View file

@ -1,13 +1,13 @@
#ifndef _BGC_MATRIX2X2_H_
#define _BGC_MATRIX2X2_H_
#ifndef _BGC_MATRIX2X2_H_INCLUDED_
#define _BGC_MATRIX2X2_H_INCLUDED_
#include "angle.h"
#include "vector2.h"
#include "matrixes.h"
#include "matrices.h"
// =================== Reset ==================== //
inline void bgc_matrix2x2_reset_fp32(BgcMatrix2x2FP32* matrix)
inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix)
{
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
@ -15,7 +15,7 @@ inline void bgc_matrix2x2_reset_fp32(BgcMatrix2x2FP32* matrix)
matrix->r2c2 = 0.0f;
}
inline void bgc_matrix2x2_reset_fp64(BgcMatrix2x2FP64* matrix)
inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix)
{
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
@ -25,7 +25,7 @@ inline void bgc_matrix2x2_reset_fp64(BgcMatrix2x2FP64* matrix)
// ================== Identity ================== //
inline void bgc_matrix2x2_set_to_identity_fp32(BgcMatrix2x2FP32* matrix)
inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix)
{
matrix->r1c1 = 1.0f;
matrix->r1c2 = 0.0f;
@ -33,7 +33,7 @@ inline void bgc_matrix2x2_set_to_identity_fp32(BgcMatrix2x2FP32* matrix)
matrix->r2c2 = 1.0f;
}
inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix)
inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix)
{
matrix->r1c1 = 1.0;
matrix->r1c2 = 0.0;
@ -43,7 +43,7 @@ inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix)
// ================ Set Diagonal ================ //
inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, BgcMatrix2x2FP32* matrix)
inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2)
{
matrix->r1c1 = d1;
matrix->r1c2 = 0.0f;
@ -51,7 +51,7 @@ inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, B
matrix->r2c2 = d2;
}
inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, BgcMatrix2x2FP64* matrix)
inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2)
{
matrix->r1c1 = d1;
matrix->r1c2 = 0.0;
@ -61,9 +61,9 @@ inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2,
// ============== Rotation Matrix =============== //
inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix)
inline void bgc_fp32_matrix2x2_set_turn(BGC_FP32_Matrix2x2* matrix, const float angle, const int angle_unit)
{
const float radians = bgc_angle_to_radians_fp32(angle, unit);
const float radians = bgc_fp32_angle_to_radians(angle, angle_unit);
const float cosine = cosf(radians);
const float sine = sinf(radians);
@ -73,9 +73,9 @@ inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnu
matrix->r2c2 = cosine;
}
inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix)
inline void bgc_fp64_matrix2x2_set_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit)
{
const double radians = bgc_angle_to_radians_fp64(angle, unit);
const double radians = bgc_fp64_angle_to_radians(angle, angle_unit);
const double cosine = cos(radians);
const double sine = sin(radians);
@ -87,65 +87,73 @@ inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEn
// ================ Determinant ================= //
inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix)
inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix)
{
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
}
inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix)
inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix)
{
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
}
// ================== Singular ================== //
// ================ Is Identity ================= //
inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix)
inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* matrix)
{
return bgc_is_zero_fp32(bgc_matrix2x2_get_determinant_fp32(matrix));
return bgc_fp32_is_unit(matrix->r1c1) && bgc_fp32_is_zero(matrix->r1c2)
&& bgc_fp32_is_zero(matrix->r2c1) && bgc_fp32_is_unit(matrix->r2c2);
}
inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix)
inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* matrix)
{
return bgc_is_zero_fp64(bgc_matrix2x2_get_determinant_fp64(matrix));
return bgc_fp64_is_unit(matrix->r1c1) && bgc_fp64_is_zero(matrix->r1c2)
&& bgc_fp64_is_zero(matrix->r2c1) && bgc_fp64_is_unit(matrix->r2c2);
}
// ================ Is Singular ================= //
inline int bgc_fp32_matrix2x2_is_singular(const BGC_FP32_Matrix2x2* matrix)
{
return bgc_fp32_is_zero(bgc_fp32_matrix2x2_get_determinant(matrix));
}
inline int bgc_fp64_matrix2x2_is_singular(const BGC_FP64_Matrix2x2* matrix)
{
return bgc_fp64_is_zero(bgc_fp64_matrix2x2_get_determinant(matrix));
}
// ================ Is Rotation ================= //
inline int bgc_matrix2x2_is_rotation_fp32(const BgcMatrix2x2FP32* matrix)
inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix)
{
if (!bgc_is_unit_fp32(bgc_matrix2x2_get_determinant_fp32(matrix))) {
return 0;
BGC_FP32_Matrix2x2 product;
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_fp32_matrix2x2_is_identity(&product);
}
const float product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
const float product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
const float product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
const float product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_is_unit_fp32(product_r1c1) && bgc_is_zero_fp32(product_r1c2)
&& bgc_is_zero_fp32(product_r2c1) && bgc_is_unit_fp32(product_r2c2);
}
inline int bgc_matrix2x2_is_rotation_fp64(const BgcMatrix2x2FP64* matrix)
inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix)
{
if (!bgc_is_unit_fp64(bgc_matrix2x2_get_determinant_fp64(matrix))) {
return 0;
}
BGC_FP64_Matrix2x2 product;
const double product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
const double product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
const double product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
const double product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_is_unit_fp64(product_r1c1) && bgc_is_zero_fp64(product_r1c2)
&& bgc_is_zero_fp64(product_r2c1) && bgc_is_unit_fp64(product_r2c2);
return bgc_fp64_matrix2x2_is_identity(&product);
}
// ==================== Copy ==================== //
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination)
inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -154,7 +162,7 @@ inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2
destination->r2c2 = source->r2c2;
}
inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP64* destination)
inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -165,7 +173,7 @@ inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2
// ==================== Swap ==================== //
inline void bgc_matrix2x2_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32* matrix2)
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
@ -186,7 +194,7 @@ inline void bgc_matrix2x2_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32*
matrix1->r2c2 = r2c2;
}
inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64* matrix2)
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
@ -209,7 +217,7 @@ inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64*
// ================== Convert =================== //
inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP32* destination)
inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
{
destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2;
@ -218,7 +226,7 @@ inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, B
destination->r2c2 = (float)source->r2c2;
}
inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP64* destination)
inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -227,13 +235,13 @@ inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, B
destination->r2c2 = source->r2c2;
}
// =================== Invert =================== //
// ================ Get Inverse ================= //
inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted)
inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC_FP32_Matrix2x2* matrix)
{
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
const float determinant = bgc_fp32_matrix2x2_get_determinant(matrix);
if (bgc_is_zero_fp32(determinant)) {
if (bgc_fp32_is_zero(determinant)) {
return 0;
}
@ -245,20 +253,20 @@ inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x
const float multiplier = 1.0f / determinant;
inverted->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverted->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
return 1;
}
inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted)
inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC_FP64_Matrix2x2* matrix)
{
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
const double determinant = bgc_fp64_matrix2x2_get_determinant(matrix);
if (bgc_is_zero_fp64(determinant)) {
if (bgc_fp64_is_zero(determinant)) {
return 0;
}
@ -270,18 +278,46 @@ inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x
const double multiplier = 1.0 / determinant;
inverted->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverted->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
return 1;
}
// =================== Invert =================== //
inline int bgc_fp32_matrix2x2_invert(BGC_FP32_Matrix2x2* matrix)
{
return bgc_fp32_matrix2x2_get_inverse(matrix, matrix);
}
inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix)
{
return bgc_fp64_matrix2x2_get_inverse(matrix, matrix);
}
// ================= Transpose ================== //
inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed)
inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix)
{
const float r1c2 = matrix->r1c2;
matrix->r1c2 = matrix->r2c1;
matrix->r2c1 = r1c2;
}
inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix)
{
const double r1c2 = matrix->r1c2;
matrix->r1c2 = matrix->r2c1;
matrix->r2c1 = r1c2;
}
// =============== Get Transpose ================ //
inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix)
{
const float r1c2 = matrix->r1c2;
@ -292,7 +328,7 @@ inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatr
transposed->r2c2 = matrix->r2c2;
}
inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed)
inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* matrix)
{
const double r1c2 = matrix->r1c2;
@ -303,65 +339,145 @@ inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatr
transposed->r2c2 = matrix->r2c2;
}
// ================= Set Row 1 ================== //
// ================== Get Row =================== //
inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix)
inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
// ================= Set Row 2 ================== //
inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
row->x1 = 0.0f;
row->x2 = 0.0f;
}
inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix)
inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
// ================ Set Column 1 ================ //
inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
row->x1 = 0.0;
row->x2 = 0.0;
}
// ================ Set Column 2 ================ //
// ================== Set Row =================== //
inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix)
inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix)
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
}
}
inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
}
}
// ================= Get Column ================= //
inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
}
inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
}
// ================= Set Column ================= //
inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
}
}
inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
}
}
// ==================== Add ===================== //
inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum)
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -370,7 +486,7 @@ inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMat
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
}
inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum)
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -381,7 +497,7 @@ inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMat
// ================= Add scaled ================= //
inline void bgc_matrix2x2_add_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* sum)
inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -390,7 +506,7 @@ inline void bgc_matrix2x2_add_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix,
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
}
inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* sum)
inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -401,7 +517,7 @@ inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix,
// ================== Subtract ================== //
inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference)
inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -410,7 +526,7 @@ inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const B
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
}
inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const BgcMatrix2x2FP64* subtrahend, BgcMatrix2x2FP64* difference)
inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -419,29 +535,9 @@ inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const B
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
}
// ============== Subtract scaled =============== //
inline void bgc_matrix2x2_subtract_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
}
inline void bgc_matrix2x2_subtract_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
}
// ================== Multiply ================== //
inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product)
inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -450,7 +546,7 @@ inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, co
product->r2c2 = multiplicand->r2c2 * multiplier;
}
inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, const double multiplier, BgcMatrix2x2FP64* product)
inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -461,39 +557,43 @@ inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, co
// =================== Divide =================== //
inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient)
inline void bgc_fp32_matrix2x2_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor)
{
bgc_matrix2x2_multiply_fp32(dividend, 1.0f / divisor, quotient);
bgc_fp32_matrix2x2_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_matrix2x2_divide_fp64(const BgcMatrix2x2FP64* dividend, const double divisor, BgcMatrix2x2FP64* quotient)
inline void bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor)
{
bgc_matrix2x2_multiply_fp64(dividend, 1.0 / divisor, quotient);
bgc_fp64_matrix2x2_multiply(quotient, dividend, 1.0 / divisor);
}
// ============ Left Vector Product ============= //
// ================ Interpolate ================= //
inline void bgc_matrix2x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* product)
inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase)
{
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
const float counter_phase = 1.0f - phase;
product->x1 = x1;
product->x2 = x2;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
}
inline void bgc_matrix2x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* product)
inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase)
{
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
const double counter_phase = 1.0 - phase;
product->x1 = x1;
product->x2 = x2;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
}
// ============ Right Vector Product ============ //
inline void bgc_matrix2x2_get_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* product)
inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector)
{
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
@ -502,7 +602,7 @@ inline void bgc_matrix2x2_get_right_product_fp32(const BgcMatrix2x2FP32* matrix,
product->x2 = x2;
}
inline void bgc_matrix2x2_get_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* product)
inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector)
{
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
@ -511,4 +611,24 @@ inline void bgc_matrix2x2_get_right_product_fp64(const BgcMatrix2x2FP64* matrix,
product->x2 = x2;
}
// ============ Left Vector Product ============= //
inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix)
{
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;
}
inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix)
{
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;
}
#endif

View file

@ -1,55 +1,52 @@
#include "matrix2x3.h"
extern inline void bgc_matrix2x3_reset_fp32(BgcMatrix2x3FP32* matrix);
extern inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix);
extern inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix);
extern inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP32* destination);
extern inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP64* destination);
extern inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source);
extern inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source);
extern inline void bgc_matrix2x3_swap_fp32(BgcMatrix2x3FP32* matrix1, BgcMatrix2x3FP32* matrix2);
extern inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64* matrix2);
extern inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* matrix1, BGC_FP32_Matrix2x3* matrix2);
extern inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix2x3* matrix2);
extern inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP32* destination);
extern inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP64* destination);
extern inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source);
extern inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source);
extern inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed);
extern inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed);
extern inline void bgc_fp32_matrix2x3_get_transposed(BGC_FP32_Matrix2x3* transposed, const BGC_FP32_Matrix3x2* matrix);
extern inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, const BGC_FP64_Matrix3x2* matrix);
extern inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix);
extern inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix);
extern inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x3* matrix, const int row_number);
extern inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x3* matrix, const int row_number);
extern inline void bgc_matrix2x3_set_row2_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix);
extern inline void bgc_matrix2x3_set_row2_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix);
extern inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* matrix, const int row_number, const BGC_FP32_Vector2* row);
extern inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row_number, const BGC_FP64_Vector2* row);
extern inline void bgc_matrix2x3_set_row3_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix);
extern inline void bgc_matrix2x3_set_row3_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix);
extern inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix2x3* matrix, const int column_number);
extern inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix2x3* matrix, const int column_number);
extern inline void bgc_matrix2x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix);
extern inline void bgc_matrix2x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix);
extern inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* matrix, const int number, const BGC_FP32_Vector3* column);
extern inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int number, const BGC_FP64_Vector3* column);
extern inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix);
extern inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix);
extern inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2);
extern inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2);
extern inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum);
extern inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* sum);
extern inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale);
extern inline void bgc_matrix2x3_add_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* sum);
extern inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* sum);
extern inline void bgc_fp32_matrix2x3_subtract(BGC_FP32_Matrix2x3* difference, const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend);
extern inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend);
extern inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference);
extern inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const BgcMatrix2x3FP64* subtrahend, BgcMatrix2x3FP64* difference);
extern inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier);
extern inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier);
extern inline void bgc_matrix2x3_subtract_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* difference);
extern inline void bgc_matrix2x3_subtract_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* difference);
extern inline void bgc_fp32_matrix2x3_divide(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor);
extern inline void bgc_fp64_matrix2x3_divide(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor);
extern inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product);
extern inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, const double multiplier, BgcMatrix2x3FP64* product);
extern inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase);
extern inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase);
extern inline void bgc_matrix2x3_divide_fp32(const BgcMatrix2x3FP32* dividend, const float divisor, BgcMatrix2x3FP32* quotient);
extern inline void bgc_matrix2x3_divide_fp64(const BgcMatrix2x3FP64* dividend, const double divisor, BgcMatrix2x3FP64* quotient);
extern inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix);
extern inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix2x3FP32* matrix, BgcVector2FP32* result);
extern inline void bgc_matrix2x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix2x3FP64* matrix, BgcVector2FP64* result);
extern inline void bgc_matrix2x3_get_right_product_fp32(const BgcMatrix2x3FP32* matrix, const BgcVector2FP32* vector, BgcVector3FP32* result);
extern inline void bgc_matrix2x3_get_right_product_fp64(const BgcMatrix2x3FP64* matrix, const BgcVector2FP64* vector, BgcVector3FP64* result);
extern inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector);
extern inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector);

View file

@ -1,13 +1,13 @@
#ifndef _BGC_MATRIX2X3_H_
#define _BGC_MATRIX2X3_H_
#ifndef _BGC_MATRIX2X3_H_INCLUDED_
#define _BGC_MATRIX2X3_H_INCLUDED_
#include "vector2.h"
#include "vector3.h"
#include "matrixes.h"
#include "matrices.h"
// =================== Reset ==================== //
inline void bgc_matrix2x3_reset_fp32(BgcMatrix2x3FP32* matrix)
inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix)
{
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
@ -19,7 +19,7 @@ inline void bgc_matrix2x3_reset_fp32(BgcMatrix2x3FP32* matrix)
matrix->r3c2 = 0.0f;
}
inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix)
inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix)
{
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
@ -33,7 +33,7 @@ inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix)
// ==================== Copy ==================== //
inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP32* destination)
inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -45,7 +45,7 @@ inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3
destination->r3c2 = source->r3c2;
}
inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP64* destination)
inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -59,7 +59,7 @@ inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3
// ==================== Swap ==================== //
inline void bgc_matrix2x3_swap_fp32(BgcMatrix2x3FP32* matrix1, BgcMatrix2x3FP32* matrix2)
inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* matrix1, BGC_FP32_Matrix2x3* matrix2)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
@ -89,7 +89,7 @@ inline void bgc_matrix2x3_swap_fp32(BgcMatrix2x3FP32* matrix1, BgcMatrix2x3FP32*
matrix1->r3c2 = r3c2;
}
inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64* matrix2)
inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix2x3* matrix2)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
@ -121,7 +121,7 @@ inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64*
// ================== Convert =================== //
inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP32* destination)
inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source)
{
destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2;
@ -133,7 +133,7 @@ inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, B
destination->r3c2 = (float)source->r3c2;
}
inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP64* destination)
inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -147,7 +147,7 @@ inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, B
// ================= Transpose ================== //
inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed)
inline void bgc_fp32_matrix2x3_get_transposed(BGC_FP32_Matrix2x3* transposed, const BGC_FP32_Matrix3x2* matrix)
{
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
@ -159,7 +159,7 @@ inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatr
transposed->r3c2 = matrix->r2c3;
}
inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed)
inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, const BGC_FP64_Matrix3x2* matrix)
{
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
@ -171,83 +171,169 @@ inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatr
transposed->r3c2 = matrix->r2c3;
}
// ================= Set Row 1 ================== //
// ================== Get Row =================== //
inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix)
inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x3* matrix, const int row_number)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
// ================= Set Row 2 ================== //
inline void bgc_matrix2x3_set_row2_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
if (row_number == 3) {
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
return;
}
inline void bgc_matrix2x3_set_row2_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
row->x1 = 0.0f;
row->x2 = 0.0f;
}
// ================= Set Row 3 ================== //
inline void bgc_matrix2x3_set_row3_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix)
inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x3* matrix, const int row_number)
{
matrix->r3c1 = c1;
matrix->r3c2 = c2;
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
inline void bgc_matrix2x3_set_row3_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix)
{
matrix->r3c1 = c1;
matrix->r3c2 = c2;
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
// ================ Set Column 1 ================ //
inline void bgc_matrix2x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
matrix->r3c1 = r3;
if (row_number == 3) {
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
return;
}
inline void bgc_matrix2x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
matrix->r3c1 = r3;
row->x1 = 0.0f;
row->x2 = 0.0f;
}
// ================ Set Column 2 ================ //
// ================== Set Row =================== //
inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix)
inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* matrix, const int row_number, const BGC_FP32_Vector2* row)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
matrix->r3c2 = r3;
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix)
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
return;
}
if (row_number == 3) {
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
}
}
inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row_number, const BGC_FP64_Vector2* row)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
matrix->r3c2 = r3;
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
return;
}
if (row_number == 3) {
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
}
}
// ================= Get Column ================= //
inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix2x3* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
}
}
inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix2x3* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
}
}
// ================= Set Column ================= //
inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* matrix, const int column_number, const BGC_FP32_Vector3* column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
}
}
inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int column_number, const BGC_FP64_Vector3* column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
}
}
// ==================== Add ===================== //
inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum)
inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -259,7 +345,7 @@ inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMat
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
}
inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* sum)
inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -273,7 +359,7 @@ inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMat
// ================= Add scaled ================= //
inline void bgc_matrix2x3_add_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* sum)
inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -285,7 +371,7 @@ inline void bgc_matrix2x3_add_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix,
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
}
inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* sum)
inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -299,7 +385,7 @@ inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix,
// ================== Subtract ================== //
inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference)
inline void bgc_fp32_matrix2x3_subtract(BGC_FP32_Matrix2x3* difference, const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -311,7 +397,7 @@ inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const B
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
}
inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const BgcMatrix2x3FP64* subtrahend, BgcMatrix2x3FP64* difference)
inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -323,35 +409,9 @@ inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const B
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
}
// ============== Subtract scaled =============== //
inline void bgc_matrix2x3_subtract_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
}
inline void bgc_matrix2x3_subtract_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
}
// ================== Multiply ================== //
inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product)
inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -363,7 +423,7 @@ inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, co
product->r3c2 = multiplicand->r3c2 * multiplier;
}
inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, const double multiplier, BgcMatrix2x3FP64* product)
inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -377,44 +437,74 @@ inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, co
// =================== Divide =================== //
inline void bgc_matrix2x3_divide_fp32(const BgcMatrix2x3FP32* dividend, const float divisor, BgcMatrix2x3FP32* quotient)
inline void bgc_fp32_matrix2x3_divide(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor)
{
bgc_matrix2x3_multiply_fp32(dividend, 1.0f / divisor, quotient);
bgc_fp32_matrix2x3_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_matrix2x3_divide_fp64(const BgcMatrix2x3FP64* dividend, const double divisor, BgcMatrix2x3FP64* quotient)
inline void bgc_fp64_matrix2x3_divide(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor)
{
bgc_matrix2x3_multiply_fp64(dividend, 1.0 / divisor, quotient);
bgc_fp64_matrix2x3_multiply(quotient, dividend, 1.0 / divisor);
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase)
{
const float couter_phase = 1.0f - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase;
}
inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase)
{
const double couter_phase = 1.0 - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase;
}
// ============ Left Vector Product ============= //
inline void bgc_matrix2x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix2x3FP32* matrix, BgcVector2FP32* result)
inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix)
{
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
}
inline void bgc_matrix2x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix2x3FP64* matrix, BgcVector2FP64* result)
inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix)
{
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
}
// ============ Right Vector Product ============ //
inline void bgc_matrix2x3_get_right_product_fp32(const BgcMatrix2x3FP32* matrix, const BgcVector2FP32* vector, BgcVector3FP32* result)
inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector)
{
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
}
inline void bgc_matrix2x3_get_right_product_fp64(const BgcMatrix2x3FP64* matrix, const BgcVector2FP64* vector, BgcVector3FP64* result)
inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector)
{
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
}
#endif

View file

@ -1,55 +1,52 @@
#include "matrix3x2.h"
extern inline void bgc_matrix3x2_reset_fp32(BgcMatrix3x2FP32* matrix);
extern inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix);
extern inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix);
extern inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP32* destination);
extern inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP64* destination);
extern inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source);
extern inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source);
extern inline void bgc_matrix3x2_swap_fp32(BgcMatrix3x2FP32* matrix1, BgcMatrix3x2FP32* matrix2);
extern inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64* matrix2);
extern inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* matrix1, BGC_FP32_Matrix3x2* matrix2);
extern inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix3x2* matrix2);
extern inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP32* destination);
extern inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP64* destination);
extern inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source);
extern inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source);
extern inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatrix3x2FP32* transposed);
extern inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatrix3x2FP64* transposed);
extern inline void bgc_fp32_matrix3x2_get_transposed(BGC_FP32_Matrix3x2* transposed, const BGC_FP32_Matrix2x3* matrix);
extern inline void bgc_fp64_matrix3x2_get_transposed(BGC_FP64_Matrix3x2* transposed, const BGC_FP64_Matrix2x3* matrix);
extern inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix);
extern inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix);
extern inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x2* matrix, const int row_number);
extern inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x2* matrix, const int row_number);
extern inline void bgc_matrix3x2_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix);
extern inline void bgc_matrix3x2_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix);
extern inline void bgc_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* matrix, const int row_number, const BGC_FP32_Vector3* row);
extern inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* matrix, const int row_number, const BGC_FP64_Vector3* row);
extern inline void bgc_matrix3x2_set_column1_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix);
extern inline void bgc_matrix3x2_set_column1_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix);
extern inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix3x2* matrix, const int column_number);
extern inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix3x2* matrix, const int column_number);
extern inline void bgc_matrix3x2_set_column2_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix);
extern inline void bgc_matrix3x2_set_column2_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix);
extern inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* matrix, const int column_number, const BGC_FP32_Vector2* column);
extern inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int column_number, const BGC_FP64_Vector2* column);
extern inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix);
extern inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix);
extern inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2);
extern inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2);
extern inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum);
extern inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* sum);
extern inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale);
extern inline void bgc_matrix3x2_add_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* sum);
extern inline void bgc_matrix3x2_add_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* sum);
extern inline void bgc_fp32_matrix3x2_subtract(BGC_FP32_Matrix3x2* difference, const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend);
extern inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend);
extern inline void bgc_matrix3x2_subtract_fp32(const BgcMatrix3x2FP32* minuend, const BgcMatrix3x2FP32* subtrahend, BgcMatrix3x2FP32* difference);
extern inline void bgc_matrix3x2_subtract_fp64(const BgcMatrix3x2FP64* minuend, const BgcMatrix3x2FP64* subtrahend, BgcMatrix3x2FP64* difference);
extern inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier);
extern inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier);
extern inline void bgc_matrix3x2_subtract_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* difference);
extern inline void bgc_matrix3x2_subtract_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* difference);
extern inline void bgc_fp32_matrix3x2_divide(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor);
extern inline void bgc_fp64_matrix3x2_divide(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor);
extern inline void bgc_matrix3x2_multiply_fp32(const BgcMatrix3x2FP32* multiplicand, const float multiplier, BgcMatrix3x2FP32* product);
extern inline void bgc_matrix3x2_multiply_fp64(const BgcMatrix3x2FP64* multiplicand, const double multiplier, BgcMatrix3x2FP64* product);
extern inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase);
extern inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase);
extern inline void bgc_matrix3x2_divide_fp32(const BgcMatrix3x2FP32* dividend, const float divisor, BgcMatrix3x2FP32* quotient);
extern inline void bgc_matrix3x2_divide_fp64(const BgcMatrix3x2FP64* dividend, const double divisor, BgcMatrix3x2FP64* quotient);
extern inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix);
extern inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix3x2FP32* matrix, BgcVector3FP32* result);
extern inline void bgc_matrix3x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix3x2FP64* matrix, BgcVector3FP64* result);
extern inline void bgc_matrix3x2_get_right_product_fp32(const BgcMatrix3x2FP32* matrix, const BgcVector3FP32* vector, BgcVector2FP32* result);
extern inline void bgc_matrix3x2_get_right_product_fp64(const BgcMatrix3x2FP64* matrix, const BgcVector3FP64* vector, BgcVector2FP64* result);
extern inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector);
extern inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector);

View file

@ -1,13 +1,13 @@
#ifndef _BGC_MATRIX3X2_H_
#define _BGC_MATRIX3X2_H_
#ifndef _BGC_MATRIX3X2_H_INCLUDED_
#define _BGC_MATRIX3X2_H_INCLUDED_
#include "vector2.h"
#include "vector3.h"
#include "matrixes.h"
#include "matrices.h"
// =================== Reset ==================== //
inline void bgc_matrix3x2_reset_fp32(BgcMatrix3x2FP32* matrix)
inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix)
{
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
@ -18,7 +18,7 @@ inline void bgc_matrix3x2_reset_fp32(BgcMatrix3x2FP32* matrix)
matrix->r2c3 = 0.0f;
}
inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix)
inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix)
{
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
@ -31,7 +31,7 @@ inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix)
// ==================== Copy ==================== //
inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP32* destination)
inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -42,7 +42,7 @@ inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2
destination->r2c3 = source->r2c3;
}
inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP64* destination)
inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -55,7 +55,7 @@ inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2
// ==================== Swap ==================== //
inline void bgc_matrix3x2_swap_fp32(BgcMatrix3x2FP32* matrix1, BgcMatrix3x2FP32* matrix2)
inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* matrix1, BGC_FP32_Matrix3x2* matrix2)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
@ -82,7 +82,7 @@ inline void bgc_matrix3x2_swap_fp32(BgcMatrix3x2FP32* matrix1, BgcMatrix3x2FP32*
matrix1->r2c3 = r2c3;
}
inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64* matrix2)
inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix3x2* matrix2)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
@ -111,7 +111,7 @@ inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64*
// ================== Convert =================== //
inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP32* destination)
inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source)
{
destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2;
@ -122,7 +122,7 @@ inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, B
destination->r2c3 = (float)source->r2c3;
}
inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP64* destination)
inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -135,7 +135,7 @@ inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, B
// ================= Transpose ================== //
inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatrix3x2FP32* transposed)
inline void bgc_fp32_matrix3x2_get_transposed(BGC_FP32_Matrix3x2* transposed, const BGC_FP32_Matrix2x3* matrix)
{
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
@ -146,7 +146,7 @@ inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatr
transposed->r2c3 = matrix->r3c2;
}
inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatrix3x2FP64* transposed)
inline void bgc_fp64_matrix3x2_get_transposed(BGC_FP64_Matrix3x2* transposed, const BGC_FP64_Matrix2x3* matrix)
{
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
@ -157,83 +157,199 @@ inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatr
transposed->r2c3 = matrix->r3c2;
}
// ================= Set Row 1 ================== //
// ================== Get Row =================== //
inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix)
inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x2* matrix, const int row_number)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
matrix->r1c3 = c3;
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix)
if (row_number == 2)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
matrix->r1c3 = c3;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
// ================= Set Row 2 ================== //
inline void bgc_matrix3x2_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
matrix->r2c3 = c3;
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
}
inline void bgc_matrix3x2_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix)
inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x2* matrix, const int row_number)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
matrix->r2c3 = c3;
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
// ================ Set Column 1 ================ //
inline void bgc_matrix3x2_set_column1_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix)
if (row_number == 2)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
inline void bgc_matrix3x2_set_column1_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
}
// ================ Set Column 2 ================ //
// ================== Set Row =================== //
inline void bgc_matrix3x2_set_column2_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix)
inline void bgc_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* matrix, const int row_number, const BGC_FP32_Vector3* row)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
inline void bgc_matrix3x2_set_column2_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix)
if (row_number == 2)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
}
}
// ================ Set Column 3 ================ //
inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix)
inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* matrix, const int row_number, const BGC_FP64_Vector3* row)
{
matrix->r1c3 = r1;
matrix->r2c3 = r2;
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix)
if (row_number == 2)
{
matrix->r1c3 = r1;
matrix->r2c3 = r2;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
}
}
// ================= Get Column ================= //
inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix3x2* matrix, const int column_number)
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
}
inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix3x2* matrix, const int column_number)
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
}
// ================= Set Column ================= //
inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* matrix, const int column_number, const BGC_FP32_Vector2* column)
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
}
}
inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int column_number, const BGC_FP64_Vector2* column)
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
}
}
// ==================== Add ===================== //
inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum)
inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -244,7 +360,7 @@ inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMat
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
}
inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* sum)
inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -257,7 +373,7 @@ inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMat
// ================= Add scaled ================= //
inline void bgc_matrix3x2_add_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* sum)
inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -268,7 +384,7 @@ inline void bgc_matrix3x2_add_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix,
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
}
inline void bgc_matrix3x2_add_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* sum)
inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -281,7 +397,7 @@ inline void bgc_matrix3x2_add_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix,
// ================== Subtract ================== //
inline void bgc_matrix3x2_subtract_fp32(const BgcMatrix3x2FP32* minuend, const BgcMatrix3x2FP32* subtrahend, BgcMatrix3x2FP32* difference)
inline void bgc_fp32_matrix3x2_subtract(BGC_FP32_Matrix3x2* difference, const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -292,7 +408,7 @@ inline void bgc_matrix3x2_subtract_fp32(const BgcMatrix3x2FP32* minuend, const B
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
}
inline void bgc_matrix3x2_subtract_fp64(const BgcMatrix3x2FP64* minuend, const BgcMatrix3x2FP64* subtrahend, BgcMatrix3x2FP64* difference)
inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -303,33 +419,9 @@ inline void bgc_matrix3x2_subtract_fp64(const BgcMatrix3x2FP64* minuend, const B
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
}
// ============== Subtract scaled =============== //
inline void bgc_matrix3x2_subtract_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
}
inline void bgc_matrix3x2_subtract_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
}
// ================== Multiply ================== //
inline void bgc_matrix3x2_multiply_fp32(const BgcMatrix3x2FP32* multiplicand, const float multiplier, BgcMatrix3x2FP32* product)
inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -340,7 +432,7 @@ inline void bgc_matrix3x2_multiply_fp32(const BgcMatrix3x2FP32* multiplicand, co
product->r2c3 = multiplicand->r2c3 * multiplier;
}
inline void bgc_matrix3x2_multiply_fp64(const BgcMatrix3x2FP64* multiplicand, const double multiplier, BgcMatrix3x2FP64* product)
inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -353,44 +445,72 @@ inline void bgc_matrix3x2_multiply_fp64(const BgcMatrix3x2FP64* multiplicand, co
// =================== Divide =================== //
inline void bgc_matrix3x2_divide_fp32(const BgcMatrix3x2FP32* dividend, const float divisor, BgcMatrix3x2FP32* quotient)
inline void bgc_fp32_matrix3x2_divide(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor)
{
bgc_matrix3x2_multiply_fp32(dividend, 1.0f / divisor, quotient);
bgc_fp32_matrix3x2_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_matrix3x2_divide_fp64(const BgcMatrix3x2FP64* dividend, const double divisor, BgcMatrix3x2FP64* quotient)
inline void bgc_fp64_matrix3x2_divide(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor)
{
bgc_matrix3x2_multiply_fp64(dividend, 1.0 / divisor, quotient);
bgc_fp64_matrix3x2_multiply(quotient, dividend, 1.0 / divisor);
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase)
{
const float couter_phase = 1.0f - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * couter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * couter_phase + second->r2c3 * phase;
}
inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase)
{
const double couter_phase = 1.0 - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * couter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * couter_phase + second->r2c3 * phase;
}
// ============ Left Vector Product ============= //
inline void bgc_matrix3x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix3x2FP32* matrix, BgcVector3FP32* result)
inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix)
{
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
}
inline void bgc_matrix3x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix3x2FP64* matrix, BgcVector3FP64* result)
inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix)
{
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
}
// ============ Right Vector Product ============ //
inline void bgc_matrix3x2_get_right_product_fp32(const BgcMatrix3x2FP32* matrix, const BgcVector3FP32* vector, BgcVector2FP32* result)
inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector)
{
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
}
inline void bgc_matrix3x2_get_right_product_fp64(const BgcMatrix3x2FP64* matrix, const BgcVector3FP64* vector, BgcVector2FP64* result)
inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector)
{
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
}
#endif

View file

@ -1,84 +1,87 @@
#include "matrix3x3.h"
extern inline void bgc_matrix3x3_reset_fp32(BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_reset_fp64(BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_reset(BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_fp64_matrix3x3_reset(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_to_identity_fp32(BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_to_identity_fp64(BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_make_identity(BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_fp64_matrix3x3_make_identity(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const float d3, BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, const double d3, BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_make_diagonal(BGC_FP32_Matrix3x3* matrix, const float d1, const float d2, const float d3);
extern inline void bgc_fp64_matrix3x3_make_diagonal(BGC_FP64_Matrix3x3* matrix, const double d1, const double d2, const double d3);
extern inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP32* destination);
extern inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP64* destination);
extern inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source);
extern inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source);
extern inline void bgc_matrix3x3_swap_fp32(BgcMatrix3x3FP32* matrix1, BgcMatrix3x3FP32* matrix2);
extern inline void bgc_matrix3x3_swap_fp64(BgcMatrix3x3FP64* matrix1, BgcMatrix3x3FP64* matrix2);
extern inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* matrix1, BGC_FP32_Matrix3x3* matrix2);
extern inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* matrix1, BGC_FP64_Matrix3x3* matrix2);
extern inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP32* destination);
extern inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP64* destination);
extern inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source);
extern inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source);
extern inline float bgc_matrix3x3_get_determinant_fp32(const BgcMatrix3x3FP32* matrix);
extern inline double bgc_matrix3x3_get_determinant_fp64(const BgcMatrix3x3FP64* matrix);
extern inline float bgc_fp32_matrix3x3_get_determinant(const BGC_FP32_Matrix3x3* matrix);
extern inline double bgc_fp64_matrix3x3_get_determinant(const BGC_FP64_Matrix3x3* matrix);
extern inline int bgc_matrix3x3_is_singular_fp32(const BgcMatrix3x3FP32* matrix);
extern inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix);
extern inline int bgc_fp32_matrix3x3_is_identity(const BGC_FP32_Matrix3x3* matrix);
extern inline int bgc_fp64_matrix3x3_is_identity(const BGC_FP64_Matrix3x3* matrix);
extern inline int bgc_matrix3x3_is_rotation_fp32(const BgcMatrix3x3FP32* matrix);
extern inline int bgc_matrix3x3_is_rotation_fp64(const BgcMatrix3x3FP64* matrix);
extern inline int bgc_fp32_matrix3x3_is_singular(const BGC_FP32_Matrix3x3* matrix);
extern inline int bgc_fp64_matrix3x3_is_singular(const BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* transposed);
extern inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* transposed);
extern inline int bgc_fp32_matrix3x3_is_rotation(const BGC_FP32_Matrix3x3* matrix);
extern inline int bgc_fp64_matrix3x3_is_rotation(const BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix);
extern inline int bgc_fp32_matrix3x3_invert(BGC_FP32_Matrix3x3* matrix);
extern inline int bgc_fp64_matrix3x3_invert(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_transpose(BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_fp64_matrix3x3_transpose(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row3_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_row3_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_get_transposed(BGC_FP32_Matrix3x3* transposed, const BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_fp64_matrix3x3_get_transposed(BGC_FP64_Matrix3x3* transposed, const BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x3* matrix, const int row_number);
extern inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x3* matrix, const int row_number);
extern inline void bgc_matrix3x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_set_row(BGC_FP32_Matrix3x3* matrix, const int row_number, const BGC_FP32_Vector3* row);
extern inline void bgc_fp64_matrix3x3_set_row(BGC_FP64_Matrix3x3* matrix, const int row_number, const BGC_FP64_Vector3* row);
extern inline void bgc_matrix3x3_set_column3_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix);
extern inline void bgc_matrix3x3_set_column3_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix);
extern inline void bgc_fp32_matrix3x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix3x3* matrix, const int column_number);
extern inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix3x3* matrix, const int column_number);
extern inline void bgc_matrix3x3_add_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x3FP32* sum);
extern inline void bgc_matrix3x3_add_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x3FP64* sum);
extern inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* matrix, const int column_number, const BGC_FP32_Vector3* column);
extern inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* matrix, const int column_number, const BGC_FP64_Vector3* column);
extern inline void bgc_matrix3x3_add_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* sum);
extern inline void bgc_matrix3x3_add_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* sum);
extern inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2);
extern inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2);
extern inline void bgc_matrix3x3_subtract_fp32(const BgcMatrix3x3FP32* minuend, const BgcMatrix3x3FP32* subtrahend, BgcMatrix3x3FP32* difference);
extern inline void bgc_matrix3x3_subtract_fp64(const BgcMatrix3x3FP64* minuend, const BgcMatrix3x3FP64* subtrahend, BgcMatrix3x3FP64* difference);
extern inline void bgc_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* basic_matrix, const BGC_FP32_Matrix3x3* scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* basic_matrix, const BGC_FP64_Matrix3x3* scalable_matrix, const double scale);
extern inline void bgc_matrix3x3_subtract_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* difference);
extern inline void bgc_matrix3x3_subtract_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* difference);
extern inline void bgc_fp32_matrix3x3_subtract(BGC_FP32_Matrix3x3* difference, const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend);
extern inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend);
extern inline void bgc_matrix3x3_multiply_fp32(const BgcMatrix3x3FP32* multiplicand, const float multiplier, BgcMatrix3x3FP32* product);
extern inline void bgc_matrix3x3_multiply_fp64(const BgcMatrix3x3FP64* multiplicand, const double multiplier, BgcMatrix3x3FP64* product);
extern inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier);
extern inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier);
extern inline void bgc_matrix3x3_divide_fp32(const BgcMatrix3x3FP32* dividend, const float divisor, BgcMatrix3x3FP32* quotient);
extern inline void bgc_matrix3x3_divide_fp64(const BgcMatrix3x3FP64* dividend, const double divisor, BgcMatrix3x3FP64* quotient);
extern inline void bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor);
extern inline void bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor);
extern inline void bgc_matrix3x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix3x3FP32* matrix, BgcVector3FP32* result);
extern inline void bgc_matrix3x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix3x3FP64* matrix, BgcVector3FP64* result);
extern inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase);
extern inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase);
extern inline void bgc_matrix3x3_get_right_product_fp32(const BgcMatrix3x3FP32* matrix, const BgcVector3FP32* vector, BgcVector3FP32* result);
extern inline void bgc_matrix3x3_get_right_product_fp64(const BgcMatrix3x3FP64* matrix, const BgcVector3FP64* vector, BgcVector3FP64* result);
extern inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix);
// =================== Invert =================== //
extern inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector);
extern inline void bgc_fp64_multiply_matrix3x3_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector);
int bgc_matrix3x3_invert_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* inverted)
// ================ Get Inverse ================= //
int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_Matrix3x3* matrix)
{
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix);
const float determinant = bgc_fp32_matrix3x3_get_determinant(matrix);
if (bgc_is_zero_fp32(determinant)) {
if (bgc_fp32_is_zero(determinant)) {
return 0;
}
@ -96,26 +99,26 @@ int bgc_matrix3x3_invert_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32*
const float multiplier = 1.0f / determinant;
inverted->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier;
inverted->r1c3 = r1c3 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverse->r1c3 = r1c3 * multiplier;
inverted->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier;
inverted->r2c3 = r2c3 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
inverse->r2c3 = r2c3 * multiplier;
inverted->r3c1 = r3c1 * multiplier;
inverted->r3c2 = r3c2 * multiplier;
inverted->r3c3 = r3c3 * multiplier;
inverse->r3c1 = r3c1 * multiplier;
inverse->r3c2 = r3c2 * multiplier;
inverse->r3c3 = r3c3 * multiplier;
return 1;
}
int bgc_matrix3x3_invert_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* inverted)
int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_Matrix3x3* matrix)
{
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix);
const double determinant = bgc_fp64_matrix3x3_get_determinant(matrix);
if (bgc_is_zero_fp64(determinant)) {
if (bgc_fp64_is_zero(determinant)) {
return 0;
}
@ -133,17 +136,17 @@ int bgc_matrix3x3_invert_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64*
const double multiplier = 1.0 / determinant;
inverted->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier;
inverted->r1c3 = r1c3 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverse->r1c3 = r1c3 * multiplier;
inverted->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier;
inverted->r2c3 = r2c3 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
inverse->r2c3 = r2c3 * multiplier;
inverted->r3c1 = r3c1 * multiplier;
inverted->r3c2 = r3c2 * multiplier;
inverted->r3c3 = r3c3 * multiplier;
inverse->r3c1 = r3c1 * multiplier;
inverse->r3c2 = r3c2 * multiplier;
inverse->r3c3 = r3c3 * multiplier;
return 1;
}

View file

@ -1,12 +1,12 @@
#ifndef _BGC_MATRIX3X3_H_
#define _BGC_MATRIX3X3_H_
#ifndef _BGC_MATRIX3X3_H_INCLUDED_
#define _BGC_MATRIX3X3_H_INCLUDED_
#include "vector3.h"
#include "matrixes.h"
#include "matrices.h"
// =================== Reset ==================== //
inline void bgc_matrix3x3_reset_fp32(BgcMatrix3x3FP32* matrix)
inline void bgc_fp32_matrix3x3_reset(BGC_FP32_Matrix3x3* matrix)
{
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
@ -21,7 +21,7 @@ inline void bgc_matrix3x3_reset_fp32(BgcMatrix3x3FP32* matrix)
matrix->r3c3 = 0.0f;
}
inline void bgc_matrix3x3_reset_fp64(BgcMatrix3x3FP64* matrix)
inline void bgc_fp64_matrix3x3_reset(BGC_FP64_Matrix3x3* matrix)
{
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
@ -38,7 +38,7 @@ inline void bgc_matrix3x3_reset_fp64(BgcMatrix3x3FP64* matrix)
// ================== Identity ================== //
inline void bgc_matrix3x3_set_to_identity_fp32(BgcMatrix3x3FP32* matrix)
inline void bgc_fp32_matrix3x3_make_identity(BGC_FP32_Matrix3x3* matrix)
{
matrix->r1c1 = 1.0f;
matrix->r1c2 = 0.0f;
@ -53,7 +53,7 @@ inline void bgc_matrix3x3_set_to_identity_fp32(BgcMatrix3x3FP32* matrix)
matrix->r3c3 = 1.0f;
}
inline void bgc_matrix3x3_set_to_identity_fp64(BgcMatrix3x3FP64* matrix)
inline void bgc_fp64_matrix3x3_make_identity(BGC_FP64_Matrix3x3* matrix)
{
matrix->r1c1 = 1.0;
matrix->r1c2 = 0.0;
@ -70,7 +70,7 @@ inline void bgc_matrix3x3_set_to_identity_fp64(BgcMatrix3x3FP64* matrix)
// ================ Set Diagonal ================ //
inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const float d3, BgcMatrix3x3FP32* matrix)
inline void bgc_fp32_matrix3x3_make_diagonal(BGC_FP32_Matrix3x3* matrix, const float d1, const float d2, const float d3)
{
matrix->r1c1 = d1;
matrix->r1c2 = 0.0f;
@ -85,7 +85,7 @@ inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, c
matrix->r3c3 = d2;
}
inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, const double d3, BgcMatrix3x3FP64* matrix)
inline void bgc_fp64_matrix3x3_make_diagonal(BGC_FP64_Matrix3x3* matrix, const double d1, const double d2, const double d3)
{
matrix->r1c1 = d1;
matrix->r1c2 = 0.0;
@ -102,7 +102,7 @@ inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2,
// ==================== Copy ==================== //
inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP32* destination)
inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -117,7 +117,7 @@ inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* source, BgcMatrix3x3
destination->r3c3 = source->r3c3;
}
inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP64* destination)
inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -134,7 +134,7 @@ inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* source, BgcMatrix3x3
// ==================== Swap ==================== //
inline void bgc_matrix3x3_swap_fp32(BgcMatrix3x3FP32* matrix1, BgcMatrix3x3FP32* matrix2)
inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* matrix1, BGC_FP32_Matrix3x3* matrix2)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
@ -173,7 +173,7 @@ inline void bgc_matrix3x3_swap_fp32(BgcMatrix3x3FP32* matrix1, BgcMatrix3x3FP32*
matrix1->r3c3 = r3c3;
}
inline void bgc_matrix3x3_swap_fp64(BgcMatrix3x3FP64* matrix1, BgcMatrix3x3FP64* matrix2)
inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* matrix1, BGC_FP64_Matrix3x3* matrix2)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
@ -214,7 +214,7 @@ inline void bgc_matrix3x3_swap_fp64(BgcMatrix3x3FP64* matrix1, BgcMatrix3x3FP64*
// ================== Convert =================== //
inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP32* destination)
inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source)
{
destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2;
@ -229,7 +229,7 @@ inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* source, B
destination->r3c3 = (float)source->r3c3;
}
inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP64* destination)
inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source)
{
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
@ -246,89 +246,141 @@ inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* source, B
// ================ Determinant ================= //
inline float bgc_matrix3x3_get_determinant_fp32(const BgcMatrix3x3FP32* matrix)
inline float bgc_fp32_matrix3x3_get_determinant(const BGC_FP32_Matrix3x3* matrix)
{
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
+ matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1);
}
inline double bgc_matrix3x3_get_determinant_fp64(const BgcMatrix3x3FP64* matrix)
inline double bgc_fp64_matrix3x3_get_determinant(const BGC_FP64_Matrix3x3* matrix)
{
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
+ matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1);
}
// ================== Singular ================== //
// ================ Is Identity ================= //
inline int bgc_matrix3x3_is_singular_fp32(const BgcMatrix3x3FP32* matrix)
inline int bgc_fp32_matrix3x3_is_identity(const BGC_FP32_Matrix3x3* matrix)
{
return bgc_is_zero_fp32(bgc_matrix3x3_get_determinant_fp32(matrix));
return bgc_fp32_is_unit(matrix->r1c1) && bgc_fp32_is_zero(matrix->r1c2) && bgc_fp32_is_zero(matrix->r1c3)
&& bgc_fp32_is_zero(matrix->r2c1) && bgc_fp32_is_unit(matrix->r2c2) && bgc_fp32_is_zero(matrix->r2c3)
&& bgc_fp32_is_zero(matrix->r3c1) && bgc_fp32_is_zero(matrix->r3c2) && bgc_fp32_is_unit(matrix->r3c3);
}
inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix)
inline int bgc_fp64_matrix3x3_is_identity(const BGC_FP64_Matrix3x3* matrix)
{
return bgc_is_zero_fp64(bgc_matrix3x3_get_determinant_fp64(matrix));
return bgc_fp64_is_unit(matrix->r1c1) && bgc_fp64_is_zero(matrix->r1c2) && bgc_fp64_is_zero(matrix->r1c3)
&& bgc_fp64_is_zero(matrix->r2c1) && bgc_fp64_is_unit(matrix->r2c2) && bgc_fp64_is_zero(matrix->r2c3)
&& bgc_fp64_is_zero(matrix->r3c1) && bgc_fp64_is_zero(matrix->r3c2) && bgc_fp64_is_unit(matrix->r3c3);
}
// ================ Is Singular ================= //
inline int bgc_fp32_matrix3x3_is_singular(const BGC_FP32_Matrix3x3* matrix)
{
return bgc_fp32_is_zero(bgc_fp32_matrix3x3_get_determinant(matrix));
}
inline int bgc_fp64_matrix3x3_is_singular(const BGC_FP64_Matrix3x3* matrix)
{
return bgc_fp64_is_zero(bgc_fp64_matrix3x3_get_determinant(matrix));
}
// ================ Is Rotation ================= //
inline int bgc_matrix3x3_is_rotation_fp32(const BgcMatrix3x3FP32* matrix)
inline int bgc_fp32_matrix3x3_is_rotation(const BGC_FP32_Matrix3x3* matrix)
{
if (!bgc_is_unit_fp32(bgc_matrix3x3_get_determinant_fp32(matrix))) {
return 0;
BGC_FP32_Matrix3x3 product;
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1;
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2;
product.r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3;
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1;
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2;
product.r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3;
product.r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1;
product.r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2;
product.r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3;
return bgc_fp32_matrix3x3_is_identity(&product);
}
const float product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1;
const float product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2;
const float product_r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3;
const float product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1;
const float product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2;
const float product_r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3;
const float product_r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1;
const float product_r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2;
const float product_r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3;
return bgc_is_unit_fp32(product_r1c1) && bgc_is_zero_fp32(product_r1c2) && bgc_is_zero_fp32(product_r1c3)
&& bgc_is_zero_fp32(product_r2c1) && bgc_is_unit_fp32(product_r2c2) && bgc_is_zero_fp32(product_r2c3)
&& bgc_is_zero_fp32(product_r3c1) && bgc_is_zero_fp32(product_r3c2) && bgc_is_unit_fp32(product_r3c3);
}
inline int bgc_matrix3x3_is_rotation_fp64(const BgcMatrix3x3FP64* matrix)
inline int bgc_fp64_matrix3x3_is_rotation(const BGC_FP64_Matrix3x3* matrix)
{
if (!bgc_is_unit_fp64(bgc_matrix3x3_get_determinant_fp64(matrix))) {
return 0;
BGC_FP64_Matrix3x3 product;
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1;
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2;
product.r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3;
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1;
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2;
product.r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3;
product.r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1;
product.r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2;
product.r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3;
return bgc_fp64_matrix3x3_is_identity(&product);
}
const double product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1;
const double product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2;
const double product_r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3;
// ================ Get Inverse ================= //
const double product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1;
const double product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2;
const double product_r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3;
int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_Matrix3x3* matrix);
const double product_r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1;
const double product_r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2;
const double product_r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3;
return bgc_is_unit_fp64(product_r1c1) && bgc_is_zero_fp64(product_r1c2) && bgc_is_zero_fp64(product_r1c3)
&& bgc_is_zero_fp64(product_r2c1) && bgc_is_unit_fp64(product_r2c2) && bgc_is_zero_fp64(product_r2c3)
&& bgc_is_zero_fp64(product_r3c1) && bgc_is_zero_fp64(product_r3c2) && bgc_is_unit_fp64(product_r3c3);
}
int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_Matrix3x3* matrix);
// =================== Invert =================== //
int bgc_matrix3x3_invert_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* inverted);
inline int bgc_fp32_matrix3x3_invert(BGC_FP32_Matrix3x3* matrix)
{
return bgc_fp32_matrix3x3_get_inverse(matrix, matrix);
}
int bgc_matrix3x3_invert_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* inverted);
inline int bgc_fp64_matrix3x3_invert(BGC_FP64_Matrix3x3* matrix)
{
return bgc_fp64_matrix3x3_get_inverse(matrix, matrix);
}
// ================= Transpose ================== //
inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* transposed)
inline void bgc_fp32_matrix3x3_transpose(BGC_FP32_Matrix3x3* matrix)
{
const float r1c2 = matrix->r1c2;
const float r1c3 = matrix->r1c3;
const float r2c3 = matrix->r2c3;
matrix->r1c2 = matrix->r2c1;
matrix->r1c3 = matrix->r3c1;
matrix->r2c3 = matrix->r3c2;
matrix->r2c1 = r1c2;
matrix->r3c1 = r1c3;
matrix->r3c2 = r2c3;
}
inline void bgc_fp64_matrix3x3_transpose(BGC_FP64_Matrix3x3* matrix)
{
const double r1c2 = matrix->r1c2;
const double r1c3 = matrix->r1c3;
const double r2c3 = matrix->r2c3;
matrix->r1c2 = matrix->r2c1;
matrix->r1c3 = matrix->r3c1;
matrix->r2c3 = matrix->r3c2;
matrix->r2c1 = r1c2;
matrix->r3c1 = r1c3;
matrix->r3c2 = r2c3;
}
// =============== Get Transpose ================ //
inline void bgc_fp32_matrix3x3_get_transposed(BGC_FP32_Matrix3x3* transposed, const BGC_FP32_Matrix3x3* matrix)
{
transposed->r1c1 = matrix->r1c1;
transposed->r2c2 = matrix->r2c2;
@ -347,7 +399,7 @@ inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatr
transposed->r3c2 = r2c3;
}
inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* transposed)
inline void bgc_fp64_matrix3x3_get_transposed(BGC_FP64_Matrix3x3* transposed, const BGC_FP64_Matrix3x3* matrix)
{
transposed->r1c1 = matrix->r1c1;
transposed->r2c2 = matrix->r2c2;
@ -366,105 +418,245 @@ inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatr
transposed->r3c2 = r2c3;
}
// ================= Set Row 1 ================== //
// ================== Get Row -================== //
inline void bgc_matrix3x3_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix)
inline void bgc_fp32_matrix3x3_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x3* matrix, const int row_number)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
matrix->r1c3 = c3;
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
inline void bgc_matrix3x3_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix)
if (row_number == 2)
{
matrix->r1c1 = c1;
matrix->r1c2 = c2;
matrix->r1c3 = c3;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
// ================= Set Row 2 ================== //
inline void bgc_matrix3x3_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix)
if (row_number == 3)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
matrix->r2c3 = c3;
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x3 = matrix->r3c3;
return;
}
inline void bgc_matrix3x3_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix)
{
matrix->r2c1 = c1;
matrix->r2c2 = c2;
matrix->r2c3 = c3;
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
}
// ================= Set Row 3 ================== //
inline void bgc_matrix3x3_set_row3_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix)
inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x3* matrix, const int row_number)
{
matrix->r3c1 = c1;
matrix->r3c2 = c2;
matrix->r3c3 = c3;
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
inline void bgc_matrix3x3_set_row3_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix)
if (row_number == 2)
{
matrix->r3c1 = c1;
matrix->r3c2 = c2;
matrix->r3c3 = c3;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
// ================ Set Column 1 ================ //
inline void bgc_matrix3x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix)
if (row_number == 3)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
matrix->r3c1 = r3;
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x3 = matrix->r3c3;
return;
}
inline void bgc_matrix3x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix)
{
matrix->r1c1 = r1;
matrix->r2c1 = r2;
matrix->r3c1 = r3;
row->x1 = 0.0;
row->x2 = 0.0;
row->x3 = 0.0;
}
// ================ Set Column 2 ================ //
// ================== Set Row =================== //
inline void bgc_matrix3x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix)
inline void bgc_fp32_matrix3x3_set_row(BGC_FP32_Matrix3x3* matrix, const int row_number, const BGC_FP32_Vector3* row)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
matrix->r3c2 = r3;
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
inline void bgc_matrix3x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix)
if (row_number == 2)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
matrix->r3c2 = r3;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
return;
}
// ================ Set Column 3 ================ //
inline void bgc_matrix3x3_set_column3_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix)
if (row_number == 3)
{
matrix->r1c3 = r1;
matrix->r2c3 = r2;
matrix->r3c3 = r3;
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c3 = row->x3;
}
}
inline void bgc_matrix3x3_set_column3_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix)
inline void bgc_fp64_matrix3x3_set_row(BGC_FP64_Matrix3x3* matrix, const int row_number, const BGC_FP64_Vector3* row)
{
matrix->r1c3 = r1;
matrix->r2c3 = r2;
matrix->r3c3 = r3;
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
if (row_number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
return;
}
if (row_number == 3)
{
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c3 = row->x3;
}
}
// ================= Get Column ================= //
inline void bgc_fp32_matrix3x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix3x3* matrix, const int column_number)
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x3 = matrix->r3c3;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
column->x3 = 0.0f;
}
inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix3x3* matrix, const int column_number)
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x3 = matrix->r3c3;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
column->x3 = 0.0;
}
// ================= Set Column ================= //
inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* matrix, const int column_number, const BGC_FP32_Vector3* column)
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
matrix->r3c3 = column->x3;
}
}
inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* matrix, const int column_number, const BGC_FP64_Vector3* column)
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
matrix->r3c3 = column->x3;
}
}
// ==================== Add ===================== //
inline void bgc_matrix3x3_add_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x3FP32* sum)
inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -479,7 +671,7 @@ inline void bgc_matrix3x3_add_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMat
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
}
inline void bgc_matrix3x3_add_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x3FP64* sum)
inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -496,7 +688,7 @@ inline void bgc_matrix3x3_add_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMat
// ================= Add scaled ================= //
inline void bgc_matrix3x3_add_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* sum)
inline void bgc_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* basic_matrix, const BGC_FP32_Matrix3x3* scalable_matrix, const float scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -511,7 +703,7 @@ inline void bgc_matrix3x3_add_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix,
sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale;
}
inline void bgc_matrix3x3_add_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* sum)
inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* basic_matrix, const BGC_FP64_Matrix3x3* scalable_matrix, const double scale)
{
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -528,7 +720,7 @@ inline void bgc_matrix3x3_add_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix,
// ================== Subtract ================== //
inline void bgc_matrix3x3_subtract_fp32(const BgcMatrix3x3FP32* minuend, const BgcMatrix3x3FP32* subtrahend, BgcMatrix3x3FP32* difference)
inline void bgc_fp32_matrix3x3_subtract(BGC_FP32_Matrix3x3* difference, const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -543,7 +735,7 @@ inline void bgc_matrix3x3_subtract_fp32(const BgcMatrix3x3FP32* minuend, const B
difference->r3c3 = minuend->r3c3 - subtrahend->r3c3;
}
inline void bgc_matrix3x3_subtract_fp64(const BgcMatrix3x3FP64* minuend, const BgcMatrix3x3FP64* subtrahend, BgcMatrix3x3FP64* difference)
inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend)
{
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -558,41 +750,9 @@ inline void bgc_matrix3x3_subtract_fp64(const BgcMatrix3x3FP64* minuend, const B
difference->r3c3 = minuend->r3c3 - subtrahend->r3c3;
}
// ================= Add scaled ================= //
inline void bgc_matrix3x3_subtract_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
difference->r3c3 = basic_matrix->r3c3 - scalable_matrix->r3c3 * scale;
}
inline void bgc_matrix3x3_subtract_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
difference->r3c3 = basic_matrix->r3c3 - scalable_matrix->r3c3 * scale;
}
// ================== Multiply ================== //
inline void bgc_matrix3x3_multiply_fp32(const BgcMatrix3x3FP32* multiplicand, const float multiplier, BgcMatrix3x3FP32* product)
inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -607,7 +767,7 @@ inline void bgc_matrix3x3_multiply_fp32(const BgcMatrix3x3FP32* multiplicand, co
product->r3c3 = multiplicand->r3c3 * multiplier;
}
inline void bgc_matrix3x3_multiply_fp64(const BgcMatrix3x3FP64* multiplicand, const double multiplier, BgcMatrix3x3FP64* product)
inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier)
{
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
@ -624,62 +784,98 @@ inline void bgc_matrix3x3_multiply_fp64(const BgcMatrix3x3FP64* multiplicand, co
// =================== Divide =================== //
inline void bgc_matrix3x3_divide_fp32(const BgcMatrix3x3FP32* dividend, const float divisor, BgcMatrix3x3FP32* quotient)
inline void bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor)
{
bgc_matrix3x3_multiply_fp32(dividend, 1.0f / divisor, quotient);
bgc_fp32_matrix3x3_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_matrix3x3_divide_fp64(const BgcMatrix3x3FP64* dividend, const double divisor, BgcMatrix3x3FP64* quotient)
inline void bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor)
{
bgc_matrix3x3_multiply_fp64(dividend, 1.0 / divisor, quotient);
bgc_fp64_matrix3x3_multiply(quotient, dividend, 1.0 / divisor);
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase)
{
const float counter_phase = 1.0f - phase;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * counter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * counter_phase + second->r2c3 * phase;
interpolation->r3c1 = first->r3c1 * counter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * counter_phase + second->r3c2 * phase;
interpolation->r3c3 = first->r3c3 * counter_phase + second->r3c3 * phase;
}
inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase)
{
const double counter_phase = 1.0 - phase;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * counter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * counter_phase + second->r2c3 * phase;
interpolation->r3c1 = first->r3c1 * counter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * counter_phase + second->r3c2 * phase;
interpolation->r3c3 = first->r3c3 * counter_phase + second->r3c3 * phase;
}
// ============ Left Vector Product ============= //
inline void bgc_matrix3x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix3x3FP32* matrix, BgcVector3FP32* result)
inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix)
{
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
const float x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
result->x1 = x1;
result->x2 = x2;
result->x3 = x3;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
}
inline void bgc_matrix3x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix3x3FP64* matrix, BgcVector3FP64* result)
inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix)
{
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
const double x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
result->x1 = x1;
result->x2 = x2;
result->x3 = x3;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
}
// ============ Right Vector Product ============ //
inline void bgc_matrix3x3_get_right_product_fp32(const BgcMatrix3x3FP32* matrix, const BgcVector3FP32* vector, BgcVector3FP32* result)
inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector)
{
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
const float x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
result->x1 = x1;
result->x2 = x2;
result->x3 = x3;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
}
inline void bgc_matrix3x3_get_right_product_fp64(const BgcMatrix3x3FP64* matrix, const BgcVector3FP64* vector, BgcVector3FP64* result)
inline void bgc_fp64_multiply_matrix3x3_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector)
{
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
const double x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
result->x1 = x1;
result->x2 = x2;
result->x3 = x3;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
}
#endif

View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -1,280 +0,0 @@
#include "matrixes.h"
extern inline void bgc_matrix_product_2x2_at_2x2_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* result);
extern inline void bgc_matrix_product_2x2_at_2x2_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* result);
// ========== Matrix Product 2x2 at 3x2 ========= //
void bgc_matrix_product_2x2_at_3x2_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* result)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;