Переход на парадигму Destination first в порядке параметров функий

This commit is contained in:
Andrey Pokidov 2026-02-01 23:42:51 +07:00
parent f7e41645fe
commit 03627f4401
41 changed files with 1570 additions and 1978 deletions

View file

@ -41,18 +41,18 @@ BGC_FP32_Affine3* _create_bgc_affine3_random_list(int affine_amount)
for (int i = 0; i < affine_amount; i++) { for (int i = 0; i < affine_amount; i++) {
bgc_fp32_versor_make( bgc_fp32_versor_make(
&position.turn,
get_random_value_fp32(), get_random_value_fp32(),
get_random_value_fp32(), get_random_value_fp32(),
get_random_value_fp32(), get_random_value_fp32(),
get_random_value_fp32(), get_random_value_fp32()
&position.turn
); );
position.shift.x1 = get_random_value_fp32(); position.shift.x1 = get_random_value_fp32();
position.shift.x2 = get_random_value_fp32(); position.shift.x2 = get_random_value_fp32();
position.shift.x3 = get_random_value_fp32(); position.shift.x3 = get_random_value_fp32();
bgc_fp32_position3_get_outward_affine(&position, &affines[i]); bgc_fp32_position3_get_outward_affine(&affines[i], &position);
} }
return affines; return affines;
@ -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 i = 0; i < affine_amount; i++)
{ {
for (int j = 0; j < vector_per_affine; j++) { for (int j = 0; j < vector_per_affine; j++) {
bgc_fp32_affine3_transform_point(&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++; vector_index++;
} }
} }

View file

@ -30,19 +30,19 @@ structure_fp32_t* make_structures(const unsigned int amount)
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
bgc_fp32_versor_make( bgc_fp32_versor_make(
&list[i].versor1,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f
&list[i].versor1
); );
bgc_fp32_versor_make( bgc_fp32_versor_make(
&list[i].versor2,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f
&list[i].versor2
); );
bgc_fp32_versor_reset(&list[i].result); bgc_fp32_versor_reset(&list[i].result);
@ -157,74 +157,74 @@ void test_basis_difference_fp32()
BGC_FP32_Versor turn; BGC_FP32_Versor turn;
// No turn // No turn
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nNo turn:\n"); printf("\nNo turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Turn around (1, 1, 0) axis on 180 degrees // Turn around (1, 1, 0) axis on 180 degrees
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 1.0f, 0.0f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 180 degree turn // 180 degree turn
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, -1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n180 degree turn around (0, 1, 0):\n"); printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 90 degree turn around x3 axis // 90 degree turn around x3 axis
bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 2.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 3.1f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 3.1f, 0.0f);
bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 0.0f, 10.0f, 0.0f);
bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary,-1.0f, 0.0f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n90 degree turn around (0, 0, 1):\n"); printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Unorthogonal pairs turn at 90 degrees around x3 axis // Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 2.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(-2.0f, 3.1f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, -2.0f, 3.1f, 0.0f);
bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 0.0f, 10.0f, 0.0f);
bgc_fp32_vector3_make(-1.0f, 5.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, -1.0f, 5.0f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Zero vectors // Zero vectors
bgc_fp32_vector3_make(0.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 0.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
int code; int code;
code = bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) { if (code >= 0) {
printf("\nZero vectors: this cannot be!\n"); printf("\nZero vectors: this cannot be!\n");
@ -235,12 +235,12 @@ void test_basis_difference_fp32()
} }
// Parallel vectors // Parallel vectors
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 2.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
code = bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) { if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n"); printf("\nParallel vectors: this cannot be!\n");
@ -251,60 +251,60 @@ void test_basis_difference_fp32()
} }
// Small angle turn (about 1 degree): // Small angle turn (about 1 degree):
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 0.999848f, 0.017452f, 0.0f);
bgc_fp32_vector3_make(-0.017452f, 0.999848f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, -0.017452f, 0.999848f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn , &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nSmall angle turn (about 1 degree):\n"); printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 179 degrees turn // About 179 degrees turn
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(-0.999848f, -0.017452f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, -0.999848f, -0.017452f, 0.0f);
bgc_fp32_vector3_make(0.017452f, -0.999848f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 0.017452f, -0.999848f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 179 degrees turn:\n"); printf("\nAbout 179 degrees turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 120 degrees around (-1, -1, 1) // 120 degrees around (-1, -1, 1)
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(0.0f, 0.0f, -1.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 0.0f, -1.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n120 degees turn:\n"); printf("\n120 degees turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions // About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 0.999848f, 0.017452f, 0.0f);
bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f);
bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, -1.0f, 0.0f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_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"); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 0.01 degree turn difference between initial_primary and initial_auxiliary directions // About 0.01 degree turn difference between initial_primary and initial_auxiliary directions
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
bgc_fp32_vector3_make(1.0f, 0.000001f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(&initial_auxiliary, 1.0f, 0.000001f, 0.0f);
bgc_fp32_vector3_make(0.0f, -1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(&final_primary, 0.0f, -1.0f, 0.0f);
bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(&final_auxiliary, 1.0f, 0.0f, 0.0f);
bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_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"); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
@ -318,72 +318,72 @@ void test_basis_difference_fp64()
BGC_FP64_Versor turn; BGC_FP64_Versor turn;
// No turn // No turn
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nNo turn:\n"); printf("\nNo turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Turn around (1, 1, 0) axis on 180 degrees // Turn around (1, 1, 0) axis on 180 degrees
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 1.0, 0.0, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 180 degree turn // 180 degree turn
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(&initial_auxiliary, -1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n180 degree turn around (0, 1, 0):\n"); printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 90 degree turn around x3 axis // 90 degree turn around x3 axis
bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 2.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 3.1, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 3.1, 0.0);
bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 0.0, 10.0, 0.0);
bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, -1.0, 0.0, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n90 degree turn around (0, 0, 1):\n"); printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Unorthogonal pairs turn at 90 degrees around x3 axis // Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 2.0, 0.0, 0.0);
bgc_fp64_vector3_make(-2.0, 3.1, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, -2.0, 3.1, 0.0);
bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 0.0, 10.0, 0.0);
bgc_fp64_vector3_make(-1.0, 5.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, -1.0, 5.0, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Zero vectors // Zero vectors
bgc_fp64_vector3_make(0.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 0.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
int code; int code;
code = bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) { if (code >= 0) {
printf("\nZero vectors: this cannot be!\n"); printf("\nZero vectors: this cannot be!\n");
@ -394,12 +394,12 @@ void test_basis_difference_fp64()
} }
// Parallel vectors // Parallel vectors
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 2.0, 0.0, 0.0);
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0);
code = bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
if (code >= 0) { if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n"); printf("\nParallel vectors: this cannot be!\n");
@ -410,60 +410,60 @@ void test_basis_difference_fp64()
} }
// Small angle turn (about 1 degree): // Small angle turn (about 1 degree):
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 0.999848, 0.017452, 0.0);
bgc_fp64_vector3_make(-0.017452, 0.999848, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, -0.017452, 0.999848, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nSmall angle turn (about 1 degree):\n"); printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 179 degrees turn // About 179 degrees turn
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(-0.999848, -0.017452, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, -0.999848, -0.017452, 0.0);
bgc_fp64_vector3_make(0.017452, -0.999848, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 0.017452, -0.999848, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\nAbout 179 degrees turn:\n"); printf("\nAbout 179 degrees turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 120 degrees around (-1, -1, 1) // 120 degrees around (-1, -1, 1)
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(0.0, 0.0, -1.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 0.0, -1.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
printf("\n120 degees turn:\n"); printf("\n120 degees turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions // About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 0.999848, 0.017452, 0.0);
bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0);
bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, -1.0, 0.0, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_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"); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 0.001 degree turn difference between initial_primary and initial_auxiliary directions // About 0.001 degree turn difference between initial_primary and initial_auxiliary directions
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0);
bgc_fp64_vector3_make(1.0, 0.000001, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(&initial_auxiliary, 1.0, 0.000001, 0.0);
bgc_fp64_vector3_make(0.0, -1.0, 0.0, &final_primary); bgc_fp64_vector3_make(&final_primary, 0.0, -1.0, 0.0);
bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(&final_auxiliary, 1.0, 0.0, 0.0);
bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_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"); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
@ -475,23 +475,23 @@ int main()
{ {
//BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f }; //BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
//BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f }; //BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f };
/*
BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f }; BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
BGC_FP32_Versor end = { 0.9999f, 0.01414f, 0.0f, 0.0f }; BGC_FP32_Versor end = { 0.9999f, 0.01414f, 0.0f, 0.0f };
BGC_FP32_Slerp slerp; BGC_FP32_Slerp slerp;
BGC_FP32_Versor result; BGC_FP32_Versor result;
bgc_fp32_slerp_make_full(&start, &end, &slerp); bgc_fp32_slerp_make_full(&slerp, &start, &end);
bgc_fp32_slerp_get_phase_versor(&slerp, 0.5f, &result); bgc_fp32_slerp_get_phase_versor(&result, &slerp, 0.5f);
print_versor_fp32(&result); //print_versor_fp32(&result);
*/
//test_basis_difference_fp64();
printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10)); test_basis_difference_fp64();
printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3)); //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("offsetof(shift) = %zu\n", offsetof(BGC_FP32_Affine3, shift));
printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3)); //printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3));
return 0; return 0;
} }

