Продолжение переименования типов и функций
This commit is contained in:
parent
605afabd94
commit
3b6efaafa9
25 changed files with 768 additions and 916 deletions
|
|
@ -31,7 +31,6 @@
|
||||||
<Add directory="../basic-geometry" />
|
<Add directory="../basic-geometry" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
<Add option="-O2" />
|
|
||||||
<Add option="-s" />
|
<Add option="-s" />
|
||||||
<Add library="basic-geometry" />
|
<Add library="basic-geometry" />
|
||||||
<Add library="m" />
|
<Add library="m" />
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,19 @@
|
||||||
#endif // _WINDOWS_
|
#endif // _WINDOWS_
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// fp32_versor_t versor1, versor2, result;
|
versor_fp32_t versor1, versor2, result;
|
||||||
fp32_matrix3x3_t matrix;
|
matrix3x3_fp32_t matrix;
|
||||||
fp32_vector3_t vector1, vector2;
|
vector3_fp32_t vector1, vector2;
|
||||||
} fp32_structure_t;
|
} structure_fp32_t;
|
||||||
|
|
||||||
fp32_structure_t* allocate_structures(const unsigned int amount)
|
structure_fp32_t* allocate_structures(const unsigned int amount)
|
||||||
{
|
{
|
||||||
return calloc(amount, sizeof(fp32_structure_t));
|
return calloc(amount, sizeof(structure_fp32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
fp32_structure_t* make_structures(const unsigned int amount)
|
structure_fp32_t* make_structures(const unsigned int amount)
|
||||||
{
|
{
|
||||||
fp32_structure_t* list = allocate_structures(amount);
|
structure_fp32_t* list = allocate_structures(amount);
|
||||||
|
|
||||||
if (list == 0) {
|
if (list == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -31,8 +31,7 @@ fp32_structure_t* make_structures(const unsigned int amount)
|
||||||
const float multiplier = 2.0f / RAND_MAX;
|
const float multiplier = 2.0f / RAND_MAX;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
for (unsigned int i = 0; i < amount; i++) {
|
||||||
/*
|
versor_fp32_set_values(
|
||||||
fp32_versor_set_values(
|
|
||||||
rand() * multiplier - 1.0f,
|
rand() * multiplier - 1.0f,
|
||||||
rand() * multiplier - 1.0f,
|
rand() * multiplier - 1.0f,
|
||||||
rand() * multiplier - 1.0f,
|
rand() * multiplier - 1.0f,
|
||||||
|
|
@ -40,7 +39,7 @@ fp32_structure_t* make_structures(const unsigned int amount)
|
||||||
&list[i].versor1
|
&list[i].versor1
|
||||||
);
|
);
|
||||||
|
|
||||||
fp32_versor_set_values(
|
versor_fp32_set_values(
|
||||||
rand() * multiplier - 1.0f,
|
rand() * multiplier - 1.0f,
|
||||||
rand() * multiplier - 1.0f,
|
rand() * multiplier - 1.0f,
|
||||||
rand() * multiplier - 1.0f,
|
rand() * multiplier - 1.0f,
|
||||||
|
|
@ -48,54 +47,54 @@ fp32_structure_t* make_structures(const unsigned int amount)
|
||||||
&list[i].versor2
|
&list[i].versor2
|
||||||
);
|
);
|
||||||
|
|
||||||
fp32_versor_reset(&list[i].result);
|
versor_reset_fp32(&list[i].result);
|
||||||
*/
|
|
||||||
fp32_matrix3x3_set_to_identity(&list[i].matrix);
|
|
||||||
|
|
||||||
fp32_vector3_set_values(
|
matrix3x3_fp32_set_to_identity(&list[i].matrix);
|
||||||
|
|
||||||
|
vector3_set_fp32(
|
||||||
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].vector1
|
&list[i].vector1
|
||||||
);
|
);
|
||||||
|
|
||||||
fp32_vector3_reset(&list[i].vector2);
|
vector3_reset_fp32(&list[i].vector2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_versor(const fp32_versor_t* versor)
|
void print_versor_fp32(const versor_fp32_t* versor)
|
||||||
{
|
{
|
||||||
printf("Versor (%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
printf("Versor (%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_vector(const fp32_vector3_t* vector)
|
void print_versor_fp64(const versor_fp64_t* versor)
|
||||||
{
|
{
|
||||||
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, fp32_vector3_get_modulus(vector));
|
printf("Versor (%lf, %lf, %lf, %lf)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void item_work(fp32_structure_t* item)
|
void print_vector_fp32(const vector3_fp32_t* vector)
|
||||||
{
|
{
|
||||||
//fp32_versor_combine(&item->versor1, &item->versor1, &item->result);
|
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, vector3_get_modulus_fp32(vector));
|
||||||
//fp32_versor_make_rotation_matrix(&item->result, &item->matrix);
|
|
||||||
fp32_matrix3x3_right_product(&item->matrix, &item->vector1, &item->vector2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void circle_work(const unsigned int amount, fp32_structure_t* list)
|
void print_vector_fp64(const vector3_fp64_t* vector)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, vector3_get_modulus_fp64(vector));
|
||||||
//fp32_versor_combine(&list[i].versor1, &list[i].versor1, &list[i].result);
|
}
|
||||||
//fp32_versor_make_rotation_matrix(&list[i].result, &list[i].matrix);
|
|
||||||
fp32_matrix3x3_right_product(&list[i].matrix, &list[i].vector1, &list[i].vector2);
|
void item_work(structure_fp32_t* item)
|
||||||
//fp32_versor_turn(&list[i].result, &list[i].vector1, &list[i].vector2);
|
{
|
||||||
}
|
versor_fp32_combine(&item->versor1, &item->versor1, &item->result);
|
||||||
|
versor_fp32_make_rotation_matrix(&item->result, &item->matrix);
|
||||||
|
matrix3x3_fp32_right_product(&item->matrix, &item->vector1, &item->vector2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const unsigned int amount = 1000000;
|
const unsigned int amount = 1000000;
|
||||||
fp32_structure_t* list;
|
structure_fp32_t* list;
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
ULONGLONG now, start, end;
|
ULONGLONG now, start, end;
|
||||||
|
|
@ -121,14 +120,13 @@ int main()
|
||||||
clock_gettime(CLOCK_REALTIME, &start);
|
clock_gettime(CLOCK_REALTIME, &start);
|
||||||
#endif // _WIN64
|
#endif // _WIN64
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++) {
|
|
||||||
//circle(amount, list);
|
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
for (unsigned int i = 0; i < amount; i++) {
|
||||||
|
for (int j = 0; j < 1000; j++) {
|
||||||
//item_work(list + i);
|
//item_work(list + i);
|
||||||
//fp32_versor_combine(&list[i].versor1, &list[i].versor1, &list[i].result);
|
versor_fp32_combine(&list[i].versor1, &list[i].versor2, &list[i].result);
|
||||||
//fp32_versor_make_rotation_matrix(&list[i].result, &list[i].matrix);
|
versor_fp32_make_rotation_matrix(&list[i].result, &list[i].matrix);
|
||||||
fp32_matrix3x3_right_product(&list[i].matrix, &list[i].vector1, &list[i].vector2);
|
matrix3x3_fp32_right_product(&list[i].matrix, &list[i].vector1, &list[i].vector2);
|
||||||
//fp32_versor_turn(&list[i].result, &list[i].vector1, &list[i].vector2);
|
//versor_fp32_turn(&list[i].result, &list[i].vector1, &list[i].vector2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,196 +140,11 @@ int main()
|
||||||
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
||||||
#endif // _WIN64
|
#endif // _WIN64
|
||||||
|
|
||||||
//print_versor(&list[10].versor1);
|
//print_versor_fp32(&list[10].versor1);
|
||||||
//print_versor(&list[10].versor2);
|
//print_versor_fp32(&list[10].versor2);
|
||||||
//print_versor(&list[10].result);
|
//print_versor_fp32(&list[10].result);
|
||||||
|
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
fp32_vector3_t* allocate_vectors3(const unsigned int amount)
|
|
||||||
{
|
|
||||||
return calloc(amount, sizeof(fp32_vector3_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_vector3_t* make_zero_vectors3(const unsigned int amount)
|
|
||||||
{
|
|
||||||
fp32_vector3_t* list = allocate_vectors3(amount);
|
|
||||||
|
|
||||||
if (list == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
|
||||||
fp32_vector3_reset(&list[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_vector3_t* make_random_vectors3(const unsigned int amount)
|
|
||||||
{
|
|
||||||
fp32_vector3_t* list = allocate_vectors3(amount);
|
|
||||||
|
|
||||||
if (list == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float multiplier = 2.0f / RAND_MAX;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
|
||||||
list[i].x1 = rand() * multiplier - 1.0f;
|
|
||||||
list[i].x2 = rand() * multiplier - 1.0f;
|
|
||||||
list[i].x3 = rand() * multiplier - 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_versor_t* allocate_versors(const unsigned int amount)
|
|
||||||
{
|
|
||||||
return calloc(amount, sizeof(fp32_versor_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_versor_t * make_zero_versors(const unsigned int amount)
|
|
||||||
{
|
|
||||||
fp32_versor_t * list = allocate_versors(amount);
|
|
||||||
|
|
||||||
if (list == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
|
||||||
fp32_versor_reset(&list[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_versor_t * make_random_versors(const unsigned int amount)
|
|
||||||
{
|
|
||||||
fp32_versor_t * list = allocate_versors(amount);
|
|
||||||
|
|
||||||
if (list == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float multiplier = 2.0f / RAND_MAX;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
|
||||||
fp32_versor_set_values(
|
|
||||||
rand() * multiplier - 1.0f,
|
|
||||||
rand() * multiplier - 1.0f,
|
|
||||||
rand() * multiplier - 1.0f,
|
|
||||||
rand() * multiplier - 1.0f,
|
|
||||||
&list[i]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
const unsigned int amount = 1000000;
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
ULONGLONG now, start, end;
|
|
||||||
now = GetTickCount64();
|
|
||||||
srand((unsigned int)(now & 0xfffffff));
|
|
||||||
#else
|
|
||||||
struct timespec now, start, end;
|
|
||||||
clock_gettime(0, &now);
|
|
||||||
srand((unsigned int)(now.tv_nsec & 0xfffffff));
|
|
||||||
#endif // _WIN64
|
|
||||||
|
|
||||||
fp32_versor_t * versors1 = make_random_versors(amount);
|
|
||||||
|
|
||||||
if (versors1 == 0) {
|
|
||||||
printf("Cannot allocate memory for versors1");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_versor_t * versors2 = make_random_versors(amount);
|
|
||||||
|
|
||||||
if (versors2 == 0) {
|
|
||||||
printf("Cannot allocate memory for versors2");
|
|
||||||
free(versors1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_versor_t * results = make_zero_versors(amount);
|
|
||||||
|
|
||||||
if (results == 0) {
|
|
||||||
printf("Cannot allocate memory for results");
|
|
||||||
free(versors2);
|
|
||||||
free(versors1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_matrix3x3_t* matrixes =malloc(amount * sizeof(fp32_matrix3x3_t));
|
|
||||||
|
|
||||||
if (matrixes == 0) {
|
|
||||||
printf("Cannot allocate memory for matrixes");
|
|
||||||
free(results);
|
|
||||||
free(versors2);
|
|
||||||
free(versors1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32_vector3_t* vectors = make_random_vectors3(amount);
|
|
||||||
|
|
||||||
if (results == 0) {
|
|
||||||
printf("Cannot allocate memory for result vectors");
|
|
||||||
free(matrixes);
|
|
||||||
free(results);
|
|
||||||
free(versors2);
|
|
||||||
free(versors1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
end = GetTickCount64();
|
|
||||||
printf("Setup time: %lld\n", end - now);
|
|
||||||
|
|
||||||
start = GetTickCount64();
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
|
||||||
printf("Time: %lf\n", (end.tv_sec - now.tv_sec) * 1000.0 + (end.tv_nsec - now.tv_nsec) * 0.000001);
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &start);
|
|
||||||
#endif // _WIN64
|
|
||||||
for (int j = 0; j < 1000; j++) {
|
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
|
||||||
fp32_versor_combine(&versors1[i], &versors2[i], &results[i]);
|
|
||||||
fp32_versor_make_rotation_matrix(&versors1[i], &matrixes[i]);
|
|
||||||
fp32_matrix3x3_right_product(&matrixes[i], &vectors[i], &vectors[i]);
|
|
||||||
//fp32_versor_turn(&results[i], &vectors[i], &vectors[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
end = GetTickCount64();
|
|
||||||
|
|
||||||
printf("Time: %lld\n", end - start);
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
|
||||||
|
|
||||||
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
|
||||||
#endif // _WIN64
|
|
||||||
|
|
||||||
print_versor(versors1 + 10);
|
|
||||||
print_versor(versors2 + 10);
|
|
||||||
print_versor(results + 10);
|
|
||||||
|
|
||||||
free(vectors);
|
|
||||||
free(matrixes);
|
|
||||||
free(results);
|
|
||||||
free(versors2);
|
|
||||||
free(versors1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include "fp32_vector2_test.h"
|
#include "vector2_fp32_test.h"
|
||||||
|
|
||||||
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
|
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
|
||||||
|
|
||||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1[] = {
|
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1[] = {
|
||||||
{ 3.0f, 4.0f },
|
{ 3.0f, 4.0f },
|
||||||
{ -3.0f, -4.0f },
|
{ -3.0f, -4.0f },
|
||||||
{ 10000.0f, -20000.0f },
|
{ 10000.0f, -20000.0f },
|
||||||
|
|
@ -10,7 +10,7 @@ const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1[] = {
|
||||||
{ -123.5f, 3.7283f }
|
{ -123.5f, 3.7283f }
|
||||||
};
|
};
|
||||||
|
|
||||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_2[] = {
|
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_2[] = {
|
||||||
{ -3.0f, -4.0f },
|
{ -3.0f, -4.0f },
|
||||||
{ -3.0f, -4.0f },
|
{ -3.0f, -4.0f },
|
||||||
{ 0.002f, -0.05f },
|
{ 0.002f, -0.05f },
|
||||||
|
|
@ -22,14 +22,14 @@ const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_2[] = {
|
||||||
|
|
||||||
const float FP32_VECTOR2_SQUARE_MODULUS_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f };
|
const float FP32_VECTOR2_SQUARE_MODULUS_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f };
|
||||||
|
|
||||||
int test_fp32_vector2_square_modulus()
|
int test_vector2_fp32_square_modulus()
|
||||||
{
|
{
|
||||||
print_test_name("fp32_vector2_t square modulus");
|
print_test_name("vector2_fp32_t square modulus");
|
||||||
|
|
||||||
float square_modulus;
|
float square_modulus;
|
||||||
|
|
||||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
square_modulus = fp32_vector2_get_square_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
square_modulus = vector2_get_square_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
||||||
|
|
||||||
if (!test_fp32_are_equal(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i], TEST_FP32_TWO_EPSYLON)) {
|
if (!test_fp32_are_equal(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i], TEST_FP32_TWO_EPSYLON)) {
|
||||||
print_test_failed();
|
print_test_failed();
|
||||||
|
|
@ -45,14 +45,14 @@ int test_fp32_vector2_square_modulus()
|
||||||
|
|
||||||
const float FP32_VECTOR2_MODULUS_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
const float FP32_VECTOR2_MODULUS_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
||||||
|
|
||||||
int test_fp32_vector2_modulus()
|
int test_vector2_fp32_modulus()
|
||||||
{
|
{
|
||||||
print_test_name("fp32_vector2_t modulus");
|
print_test_name("vector2_fp32_t modulus");
|
||||||
|
|
||||||
float square_modulus;
|
float square_modulus;
|
||||||
|
|
||||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
square_modulus = fp32_vector2_get_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
square_modulus = vector2_get_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
||||||
|
|
||||||
if (!test_fp32_are_equal(square_modulus, FP32_VECTOR2_MODULUS_1[i], TEST_FP32_EPSYLON)) {
|
if (!test_fp32_are_equal(square_modulus, FP32_VECTOR2_MODULUS_1[i], TEST_FP32_EPSYLON)) {
|
||||||
print_test_failed();
|
print_test_failed();
|
||||||
|
|
@ -66,7 +66,7 @@ int test_fp32_vector2_modulus()
|
||||||
|
|
||||||
// ===================== Add ==================== //
|
// ===================== Add ==================== //
|
||||||
|
|
||||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
||||||
{ 0.0f, 0.0f },
|
{ 0.0f, 0.0f },
|
||||||
{ -6.0f, -8.0f },
|
{ -6.0f, -8.0f },
|
||||||
{ 10000.002f, -20000.05f },
|
{ 10000.002f, -20000.05f },
|
||||||
|
|
@ -74,14 +74,14 @@ const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
||||||
{ -122.0f, -19.6217f }
|
{ -122.0f, -19.6217f }
|
||||||
};
|
};
|
||||||
|
|
||||||
int test_fp32_vector2_add()
|
int test_vector2_fp32_add()
|
||||||
{
|
{
|
||||||
print_test_name("fp32_vector2_t add");
|
print_test_name("vector2_fp32_t add");
|
||||||
|
|
||||||
fp32_vector2_t vector;
|
vector2_fp32_t vector;
|
||||||
|
|
||||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
fp32_vector2_add(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
vector2_fp32_add(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||||
|
|
||||||
if (!test_fp32_are_equal(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_FP32_EPSYLON) ||
|
if (!test_fp32_are_equal(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_FP32_EPSYLON) ||
|
||||||
!test_fp32_are_equal(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_FP32_EPSYLON)) {
|
!test_fp32_are_equal(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_FP32_EPSYLON)) {
|
||||||
|
|
@ -96,7 +96,7 @@ int test_fp32_vector2_add()
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
||||||
{ 6.0f, 8.0f },
|
{ 6.0f, 8.0f },
|
||||||
{ 0.0f, 0.0f },
|
{ 0.0f, 0.0f },
|
||||||
{ 9999.998f, -19999.95f },
|
{ 9999.998f, -19999.95f },
|
||||||
|
|
@ -104,14 +104,14 @@ const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
||||||
{ -125.0f, 27.0783f }
|
{ -125.0f, 27.0783f }
|
||||||
};
|
};
|
||||||
|
|
||||||
int test_fp32_vector2_subtract()
|
int test_vector2_fp32_subtract()
|
||||||
{
|
{
|
||||||
print_test_name("fp32_vector2_t subtract");
|
print_test_name("vector2_fp32_t subtract");
|
||||||
|
|
||||||
fp32_vector2_t vector;
|
vector2_fp32_t vector;
|
||||||
|
|
||||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
fp32_vector2_subtract(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
vector2_fp32_subtract(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||||
|
|
||||||
if (!test_fp32_are_equal(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_FP32_EPSYLON) ||
|
if (!test_fp32_are_equal(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_FP32_EPSYLON) ||
|
||||||
!test_fp32_are_equal(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_FP32_EPSYLON)) {
|
!test_fp32_are_equal(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_FP32_EPSYLON)) {
|
||||||
|
|
@ -128,21 +128,21 @@ int test_fp32_vector2_subtract()
|
||||||
|
|
||||||
int test_fp32_vector2()
|
int test_fp32_vector2()
|
||||||
{
|
{
|
||||||
print_test_section("fp32_vector2_t");
|
print_test_section("vector2_fp32_t");
|
||||||
|
|
||||||
if (test_fp32_vector2_square_modulus() != TEST_RESULT_SUCCES) {
|
if (test_vector2_fp32_square_modulus() != TEST_RESULT_SUCCES) {
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_fp32_vector2_modulus() != TEST_RESULT_SUCCES) {
|
if (test_vector2_fp32_modulus() != TEST_RESULT_SUCCES) {
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_fp32_vector2_add() != TEST_RESULT_SUCCES) {
|
if (test_vector2_fp32_add() != TEST_RESULT_SUCCES) {
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_fp32_vector2_subtract() != TEST_RESULT_SUCCES) {
|
if (test_vector2_fp32_subtract() != TEST_RESULT_SUCCES) {
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
int test_fp32_vector2();
|
int test_fp32_vector2();
|
||||||
|
|
||||||
int test_fp32_vector2_square_modulus();
|
int test_vector2_fp32_square_modulus();
|
||||||
|
|
||||||
int test_fp32_vector2_modulus();
|
int test_vector2_fp32_modulus();
|
||||||
|
|
||||||
int test_fp32_vector2_add();
|
int test_vector2_fp32_add();
|
||||||
|
|
||||||
int test_fp32_vector2_subtract();
|
int test_vector2_fp32_subtract();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "geometry_test.h"
|
#include "geometry_test.h"
|
||||||
#include "fp32_vector2_test.h"
|
#include "vector2_fp32_test.h"
|
||||||
|
|
||||||
#define PROGRAM_RESULT_SUCCESS 0
|
#define PROGRAM_RESULT_SUCCESS 0
|
||||||
#define PROGRAM_RESULT_FAILED 1
|
#define PROGRAM_RESULT_FAILED 1
|
||||||
|
|
|
||||||
|
|
@ -52,31 +52,31 @@ typedef enum {
|
||||||
|
|
||||||
// ========= Convert radians to degrees ========= //
|
// ========= Convert radians to degrees ========= //
|
||||||
|
|
||||||
static inline float fp32_radians_to_degrees(const float radians)
|
inline float fp32_radians_to_degrees(const float radians)
|
||||||
{
|
{
|
||||||
return radians * FP32_DEGREES_IN_RADIAN;
|
return radians * FP32_DEGREES_IN_RADIAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_radians_to_degrees(const double radians)
|
inline double fp64_radians_to_degrees(const double radians)
|
||||||
{
|
{
|
||||||
return radians * FP64_DEGREES_IN_RADIAN;
|
return radians * FP64_DEGREES_IN_RADIAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Convert radians to turns ========== //
|
// ========== Convert radians to turns ========== //
|
||||||
|
|
||||||
static inline float fp32_radians_to_turns(const float radians)
|
inline float fp32_radians_to_turns(const float radians)
|
||||||
{
|
{
|
||||||
return radians * FP32_TURNS_IN_RADIAN;
|
return radians * FP32_TURNS_IN_RADIAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_radians_to_turns(const double radians)
|
inline double fp64_radians_to_turns(const double radians)
|
||||||
{
|
{
|
||||||
return radians * FP64_TURNS_IN_RADIAN;
|
return radians * FP64_TURNS_IN_RADIAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Convert radians to any unit ======== //
|
// ========= Convert radians to any unit ======== //
|
||||||
|
|
||||||
static inline float fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
|
inline float fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return radians * FP32_DEGREES_IN_RADIAN;
|
return radians * FP32_DEGREES_IN_RADIAN;
|
||||||
|
|
@ -89,7 +89,7 @@ static inline float fp32_radians_to_units(const float radians, const angle_unit_
|
||||||
return radians;
|
return radians;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
|
inline double fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return radians * FP64_DEGREES_IN_RADIAN;
|
return radians * FP64_DEGREES_IN_RADIAN;
|
||||||
|
|
@ -104,7 +104,7 @@ static inline double fp64_radians_to_units(const double radians, const angle_uni
|
||||||
|
|
||||||
// ============ Normalize radians ============= //
|
// ============ Normalize radians ============= //
|
||||||
|
|
||||||
static inline float fp32_radians_normalize(const float radians, const angle_range_t range)
|
inline float fp32_radians_normalize(const float radians, const angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0f <= radians && radians < FP32_TWO_PI) {
|
if (0.0f <= radians && radians < FP32_TWO_PI) {
|
||||||
|
|
@ -128,7 +128,7 @@ static inline float fp32_radians_normalize(const float radians, const angle_rang
|
||||||
return turns * FP32_TWO_PI;
|
return turns * FP32_TWO_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_radians_normalize(const double radians, const angle_range_t range)
|
inline double fp64_radians_normalize(const double radians, const angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0 <= radians && radians < FP64_TWO_PI) {
|
if (0.0 <= radians && radians < FP64_TWO_PI) {
|
||||||
|
|
@ -156,31 +156,31 @@ static inline double fp64_radians_normalize(const double radians, const angle_ra
|
||||||
|
|
||||||
// ========= Convert degrees to radians ========= //
|
// ========= Convert degrees to radians ========= //
|
||||||
|
|
||||||
static inline float fp32_degrees_to_radians(const float degrees)
|
inline float fp32_degrees_to_radians(const float degrees)
|
||||||
{
|
{
|
||||||
return degrees * FP32_RADIANS_IN_DEGREE;
|
return degrees * FP32_RADIANS_IN_DEGREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_degrees_to_radians(const double degrees)
|
inline double fp64_degrees_to_radians(const double degrees)
|
||||||
{
|
{
|
||||||
return degrees * FP64_RADIANS_IN_DEGREE;
|
return degrees * FP64_RADIANS_IN_DEGREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Convert degrees to turns ========== //
|
// ========== Convert degrees to turns ========== //
|
||||||
|
|
||||||
static inline float fp32_degrees_to_turns(const float radians)
|
inline float fp32_degrees_to_turns(const float radians)
|
||||||
{
|
{
|
||||||
return radians * FP32_TURNS_IN_DEGREE;
|
return radians * FP32_TURNS_IN_DEGREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_degrees_to_turns(const double radians)
|
inline double fp64_degrees_to_turns(const double radians)
|
||||||
{
|
{
|
||||||
return radians * FP64_TURNS_IN_DEGREE;
|
return radians * FP64_TURNS_IN_DEGREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Convert degreess to any unit ======== //
|
// ========= Convert degreess to any unit ======== //
|
||||||
|
|
||||||
static inline float fp32_degrees_to_units(const float degrees, const angle_unit_t to_unit)
|
inline float fp32_degrees_to_units(const float degrees, const angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return degrees * FP32_RADIANS_IN_DEGREE;
|
return degrees * FP32_RADIANS_IN_DEGREE;
|
||||||
|
|
@ -193,7 +193,7 @@ static inline float fp32_degrees_to_units(const float degrees, const angle_unit_
|
||||||
return degrees;
|
return degrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_unit)
|
inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return degrees * FP64_RADIANS_IN_DEGREE;
|
return degrees * FP64_RADIANS_IN_DEGREE;
|
||||||
|
|
@ -208,7 +208,7 @@ static inline double fp64_degrees_to_units(const double degrees, const angle_uni
|
||||||
|
|
||||||
// ============ Normalize degrees ============= //
|
// ============ Normalize degrees ============= //
|
||||||
|
|
||||||
static inline float fp32_degrees_normalize(const float degrees, const angle_range_t range)
|
inline float fp32_degrees_normalize(const float degrees, const angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0f <= degrees && degrees < 360.0f) {
|
if (0.0f <= degrees && degrees < 360.0f) {
|
||||||
|
|
@ -232,7 +232,7 @@ static inline float fp32_degrees_normalize(const float degrees, const angle_rang
|
||||||
return turns * 360.0f;
|
return turns * 360.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_degrees_normalize(const double degrees, const angle_range_t range)
|
inline double fp64_degrees_normalize(const double degrees, const angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0 <= degrees && degrees < 360.0) {
|
if (0.0 <= degrees && degrees < 360.0) {
|
||||||
|
|
@ -260,31 +260,31 @@ static inline double fp64_degrees_normalize(const double degrees, const angle_ra
|
||||||
|
|
||||||
// ========== Convert turns to radians ========== //
|
// ========== Convert turns to radians ========== //
|
||||||
|
|
||||||
static inline float fp32_turns_to_radians(const float turns)
|
inline float fp32_turns_to_radians(const float turns)
|
||||||
{
|
{
|
||||||
return turns * FP32_TWO_PI;
|
return turns * FP32_TWO_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_turns_to_radians(const double turns)
|
inline double fp64_turns_to_radians(const double turns)
|
||||||
{
|
{
|
||||||
return turns * FP64_TWO_PI;
|
return turns * FP64_TWO_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Convert turns to degrees ========== //
|
// ========== Convert turns to degrees ========== //
|
||||||
|
|
||||||
static inline float fp32_turns_to_degrees(const float turns)
|
inline float fp32_turns_to_degrees(const float turns)
|
||||||
{
|
{
|
||||||
return turns * 360.0f;
|
return turns * 360.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_turns_to_degrees(const double turns)
|
inline double fp64_turns_to_degrees(const double turns)
|
||||||
{
|
{
|
||||||
return turns * 360.0;
|
return turns * 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Convert turns to any unit ======== //
|
// ========= Convert turns to any unit ======== //
|
||||||
|
|
||||||
static inline float fp32_turns_to_units(const float turns, const angle_unit_t to_unit)
|
inline float fp32_turns_to_units(const float turns, const angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return turns * FP32_TWO_PI;
|
return turns * FP32_TWO_PI;
|
||||||
|
|
@ -297,7 +297,7 @@ static inline float fp32_turns_to_units(const float turns, const angle_unit_t to
|
||||||
return turns;
|
return turns;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit)
|
inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return turns * FP64_TWO_PI;
|
return turns * FP64_TWO_PI;
|
||||||
|
|
@ -312,7 +312,7 @@ static inline double fp64_turns_to_units(const double turns, const angle_unit_t
|
||||||
|
|
||||||
// ============= Normalize turns ============== //
|
// ============= Normalize turns ============== //
|
||||||
|
|
||||||
static inline float fp32_turns_normalize(const float turns, const angle_range_t range)
|
inline float fp32_turns_normalize(const float turns, const angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0f <= turns && turns < 1.0f) {
|
if (0.0f <= turns && turns < 1.0f) {
|
||||||
|
|
@ -334,7 +334,7 @@ static inline float fp32_turns_normalize(const float turns, const angle_range_t
|
||||||
return rest;
|
return rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_turns_normalize(const double turns, const angle_range_t range)
|
inline double fp64_turns_normalize(const double turns, const angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0 <= turns && turns < 1.0) {
|
if (0.0 <= turns && turns < 1.0) {
|
||||||
|
|
@ -360,7 +360,7 @@ static inline double fp64_turns_normalize(const double turns, const angle_range_
|
||||||
|
|
||||||
// ========= Convert any unit to radians ======== //
|
// ========= Convert any unit to radians ======== //
|
||||||
|
|
||||||
static inline float fp32_angle_to_radians(const float angle, const angle_unit_t unit)
|
inline float fp32_angle_to_radians(const float angle, const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return angle * FP32_RADIANS_IN_DEGREE;
|
return angle * FP32_RADIANS_IN_DEGREE;
|
||||||
|
|
@ -373,7 +373,7 @@ static inline float fp32_angle_to_radians(const float angle, const angle_unit_t
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
|
inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return angle * FP64_RADIANS_IN_DEGREE;
|
return angle * FP64_RADIANS_IN_DEGREE;
|
||||||
|
|
@ -388,7 +388,7 @@ static inline double fp64_angle_to_radians(const double angle, const angle_unit_
|
||||||
|
|
||||||
// ========= Convert any unit to degreess ======== //
|
// ========= Convert any unit to degreess ======== //
|
||||||
|
|
||||||
static inline float fp32_angle_to_degrees(const float angle, const angle_unit_t unit)
|
inline float fp32_angle_to_degrees(const float angle, const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP32_DEGREES_IN_RADIAN;
|
return angle * FP32_DEGREES_IN_RADIAN;
|
||||||
|
|
@ -401,7 +401,7 @@ static inline float fp32_angle_to_degrees(const float angle, const angle_unit_t
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
|
inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP64_DEGREES_IN_RADIAN;
|
return angle * FP64_DEGREES_IN_RADIAN;
|
||||||
|
|
@ -416,7 +416,7 @@ static inline double fp64_angle_to_degrees(const double angle, const angle_unit_
|
||||||
|
|
||||||
// ========= Convert any unit to turns ======== //
|
// ========= Convert any unit to turns ======== //
|
||||||
|
|
||||||
static inline float fp32_angle_to_turns(const float angle, const angle_unit_t unit)
|
inline float fp32_angle_to_turns(const float angle, const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP32_TURNS_IN_RADIAN;
|
return angle * FP32_TURNS_IN_RADIAN;
|
||||||
|
|
@ -429,7 +429,7 @@ static inline float fp32_angle_to_turns(const float angle, const angle_unit_t un
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
|
inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP64_TURNS_IN_RADIAN;
|
return angle * FP64_TURNS_IN_RADIAN;
|
||||||
|
|
@ -444,7 +444,7 @@ static inline double fp64_angle_to_turns(const double angle, const angle_unit_t
|
||||||
|
|
||||||
// ============= Get Full Circle ============== //
|
// ============= Get Full Circle ============== //
|
||||||
|
|
||||||
static inline float fp32_angle_get_full_circle(const angle_unit_t unit)
|
inline float fp32_angle_get_full_circle(const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return 360.0f;
|
return 360.0f;
|
||||||
|
|
@ -457,7 +457,7 @@ static inline float fp32_angle_get_full_circle(const angle_unit_t unit)
|
||||||
return FP32_TWO_PI;
|
return FP32_TWO_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_angle_get_full_circle(const angle_unit_t unit)
|
inline double fp64_angle_get_full_circle(const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return 360.0;
|
return 360.0;
|
||||||
|
|
@ -472,7 +472,7 @@ static inline double fp64_angle_get_full_circle(const angle_unit_t unit)
|
||||||
|
|
||||||
// ============= Get Half Circle ============== //
|
// ============= Get Half Circle ============== //
|
||||||
|
|
||||||
static inline float fp32_angle_get_half_circle(const angle_unit_t unit)
|
inline float fp32_angle_get_half_circle(const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return 180.0f;
|
return 180.0f;
|
||||||
|
|
@ -485,7 +485,7 @@ static inline float fp32_angle_get_half_circle(const angle_unit_t unit)
|
||||||
return FP32_PI;
|
return FP32_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_angle_get_half_circle(const angle_unit_t unit)
|
inline double fp64_angle_get_half_circle(const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return 180.0;
|
return 180.0;
|
||||||
|
|
@ -500,7 +500,7 @@ static inline double fp64_angle_get_half_circle(const angle_unit_t unit)
|
||||||
|
|
||||||
// ============= Get Half Circle ============== //
|
// ============= Get Half Circle ============== //
|
||||||
|
|
||||||
static inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
|
inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return 90.0f;
|
return 90.0f;
|
||||||
|
|
@ -513,7 +513,7 @@ static inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
|
||||||
return FP32_HALF_OF_PI;
|
return FP32_HALF_OF_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
|
inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
return 90.0;
|
return 90.0;
|
||||||
|
|
@ -528,7 +528,7 @@ static inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
|
||||||
|
|
||||||
// ================ Normalize ================= //
|
// ================ Normalize ================= //
|
||||||
|
|
||||||