View file

@ -150,105 +150,9 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="helpers.c" /> <ClCompile Include="helpers.c" />
<ClCompile Include="main.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>
<ItemGroup> <ItemGroup>
<ClInclude Include="helpers.h" /> <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> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View file

@ -3,319 +3,8 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="main.c" /> <ClCompile Include="main.c" />
<ClCompile Include="helpers.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>
<ItemGroup> <ItemGroup>
<ClInclude Include="helpers.h" /> <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> </ItemGroup>
</Project> </Project>

View file

@ -1,31 +1,31 @@
#include "affine2.h" #include "affine2.h"
extern inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * 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_fp64_affine2_reset(BGC_FP64_Affine2* affine);
extern inline void bgc_fp32_affine2_make(const BGC_FP32_Matrix2x2 * distortion, const BGC_FP32_Vector2 * shift, BGC_FP32_Affine2 * 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(const BGC_FP64_Matrix2x2 * distortion, const BGC_FP64_Vector2 * shift, BGC_FP64_Affine2 * affine); 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_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination); extern inline void bgc_fp32_affine2_copy(BGC_FP32_Affine2* destination, const BGC_FP32_Affine2* source);
extern inline void bgc_fp64_affine2_copy(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination); extern inline void bgc_fp64_affine2_copy(BGC_FP64_Affine2* destination, const BGC_FP64_Affine2* source);
extern inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2 * first, BGC_FP32_Affine2 * second); 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 void bgc_fp64_affine2_swap(BGC_FP64_Affine2* first, BGC_FP64_Affine2* second);
extern inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination); extern inline void bgc_fp32_affine2_convert_to_fp64(BGC_FP64_Affine2* destination, const BGC_FP32_Affine2* source);
extern inline void bgc_fp32_affine2_convert_to_fp64(const BGC_FP32_Affine2 * source, BGC_FP64_Affine2 * destination); extern inline void bgc_fp64_affine2_convert_to_fp32(BGC_FP32_Affine2* destination, const BGC_FP64_Affine2* source);
extern inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine); extern inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2* affine);
extern inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine); extern inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2* affine);
extern inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination); 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(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination); extern inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP64_Affine2* affine);
extern inline void bgc_fp32_affine2_combine(const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second, BGC_FP32_Affine2 * combination); 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(const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second, BGC_FP64_Affine2 * combination); 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_fp32_affine2_transform_point(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point, BGC_FP32_Vector2 * transformed_point); 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(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point, BGC_FP64_Vector2 * transformed_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(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector, BGC_FP32_Vector2 * transformed_vector); 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(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector, BGC_FP64_Vector2 * transformed_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,7 +2,7 @@
#define _BGC_AFFINE2_H_INCLUDED_ #define _BGC_AFFINE2_H_INCLUDED_
#include "vector2.h" #include "vector2.h"
#include "matrixes.h" #include "matrices.h"
#include "matrix2x2.h" #include "matrix2x2.h"
// ==================== Types ==================== // // ==================== Types ==================== //
@ -19,13 +19,13 @@ typedef struct {
// ==================== Reset ==================== // // ==================== Reset ==================== //
inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * affine) inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2* affine)
{ {
bgc_fp32_matrix2x2_make_identity(&affine->distortion); bgc_fp32_matrix2x2_make_identity(&affine->distortion);
bgc_fp32_vector2_reset(&affine->shift); bgc_fp32_vector2_reset(&affine->shift);
} }
inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine) inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2* affine)
{ {
bgc_fp64_matrix2x2_make_identity(&affine->distortion); bgc_fp64_matrix2x2_make_identity(&affine->distortion);
bgc_fp64_vector2_reset(&affine->shift); bgc_fp64_vector2_reset(&affine->shift);
@ -33,31 +33,31 @@ inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine)
// ==================== Make ===================== // // ==================== Make ===================== //
inline void bgc_fp32_affine2_make(const BGC_FP32_Matrix2x2 * distortion, const BGC_FP32_Vector2 * shift, BGC_FP32_Affine2 * affine) inline void bgc_fp32_affine2_make(BGC_FP32_Affine2* affine, const BGC_FP32_Matrix2x2* distortion, const BGC_FP32_Vector2* shift)
{ {
bgc_fp32_matrix2x2_copy(distortion, &affine->distortion); bgc_fp32_matrix2x2_copy(&affine->distortion, distortion);
bgc_fp32_vector2_copy(shift, &affine->shift); bgc_fp32_vector2_copy(&affine->shift, shift);
} }
inline void bgc_fp64_affine2_make(const BGC_FP64_Matrix2x2 * distortion, const BGC_FP64_Vector2 * shift, BGC_FP64_Affine2 * affine) inline void bgc_fp64_affine2_make(BGC_FP64_Affine2* affine, const BGC_FP64_Matrix2x2* distortion, const BGC_FP64_Vector2* shift)
{ {
bgc_fp64_matrix2x2_copy(distortion, &affine->distortion); bgc_fp64_matrix2x2_copy(&affine->distortion, distortion);
bgc_fp64_vector2_copy(shift, &affine->shift); bgc_fp64_vector2_copy(&affine->shift, shift);
} }
// ==================== Copy ===================== // // ==================== Copy ===================== //
inline void bgc_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination) inline void bgc_fp32_affine2_copy(BGC_FP32_Affine2* destination, const BGC_FP32_Affine2* source)
{ {
bgc_fp32_matrix2x2_copy(&source->distortion, &destination->distortion); bgc_fp32_matrix2x2_copy(&destination->distortion, &source->distortion);
bgc_fp32_vector2_copy(&source->shift, &destination->shift); bgc_fp32_vector2_copy(&destination->shift, &source->shift);
} }
inline void bgc_fp64_affine2_copy(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination) inline void bgc_fp64_affine2_copy(BGC_FP64_Affine2* destination, const BGC_FP64_Affine2* source)
{ {
bgc_fp64_matrix2x2_copy(&source->distortion, &destination->distortion); bgc_fp64_matrix2x2_copy(&destination->distortion, &source->distortion);
bgc_fp64_vector2_copy(&source->shift, &destination->shift); bgc_fp64_vector2_copy(&destination->shift, &source->shift);
} }
// ==================== Swap ===================== // // ==================== Swap ===================== //
@ -76,16 +76,16 @@ inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2 * first, BGC_FP64_Affine2 * s
// =================== Convert =================== // // =================== Convert =================== //
inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination) inline void bgc_fp32_affine2_convert_to_fp64(BGC_FP64_Affine2* destination, const BGC_FP32_Affine2* source)
{ {
bgc_fp64_matrix2x2_convert_to_fp32(&source->distortion, &destination->distortion); bgc_fp32_matrix2x2_convert_to_fp64(&destination->distortion, &source->distortion);
bgc_fp64_vector2_convert_to_fp32(&source->shift, &destination->shift); bgc_fp32_vector2_convert_to_fp64(&destination->shift, &source->shift);
} }
inline void bgc_fp32_affine2_convert_to_fp64(const BGC_FP32_Affine2 * source, BGC_FP64_Affine2 * destination) inline void bgc_fp64_affine2_convert_to_fp32(BGC_FP32_Affine2* destination, const BGC_FP64_Affine2 * source)
{ {
bgc_fp32_matrix2x2_convert_to_fp64(&source->distortion, &destination->distortion); bgc_fp64_matrix2x2_convert_to_fp32(&destination->distortion, &source->distortion);
bgc_fp32_vector2_convert_to_fp64(&source->shift, &destination->shift); bgc_fp64_vector2_convert_to_fp32(&destination->shift, &source->shift);
} }
// =================== Invert ==================== // // =================== Invert ==================== //
@ -96,7 +96,7 @@ inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine)
return 0; return 0;
} }
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift); bgc_fp32_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp32_vector2_revert(&affine->shift); bgc_fp32_vector2_revert(&affine->shift);
return 1; return 1;
@ -108,7 +108,7 @@ inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine)
return 0; return 0;
} }
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift); bgc_fp64_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp64_vector2_revert(&affine->shift); bgc_fp64_vector2_revert(&affine->shift);
return 1; return 1;
@ -116,74 +116,74 @@ inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine)
// ================= Get Inverse ================= // // ================= Get Inverse ================= //
inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination) inline int bgc_fp32_affine2_get_inverse(BGC_FP32_Affine2* inverse, const BGC_FP32_Affine2 * affine)
{ {
if (!bgc_fp32_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) { if (!bgc_fp32_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) {
return 0; return 0;
} }
bgc_fp32_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift); bgc_fp32_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
bgc_fp32_vector2_revert(&destination->shift); bgc_fp32_vector2_revert(&inverse->shift);
return 1; return 1;
} }
inline int bgc_fp64_affine2_get_inverse(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination) inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP64_Affine2 * affine)
{ {
if (!bgc_fp64_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) { if (!bgc_fp64_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) {
return 0; return 0;
} }
bgc_fp64_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift); bgc_fp64_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
bgc_fp64_vector2_revert(&destination->shift); bgc_fp64_vector2_revert(&inverse->shift);
return 1; return 1;
} }
// =================== Combine =================== // // =================== Combine =================== //
inline void bgc_fp32_affine2_combine(const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second, BGC_FP32_Affine2 * combination) inline void bgc_fp32_affine2_combine(BGC_FP32_Affine2* combination, const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second)
{ {
BGC_FP32_Vector2 first_shift; BGC_FP32_Vector2 first_shift;
bgc_fp32_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift); bgc_fp32_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift);
bgc_fp32_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion); bgc_fp32_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp32_vector2_add(&first_shift, &second->shift, &combination->shift); bgc_fp32_vector2_add(&combination->shift, &second->shift, &first_shift);
} }
inline void bgc_fp64_affine2_combine(const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second, BGC_FP64_Affine2 * combination) inline void bgc_fp64_affine2_combine(BGC_FP64_Affine2* combination, const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second)
{ {
BGC_FP64_Vector2 first_shift; BGC_FP64_Vector2 first_shift;
bgc_fp64_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift); bgc_fp64_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift);
bgc_fp64_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion); bgc_fp64_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp64_vector2_add(&first_shift, &second->shift, &combination->shift); bgc_fp64_vector2_add(&combination->shift, &second->shift, &first_shift);
} }
// =============== Transform Point =============== // // =============== Transform Point =============== //
inline void bgc_fp32_affine2_transform_point(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point, BGC_FP32_Vector2 * 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)
{ {
BGC_FP32_Vector2 distorted; BGC_FP32_Vector2 distorted;
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted); bgc_fp32_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point);
bgc_fp32_vector2_add(&affine->shift, &distorted, transformed_point); bgc_fp32_vector2_add(transformed_point, &affine->shift, &distorted);
} }
inline void bgc_fp64_affine2_transform_point(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point, BGC_FP64_Vector2 * 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)
{ {
BGC_FP64_Vector2 distorted; BGC_FP64_Vector2 distorted;
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted); bgc_fp64_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point);
bgc_fp64_vector2_add(&affine->shift, &distorted, transformed_point); bgc_fp64_vector2_add(transformed_point, &affine->shift, &distorted);
} }
// ============== Transform Vector =============== // // ============== Transform Vector =============== //
inline void bgc_fp32_affine2_transform_vector(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector, BGC_FP32_Vector2 * 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_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector); bgc_fp32_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector);
} }
inline void bgc_fp64_affine2_transform_vector(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector, BGC_FP64_Vector2 * 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_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector); bgc_fp64_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector);
} }
#endif #endif

View file

@ -1,31 +1,31 @@
#include "affine3.h" #include "affine3.h"
extern inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3 * 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_fp64_affine3_reset(BGC_FP64_Affine3* affine);
extern inline void bgc_fp32_affine3_make(const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift, BGC_FP32_Affine3 * 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(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine); 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_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination); extern inline void bgc_fp32_affine3_copy(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3* source);
extern inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination); extern inline void bgc_fp64_affine3_copy(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3* source);
extern inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second); 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 void bgc_fp64_affine3_swap(BGC_FP64_Affine3* first, BGC_FP64_Affine3* second);
extern inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination); extern inline void bgc_fp32_affine3_convert_to_fp64(BGC_FP64_Affine3* destination, const BGC_FP32_Affine3* source);
extern inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination); extern inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, const BGC_FP64_Affine3* source);
extern inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine); extern inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3* affine);
extern inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine); extern inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3* affine);
extern inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination); 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(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination); extern inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* inverse, const BGC_FP64_Affine3* affine);
extern inline void bgc_fp32_affine3_combine(const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second, BGC_FP32_Affine3 * combination); 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(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination); 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_fp32_affine3_transform_point(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point, BGC_FP32_Vector3 * transformed_point); 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(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point, BGC_FP64_Vector3 * transformed_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(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector, BGC_FP32_Vector3 * transformed_vector); 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(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector, BGC_FP64_Vector3 * transformed_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,7 +2,7 @@
#define _BGC_AFFINE3_H_INCLUDED_ #define _BGC_AFFINE3_H_INCLUDED_
#include "vector3.h" #include "vector3.h"
#include "matrixes.h" #include "matrices.h"
#include "matrix3x3.h" #include "matrix3x3.h"
// ==================== Types ==================== // // ==================== Types ==================== //
@ -33,58 +33,58 @@ inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine)
// ==================== Make ===================== // // ==================== Make ===================== //
inline void bgc_fp32_affine3_make(const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift, BGC_FP32_Affine3 * affine) inline void bgc_fp32_affine3_make(BGC_FP32_Affine3* affine, const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift)
{ {
bgc_fp32_matrix3x3_copy(distortion, &affine->distortion); bgc_fp32_matrix3x3_copy(&affine->distortion, distortion);
bgc_fp32_vector3_copy(shift, &affine->shift); bgc_fp32_vector3_copy(&affine->shift, shift);
} }
inline void bgc_fp64_affine3_make(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine) inline void bgc_fp64_affine3_make(BGC_FP64_Affine3* affine, const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift)
{ {
bgc_fp64_matrix3x3_copy(distortion, &affine->distortion); bgc_fp64_matrix3x3_copy(&affine->distortion, distortion);
bgc_fp64_vector3_copy(shift, &affine->shift); bgc_fp64_vector3_copy(&affine->shift, shift);
} }
// ==================== Copy ===================== // // ==================== Copy ===================== //
inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination) inline void bgc_fp32_affine3_copy(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source)
{ {
bgc_fp32_matrix3x3_copy(&source->distortion, &destination->distortion); bgc_fp32_matrix3x3_copy(&destination->distortion, &source->distortion);
bgc_fp32_vector3_copy(&source->shift, &destination->shift); bgc_fp32_vector3_copy(&destination->shift, &source->shift);
} }
inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination) inline void bgc_fp64_affine3_copy(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source)
{ {
bgc_fp64_matrix3x3_copy(&source->distortion, &destination->distortion); bgc_fp64_matrix3x3_copy(&destination->distortion, &source->distortion);
bgc_fp64_vector3_copy(&source->shift, &destination->shift); bgc_fp64_vector3_copy(&destination->shift, &source->shift);
} }
// ==================== Swap ===================== // // ==================== Swap ===================== //
inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second) inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second)
{ {
bgc_fp32_matrix3x3_copy(&first->distortion, &second->distortion); bgc_fp32_matrix3x3_swap(&first->distortion, &second->distortion);
bgc_fp32_vector3_copy(&first->shift, &second->shift); bgc_fp32_vector3_swap(&first->shift, &second->shift);
} }
inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3 * first, BGC_FP64_Affine3 * second) inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3 * first, BGC_FP64_Affine3 * second)
{ {
bgc_fp64_matrix3x3_copy(&first->distortion, &second->distortion); bgc_fp64_matrix3x3_swap(&first->distortion, &second->distortion);
bgc_fp64_vector3_copy(&first->shift, &second->shift); bgc_fp64_vector3_swap(&first->shift, &second->shift);
} }
// =================== Convert =================== // // =================== Convert =================== //
inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination) inline void bgc_fp32_affine3_convert_to_fp64(BGC_FP64_Affine3* destination, const BGC_FP32_Affine3 * source)
{ {
bgc_fp64_matrix3x3_convert_to_fp32(&source->distortion, &destination->distortion); bgc_fp32_matrix3x3_convert_to_fp64(&destination->distortion, &source->distortion);
bgc_fp64_vector3_convert_to_fp32(&source->shift, &destination->shift); bgc_fp32_vector3_convert_to_fp64(&destination->shift, &source->shift);
} }
inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination) inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, const BGC_FP64_Affine3* source)
{ {
bgc_fp32_matrix3x3_convert_to_fp64(&source->distortion, &destination->distortion); bgc_fp64_matrix3x3_convert_to_fp32(&destination->distortion, &source->distortion);
bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift); bgc_fp64_vector3_convert_to_fp32(&destination->shift, &source->shift);
} }
// =================== Invert ==================== // // =================== Invert ==================== //
@ -95,7 +95,7 @@ inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine)
return 0; return 0;
} }
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift); bgc_fp32_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp32_vector3_revert(&affine->shift); bgc_fp32_vector3_revert(&affine->shift);
return 1; return 1;
@ -107,7 +107,7 @@ inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
return 0; return 0;
} }
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift); bgc_fp64_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp64_vector3_revert(&affine->shift); bgc_fp64_vector3_revert(&affine->shift);
return 1; return 1;
@ -115,25 +115,25 @@ inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
// ================= Get Inverse ================= // // ================= Get Inverse ================= //
inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination) inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source)
{ {
if (!bgc_fp32_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) { if (!bgc_fp32_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
return 0; return 0;
} }
bgc_fp32_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift); bgc_fp32_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
bgc_fp32_vector3_revert(&destination->shift); bgc_fp32_vector3_revert(&destination->shift);
return 1; return 1;
} }
inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination) inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source)
{ {
if (!bgc_fp64_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) { if (!bgc_fp64_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
return 0; return 0;
} }
bgc_fp64_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift); bgc_fp64_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
bgc_fp64_vector3_revert(&destination->shift); bgc_fp64_vector3_revert(&destination->shift);
return 1; return 1;
@ -141,48 +141,48 @@ inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP6
// =================== Combine =================== // // =================== Combine =================== //
inline void bgc_fp32_affine3_combine(const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second, BGC_FP32_Affine3 * combination) inline void bgc_fp32_affine3_combine(BGC_FP32_Affine3* combination, const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second)
{ {
BGC_FP32_Vector3 first_shift; BGC_FP32_Vector3 first_shift;
bgc_fp32_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift); bgc_fp32_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
bgc_fp32_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion); bgc_fp32_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp32_vector3_add(&first_shift, &second->shift, &combination->shift); bgc_fp32_vector3_add(&combination->shift, &first_shift, &second->shift);
} }
inline void bgc_fp64_affine3_combine(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination) inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second)
{ {
BGC_FP64_Vector3 first_shift; BGC_FP64_Vector3 first_shift;
bgc_fp64_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift); bgc_fp64_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
bgc_fp64_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion); bgc_fp64_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
bgc_fp64_vector3_add(&first_shift, &second->shift, &combination->shift); bgc_fp64_vector3_add(&combination->shift, &first_shift, &second->shift);
} }
// =============== Transform Point =============== // // =============== Transform Point =============== //
inline void bgc_fp32_affine3_transform_point(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point, BGC_FP32_Vector3 * 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)
{ {
BGC_FP32_Vector3 distorted; BGC_FP32_Vector3 distorted;
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted); bgc_fp32_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
bgc_fp32_vector3_add(&affine->shift, &distorted, transformed_point); bgc_fp32_vector3_add(transformed_point, &affine->shift, &distorted);
} }
inline void bgc_fp64_affine3_transform_point(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point, BGC_FP64_Vector3 * 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)
{ {
BGC_FP64_Vector3 distorted; BGC_FP64_Vector3 distorted;
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted); bgc_fp64_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
bgc_fp64_vector3_add(&affine->shift, &distorted, transformed_point); bgc_fp64_vector3_add(transformed_point, &affine->shift, &distorted);
} }
// ============== Transform Vector =============== // // ============== Transform Vector =============== //
inline void bgc_fp32_affine3_transform_vector(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector, BGC_FP32_Vector3 * 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_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector); bgc_fp32_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
} }
inline void bgc_fp64_affine3_transform_vector(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector, BGC_FP64_Vector3 * 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_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector); bgc_fp64_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
} }
#endif #endif

View file

@ -8,7 +8,7 @@
#include "./vector2.h" #include "./vector2.h"
#include "./vector3.h" #include "./vector3.h"
#include "./matrixes.h" #include "./matrices.h"
#include "./matrix2x2.h" #include "./matrix2x2.h"
#include "./matrix2x3.h" #include "./matrix2x3.h"
#include "./matrix3x2.h" #include "./matrix3x2.h"

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"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
@ -29,7 +29,7 @@
<ClInclude Include="matrix2x3.h" /> <ClInclude Include="matrix2x3.h" />
<ClInclude Include="matrix3x2.h" /> <ClInclude Include="matrix3x2.h" />
<ClInclude Include="matrix3x3.h" /> <ClInclude Include="matrix3x3.h" />
<ClInclude Include="matrixes.h" /> <ClInclude Include="matrices.h" />
<ClInclude Include="position2.h" /> <ClInclude Include="position2.h" />
<ClInclude Include="position3.h" /> <ClInclude Include="position3.h" />
<ClInclude Include="quaternion.h" /> <ClInclude Include="quaternion.h" />
@ -54,7 +54,7 @@
<ClCompile Include="matrix2x3.c" /> <ClCompile Include="matrix2x3.c" />
<ClCompile Include="matrix3x2.c" /> <ClCompile Include="matrix3x2.c" />
<ClCompile Include="matrix3x3.c" /> <ClCompile Include="matrix3x3.c" />
<ClCompile Include="matrixes.c" /> <ClCompile Include="matrices.c" />
<ClCompile Include="quaternion.c" /> <ClCompile Include="quaternion.c" />
<ClCompile Include="rotation3.c" /> <ClCompile Include="rotation3.c" />
<ClCompile Include="slerp.c" /> <ClCompile Include="slerp.c" />

View file

@ -57,7 +57,7 @@
<ClInclude Include="matrix3x2.h"> <ClInclude Include="matrix3x2.h">
<Filter>Файлы заголовков</Filter> <Filter>Файлы заголовков</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="matrixes.h"> <ClInclude Include="matrices.h">
<Filter>Файлы заголовков</Filter> <Filter>Файлы заголовков</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="complex.c"> <ClInclude Include="complex.c">
@ -113,7 +113,7 @@
<ClCompile Include="quaternion.c"> <ClCompile Include="quaternion.c">
<Filter>Исходные файлы</Filter> <Filter>Исходные файлы</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="matrixes.c"> <ClCompile Include="matrices.c">
<Filter>Исходные файлы</Filter> <Filter>Исходные файлы</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="matrix2x3.c"> <ClCompile Include="matrix2x3.c">

View file

@ -3,8 +3,8 @@
extern inline void bgc_fp32_complex_reset(BGC_FP32_Complex* 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_fp64_complex_reset(BGC_FP64_Complex* complex);
extern inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex); extern inline void bgc_fp32_complex_make(BGC_FP32_Complex* complex, const float real, const float imaginary);
extern inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex); extern inline void bgc_fp64_complex_make(BGC_FP64_Complex* complex, const double real, const double imaginary);
extern inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* 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 double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number);
@ -18,75 +18,75 @@ extern inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number);
extern inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* 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 int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number);
extern inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination); extern inline void bgc_fp32_complex_copy(BGC_FP32_Complex* destination, const BGC_FP32_Complex* source);
extern inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination); extern inline void bgc_fp64_complex_copy(BGC_FP64_Complex* destination, const BGC_FP64_Complex* source);
extern inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* 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_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2);
extern inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* 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(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination); extern inline void bgc_fp32_complex_convert_to_fp64(BGC_FP64_Complex* destination, const BGC_FP32_Complex* source);
extern inline void bgc_fp32_complex_revert(BGC_FP32_Complex* 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_fp64_complex_revert(BGC_FP64_Complex* number);
extern inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite); extern inline void bgc_fp64_complex_get_reverse(BGC_FP64_Complex* reverse, const BGC_FP64_Complex* number);
extern inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* 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_fp64_complex_normalize(BGC_FP64_Complex* number);
extern inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized); extern inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const BGC_FP64_Complex* number);
extern inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* 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_fp64_complex_conjugate(BGC_FP64_Complex* number);
extern inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate); extern inline void bgc_fp64_complex_get_conjugate(BGC_FP64_Complex* conjugate, const BGC_FP64_Complex* number);
extern inline int bgc_fp32_complex_invert(BGC_FP32_Complex* 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_fp64_complex_invert(BGC_FP64_Complex* number);
extern inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse); extern inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number);
extern inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* product); 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(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* product); 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_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor, BGC_FP32_Complex* 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(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* quotient); 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_fp32_complex_add(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* sum); 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_fp32_complex_add_scaled(const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale, BGC_FP32_Complex* 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(const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale, BGC_FP64_Complex* sum); 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_fp32_complex_subtract(const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend, BGC_FP32_Complex* 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(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference); 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_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* 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(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* product); extern inline void bgc_fp64_complex_multiply(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier);
extern inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* 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(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient); extern inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor);
extern inline void bgc_fp32_complex_get_mean2(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* mean); 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_fp32_complex_get_mean3(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3, BGC_FP64_Complex* mean); 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_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase, BGC_FP32_Complex* 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(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* interpolation); 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_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* 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); extern inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent, BGC_FP32_Complex* 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_fp32_complex_get_square_modulus(base); const float square_modulus = bgc_fp32_complex_get_square_modulus(base);
@ -106,7 +106,7 @@ void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float r
power->imaginary = power_modulus * sinf(power_angle); power->imaginary = power_modulus * sinf(power_angle);
} }
void bgc_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* 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_fp64_complex_get_square_modulus(base); const double square_modulus = bgc_fp64_complex_get_square_modulus(base);

View file

@ -32,13 +32,13 @@ inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex)
// ==================== Set ===================== // // ==================== Set ===================== //
inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex) inline void bgc_fp32_complex_make(BGC_FP32_Complex* complex, const float real, const float imaginary)
{ {
complex->real = real; complex->real = real;
complex->imaginary = imaginary; complex->imaginary = imaginary;
} }
inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex) inline void bgc_fp64_complex_make(BGC_FP64_Complex* complex, const double real, const double imaginary)
{ {
complex->real = real; complex->real = real;
complex->imaginary = imaginary; complex->imaginary = imaginary;
@ -90,13 +90,13 @@ inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number)
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination) inline void bgc_fp32_complex_copy(BGC_FP32_Complex* destination, const BGC_FP32_Complex* source)
{ {
destination->real = source->real; destination->real = source->real;
destination->imaginary = source->imaginary; destination->imaginary = source->imaginary;
} }
inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination) inline void bgc_fp64_complex_copy(BGC_FP64_Complex* destination, const BGC_FP64_Complex* source)
{ {
destination->real = source->real; destination->real = source->real;
destination->imaginary = source->imaginary; destination->imaginary = source->imaginary;
@ -130,13 +130,13 @@ inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* n
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* destination) inline void bgc_fp64_complex_convert_to_fp32(BGC_FP32_Complex* destination, const BGC_FP64_Complex* source)
{ {
destination->real = (float)source->real; destination->real = (float)source->real;
destination->imaginary = (float)source->imaginary; destination->imaginary = (float)source->imaginary;
} }
inline void bgc_fp32_complex_convert_to_fp64(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination) inline void bgc_fp32_complex_convert_to_fp64(BGC_FP64_Complex* destination, const BGC_FP32_Complex* source)
{ {
destination->real = source->real; destination->real = source->real;
destination->imaginary = source->imaginary; destination->imaginary = source->imaginary;
@ -156,16 +156,16 @@ inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number)
number->imaginary = -number->imaginary; number->imaginary = -number->imaginary;
} }
inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* opposite) inline void bgc_fp32_complex_get_reverse(BGC_FP32_Complex* reverse, const BGC_FP32_Complex* number)
{ {
opposite->real = -number->real; reverse->real = -number->real;
opposite->imaginary = -number->imaginary; reverse->imaginary = -number->imaginary;
} }
inline void bgc_fp64_complex_get_reverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite) inline void bgc_fp64_complex_get_reverse(BGC_FP64_Complex* reverse, const BGC_FP64_Complex* number)
{ {
opposite->real = -number->real; reverse->real = -number->real;
opposite->imaginary = -number->imaginary; reverse->imaginary = -number->imaginary;
} }
// ================= Normalize ================== // // ================= Normalize ================== //
@ -210,7 +210,7 @@ inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number)
return 1; return 1;
} }
inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* normalized) inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const BGC_FP32_Complex* number)
{ {
const float square_modulus = bgc_fp32_complex_get_square_modulus(number); const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
@ -234,7 +234,7 @@ inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_F
return 1; return 1;
} }
inline int bgc_fp64_complex_get_normalized(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized) inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const BGC_FP64_Complex* number)
{ {
const double square_modulus = bgc_fp64_complex_get_square_modulus(number); const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
@ -270,13 +270,13 @@ inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number)
number->imaginary = -number->imaginary; number->imaginary = -number->imaginary;
} }
inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* conjugate) inline void bgc_fp32_complex_get_conjugate(BGC_FP32_Complex* conjugate, const BGC_FP32_Complex* number)
{ {
conjugate->real = number->real; conjugate->real = number->real;
conjugate->imaginary = -number->imaginary; conjugate->imaginary = -number->imaginary;
} }
inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate) inline void bgc_fp64_complex_get_conjugate(BGC_FP64_Complex* conjugate, const BGC_FP64_Complex* number)
{ {
conjugate->real = number->real; conjugate->real = number->real;
conjugate->imaginary = -number->imaginary; conjugate->imaginary = -number->imaginary;
@ -284,7 +284,7 @@ inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_F
// =================== Invert =================== // // =================== Invert =================== //
inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* inverse) inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP32_Complex* number)
{ {
const float square_modulus = bgc_fp32_complex_get_square_modulus(number); const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
@ -300,7 +300,7 @@ inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32
return 1; return 1;
} }
inline int bgc_fp64_complex_get_inverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse) inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number)
{ {
const double square_modulus = bgc_fp64_complex_get_square_modulus(number); const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
@ -328,19 +328,19 @@ inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number)
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent, BGC_FP32_Complex* 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_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* 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 ===================== // // ==================== Add ===================== //
inline void bgc_fp32_complex_add(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* 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->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary; sum->imaginary = number1->imaginary + number2->imaginary;
} }
inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* 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->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary; sum->imaginary = number1->imaginary + number2->imaginary;
@ -348,13 +348,13 @@ inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_fp32_complex_add_scaled(const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale, BGC_FP32_Complex* 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->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale; sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
} }
inline void bgc_fp64_complex_add_scaled(const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale, BGC_FP64_Complex* 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->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale; sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
@ -362,7 +362,7 @@ inline void bgc_fp64_complex_add_scaled(const BGC_FP64_Complex* basic_number, co
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_fp32_complex_subtract(const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend, BGC_FP32_Complex* 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->real = minuend->real - subtrahend->real;
difference->imaginary = minuend->imaginary - subtrahend->imaginary; difference->imaginary = minuend->imaginary - subtrahend->imaginary;
@ -376,7 +376,7 @@ inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* 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 real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real; const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -385,7 +385,7 @@ inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const
product->imaginary = imaginary; product->imaginary = imaginary;
} }
inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* 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 real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real; const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -396,13 +396,13 @@ inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const
// ============= Multiply By Number ============= // // ============= Multiply By Number ============= //
inline void bgc_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* 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->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier; product->imaginary = multiplicand->imaginary * multiplier;
} }
inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* 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->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier; product->imaginary = multiplicand->imaginary * multiplier;
@ -410,7 +410,7 @@ inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, cons
// =================== Divide =================== // // =================== Divide =================== //
inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor, BGC_FP32_Complex* 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_fp32_complex_get_square_modulus(divisor); const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
@ -429,7 +429,7 @@ inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BG
return 1; return 1;
} }
inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* 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_fp64_complex_get_square_modulus(divisor); const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
@ -450,25 +450,25 @@ inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BG
// ============== Divide By Number ============== // // ============== Divide By Number ============== //
inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* quotient) inline void bgc_fp32_complex_divide(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor)
{ {
bgc_fp32_complex_multiply(dividend, 1.0f / divisor, quotient); bgc_fp32_complex_multiply(quotient, dividend, 1.0f / divisor);
} }
inline void bgc_fp64_complex_divide(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient) inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor)
{ {
bgc_fp64_complex_multiply(dividend, 1.0 / divisor, quotient); bgc_fp64_complex_multiply(quotient, dividend, 1.0 / divisor);
} }
// ================== Average2 ================== // // ================== Average2 ================== //
inline void bgc_fp32_complex_get_mean2(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* 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->real = (number1->real + number2->real) * 0.5f;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5f; mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5f;
} }
inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* 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->real = (number1->real + number2->real) * 0.5;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5; mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5;
@ -476,13 +476,13 @@ inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BG
// ================== Average3 ================== // // ================== Average3 ================== //
inline void bgc_fp32_complex_get_mean3(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3, BGC_FP32_Complex* 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_FP32_ONE_THIRD; mean->real = (number1->real + number2->real + number3->real) * BGC_FP32_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP32_ONE_THIRD; mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP32_ONE_THIRD;
} }
inline void bgc_fp64_complex_get_mean3(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3, BGC_FP64_Complex* 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_FP64_ONE_THIRD; mean->real = (number1->real + number2->real + number3->real) * BGC_FP64_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP64_ONE_THIRD; mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP64_ONE_THIRD;
@ -490,7 +490,7 @@ inline void bgc_fp64_complex_get_mean3(const BGC_FP64_Complex* number1, const BG
// =================== Linear =================== // // =================== Linear =================== //
inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase, BGC_FP32_Complex* 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 counter_phase = 1.0f - phase; const float counter_phase = 1.0f - phase;
@ -498,7 +498,7 @@ inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const
interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase; interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase;
} }
inline void bgc_fp64_complex_interpolate(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* 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 counter_phase = 1.0 - phase; const double counter_phase = 1.0 - phase;

View file

@ -7,11 +7,11 @@ const BGC_FP64_CotesNumber BGC_FP64_IDLE_COTES_NUMBER = { 1.0, 0.0 };
extern inline void bgc_fp32_cotes_number_reset(BGC_FP32_CotesNumber* number); extern inline void bgc_fp32_cotes_number_reset(BGC_FP32_CotesNumber* number);
extern inline void bgc_fp64_cotes_number_reset(BGC_FP64_CotesNumber* number); extern inline void bgc_fp64_cotes_number_reset(BGC_FP64_CotesNumber* number);
extern inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_CotesNumber* number); extern inline void bgc_fp32_cotes_number_make(BGC_FP32_CotesNumber* number, const float x1, const float x2);
extern inline void bgc_fp64_cotes_number_make(const double x1, const double x2, BGC_FP64_CotesNumber* number); extern inline void bgc_fp64_cotes_number_make(BGC_FP64_CotesNumber* number, const double x1, const double x2);
extern inline void bgc_fp32_cotes_number_make_for_angle(const float angle, const int angle_unit, BGC_FP32_CotesNumber* number); extern inline void bgc_fp32_cotes_number_make_for_angle(BGC_FP32_CotesNumber* number, const float angle, const int angle_unit);
extern inline void bgc_fp64_cotes_number_make_for_angle(const double angle, const int angle_unit, BGC_FP64_CotesNumber* number); extern inline void bgc_fp64_cotes_number_make_for_angle(BGC_FP64_CotesNumber* number, const double angle, const int angle_unit);
extern inline int bgc_fp32_cotes_number_is_idle(const BGC_FP32_CotesNumber* number); extern inline int bgc_fp32_cotes_number_is_idle(const BGC_FP32_CotesNumber* number);
extern inline int bgc_fp64_cotes_number_is_idle(const BGC_FP64_CotesNumber* number); extern inline int bgc_fp64_cotes_number_is_idle(const BGC_FP64_CotesNumber* number);
@ -19,41 +19,41 @@ extern inline int bgc_fp64_cotes_number_is_idle(const BGC_FP64_CotesNumber* numb
extern inline float bgc_fp32_cotes_number_get_angle(const BGC_FP32_CotesNumber* number, const int angle_unit); extern inline float bgc_fp32_cotes_number_get_angle(const BGC_FP32_CotesNumber* number, const int angle_unit);
extern inline double bgc_fp64_cotes_number_get_angle(const BGC_FP64_CotesNumber* number, const int angle_unit); extern inline double bgc_fp64_cotes_number_get_angle(const BGC_FP64_CotesNumber* number, const int angle_unit);
extern inline void bgc_fp32_cotes_number_copy(const BGC_FP32_CotesNumber* source, BGC_FP32_CotesNumber* destination); extern inline void bgc_fp32_cotes_number_copy(BGC_FP32_CotesNumber* destination, const BGC_FP32_CotesNumber* source);
extern inline void bgc_fp64_cotes_number_copy(const BGC_FP64_CotesNumber* source, BGC_FP64_CotesNumber* destination); extern inline void bgc_fp64_cotes_number_copy(BGC_FP64_CotesNumber* destination, const BGC_FP64_CotesNumber* source);
extern inline void bgc_fp32_cotes_number_swap(BGC_FP32_CotesNumber* number1, BGC_FP32_CotesNumber* number2); extern inline void bgc_fp32_cotes_number_swap(BGC_FP32_CotesNumber* number1, BGC_FP32_CotesNumber* number2);
extern inline void bgc_fp64_cotes_number_swap(BGC_FP64_CotesNumber* number1, BGC_FP64_CotesNumber* number2); extern inline void bgc_fp64_cotes_number_swap(BGC_FP64_CotesNumber* number1, BGC_FP64_CotesNumber* number2);
extern inline void bgc_fp64_cotes_number_convert_to_fp32(const BGC_FP64_CotesNumber* source, BGC_FP32_CotesNumber* destination); extern inline void bgc_fp64_cotes_number_convert_to_fp32(BGC_FP32_CotesNumber* destination, const BGC_FP64_CotesNumber* source);
extern inline void bgc_fp32_cotes_number_convert_to_fp64(const BGC_FP32_CotesNumber* source, BGC_FP64_CotesNumber* destination); extern inline void bgc_fp32_cotes_number_convert_to_fp64(BGC_FP64_CotesNumber* destination, const BGC_FP32_CotesNumber* source);
extern inline void bgc_fp32_cotes_number_revert(BGC_FP32_CotesNumber* number); extern inline void bgc_fp32_cotes_number_revert(BGC_FP32_CotesNumber* number);
extern inline void bgc_fp64_cotes_number_revert(BGC_FP64_CotesNumber* number); extern inline void bgc_fp64_cotes_number_revert(BGC_FP64_CotesNumber* number);
extern inline void bgc_fp32_cotes_number_get_reverse(const BGC_FP32_CotesNumber* number, BGC_FP32_CotesNumber* inverse); extern inline void bgc_fp32_cotes_number_get_reverse(BGC_FP32_CotesNumber* reverse, const BGC_FP32_CotesNumber* number);
extern inline void bgc_fp64_cotes_number_get_inverse(const BGC_FP64_CotesNumber* number, BGC_FP64_CotesNumber* inverse); extern inline void bgc_fp64_cotes_number_get_reverse(BGC_FP64_CotesNumber* reverse, const BGC_FP64_CotesNumber* number);
extern inline void bgc_fp32_cotes_number_get_exponation(const BGC_FP32_CotesNumber* base, const float exponent, BGC_FP32_CotesNumber* power); extern inline void bgc_fp32_cotes_number_get_exponation(BGC_FP32_CotesNumber* power, const BGC_FP32_CotesNumber* base, const float exponent);
extern inline void bgc_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* base, const double exponent, BGC_FP64_CotesNumber* power); extern inline void bgc_fp64_cotes_number_get_exponation(BGC_FP64_CotesNumber* power, const BGC_FP64_CotesNumber* base, const double exponent);
extern inline void bgc_fp32_cotes_number_combine(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2, BGC_FP32_CotesNumber* result); extern inline void bgc_fp32_cotes_number_combine(BGC_FP32_CotesNumber* combination, const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2);
extern inline void bgc_fp64_cotes_number_combine(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2, BGC_FP64_CotesNumber* result); extern inline void bgc_fp64_cotes_number_combine(BGC_FP64_CotesNumber* combination, const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2);
extern inline void bgc_fp32_cotes_number_exclude(const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant, BGC_FP32_CotesNumber* difference); extern inline void bgc_fp32_cotes_number_exclude(BGC_FP32_CotesNumber* difference, const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant);
extern inline void bgc_fp64_cotes_number_exclude(const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant, BGC_FP64_CotesNumber* difference); extern inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant);
extern inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix); extern inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number);
extern inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix); extern inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number);
extern inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix); extern inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number);
extern inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix); extern inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number);
extern inline void bgc_fp32_cotes_number_turn_vector(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result); extern inline void bgc_fp32_cotes_number_turn_vector(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector);
extern inline void bgc_fp64_cotes_number_turn_vector(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result); extern inline void bgc_fp64_cotes_number_turn_vector(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector);
extern inline void bgc_fp32_cotes_number_turn_vector_back(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result); extern inline void bgc_fp32_cotes_number_turn_vector_back(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector);
extern inline void bgc_fp64_cotes_number_turn_vector_back(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result); extern inline void bgc_fp64_cotes_number_turn_vector_back(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector);
extern inline int bgc_fp32_cotes_number_are_close(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2); extern inline int bgc_fp32_cotes_number_are_close(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2);
extern inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2); extern inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2);

View file

@ -41,7 +41,7 @@ inline void bgc_fp64_cotes_number_reset(BGC_FP64_CotesNumber* number)
// ================== Set Turn ================== // // ================== Set Turn ================== //
inline void bgc_fp32_cotes_number_make_for_angle(const float angle, const int angle_unit, BGC_FP32_CotesNumber* number) inline void bgc_fp32_cotes_number_make_for_angle(BGC_FP32_CotesNumber* number, const float angle, const int angle_unit)
{ {
const float radians = bgc_fp32_angle_to_radians(angle, angle_unit); const float radians = bgc_fp32_angle_to_radians(angle, angle_unit);
@ -49,7 +49,7 @@ inline void bgc_fp32_cotes_number_make_for_angle(const float angle, const int an
number->_sin = sinf(radians); number->_sin = sinf(radians);
} }
inline void bgc_fp64_cotes_number_make_for_angle(const double angle, const int angle_unit, BGC_FP64_CotesNumber* number) inline void bgc_fp64_cotes_number_make_for_angle(BGC_FP64_CotesNumber* number, const double angle, const int angle_unit)
{ {
const double radians = bgc_fp64_angle_to_radians(angle, angle_unit); const double radians = bgc_fp64_angle_to_radians(angle, angle_unit);
@ -76,7 +76,7 @@ void _bgc_fp32_cotes_number_normalize(BGC_FP32_CotesNumber* twin);
void _bgc_fp64_cotes_number_normalize(BGC_FP64_CotesNumber* twin); void _bgc_fp64_cotes_number_normalize(BGC_FP64_CotesNumber* twin);
inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_CotesNumber* number) inline void bgc_fp32_cotes_number_make(BGC_FP32_CotesNumber* number, const float x1, const float x2)
{ {
const float square_modulus = x1 * x1 + x2 * x2; const float square_modulus = x1 * x1 + x2 * x2;
@ -88,7 +88,7 @@ inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_
} }
} }
inline void bgc_fp64_cotes_number_make(const double x1, const double x2, BGC_FP64_CotesNumber* number) inline void bgc_fp64_cotes_number_make(BGC_FP64_CotesNumber* number, const double x1, const double x2)
{ {
const double square_modulus = x1 * x1 + x2 * x2; const double square_modulus = x1 * x1 + x2 * x2;
@ -114,13 +114,13 @@ inline double bgc_fp64_cotes_number_get_angle(const BGC_FP64_CotesNumber* number
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_fp32_cotes_number_copy(const BGC_FP32_CotesNumber* source, BGC_FP32_CotesNumber* destination) inline void bgc_fp32_cotes_number_copy(BGC_FP32_CotesNumber* destination, const BGC_FP32_CotesNumber* source)
{ {
destination->_cos = source->_cos; destination->_cos = source->_cos;
destination->_sin = source->_sin; destination->_sin = source->_sin;
} }
inline void bgc_fp64_cotes_number_copy(const BGC_FP64_CotesNumber* source, BGC_FP64_CotesNumber* destination) inline void bgc_fp64_cotes_number_copy(BGC_FP64_CotesNumber* destination, const BGC_FP64_CotesNumber* source)
{ {
destination->_cos = source->_cos; destination->_cos = source->_cos;
destination->_sin = source->_sin; destination->_sin = source->_sin;
@ -154,14 +154,14 @@ inline void bgc_fp64_cotes_number_swap(BGC_FP64_CotesNumber* number1, BGC_FP64_C
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_fp64_cotes_number_convert_to_fp32(const BGC_FP64_CotesNumber* source, BGC_FP32_CotesNumber* destination) inline void bgc_fp64_cotes_number_convert_to_fp32(BGC_FP32_CotesNumber* destination, const BGC_FP64_CotesNumber* source)
{ {
bgc_fp32_cotes_number_make((float)source->_cos, (float)source->_sin, destination); bgc_fp32_cotes_number_make(destination, (float)source->_cos, (float)source->_sin);
} }
inline void bgc_fp32_cotes_number_convert_to_fp64(const BGC_FP32_CotesNumber* source, BGC_FP64_CotesNumber* destination) inline void bgc_fp32_cotes_number_convert_to_fp64(BGC_FP64_CotesNumber* destination, const BGC_FP32_CotesNumber* source)
{ {
bgc_fp64_cotes_number_make((double)source->_cos, (double)source->_sin, destination); bgc_fp64_cotes_number_make(destination, (double)source->_cos, (double)source->_sin);
} }
// =================== Revert =================== // // =================== Revert =================== //
@ -176,21 +176,21 @@ inline void bgc_fp64_cotes_number_revert(BGC_FP64_CotesNumber* number)
number->_sin = -number->_sin; number->_sin = -number->_sin;
} }
inline void bgc_fp32_cotes_number_get_reverse(const BGC_FP32_CotesNumber* number, BGC_FP32_CotesNumber* inverse) inline void bgc_fp32_cotes_number_get_reverse(BGC_FP32_CotesNumber* reverse, const BGC_FP32_CotesNumber* number)
{ {
inverse->_cos = number->_cos; reverse->_cos = number->_cos;
inverse->_sin = -number->_sin; reverse->_sin = -number->_sin;
} }
inline void bgc_fp64_cotes_number_get_inverse(const BGC_FP64_CotesNumber* number, BGC_FP64_CotesNumber* inverse) inline void bgc_fp64_cotes_number_get_reverse(BGC_FP64_CotesNumber* reverse, const BGC_FP64_CotesNumber* number)
{ {
inverse->_cos = number->_cos; reverse->_cos = number->_cos;
inverse->_sin = -number->_sin; reverse->_sin = -number->_sin;
} }
// ================= Exponation ================= // // ================= Exponation ================= //
inline void bgc_fp32_cotes_number_get_exponation(const BGC_FP32_CotesNumber* base, const float exponent, BGC_FP32_CotesNumber* power) inline void bgc_fp32_cotes_number_get_exponation(BGC_FP32_CotesNumber* power, const BGC_FP32_CotesNumber* base, const float exponent)
{ {
const float power_angle = exponent * atan2f(base->_sin, base->_cos); const float power_angle = exponent * atan2f(base->_sin, base->_cos);
@ -198,7 +198,7 @@ inline void bgc_fp32_cotes_number_get_exponation(const BGC_FP32_CotesNumber* bas
power->_sin = sinf(power_angle); power->_sin = sinf(power_angle);
} }
inline void bgc_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* base, const double exponent, BGC_FP64_CotesNumber* power) inline void bgc_fp64_cotes_number_get_exponation(BGC_FP64_CotesNumber* power, const BGC_FP64_CotesNumber* base, const double exponent)
{ {
const double power_angle = exponent * atan2(base->_sin, base->_cos); const double power_angle = exponent * atan2(base->_sin, base->_cos);
@ -208,47 +208,47 @@ inline void bgc_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* bas
// ================ Combination ================= // // ================ Combination ================= //
inline void bgc_fp32_cotes_number_combine(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2, BGC_FP32_CotesNumber* result) inline void bgc_fp32_cotes_number_combine(BGC_FP32_CotesNumber* combination, const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2)
{ {
bgc_fp32_cotes_number_make( bgc_fp32_cotes_number_make(
combination,
number1->_cos * number2->_cos - number1->_sin * number2->_sin, number1->_cos * number2->_cos - number1->_sin * number2->_sin,
number1->_cos * number2->_sin + number1->_sin * number2->_cos, number1->_cos * number2->_sin + number1->_sin * number2->_cos
result
); );
} }
inline void bgc_fp64_cotes_number_combine(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2, BGC_FP64_CotesNumber* result) inline void bgc_fp64_cotes_number_combine(BGC_FP64_CotesNumber* combination, const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2)
{ {
bgc_fp64_cotes_number_make( bgc_fp64_cotes_number_make(
combination,
number1->_cos * number2->_cos - number1->_sin * number2->_sin, number1->_cos * number2->_cos - number1->_sin * number2->_sin,
number1->_cos * number2->_sin + number1->_sin * number2->_cos, number1->_cos * number2->_sin + number1->_sin * number2->_cos
result
); );
} }
// ================= Exclusion ================== // // ================= Exclusion ================== //
inline void bgc_fp32_cotes_number_exclude(const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant, BGC_FP32_CotesNumber* difference) inline void bgc_fp32_cotes_number_exclude(BGC_FP32_CotesNumber* difference, const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant)
{ {
bgc_fp32_cotes_number_make( bgc_fp32_cotes_number_make(
difference,
base->_cos * excludant->_cos + base->_sin * excludant->_sin, base->_cos * excludant->_cos + base->_sin * excludant->_sin,
base->_sin * excludant->_cos - base->_cos * excludant->_sin, base->_sin * excludant->_cos - base->_cos * excludant->_sin
difference
); );
} }
inline void bgc_fp64_cotes_number_exclude(const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant, BGC_FP64_CotesNumber* difference) inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant)
{ {
bgc_fp64_cotes_number_make( bgc_fp64_cotes_number_make(
difference,
base->_cos * excludant->_cos + base->_sin * excludant->_sin, base->_cos * excludant->_cos + base->_sin * excludant->_sin,
base->_sin * excludant->_cos - base->_cos * excludant->_sin, base->_sin * excludant->_cos - base->_cos * excludant->_sin
difference
); );
} }
// ============== Rotation Matrix =============== // // ============== Rotation Matrix =============== //
inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix) inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin; matrix->r1c2 = -number->_sin;
@ -256,7 +256,7 @@ inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber
matrix->r2c2 = number->_cos; matrix->r2c2 = number->_cos;
} }
inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix) inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin; matrix->r1c2 = -number->_sin;
@ -266,7 +266,7 @@ inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber
// ============== Reverse Matrix ================ // // ============== Reverse Matrix ================ //
inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix) inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin; matrix->r1c2 = number->_sin;
@ -274,7 +274,7 @@ inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber*
matrix->r2c2 = number->_cos; matrix->r2c2 = number->_cos;
} }
inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix) inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin; matrix->r1c2 = number->_sin;
@ -284,42 +284,42 @@ inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber*
// ================ Turn Vector ================= // // ================ Turn Vector ================= //
inline void bgc_fp32_cotes_number_turn_vector(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result) inline void bgc_fp32_cotes_number_turn_vector(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector)
{ {
const float x1 = number->_cos * vector->x1 - number->_sin * vector->x2; const float x1 = number->_cos * vector->x1 - number->_sin * vector->x2;
const float x2 = number->_sin * vector->x1 + number->_cos * vector->x2; const float x2 = number->_sin * vector->x1 + number->_cos * vector->x2;
result->x1 = x1; turned_vector->x1 = x1;
result->x2 = x2; turned_vector->x2 = x2;
} }
inline void bgc_fp64_cotes_number_turn_vector(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result) inline void bgc_fp64_cotes_number_turn_vector(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector)
{ {
const double x1 = number->_cos * vector->x1 - number->_sin * vector->x2; const double x1 = number->_cos * vector->x1 - number->_sin * vector->x2;
const double x2 = number->_sin * vector->x1 + number->_cos * vector->x2; const double x2 = number->_sin * vector->x1 + number->_cos * vector->x2;
result->x1 = x1; turned_vector->x1 = x1;
result->x2 = x2; turned_vector->x2 = x2;
} }
// ============ Turn Vector Backward ============ // // ============ Turn Vector Backward ============ //
inline void bgc_fp32_cotes_number_turn_vector_back(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result) inline void bgc_fp32_cotes_number_turn_vector_back(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector)
{ {
const float x1 = number->_sin * vector->x2 + number->_cos * vector->x1; const float x1 = number->_sin * vector->x2 + number->_cos * vector->x1;
const float x2 = number->_cos * vector->x2 - number->_sin * vector->x1; const float x2 = number->_cos * vector->x2 - number->_sin * vector->x1;
result->x1 = x1; turned_vector->x1 = x1;
result->x2 = x2; turned_vector->x2 = x2;
} }
inline void bgc_fp64_cotes_number_turn_vector_back(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result) inline void bgc_fp64_cotes_number_turn_vector_back(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector)
{ {
const double x1 = number->_sin * vector->x2 + number->_cos * vector->x1; const double x1 = number->_sin * vector->x2 + number->_cos * vector->x1;
const double x2 = number->_cos * vector->x2 - number->_sin * vector->x1; const double x2 = number->_cos * vector->x2 - number->_sin * vector->x1;
result->x1 = x1; turned_vector->x1 = x1;
result->x2 = x2; turned_vector->x2 = x2;
} }
// ================== Are Close ================= // // ================== Are Close ================= //

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

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,5 +1,5 @@
#ifndef _BGC_MATRIX_TYPES_H_ #ifndef _BGC_MATRICES_H_
#define _BGC_MATRIX_TYPES_H_ #define _BGC_MATRICES_H_
// ================== Matrix2x2 ================= // // ================== Matrix2x2 ================= //
@ -55,7 +55,7 @@ typedef struct {
// ========== Matrix Product 2x2 at 2x2 ========= // // ========== Matrix Product 2x2 at 2x2 ========= //
inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x2* product) 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 r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -70,7 +70,7 @@ inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(const BGC_FP32_Matrix2x2* m
product->r2c2 = r2c2; product->r2c2 = r2c2;
} }
inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* product) 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 r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -87,7 +87,7 @@ inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(const BGC_FP64_Matrix2x2* m
// ========== Matrix Product 2x2 at 3x2 ========= // // ========== Matrix Product 2x2 at 3x2 ========= //
inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x2* product) 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 r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -106,7 +106,7 @@ inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(const BGC_FP32_Matrix2x2* m
product->r2c3 = r2c3; product->r2c3 = r2c3;
} }
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x2* product) 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 r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -127,7 +127,7 @@ inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(const BGC_FP64_Matrix2x2* m
// ========== Matrix Product 2x3 at 2x2 ========= // // ========== Matrix Product 2x3 at 2x2 ========= //
inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x3* product) 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 r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -148,7 +148,7 @@ inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(const BGC_FP32_Matrix2x3* m
product->r3c2 = r3c2; product->r3c2 = r3c2;
} }
inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x3* product) 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 r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -171,7 +171,7 @@ inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(const BGC_FP64_Matrix2x3* m
// ========== Matrix Product 2x3 at 3x2 ========= // // ========== Matrix Product 2x3 at 3x2 ========= //
inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x3* product) 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->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -186,7 +186,7 @@ inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(const BGC_FP32_Matrix2x3* m
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3; product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
} }
inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x3* product) 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->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -203,7 +203,7 @@ inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(const BGC_FP64_Matrix2x3* m
// ========== Matrix Product 3x2 at 2x3 ========= // // ========== Matrix Product 3x2 at 2x3 ========= //
inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x2* product) 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->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->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
@ -212,7 +212,7 @@ inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(const BGC_FP32_Matrix3x2* m
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2; product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
} }
inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x2* product) 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->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->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
@ -223,7 +223,7 @@ inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(const BGC_FP64_Matrix3x2* m
// ========== Matrix Product 3x2 at 3x3 ========= // // ========== Matrix Product 3x2 at 3x3 ========= //
inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x2* product) 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 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 r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
@ -242,7 +242,7 @@ inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(const BGC_FP32_Matrix3x2* m
product->r2c3 = r2c3; product->r2c3 = r2c3;
} }
inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x2* product) 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 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 r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
@ -263,7 +263,7 @@ inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(const BGC_FP64_Matrix3x2* m
// ========== Matrix Product 3x3 at 2x3 ========= // // ========== Matrix Product 3x3 at 2x3 ========= //
inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x3* product) 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 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 r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
@ -284,7 +284,7 @@ inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(const BGC_FP32_Matrix3x3* m
product->r3c2 = r3c2; product->r3c2 = r3c2;
} }