Завершение большого переименования
This commit is contained in:
parent
120e651517
commit
3805354611
31 changed files with 1213 additions and 1255 deletions
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<CodeBlocks_workspace_file>
|
<CodeBlocks_workspace_file>
|
||||||
<Workspace title="Workspace">
|
<Workspace title="Workspace">
|
||||||
<Project filename="basic-geometry/basic-geometry.cbp" />
|
|
||||||
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
|
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
|
||||||
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
||||||
</Project>
|
</Project>
|
||||||
|
<Project filename="basic-geometry/basic-geometry.cbp" />
|
||||||
<Project filename="basic-geometry-test/basic-geometry-test.cbp">
|
<Project filename="basic-geometry-test/basic-geometry-test.cbp">
|
||||||
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
#endif // _WINDOWS_
|
#endif // _WINDOWS_
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
versor_fp32_t versor1, versor2, result;
|
bgc_versor_fp32_t versor1, versor2, result;
|
||||||
//matrix3x3_fp32_t matrix;
|
//matrix3x3_fp32_t matrix;
|
||||||
vector3_fp32_t vector1, vector2;
|
bgc_vector3_fp32_t vector1, vector2;
|
||||||
} structure_fp32_t;
|
} structure_fp32_t;
|
||||||
|
|
||||||
structure_fp32_t* allocate_structures(const unsigned int amount)
|
structure_fp32_t* allocate_structures(const unsigned int amount)
|
||||||
|
@ -31,7 +31,7 @@ structure_fp32_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_set_values_fp32(
|
bgc_versor_set_values_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,
|
||||||
|
@ -39,7 +39,7 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
||||||
&list[i].versor1
|
&list[i].versor1
|
||||||
);
|
);
|
||||||
|
|
||||||
versor_set_values_fp32(
|
bgc_versor_set_values_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,
|
||||||
|
@ -47,49 +47,49 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
||||||
&list[i].versor2
|
&list[i].versor2
|
||||||
);
|
);
|
||||||
|
|
||||||
versor_reset_fp32(&list[i].result);
|
bgc_versor_reset_fp32(&list[i].result);
|
||||||
|
|
||||||
//matrix3x3_set_to_identity_fp32(&list[i].matrix);
|
//matrix3x3_set_to_identity_fp32(&list[i].matrix);
|
||||||
|
|
||||||
vector3_set_values_fp32(
|
bgc_vector3_set_values_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
|
||||||
);
|
);
|
||||||
|
|
||||||
vector3_reset_fp32(&list[i].vector2);
|
bgc_vector3_reset_fp32(&list[i].vector2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_versor_fp32(const versor_fp32_t* versor)
|
void print_versor_fp32(const bgc_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_versor_fp64(const versor_fp64_t* versor)
|
void print_versor_fp64(const bgc_versor_fp64_t* versor)
|
||||||
{
|
{
|
||||||
printf("Versor (%lf, %lf, %lf, %lf)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
printf("Versor (%lf, %lf, %lf, %lf)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_vector_fp32(const vector3_fp32_t* vector)
|
void print_vector_fp32(const bgc_vector3_fp32_t* vector)
|
||||||
{
|
{
|
||||||
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, vector3_get_modulus_fp32(vector));
|
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp32(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_vector_fp64(const vector3_fp64_t* vector)
|
void print_vector_fp64(const bgc_vector3_fp64_t* vector)
|
||||||
{
|
{
|
||||||
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, vector3_get_modulus_fp64(vector));
|
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp64(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
void item_work(structure_fp32_t* item)
|
void item_work(structure_fp32_t* item)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 1000; j++) {
|
//for (int j = 0; j < 1000; j++) {
|
||||||
versor_combine_fp32(&item->versor1, &item->versor2, &item->result);
|
bgc_versor_combine_fp32(&item->versor1, &item->versor2, &item->result);
|
||||||
versor_turn_vector_fp32(&item->result, &item->vector1, &item->vector2);
|
bgc_versor_turn_vector_fp32(&item->result, &item->vector1, &item->vector2);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -125,8 +125,8 @@ int main()
|
||||||
//for (int j = 0; j < 1000; j++) {
|
//for (int j = 0; j < 1000; j++) {
|
||||||
item_work(list + i);
|
item_work(list + i);
|
||||||
//structure_fp32_t* item = list + i;
|
//structure_fp32_t* item = list + i;
|
||||||
//versor_combine_fp32(&item->versor1, &item->versor2, &item->result);
|
//bgc_versor_combine_fp32(&item->versor1, &item->versor2, &item->result);
|
||||||
//versor_turn_vector_fp32(&item->result, &item->vector1, &item->vector2);
|
//bgc_versor_turn_vector_fp32(&item->result, &item->vector1, &item->vector2);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
|
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
|
||||||
|
|
||||||
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1[] = {
|
const bgc_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 vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1[] = {
|
||||||
{ -123.5f, 3.7283f }
|
{ -123.5f, 3.7283f }
|
||||||
};
|
};
|
||||||
|
|
||||||
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_2[] = {
|
const bgc_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 },
|
||||||
|
@ -29,9 +29,9 @@ int test_vector2_fp32_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 = vector2_get_square_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
square_modulus = bgc_vector2_get_square_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
||||||
|
|
||||||
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i], TEST_FP32_TWO_EPSYLON)) {
|
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i], TEST_BGC_TWO_EPSYLON_FP32)) {
|
||||||
print_test_failed();
|
print_test_failed();
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ int test_vector2_fp32_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 = vector2_get_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
square_modulus = bgc_vector2_get_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
||||||
|
|
||||||
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_MODULUS_1[i], TEST_FP32_EPSYLON)) {
|
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_MODULUS_1[i], TEST_BGC_EPSYLON_FP32)) {
|
||||||
print_test_failed();
|
print_test_failed();
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ int test_vector2_fp32_modulus()
|
||||||
|
|
||||||
// ===================== Add ==================== //
|
// ===================== Add ==================== //
|
||||||
|
|
||||||
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
const bgc_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 },
|
||||||
|
@ -78,13 +78,13 @@ int test_vector2_add_fp32()
|
||||||
{
|
{
|
||||||
print_test_name("vector2_fp32_t add");
|
print_test_name("vector2_fp32_t add");
|
||||||
|
|
||||||
vector2_fp32_t vector;
|
bgc_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++) {
|
||||||
vector2_add_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
bgc_vector2_add_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||||
|
|
||||||
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_FP32_EPSYLON) ||
|
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_BGC_EPSYLON_FP32) ||
|
||||||
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_FP32_EPSYLON)) {
|
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_BGC_EPSYLON_FP32)) {
|
||||||
print_test_failed();
|
print_test_failed();
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ int test_vector2_add_fp32()
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
const vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
const bgc_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 },
|
||||||
|
@ -108,13 +108,13 @@ int test_vector2_subtract_fp32()
|
||||||
{
|
{
|
||||||
print_test_name("vector2_fp32_t subtract");
|
print_test_name("vector2_fp32_t subtract");
|
||||||
|
|
||||||
vector2_fp32_t vector;
|
bgc_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++) {
|
||||||
vector2_subtract_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
bgc_vector2_subtract_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||||
|
|
||||||
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_FP32_EPSYLON) ||
|
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_BGC_EPSYLON_FP32) ||
|
||||||
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_FP32_EPSYLON)) {
|
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_BGC_EPSYLON_FP32)) {
|
||||||
print_test_failed();
|
print_test_failed();
|
||||||
return TEST_RESULT_FAILED;
|
return TEST_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
#define TEST_RESULT_SUCCES 0
|
#define TEST_RESULT_SUCCES 0
|
||||||
#define TEST_RESULT_FAILED 100
|
#define TEST_RESULT_FAILED 100
|
||||||
|
|
||||||
#define TEST_FP32_EPSYLON 1E-6f
|
#define TEST_BGC_EPSYLON_FP32 1E-6f
|
||||||
#define TEST_FP32_TWO_EPSYLON 2E-6f
|
#define TEST_BGC_TWO_EPSYLON_FP32 2E-6f
|
||||||
#define TEST_FP32_SQUARE_EPSYLON 1E-12f
|
#define TEST_BGC_SQUARE_EPSYLON_FP32 1E-12f
|
||||||
|
|
||||||
#define TEST_FP64_EPSYLON 1E-13f
|
#define TEST_BGC_EPSYLON_FP64 1E-13f
|
||||||
#define TEST_FP64_TWO_EPSYLON 2E-13f
|
#define TEST_BGC_TWO_EPSYLON_FP64 2E-13f
|
||||||
#define TEST_FP64_SQUARE_EPSYLON 1E-26f
|
#define TEST_BGC_SQUARE_EPSYLON_FP64 1E-26f
|
||||||
|
|
||||||
void print_test_section(const char * name);
|
void print_test_section(const char * name);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#include "basis.h"
|
#include "utilities.h"
|
||||||
#include "angle.h"
|
#include "angle.h"
|
||||||
|
|
||||||
|
|
|
@ -1,102 +1,102 @@
|
||||||
#ifndef _BASIC_GEOMETRY_ANGLE_H_
|
#ifndef _BGC_ANGLE_H_
|
||||||
#define _BASIC_GEOMETRY_ANGLE_H_
|
#define _BGC_ANGLE_H_
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "basis.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
#define FP32_PI 3.1415926536f
|
#define BGC_PI_FP32 3.1415926536f
|
||||||
#define FP32_TWO_PI 6.2831853072f
|
#define BGC_TWO_PI_FP32 6.2831853072f
|
||||||
#define FP32_HALF_OF_PI 1.5707963268f
|
#define BGC_HALF_OF_PI_FP32 1.5707963268f
|
||||||
#define FP32_THIRD_OF_PI 1.0471975512f
|
#define BGC_THIRD_OF_PI_FP32 1.0471975512f
|
||||||
#define FP32_FOURTH_OF_PI 0.7853981634f
|
#define BGC_FOURTH_OF_PI_FP32 0.7853981634f
|
||||||
#define FP32_SIXTH_OF_PI 0.5235987756f
|
#define BGC_SIXTH_OF_PI_FP32 0.5235987756f
|
||||||
|
|
||||||
#define FP32_DEGREES_IN_RADIAN 57.295779513f
|
#define BGC_DEGREES_IN_RADIAN_FP32 57.295779513f
|
||||||
#define FP32_TURNS_IN_RADIAN 0.1591549431f
|
#define BGC_TURNS_IN_RADIAN_FP32 0.1591549431f
|
||||||
#define FP32_RADIANS_IN_DEGREE 1.745329252E-2f
|
#define BGC_RADIANS_IN_DEGREE_FP32 1.745329252E-2f
|
||||||
#define FP32_TURNS_IN_DEGREE 2.7777777778E-3f
|
#define BGC_TURNS_IN_DEGREE_FP32 2.7777777778E-3f
|
||||||
|
|
||||||
#define FP64_PI 3.14159265358979324
|
#define BGC_PI_FP64 3.14159265358979324
|
||||||
#define FP64_TWO_PI 6.28318530717958648
|
#define BGC_TWO_PI_FP64 6.28318530717958648
|
||||||
#define FP64_HALF_OF_PI 1.57079632679489662
|
#define BGC_HALF_OF_PI_FP64 1.57079632679489662
|
||||||
#define FP64_THIRD_OF_PI 1.04719755119659775
|
#define BGC_THIRD_OF_PI_FP64 1.04719755119659775
|
||||||
#define FP64_FOURTH_OF_PI 0.78539816339744831
|
#define BGC_FOURTH_OF_PI_FP64 0.78539816339744831
|
||||||
#define FP64_SIXTH_OF_PI 0.523598775598298873
|
#define BGC_SIXTH_OF_PI_FP64 0.523598775598298873
|
||||||
|
|
||||||
#define FP64_DEGREES_IN_RADIAN 57.2957795130823209
|
#define BGC_DEGREES_IN_RADIAN_FP64 57.2957795130823209
|
||||||
#define FP64_TURNS_IN_RADIAN 0.159154943091895336
|
#define BGC_TURNS_IN_RADIAN_FP64 0.159154943091895336
|
||||||
#define FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2
|
#define BGC_RADIANS_IN_DEGREE_FP64 1.74532925199432958E-2
|
||||||
#define FP64_TURNS_IN_DEGREE 2.77777777777777778E-3
|
#define BGC_TURNS_IN_DEGREE_FP64 2.77777777777777778E-3
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BG_ANGLE_UNIT_RADIANS = 1,
|
BGC_ANGLE_UNIT_RADIANS = 1,
|
||||||
BG_ANGLE_UNIT_DEGREES = 2,
|
BGC_ANGLE_UNIT_DEGREES = 2,
|
||||||
BG_ANGLE_UNIT_TURNS = 3
|
BGC_ANGLE_UNIT_TURNS = 3
|
||||||
} angle_unit_t;
|
} bgc_angle_unit_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/**
|
/**
|
||||||
* The measure of an angle with a range of:
|
* The measure of an angle with a range of:
|
||||||
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
|
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
|
||||||
*/
|
*/
|
||||||
BG_ANGLE_RANGE_UNSIGNED = 1,
|
BGC_ANGLE_RANGE_UNSIGNED = 1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The measure of an angle with a range of:
|
* The measure of an angle with a range of:
|
||||||
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
|
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
|
||||||
*/
|
*/
|
||||||
BG_ANGLE_RANGE_SIGNED = 2
|
BGC_ANGLE_RANGE_SIGNED = 2
|
||||||
} angle_range_t;
|
} bgc_angle_range_t;
|
||||||
|
|
||||||
// !================= Radians ==================! //
|
// !================= Radians ==================! //
|
||||||
|
|
||||||
// ========= Convert radians to degrees ========= //
|
// ========= Convert radians to degrees ========= //
|
||||||
|
|
||||||
inline float fp32_radians_to_degrees(const float radians)
|
inline float bgc_radians_to_degrees_fp32(const float radians)
|
||||||
{
|
{
|
||||||
return radians * FP32_DEGREES_IN_RADIAN;
|
return radians * BGC_DEGREES_IN_RADIAN_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_radians_to_degrees(const double radians)
|
inline double bgc_radians_to_degrees_fp64(const double radians)
|
||||||
{
|
{
|
||||||
return radians * FP64_DEGREES_IN_RADIAN;
|
return radians * BGC_DEGREES_IN_RADIAN_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Convert radians to turns ========== //
|
// ========== Convert radians to turns ========== //
|
||||||
|
|
||||||
inline float fp32_radians_to_turns(const float radians)
|
inline float bgc_radians_to_turns_fp32(const float radians)
|
||||||
{
|
{
|
||||||
return radians * FP32_TURNS_IN_RADIAN;
|
return radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_radians_to_turns(const double radians)
|
inline double bgc_radians_to_turns_fp64(const double radians)
|
||||||
{
|
{
|
||||||
return radians * FP64_TURNS_IN_RADIAN;
|
return radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Convert radians to any unit ======== //
|
// ========= Convert radians to any unit ======== //
|
||||||
|
|
||||||
inline float fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
|
inline float bgc_radians_to_units_fp32(const float radians, const bgc_angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return radians * FP32_DEGREES_IN_RADIAN;
|
return radians * BGC_DEGREES_IN_RADIAN_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return radians * FP32_TURNS_IN_RADIAN;
|
return radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
return radians;
|
return radians;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
|
inline double bgc_radians_to_units_fp64(const double radians, const bgc_angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return radians * FP64_DEGREES_IN_RADIAN;
|
return radians * BGC_DEGREES_IN_RADIAN_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return radians * FP64_TURNS_IN_RADIAN;
|
return radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
return radians;
|
return radians;
|
||||||
|
@ -104,103 +104,103 @@ inline double fp64_radians_to_units(const double radians, const angle_unit_t to_
|
||||||
|
|
||||||
// ============ Normalize radians ============= //
|
// ============ Normalize radians ============= //
|
||||||
|
|
||||||
inline float fp32_radians_normalize(const float radians, const angle_range_t range)
|
inline float bgc_radians_normalize_fp32(const float radians, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0f <= radians && radians < FP32_TWO_PI) {
|
if (0.0f <= radians && radians < BGC_TWO_PI_FP32) {
|
||||||
return radians;
|
return radians;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (-FP32_PI < radians && radians <= FP32_PI) {
|
if (-BGC_PI_FP32 < radians && radians <= BGC_PI_FP32) {
|
||||||
return radians;
|
return radians;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float turns = radians * FP32_TURNS_IN_RADIAN;
|
float turns = radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||||
|
|
||||||
turns -= floorf(turns);
|
turns -= floorf(turns);
|
||||||
|
|
||||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||||
turns -= 1.0f;
|
turns -= 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return turns * FP32_TWO_PI;
|
return turns * BGC_TWO_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_radians_normalize(const double radians, const angle_range_t range)
|
inline double bgc_radians_normalize_fp64(const double radians, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0 <= radians && radians < FP64_TWO_PI) {
|
if (0.0 <= radians && radians < BGC_TWO_PI_FP64) {
|
||||||
return radians;
|
return radians;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (-FP64_PI < radians && radians <= FP64_PI) {
|
if (-BGC_PI_FP64 < radians && radians <= BGC_PI_FP64) {
|
||||||
return radians;
|
return radians;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double turns = radians * FP64_TURNS_IN_RADIAN;
|
double turns = radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||||
|
|
||||||
turns -= floor(turns);
|
turns -= floor(turns);
|
||||||
|
|
||||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||||
turns -= 1.0;
|
turns -= 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return turns * FP64_TWO_PI;
|
return turns * BGC_TWO_PI_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !================= Degrees ==================! //
|
// !================= Degrees ==================! //
|
||||||
|
|
||||||
// ========= Convert degrees to radians ========= //
|
// ========= Convert degrees to radians ========= //
|
||||||
|
|
||||||
inline float fp32_degrees_to_radians(const float degrees)
|
inline float bgc_degrees_to_radians_fp32(const float degrees)
|
||||||
{
|
{
|
||||||
return degrees * FP32_RADIANS_IN_DEGREE;
|
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_degrees_to_radians(const double degrees)
|
inline double bgc_degrees_to_radians_fp64(const double degrees)
|
||||||
{
|
{
|
||||||
return degrees * FP64_RADIANS_IN_DEGREE;
|
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Convert degrees to turns ========== //
|
// ========== Convert degrees to turns ========== //
|
||||||
|
|
||||||
inline float fp32_degrees_to_turns(const float radians)
|
inline float bgc_degrees_to_turns_fp32(const float radians)
|
||||||
{
|
{
|
||||||
return radians * FP32_TURNS_IN_DEGREE;
|
return radians * BGC_TURNS_IN_DEGREE_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 * BGC_TURNS_IN_DEGREE_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Convert degreess to any unit ======== //
|
// ========= Convert degreess to any unit ======== //
|
||||||
|
|
||||||
inline float fp32_degrees_to_units(const float degrees, const angle_unit_t to_unit)
|
inline float bgc_degrees_to_units_fp32(const float degrees, const bgc_angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return degrees * FP32_RADIANS_IN_DEGREE;
|
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return degrees * FP32_TURNS_IN_DEGREE;
|
return degrees * BGC_TURNS_IN_DEGREE_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
return degrees;
|
return degrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_unit)
|
inline double bgc_degrees_to_units_fp64(const double degrees, const bgc_angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return degrees * FP64_RADIANS_IN_DEGREE;
|
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return degrees * FP64_TURNS_IN_DEGREE;
|
return degrees * BGC_TURNS_IN_DEGREE_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
return degrees;
|
return degrees;
|
||||||
|
@ -208,9 +208,9 @@ inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_
|
||||||
|
|
||||||
// ============ Normalize degrees ============= //
|
// ============ Normalize degrees ============= //
|
||||||
|
|
||||||
inline float fp32_degrees_normalize(const float degrees, const angle_range_t range)
|
inline float bgc_degrees_normalize_fp32(const float degrees, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0f <= degrees && degrees < 360.0f) {
|
if (0.0f <= degrees && degrees < 360.0f) {
|
||||||
return degrees;
|
return degrees;
|
||||||
}
|
}
|
||||||
|
@ -221,20 +221,20 @@ inline float fp32_degrees_normalize(const float degrees, const angle_range_t ran
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float turns = degrees * FP32_TURNS_IN_DEGREE;
|
float turns = degrees * BGC_TURNS_IN_DEGREE_FP32;
|
||||||
|
|
||||||
turns -= floorf(turns);
|
turns -= floorf(turns);
|
||||||
|
|
||||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||||
turns -= 1.0f;
|
turns -= 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return turns * 360.0f;
|
return turns * 360.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_degrees_normalize(const double degrees, const angle_range_t range)
|
inline double bgc_degrees_normalize_fp64(const double degrees, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0 <= degrees && degrees < 360.0) {
|
if (0.0 <= degrees && degrees < 360.0) {
|
||||||
return degrees;
|
return degrees;
|
||||||
}
|
}
|
||||||
|
@ -245,11 +245,11 @@ inline double fp64_degrees_normalize(const double degrees, const angle_range_t r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double turns = degrees * FP64_TURNS_IN_DEGREE;
|
double turns = degrees * BGC_TURNS_IN_DEGREE_FP64;
|
||||||
|
|
||||||
turns -= floor(turns);
|
turns -= floor(turns);
|
||||||
|
|
||||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||||
turns -= 1.0;
|
turns -= 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,50 +260,50 @@ inline double fp64_degrees_normalize(const double degrees, const angle_range_t r
|
||||||
|
|
||||||
// ========== Convert turns to radians ========== //
|
// ========== Convert turns to radians ========== //
|
||||||
|
|
||||||
inline float fp32_turns_to_radians(const float turns)
|
inline float bgc_turns_to_radians_fp32(const float turns)
|
||||||
{
|
{
|
||||||
return turns * FP32_TWO_PI;
|
return turns * BGC_TWO_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_turns_to_radians(const double turns)
|
inline double bgc_turns_to_radians_fp64(const double turns)
|
||||||
{
|
{
|
||||||
return turns * FP64_TWO_PI;
|
return turns * BGC_TWO_PI_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Convert turns to degrees ========== //
|
// ========== Convert turns to degrees ========== //
|
||||||
|
|
||||||
inline float fp32_turns_to_degrees(const float turns)
|
inline float bgc_turns_to_degrees_fp32(const float turns)
|
||||||
{
|
{
|
||||||
return turns * 360.0f;
|
return turns * 360.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_turns_to_degrees(const double turns)
|
inline double bgc_turns_to_degrees_fp64(const double turns)
|
||||||
{
|
{
|
||||||
return turns * 360.0;
|
return turns * 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Convert turns to any unit ======== //
|
// ========= Convert turns to any unit ======== //
|
||||||
|
|
||||||
inline float fp32_turns_to_units(const float turns, const angle_unit_t to_unit)
|
inline float bgc_turns_to_units_fp32(const float turns, const bgc_angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return turns * FP32_TWO_PI;
|
return turns * BGC_TWO_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return turns * 360.0f;
|
return turns * 360.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return turns;
|
return turns;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit)
|
inline double bgc_turns_to_units_fp64(const double turns, const bgc_angle_unit_t to_unit)
|
||||||
{
|
{
|
||||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return turns * FP64_TWO_PI;
|
return turns * BGC_TWO_PI_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return turns * 360.0;
|
return turns * 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,9 +312,9 @@ inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit
|
||||||
|
|
||||||
// ============= Normalize turns ============== //
|
// ============= Normalize turns ============== //
|
||||||
|
|
||||||
inline float fp32_turns_normalize(const float turns, const angle_range_t range)
|
inline float bgc_turns_normalize_fp32(const float turns, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0f <= turns && turns < 1.0f) {
|
if (0.0f <= turns && turns < 1.0f) {
|
||||||
return turns;
|
return turns;
|
||||||
}
|
}
|
||||||
|
@ -327,16 +327,16 @@ inline float fp32_turns_normalize(const float turns, const angle_range_t range)
|
||||||
|
|
||||||
float rest = turns - floorf(turns);
|
float rest = turns - floorf(turns);
|
||||||
|
|
||||||
if (range == BG_ANGLE_RANGE_SIGNED && rest > 0.5f) {
|
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) {
|
||||||
return rest - 1.0f;
|
return rest - 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rest;
|
return rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_turns_normalize(const double turns, const angle_range_t range)
|
inline double bgc_turns_normalize_fp64(const double turns, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||||
if (0.0 <= turns && turns < 1.0) {
|
if (0.0 <= turns && turns < 1.0) {
|
||||||
return turns;
|
return turns;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ inline double fp64_turns_normalize(const double turns, const angle_range_t range
|
||||||
|
|
||||||
double rest = turns - floor(turns);
|
double rest = turns - floor(turns);
|
||||||
|
|
||||||
if (range == BG_ANGLE_RANGE_SIGNED && rest > 0.5) {
|
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) {
|
||||||
return rest - 1.0;
|
return rest - 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,27 +360,27 @@ inline double fp64_turns_normalize(const double turns, const angle_range_t range
|
||||||
|
|
||||||
// ========= Convert any unit to radians ======== //
|
// ========= Convert any unit to radians ======== //
|
||||||
|
|
||||||
inline float fp32_angle_to_radians(const float angle, const angle_unit_t unit)
|
inline float bgc_angle_to_radians_fp32(const float angle, const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return angle * FP32_RADIANS_IN_DEGREE;
|
return angle * BGC_RADIANS_IN_DEGREE_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return angle * FP32_TWO_PI;
|
return angle * BGC_TWO_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
|
inline double bgc_angle_to_radians_fp64(const double angle, const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return angle * FP64_RADIANS_IN_DEGREE;
|
return angle * BGC_RADIANS_IN_DEGREE_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return angle * FP64_TWO_PI;
|
return angle * BGC_TWO_PI_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
return angle;
|
return angle;
|
||||||
|
@ -388,26 +388,26 @@ inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
|
||||||
|
|
||||||
// ========= Convert any unit to degreess ======== //
|
// ========= Convert any unit to degreess ======== //
|
||||||
|
|
||||||
inline float fp32_angle_to_degrees(const float angle, const angle_unit_t unit)
|
inline float bgc_angle_to_degrees_fp32(const float angle, const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP32_DEGREES_IN_RADIAN;
|
return angle * BGC_DEGREES_IN_RADIAN_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return angle * 360.0f;
|
return angle * 360.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
|
inline double bgc_angle_to_degrees_fp64(const double angle, const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP64_DEGREES_IN_RADIAN;
|
return angle * BGC_DEGREES_IN_RADIAN_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return angle * 360.0;
|
return angle * 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,27 +416,27 @@ inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
|
||||||
|
|
||||||
// ========= Convert any unit to turns ======== //
|
// ========= Convert any unit to turns ======== //
|
||||||
|
|
||||||
inline float fp32_angle_to_turns(const float angle, const angle_unit_t unit)
|
inline float bgc_angle_to_turns_fp32(const float angle, const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP32_TURNS_IN_RADIAN;
|
return angle * BGC_TURNS_IN_RADIAN_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return angle * FP32_TURNS_IN_DEGREE;
|
return angle * BGC_TURNS_IN_DEGREE_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
|
inline double bgc_angle_to_turns_fp64(const double angle, const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * FP64_TURNS_IN_RADIAN;
|
return angle * BGC_TURNS_IN_RADIAN_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return angle * FP64_TURNS_IN_DEGREE;
|
return angle * BGC_TURNS_IN_DEGREE_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
return angle;
|
return angle;
|
||||||
|
@ -444,114 +444,114 @@ inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
|
||||||
|
|
||||||
// ============= Get Full Circle ============== //
|
// ============= Get Full Circle ============== //
|
||||||
|
|
||||||
inline float fp32_angle_get_full_circle(const angle_unit_t unit)
|
inline float bgc_angle_get_full_circle_fp32(const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 360.0f;
|
return 360.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FP32_TWO_PI;
|
return BGC_TWO_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_angle_get_full_circle(const angle_unit_t unit)
|
inline double bgc_angle_get_full_circle_fp64(const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 360.0;
|
return 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FP64_TWO_PI;
|
return BGC_TWO_PI_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Get Half Circle ============== //
|
// ============= Get Half Circle ============== //
|
||||||
|
|
||||||
inline float fp32_angle_get_half_circle(const angle_unit_t unit)
|
inline float bgc_angle_get_half_circle_fp32(const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 180.0f;
|
return 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return 0.5f;
|
return 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FP32_PI;
|
return BGC_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_angle_get_half_circle(const angle_unit_t unit)
|
inline double bgc_angle_get_half_circle_fp64(const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 180.0;
|
return 180.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FP64_PI;
|
return BGC_PI_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Get Half Circle ============== //
|
// ============= Get Half Circle ============== //
|
||||||
|
|
||||||
inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
|
inline float bgc_angle_get_quater_circle_fp32(const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 90.0f;
|
return 90.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return 0.25f;
|
return 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FP32_HALF_OF_PI;
|
return BGC_HALF_OF_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
|
inline double bgc_angle_get_quater_circle_fp64(const bgc_angle_unit_t unit)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 90.0;
|
return 90.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return 0.25;
|
return 0.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FP64_HALF_OF_PI;
|
return BGC_HALF_OF_PI_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Normalize ================= //
|
// ================ Normalize ================= //
|
||||||
|
|
||||||
inline float fp32_angle_normalize(const float angle, const angle_unit_t unit, const angle_range_t range)
|
inline float bgc_angle_normalize_fp32(const float angle, const bgc_angle_unit_t unit, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return fp32_degrees_normalize(angle, range);
|
return bgc_degrees_normalize_fp32(angle, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return fp32_turns_normalize(angle, range);
|
return bgc_turns_normalize_fp32(angle, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fp32_radians_normalize(angle, range);
|
return bgc_radians_normalize_fp32(angle, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double fp64_angle_normalize(const double angle, const angle_unit_t unit, const angle_range_t range)
|
inline double bgc_angle_normalize_fp64(const double angle, const bgc_angle_unit_t unit, const bgc_angle_range_t range)
|
||||||
{
|
{
|
||||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return fp64_degrees_normalize(angle, range);
|
return bgc_degrees_normalize_fp64(angle, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||||
return fp64_turns_normalize(angle, range);
|
return bgc_turns_normalize_fp64(angle, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fp64_radians_normalize(angle, range);
|
return bgc_radians_normalize_fp64(angle, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,7 +51,6 @@
|
||||||
<Unit filename="basis.c">
|
<Unit filename="basis.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="basis.h" />
|
|
||||||
<Unit filename="matrix2x2.c">
|
<Unit filename="matrix2x2.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
@ -78,6 +77,7 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="tangent.h" />
|
<Unit filename="tangent.h" />
|
||||||
|
<Unit filename="utilities.h" />
|
||||||
<Unit filename="vector2.c">
|
<Unit filename="vector2.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __GEOMETRY_H__
|
#ifndef _BGC_H_
|
||||||
#define __GEOMETRY_H__
|
#define _BGC_H_
|
||||||
|
|
||||||
#include "basis.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
#include "angle.h"
|
#include "angle.h"
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="angle.h" />
|
<ClInclude Include="angle.h" />
|
||||||
<ClInclude Include="basis.h" />
|
|
||||||
<ClInclude Include="basic-geometry.h" />
|
<ClInclude Include="basic-geometry.h" />
|
||||||
<ClInclude Include="matrix2x2.h" />
|
<ClInclude Include="matrix2x2.h" />
|
||||||
<ClInclude Include="matrix2x3.h" />
|
<ClInclude Include="matrix2x3.h" />
|
||||||
|
@ -30,6 +29,7 @@
|
||||||
<ClInclude Include="quaternion.h" />
|
<ClInclude Include="quaternion.h" />
|
||||||
<ClInclude Include="rotation3.h" />
|
<ClInclude Include="rotation3.h" />
|
||||||
<ClInclude Include="tangent.h" />
|
<ClInclude Include="tangent.h" />
|
||||||
|
<ClInclude Include="utilities.h" />
|
||||||
<ClInclude Include="versor.h" />
|
<ClInclude Include="versor.h" />
|
||||||
<ClInclude Include="vector2.h" />
|
<ClInclude Include="vector2.h" />
|
||||||
<ClInclude Include="vector3.h" />
|
<ClInclude Include="vector3.h" />
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<ClInclude Include="angle.h">
|
<ClInclude Include="angle.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="basis.h">
|
<ClInclude Include="utilities.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="basic-geometry.h">
|
<ClInclude Include="basic-geometry.h">
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#include "basis.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
#ifndef _GEOMETRY_BASIS_H_
|
|
||||||
#define _GEOMETRY_BASIS_H_
|
|
||||||
|
|
||||||
#define FP32_EPSYLON_EFFECTIVENESS_LIMIT 10.0f
|
|
||||||
|
|
||||||
#define FP32_EPSYLON 5E-7f
|
|
||||||
#define FP32_TWO_EPSYLON 1E-6f
|
|
||||||
#define FP32_SQUARE_EPSYLON 2.5E-13f
|
|
||||||
|
|
||||||
#define FP32_ONE_THIRD 0.333333333f
|
|
||||||
#define FP32_ONE_SIXTH 0.166666667f
|
|
||||||
#define FP32_ONE_NINETH 0.111111111f
|
|
||||||
|
|
||||||
#define FP32_GOLDEN_RATIO_HIGH 1.618034f
|
|
||||||
#define FP32_GOLDEN_RATIO_LOW 0.618034f
|
|
||||||
|
|
||||||
#define FP64_EPSYLON_EFFECTIVENESS_LIMIT 10.0
|
|
||||||
|
|
||||||
#define FP64_EPSYLON 5E-14
|
|
||||||
#define FP64_TWO_EPSYLON 1E-13
|
|
||||||
#define FP64_SQUARE_EPSYLON 2.5E-27
|
|
||||||
|
|
||||||
#define FP64_ONE_THIRD 0.333333333333333333
|
|
||||||
#define FP64_ONE_SIXTH 0.166666666666666667
|
|
||||||
#define FP64_ONE_NINETH 0.111111111111111111
|
|
||||||
|
|
||||||
#define FP64_GOLDEN_RATIO_HIGH 1.61803398874989485
|
|
||||||
#define FP64_GOLDEN_RATIO_LOW 0.61803398874989485
|
|
||||||
|
|
||||||
inline int fp32_are_equal(const float value1, const float value2)
|
|
||||||
{
|
|
||||||
if (-FP32_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
|
|
||||||
return -FP32_EPSYLON <= (value1 - value2) && (value1 - value2) <= FP32_EPSYLON;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value1 < 0.0f) {
|
|
||||||
return (1.0f + FP32_EPSYLON) * value2 <= value1 && (1.0f + FP32_EPSYLON) * value1 <= value2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value2 <= value1 * (1.0f + FP32_EPSYLON) && value1 <= value2 * (1.0f + FP32_EPSYLON);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int fp64_are_equal(const double value1, const double value2)
|
|
||||||
{
|
|
||||||
if (-FP64_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
|
|
||||||
return -FP64_EPSYLON <= (value1 - value2) && (value1 - value2) <= FP64_EPSYLON;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value1 < 0.0) {
|
|
||||||
return (1.0 + FP64_EPSYLON) * value2 <= value1 && (1.0 + FP64_EPSYLON) * value1 <= value2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value2 <= value1 * (1.0 + FP64_EPSYLON) && value1 <= value2 * (1.0 + FP64_EPSYLON);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _BASIC_GEOMETRY_MATRIX2X2_H_
|
#ifndef _BGC_MATRIX2X2_H_
|
||||||
#define _BASIC_GEOMETRY_MATRIX2X2_H_
|
#define _BGC_MATRIX2X2_H_
|
||||||
|
|
||||||
#include "angle.h"
|
#include "angle.h"
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
inline void matrix2x2_reset_fp32(matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_reset_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0f;
|
matrix->r1c1 = 0.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -15,7 +15,7 @@ inline void matrix2x2_reset_fp32(matrix2x2_fp32_t* matrix)
|
||||||
matrix->r2c2 = 0.0f;
|
matrix->r2c2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_reset_fp64(matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_reset_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0;
|
matrix->r1c1 = 0.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -25,7 +25,7 @@ inline void matrix2x2_reset_fp64(matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// ================== Identity ================== //
|
// ================== Identity ================== //
|
||||||
|
|
||||||
inline void matrix2x2_set_to_identity_fp32(matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_to_identity_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 1.0f;
|
matrix->r1c1 = 1.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -33,7 +33,7 @@ inline void matrix2x2_set_to_identity_fp32(matrix2x2_fp32_t* matrix)
|
||||||
matrix->r2c2 = 1.0f;
|
matrix->r2c2 = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_set_to_identity_fp64(matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_to_identity_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 1.0;
|
matrix->r1c1 = 1.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -43,7 +43,7 @@ inline void matrix2x2_set_to_identity_fp64(matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// ================ Make Diagonal =============== //
|
// ================ Make Diagonal =============== //
|
||||||
|
|
||||||
inline void matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -51,7 +51,7 @@ inline void matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, matri
|
||||||
matrix->r2c2 = d2;
|
matrix->r2c2 = d2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -61,9 +61,9 @@ inline void matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, mat
|
||||||
|
|
||||||
// ============== Rotation Matrix =============== //
|
// ============== Rotation Matrix =============== //
|
||||||
|
|
||||||
inline void matrix2x2_make_rotation_fp32(const float angle, const angle_unit_t unit, matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const bgc_angle_unit_t unit, bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
const float radians = fp32_angle_to_radians(angle, unit);
|
const float radians = bgc_angle_to_radians_fp32(angle, unit);
|
||||||
const float cosine = cosf(radians);
|
const float cosine = cosf(radians);
|
||||||
const float sine = sinf(radians);
|
const float sine = sinf(radians);
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ inline void matrix2x2_make_rotation_fp32(const float angle, const angle_unit_t u
|
||||||
matrix->r2c2 = cosine;
|
matrix->r2c2 = cosine;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_make_rotation_fp64(const double angle, const angle_unit_t unit, matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const bgc_angle_unit_t unit, bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
const double radians = fp64_angle_to_radians(angle, unit);
|
const double radians = bgc_angle_to_radians_fp64(angle, unit);
|
||||||
const double cosine = cos(radians);
|
const double cosine = cos(radians);
|
||||||
const double sine = sin(radians);
|
const double sine = sin(radians);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ inline void matrix2x2_make_rotation_fp64(const double angle, const angle_unit_t
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void matrix2x2_copy_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t* to)
|
inline void bgc_matrix2x2_copy_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -96,7 +96,7 @@ inline void matrix2x2_copy_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t*
|
||||||
to->r2c2 = from->r2c2;
|
to->r2c2 = from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_copy_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t* to)
|
inline void bgc_matrix2x2_copy_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -107,7 +107,7 @@ inline void matrix2x2_copy_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t*
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void matrix2x2_swap_fp32(matrix2x2_fp32_t* matrix1, matrix2x2_fp32_t* matrix2)
|
inline void bgc_matrix2x2_swap_fp32(bgc_matrix2x2_fp32_t* matrix1, bgc_matrix2x2_fp32_t* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matrix2->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matrix2->r1c2;
|
||||||
|
@ -128,7 +128,7 @@ inline void matrix2x2_swap_fp32(matrix2x2_fp32_t* matrix1, matrix2x2_fp32_t* mat
|
||||||
matrix1->r2c2 = r2c2;
|
matrix1->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_swap_fp64(matrix2x2_fp64_t* matrix1, matrix2x2_fp64_t* matrix2)
|
inline void bgc_matrix2x2_swap_fp64(bgc_matrix2x2_fp64_t* matrix1, bgc_matrix2x2_fp64_t* matrix2)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matrix2->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matrix2->r1c2;
|
||||||
|
@ -151,7 +151,7 @@ inline void matrix2x2_swap_fp64(matrix2x2_fp64_t* matrix1, matrix2x2_fp64_t* mat
|
||||||
|
|
||||||
// ============= Copy to twin type ============== //
|
// ============= Copy to twin type ============== //
|
||||||
|
|
||||||
inline void matrix2x2_convert_fp64_to_fp32(const matrix2x2_fp64_t* from, matrix2x2_fp32_t* to)
|
inline void bgc_matrix2x2_convert_fp64_to_fp32(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = (float)from->r1c1;
|
to->r1c1 = (float)from->r1c1;
|
||||||
to->r1c2 = (float)from->r1c2;
|
to->r1c2 = (float)from->r1c2;
|
||||||
|
@ -160,7 +160,7 @@ inline void matrix2x2_convert_fp64_to_fp32(const matrix2x2_fp64_t* from, matrix2
|
||||||
to->r2c2 = (float)from->r2c2;
|
to->r2c2 = (float)from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_convert_fp32_to_fp64(const matrix2x2_fp32_t* from, matrix2x2_fp64_t* to)
|
inline void bgc_matrix2x2_convert_fp32_to_fp64(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -171,42 +171,42 @@ inline void matrix2x2_convert_fp32_to_fp64(const matrix2x2_fp32_t* from, matrix2
|
||||||
|
|
||||||
// ================ Determinant ================= //
|
// ================ Determinant ================= //
|
||||||
|
|
||||||
inline float matrix2x2_get_determinant_fp32(const matrix2x2_fp32_t* matrix)
|
inline float bgc_matrix2x2_get_determinant_fp32(const bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double matrix2x2_get_determinant_fp64(const matrix2x2_fp64_t* matrix)
|
inline double bgc_matrix2x2_get_determinant_fp64(const bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Singular ================== //
|
// ================== Singular ================== //
|
||||||
|
|
||||||
inline int matrix2x2_is_singular_fp32(const matrix2x2_fp32_t* matrix)
|
inline int bgc_matrix2x2_is_singular_fp32(const bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
const float determinant = matrix2x2_get_determinant_fp32(matrix);
|
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
return -FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON;
|
return -BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int matrix2x2_is_singular_fp64(const matrix2x2_fp64_t* matrix)
|
inline int bgc_matrix2x2_is_singular_fp64(const bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
const double determinant = matrix2x2_get_determinant_fp64(matrix);
|
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
return -FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON;
|
return -BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Transposition ================ //
|
// =============== Transposition ================ //
|
||||||
|
|
||||||
inline void matrix2x2_transpose_fp32(matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_transpose_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
const float tmp = matrix->r1c2;
|
const float tmp = matrix->r1c2;
|
||||||
matrix->r1c2 = matrix->r2c1;
|
matrix->r1c2 = matrix->r2c1;
|
||||||
matrix->r2c1 = tmp;
|
matrix->r2c1 = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_transpose_fp64(matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_transpose_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
const double tmp = matrix->r1c2;
|
const double tmp = matrix->r1c2;
|
||||||
matrix->r1c2 = matrix->r2c1;
|
matrix->r1c2 = matrix->r2c1;
|
||||||
|
@ -215,11 +215,11 @@ inline void matrix2x2_transpose_fp64(matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// ================= Inversion ================== //
|
// ================= Inversion ================== //
|
||||||
|
|
||||||
inline int matrix2x2_invert_fp32(matrix2x2_fp32_t* matrix)
|
inline int bgc_matrix2x2_invert_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
const float determinant = matrix2x2_get_determinant_fp32(matrix);
|
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
if (-FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON) {
|
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,11 +240,11 @@ inline int matrix2x2_invert_fp32(matrix2x2_fp32_t* matrix)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int matrix2x2_invert_fp64(matrix2x2_fp64_t* matrix)
|
inline int bgc_matrix2x2_invert_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
const double determinant = matrix2x2_get_determinant_fp64(matrix);
|
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
if (-FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON) {
|
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ inline int matrix2x2_invert_fp64(matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// =============== Set Transposed =============== //
|
// =============== Set Transposed =============== //
|
||||||
|
|
||||||
inline void matrix2x2_set_transposed_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t* to)
|
inline void bgc_matrix2x2_set_transposed_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
float tmp = from->r1c2;
|
float tmp = from->r1c2;
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ inline void matrix2x2_set_transposed_fp32(const matrix2x2_fp32_t* from, matrix2x
|
||||||
to->r2c2 = from->r2c2;
|
to->r2c2 = from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_set_transposed_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t* to)
|
inline void bgc_matrix2x2_set_transposed_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
double tmp = from->r1c2;
|
double tmp = from->r1c2;
|
||||||
|
|
||||||
|
@ -291,11 +291,11 @@ inline void matrix2x2_set_transposed_fp64(const matrix2x2_fp64_t* from, matrix2x
|
||||||
|
|
||||||
// ================ Set Inverted ================ //
|
// ================ Set Inverted ================ //
|
||||||
|
|
||||||
inline int matrix2x2_set_inverted_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t* to)
|
inline int bgc_matrix2x2_set_inverted_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
const float determinant = matrix2x2_get_determinant_fp32(from);
|
const float determinant = bgc_matrix2x2_get_determinant_fp32(from);
|
||||||
|
|
||||||
if (-FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON) {
|
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,11 +316,11 @@ inline int matrix2x2_set_inverted_fp32(const matrix2x2_fp32_t* from, matrix2x2_f
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int matrix2x2_set_inverted_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t* to)
|
inline int bgc_matrix2x2_set_inverted_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
const double determinant = matrix2x2_get_determinant_fp64(from);
|
const double determinant = bgc_matrix2x2_get_determinant_fp64(from);
|
||||||
|
|
||||||
if (-FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON) {
|
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,13 +343,13 @@ inline int matrix2x2_set_inverted_fp64(const matrix2x2_fp64_t* from, matrix2x2_f
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
inline void matrix2x2_set_row1_fp32(const float c1, const float c2, matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_set_row1_fp64(const double c1, const double c2, matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
|
@ -357,13 +357,13 @@ inline void matrix2x2_set_row1_fp64(const double c1, const double c2, matrix2x2_
|
||||||
|
|
||||||
// ================= Set Row 2 ================== //
|
// ================= Set Row 2 ================== //
|
||||||
|
|
||||||
inline void matrix2x2_set_row2_fp32(const float c1, const float c2, matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_set_row2_fp64(const double c1, const double c2, matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
|
@ -371,13 +371,13 @@ inline void matrix2x2_set_row2_fp64(const double c1, const double c2, matrix2x2_
|
||||||
|
|
||||||
// ================ Set Column 1 ================ //
|
// ================ Set Column 1 ================ //
|
||||||
|
|
||||||
inline void matrix2x2_set_column1_fp32(const float r1, const float r2, matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_set_column1_fp64(const double r1, const double r2, matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
|
@ -385,41 +385,21 @@ inline void matrix2x2_set_column1_fp64(const double r1, const double r2, matrix2
|
||||||
|
|
||||||
// ================ Set Column 2 ================ //
|
// ================ Set Column 2 ================ //
|
||||||
|
|
||||||
inline void matrix2x2_set_column2_fp32(const float r1, const float r2, matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, bgc_matrix2x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_set_column2_fp64(const double r1, const double r2, matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, bgc_matrix2x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Append scaled =============== //
|
|
||||||
|
|
||||||
inline void matrix2x2_add_scaled_fp32(matrix2x2_fp32_t* basic_vector, const matrix2x2_fp32_t* scalable_vector, const float scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void matrix2x2_add_scaled_fp64(matrix2x2_fp64_t* basic_vector, const matrix2x2_fp64_t* scalable_vector, const double scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// ================== Addition ================== //
|
||||||
|
|
||||||
inline void matrix2x2_add_fp32(const matrix2x2_fp32_t* matrix1, const matrix2x2_fp32_t* matrix2, matrix2x2_fp32_t* sum)
|
inline void bgc_matrix2x2_add_fp32(const bgc_matrix2x2_fp32_t* matrix1, const bgc_matrix2x2_fp32_t* matrix2, bgc_matrix2x2_fp32_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -428,7 +408,7 @@ inline void matrix2x2_add_fp32(const matrix2x2_fp32_t* matrix1, const matrix2x2_
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_add_fp64(const matrix2x2_fp64_t* matrix1, const matrix2x2_fp64_t* matrix2, matrix2x2_fp64_t* sum)
|
inline void bgc_matrix2x2_add_fp64(const bgc_matrix2x2_fp64_t* matrix1, const bgc_matrix2x2_fp64_t* matrix2, bgc_matrix2x2_fp64_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -437,9 +417,29 @@ inline void matrix2x2_add_fp64(const matrix2x2_fp64_t* matrix1, const matrix2x2_
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================= Add scaled ================= //
|
||||||
|
|
||||||
|
inline void bgc_matrix2x2_add_scaled_fp32(const bgc_matrix2x2_fp32_t* basic_matrix, const bgc_matrix2x2_fp32_t* scalable_matrix, const float scale, bgc_matrix2x2_fp32_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix2x2_add_scaled_fp64(const bgc_matrix2x2_fp64_t* basic_matrix, const bgc_matrix2x2_fp64_t* scalable_matrix, const double scale, bgc_matrix2x2_fp64_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
// ================ Subtraction ================= //
|
// ================ Subtraction ================= //
|
||||||
|
|
||||||
inline void matrix2x2_subtract_fp32(const matrix2x2_fp32_t* minuend, const matrix2x2_fp32_t* subtrahend, matrix2x2_fp32_t* difference)
|
inline void bgc_matrix2x2_subtract_fp32(const bgc_matrix2x2_fp32_t* minuend, const bgc_matrix2x2_fp32_t* subtrahend, bgc_matrix2x2_fp32_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -448,7 +448,7 @@ inline void matrix2x2_subtract_fp32(const matrix2x2_fp32_t* minuend, const matri
|
||||||
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_subtract_fp64(const matrix2x2_fp64_t* minuend, const matrix2x2_fp64_t* subtrahend, matrix2x2_fp64_t* difference)
|
inline void bgc_matrix2x2_subtract_fp64(const bgc_matrix2x2_fp64_t* minuend, const bgc_matrix2x2_fp64_t* subtrahend, bgc_matrix2x2_fp64_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -459,7 +459,7 @@ inline void matrix2x2_subtract_fp64(const matrix2x2_fp64_t* minuend, const matri
|
||||||
|
|
||||||
// =============== Multiplication =============== //
|
// =============== Multiplication =============== //
|
||||||
|
|
||||||
inline void matrix2x2_multiply_fp32(const matrix2x2_fp32_t* multiplicand, const float multiplier, matrix2x2_fp32_t* product)
|
inline void bgc_matrix2x2_multiply_fp32(const bgc_matrix2x2_fp32_t* multiplicand, const float multiplier, bgc_matrix2x2_fp32_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -468,7 +468,7 @@ inline void matrix2x2_multiply_fp32(const matrix2x2_fp32_t* multiplicand, const
|
||||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_multiply_fp64(const matrix2x2_fp64_t* multiplicand, const double multiplier, matrix2x2_fp64_t* product)
|
inline void bgc_matrix2x2_multiply_fp64(const bgc_matrix2x2_fp64_t* multiplicand, const double multiplier, bgc_matrix2x2_fp64_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -479,19 +479,19 @@ inline void matrix2x2_multiply_fp64(const matrix2x2_fp64_t* multiplicand, const
|
||||||
|
|
||||||
// ================== Division ================== //
|
// ================== Division ================== //
|
||||||
|
|
||||||
inline void matrix2x2_divide_fp32(const matrix2x2_fp32_t* dividend, const float divisor, matrix2x2_fp32_t* quotient)
|
inline void bgc_matrix2x2_divide_fp32(const bgc_matrix2x2_fp32_t* dividend, const float divisor, bgc_matrix2x2_fp32_t* quotient)
|
||||||
{
|
{
|
||||||
matrix2x2_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
bgc_matrix2x2_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_fp64_divide(const matrix2x2_fp64_t* dividend, const double divisor, matrix2x2_fp64_t* quotient)
|
inline void bgc_matrix2x2_divide_fp64(const bgc_matrix2x2_fp64_t* dividend, const double divisor, bgc_matrix2x2_fp64_t* quotient)
|
||||||
{
|
{
|
||||||
matrix2x2_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
bgc_matrix2x2_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void matrix2x2_left_product_fp32(const vector2_fp32_t* vector, const matrix2x2_fp32_t* matrix, vector2_fp32_t* result)
|
inline void bgc_matrix2x2_left_product_fp32(const bgc_vector2_fp32_t* vector, const bgc_matrix2x2_fp32_t* matrix, bgc_vector2_fp32_t* result)
|
||||||
{
|
{
|
||||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
@ -500,7 +500,7 @@ inline void matrix2x2_left_product_fp32(const vector2_fp32_t* vector, const matr
|
||||||
result->x2 = x2;
|
result->x2 = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_left_product_fp64(const vector2_fp64_t* vector, const matrix2x2_fp64_t* matrix, vector2_fp64_t* result)
|
inline void bgc_matrix2x2_left_product_fp64(const bgc_vector2_fp64_t* vector, const bgc_matrix2x2_fp64_t* matrix, bgc_vector2_fp64_t* result)
|
||||||
{
|
{
|
||||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
@ -511,7 +511,7 @@ inline void matrix2x2_left_product_fp64(const vector2_fp64_t* vector, const matr
|
||||||
|
|
||||||
// ============ Right Vector Product ============ //
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
inline void matrix2x2_right_product_fp32(const matrix2x2_fp32_t* matrix, const vector2_fp32_t* vector, vector2_fp32_t* result)
|
inline void bgc_matrix2x2_right_product_fp32(const bgc_matrix2x2_fp32_t* matrix, const bgc_vector2_fp32_t* vector, bgc_vector2_fp32_t* result)
|
||||||
{
|
{
|
||||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
@ -520,7 +520,7 @@ inline void matrix2x2_right_product_fp32(const matrix2x2_fp32_t* matrix, const v
|
||||||
result->x2 = x2;
|
result->x2 = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x2_right_product_fp64(const matrix2x2_fp64_t* matrix, const vector2_fp64_t* vector, vector2_fp64_t* result)
|
inline void bgc_matrix2x2_right_product_fp64(const bgc_matrix2x2_fp64_t* matrix, const bgc_vector2_fp64_t* vector, bgc_vector2_fp64_t* result)
|
||||||
{
|
{
|
||||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _BASIC_GEOMETRY_MATRIX2X3_H_
|
#ifndef _BGC_MATRIX2X3_H_
|
||||||
#define _BASIC_GEOMETRY_MATRIX2X3_H_
|
#define _BGC_MATRIX2X3_H_
|
||||||
|
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
inline void matrix2x3_reset_fp32(matrix2x3_fp32_t* matrix)
|
inline void bgc_matrix2x3_reset_fp32(bgc_matrix2x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0f;
|
matrix->r1c1 = 0.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -19,7 +19,7 @@ inline void matrix2x3_reset_fp32(matrix2x3_fp32_t* matrix)
|
||||||
matrix->r3c2 = 0.0f;
|
matrix->r3c2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_reset_fp64(matrix2x3_fp64_t* matrix)
|
inline void bgc_matrix2x3_reset_fp64(bgc_matrix2x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0;
|
matrix->r1c1 = 0.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -33,7 +33,7 @@ inline void matrix2x3_reset_fp64(matrix2x3_fp64_t* matrix)
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void matrix2x3_copy_fp32(const matrix2x3_fp32_t* from, matrix2x3_fp32_t* to)
|
inline void bgc_matrix2x3_copy_fp32(const bgc_matrix2x3_fp32_t* from, bgc_matrix2x3_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -45,7 +45,7 @@ inline void matrix2x3_copy_fp32(const matrix2x3_fp32_t* from, matrix2x3_fp32_t*
|
||||||
to->r3c2 = from->r3c2;
|
to->r3c2 = from->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_copy_fp64(const matrix2x3_fp64_t* from, matrix2x3_fp64_t* to)
|
inline void bgc_matrix2x3_copy_fp64(const bgc_matrix2x3_fp64_t* from, bgc_matrix2x3_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -59,7 +59,7 @@ inline void matrix2x3_copy_fp64(const matrix2x3_fp64_t* from, matrix2x3_fp64_t*
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void matrix2x3_swap_fp32(matrix2x3_fp32_t* matrix1, matrix2x3_fp32_t* matrix2)
|
inline void bgc_matrix2x3_swap_fp32(bgc_matrix2x3_fp32_t* matrix1, bgc_matrix2x3_fp32_t* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matrix2->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matrix2->r1c2;
|
||||||
|
@ -89,7 +89,7 @@ inline void matrix2x3_swap_fp32(matrix2x3_fp32_t* matrix1, matrix2x3_fp32_t* mat
|
||||||
matrix1->r3c2 = r3c2;
|
matrix1->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_swap_fp64(matrix2x3_fp64_t* matrix1, matrix2x3_fp64_t* matrix2)
|
inline void bgc_matrix2x3_swap_fp64(bgc_matrix2x3_fp64_t* matrix1, bgc_matrix2x3_fp64_t* matrix2)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matrix2->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matrix2->r1c2;
|
||||||
|
@ -121,7 +121,7 @@ inline void matrix2x3_swap_fp64(matrix2x3_fp64_t* matrix1, matrix2x3_fp64_t* mat
|
||||||
|
|
||||||
// ============= Copy to twin type ============== //
|
// ============= Copy to twin type ============== //
|
||||||
|
|
||||||
inline void matrix2x3_convert_fp64_to_fp32(const matrix2x3_fp64_t* from, matrix2x3_fp32_t* to)
|
inline void bgc_matrix2x3_convert_fp64_to_fp32(const bgc_matrix2x3_fp64_t* from, bgc_matrix2x3_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = (float) from->r1c1;
|
to->r1c1 = (float) from->r1c1;
|
||||||
to->r1c2 = (float) from->r1c2;
|
to->r1c2 = (float) from->r1c2;
|
||||||
|
@ -133,7 +133,7 @@ inline void matrix2x3_convert_fp64_to_fp32(const matrix2x3_fp64_t* from, matrix2
|
||||||
to->r3c2 = (float) from->r3c2;
|
to->r3c2 = (float) from->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_convert_fp32_to_fp64(const matrix2x3_fp32_t* from, matrix2x3_fp64_t* to)
|
inline void bgc_matrix2x3_convert_fp32_to_fp64(const bgc_matrix2x3_fp32_t* from, bgc_matrix2x3_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -147,7 +147,7 @@ inline void matrix2x3_convert_fp32_to_fp64(const matrix2x3_fp32_t* from, matrix2
|
||||||
|
|
||||||
// =============== Set transposed =============== //
|
// =============== Set transposed =============== //
|
||||||
|
|
||||||
inline void matrix2x3_set_transposed_fp32(const matrix3x2_fp32_t* from, matrix2x3_fp32_t* to)
|
inline void bgc_matrix2x3_set_transposed_fp32(const bgc_matrix3x2_fp32_t* from, bgc_matrix2x3_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r2c1;
|
to->r1c2 = from->r2c1;
|
||||||
|
@ -159,7 +159,7 @@ inline void matrix2x3_set_transposed_fp32(const matrix3x2_fp32_t* from, matrix2x
|
||||||
to->r3c2 = from->r2c3;
|
to->r3c2 = from->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_set_transposed_fp64(const matrix3x2_fp64_t* from, matrix2x3_fp64_t* to)
|
inline void bgc_matrix2x3_set_transposed_fp64(const bgc_matrix3x2_fp64_t* from, bgc_matrix2x3_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r2c1;
|
to->r1c2 = from->r2c1;
|
||||||
|
@ -173,7 +173,7 @@ inline void matrix2x3_set_transposed_fp64(const matrix3x2_fp64_t* from, matrix2x
|
||||||
|
|
||||||
// =============== Set transposed =============== //
|
// =============== Set transposed =============== //
|
||||||
|
|
||||||
inline void matrix2x3_set_transposed_fp32_fp64(const matrix3x2_fp64_t* from, matrix2x3_fp32_t* to)
|
inline void bgc_matrix2x3_set_transposed_fp32_fp64(const bgc_matrix3x2_fp64_t* from, bgc_matrix2x3_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = (float) from->r1c1;
|
to->r1c1 = (float) from->r1c1;
|
||||||
to->r1c2 = (float) from->r2c1;
|
to->r1c2 = (float) from->r2c1;
|
||||||
|
@ -185,7 +185,7 @@ inline void matrix2x3_set_transposed_fp32_fp64(const matrix3x2_fp64_t* from, mat
|
||||||
to->r3c2 = (float) from->r2c3;
|
to->r3c2 = (float) from->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_set_transposed_fp64_fp32(const matrix3x2_fp32_t* from, matrix2x3_fp64_t* to)
|
inline void bgc_matrix2x3_set_transposed_fp64_fp32(const bgc_matrix3x2_fp32_t* from, bgc_matrix2x3_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r2c1;
|
to->r1c2 = from->r2c1;
|
||||||
|
@ -199,13 +199,13 @@ inline void matrix2x3_set_transposed_fp64_fp32(const matrix3x2_fp32_t* from, mat
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
inline void matrix2x3_set_row1_fp32(const float c1, const float c2, matrix2x3_fp32_t* matrix)
|
inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, bgc_matrix2x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_set_row1_fp64(const double c1, const double c2, matrix2x3_fp64_t* matrix)
|
inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, bgc_matrix2x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
|
@ -213,13 +213,13 @@ inline void matrix2x3_set_row1_fp64(const double c1, const double c2, matrix2x3_
|
||||||
|
|
||||||
// ================= Set Row 2 ================== //
|
// ================= Set Row 2 ================== //
|
||||||
|
|
||||||
inline void matrix2x3_set_row2_fp32(const float c1, const float c2, matrix2x3_fp32_t* matrix)
|
inline void bgc_matrix2x3_set_row2_fp32(const float c1, const float c2, bgc_matrix2x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_set_row2_fp64(const double c1, const double c2, matrix2x3_fp64_t* matrix)
|
inline void bgc_matrix2x3_set_row2_fp64(const double c1, const double c2, bgc_matrix2x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
|
@ -227,13 +227,13 @@ inline void matrix2x3_set_row2_fp64(const double c1, const double c2, matrix2x3_
|
||||||
|
|
||||||
// ================= Set Row 3 ================== //
|
// ================= Set Row 3 ================== //
|
||||||
|
|
||||||
inline void matrix2x3_set_row3_fp32(const float c1, const float c2, matrix2x3_fp32_t* matrix)
|
inline void bgc_matrix2x3_set_row3_fp32(const float c1, const float c2, bgc_matrix2x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r3c1 = c1;
|
matrix->r3c1 = c1;
|
||||||
matrix->r3c2 = c2;
|
matrix->r3c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_set_row3_fp64(const double c1, const double c2, matrix2x3_fp64_t* matrix)
|
inline void bgc_matrix2x3_set_row3_fp64(const double c1, const double c2, bgc_matrix2x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r3c1 = c1;
|
matrix->r3c1 = c1;
|
||||||
matrix->r3c2 = c2;
|
matrix->r3c2 = c2;
|
||||||
|
@ -241,14 +241,14 @@ inline void matrix2x3_set_row3_fp64(const double c1, const double c2, matrix2x3_
|
||||||
|
|
||||||
// ================ Set Column 1 ================ //
|
// ================ Set Column 1 ================ //
|
||||||
|
|
||||||
inline void matrix2x3_set_column1_fp32(const float r1, const float r2, const float r3, matrix2x3_fp32_t* matrix)
|
inline void bgc_matrix2x3_set_column1_fp32(const float r1, const float r2, const float r3, bgc_matrix2x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
matrix->r3c1 = r3;
|
matrix->r3c1 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_set_column1_fp64(const double r1, const double r2, const double r3, matrix2x3_fp64_t* matrix)
|
inline void bgc_matrix2x3_set_column1_fp64(const double r1, const double r2, const double r3, bgc_matrix2x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
|
@ -257,49 +257,23 @@ inline void matrix2x3_set_column1_fp64(const double r1, const double r2, const d
|
||||||
|
|
||||||
// ================ Set Column 2 ================ //
|
// ================ Set Column 2 ================ //
|
||||||
|
|
||||||
inline void matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, matrix2x3_fp32_t* matrix)
|
inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, bgc_matrix2x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
matrix->r3c2 = r3;
|
matrix->r3c2 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, matrix2x3_fp64_t* matrix)
|
inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, bgc_matrix2x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
matrix->r3c2 = r3;
|
matrix->r3c2 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Append scaled =============== //
|
|
||||||
|
|
||||||
inline void matrix2x3_add_scaled_fp32(matrix2x3_fp32_t* basic_vector, const matrix2x3_fp32_t* scalable_vector, const float scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
|
|
||||||
basic_vector->r3c1 += scalable_vector->r3c1 * scale;
|
|
||||||
basic_vector->r3c2 += scalable_vector->r3c2 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void matrix2x3_add_scaled_fp64(matrix2x3_fp64_t* basic_vector, const matrix2x3_fp64_t* scalable_vector, const double scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
|
|
||||||
basic_vector->r3c1 += scalable_vector->r3c1 * scale;
|
|
||||||
basic_vector->r3c2 += scalable_vector->r3c2 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// ================== Addition ================== //
|
||||||
|
|
||||||
inline void matrix2x3_add_fp32(const matrix2x3_fp32_t* matrix1, const matrix2x3_fp32_t* matrix2, matrix2x3_fp32_t* sum)
|
inline void bgc_matrix2x3_add_fp32(const bgc_matrix2x3_fp32_t* matrix1, const bgc_matrix2x3_fp32_t* matrix2, bgc_matrix2x3_fp32_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -311,7 +285,7 @@ inline void matrix2x3_add_fp32(const matrix2x3_fp32_t* matrix1, const matrix2x3_
|
||||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_add_fp64(const matrix2x3_fp64_t* matrix1, const matrix2x3_fp64_t* matrix2, matrix2x3_fp64_t* sum)
|
inline void bgc_matrix2x3_add_fp64(const bgc_matrix2x3_fp64_t* matrix1, const bgc_matrix2x3_fp64_t* matrix2, bgc_matrix2x3_fp64_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -323,9 +297,35 @@ inline void matrix2x3_add_fp64(const matrix2x3_fp64_t* matrix1, const matrix2x3_
|
||||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================= Add scaled ================= //
|
||||||
|
|
||||||
|
inline void bgc_matrix2x3_add_scaled_fp32(const bgc_matrix2x3_fp32_t* basic_matrix, const bgc_matrix2x3_fp32_t* scalable_matrix, const float scale, bgc_matrix2x3_fp32_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
|
||||||
|
sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale;
|
||||||
|
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix2x3_add_scaled_fp64(const bgc_matrix2x3_fp64_t* basic_matrix, const bgc_matrix2x3_fp64_t* scalable_matrix, const double scale, bgc_matrix2x3_fp64_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
|
||||||
|
sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale;
|
||||||
|
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
// ================ Subtraction ================= //
|
// ================ Subtraction ================= //
|
||||||
|
|
||||||
inline void matrix2x3_subtract_fp32(const matrix2x3_fp32_t* minuend, const matrix2x3_fp32_t* subtrahend, matrix2x3_fp32_t* difference)
|
inline void bgc_matrix2x3_subtract_fp32(const bgc_matrix2x3_fp32_t* minuend, const bgc_matrix2x3_fp32_t* subtrahend, bgc_matrix2x3_fp32_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -337,7 +337,7 @@ inline void matrix2x3_subtract_fp32(const matrix2x3_fp32_t* minuend, const matri
|
||||||
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
|
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_subtract_fp64(const matrix2x3_fp64_t* minuend, const matrix2x3_fp64_t* subtrahend, matrix2x3_fp64_t* difference)
|
inline void bgc_matrix2x3_subtract_fp64(const bgc_matrix2x3_fp64_t* minuend, const bgc_matrix2x3_fp64_t* subtrahend, bgc_matrix2x3_fp64_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -351,7 +351,7 @@ inline void matrix2x3_subtract_fp64(const matrix2x3_fp64_t* minuend, const matri
|
||||||
|
|
||||||
// =============== Multiplication =============== //
|
// =============== Multiplication =============== //
|
||||||
|
|
||||||
inline void matrix2x3_multiply_fp32(const matrix2x3_fp32_t* multiplicand, const float multiplier, matrix2x3_fp32_t* product)
|
inline void bgc_matrix2x3_multiply_fp32(const bgc_matrix2x3_fp32_t* multiplicand, const float multiplier, bgc_matrix2x3_fp32_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -363,7 +363,7 @@ inline void matrix2x3_multiply_fp32(const matrix2x3_fp32_t* multiplicand, const
|
||||||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_multiply_fp64(const matrix2x3_fp64_t* multiplicand, const double multiplier, matrix2x3_fp64_t* product)
|
inline void bgc_matrix2x3_multiply_fp64(const bgc_matrix2x3_fp64_t* multiplicand, const double multiplier, bgc_matrix2x3_fp64_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -377,25 +377,25 @@ inline void matrix2x3_multiply_fp64(const matrix2x3_fp64_t* multiplicand, const
|
||||||
|
|
||||||
// ================== Division ================== //
|
// ================== Division ================== //
|
||||||
|
|
||||||
inline void matrix2x3_divide_fp32(const matrix2x3_fp32_t* dividend, const float divisor, matrix2x3_fp32_t* quotient)
|
inline void bgc_matrix2x3_divide_fp32(const bgc_matrix2x3_fp32_t* dividend, const float divisor, bgc_matrix2x3_fp32_t* quotient)
|
||||||
{
|
{
|
||||||
matrix2x3_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
bgc_matrix2x3_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_fp64_divide(const matrix2x3_fp64_t* dividend, const double divisor, matrix2x3_fp64_t* quotient)
|
inline void bgc_matrix2x3_divide_fp64(const bgc_matrix2x3_fp64_t* dividend, const double divisor, bgc_matrix2x3_fp64_t* quotient)
|
||||||
{
|
{
|
||||||
matrix2x3_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
bgc_matrix2x3_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void matrix2x3_left_product_fp32(const vector3_fp32_t* vector, const matrix2x3_fp32_t* matrix, vector2_fp32_t* result)
|
inline void bgc_matrix2x3_left_product_fp32(const bgc_vector3_fp32_t* vector, const bgc_matrix2x3_fp32_t* matrix, bgc_vector2_fp32_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||||
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_left_product_fp64(const vector3_fp64_t* vector, const matrix2x3_fp64_t* matrix, vector2_fp64_t* result)
|
inline void bgc_matrix2x3_left_product_fp64(const bgc_vector3_fp64_t* vector, const bgc_matrix2x3_fp64_t* matrix, bgc_vector2_fp64_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||||
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||||
|
@ -403,14 +403,14 @@ inline void matrix2x3_left_product_fp64(const vector3_fp64_t* vector, const matr
|
||||||
|
|
||||||
// ============ Right Vector Product ============ //
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
inline void matrix2x3_right_product_fp32(const matrix2x3_fp32_t* matrix, const vector2_fp32_t* vector, vector3_fp32_t* result)
|
inline void bgc_matrix2x3_right_product_fp32(const bgc_matrix2x3_fp32_t* matrix, const bgc_vector2_fp32_t* vector, bgc_vector3_fp32_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix2x3_right_product_fp64(const matrix2x3_fp64_t* matrix, const vector2_fp64_t* vector, vector3_fp64_t* result)
|
inline void bgc_matrix2x3_right_product_fp64(const bgc_matrix2x3_fp64_t* matrix, const bgc_vector2_fp64_t* vector, bgc_vector3_fp64_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _BASIC_GEOMETRY_MATRIX3X2_H_
|
#ifndef _BGC_MATRIX3X2_H_
|
||||||
#define _BASIC_GEOMETRY_MATRIX3X2_H_
|
#define _BGC_MATRIX3X2_H_
|
||||||
|
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
inline void matrix3x2_reset_fp32(matrix3x2_fp32_t* matrix)
|
inline void bgc_matrix3x2_reset_fp32(bgc_matrix3x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0f;
|
matrix->r1c1 = 0.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -18,7 +18,7 @@ inline void matrix3x2_reset_fp32(matrix3x2_fp32_t* matrix)
|
||||||
matrix->r2c3 = 0.0f;
|
matrix->r2c3 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_reset_fp64(matrix3x2_fp64_t* matrix)
|
inline void bgc_matrix3x2_reset_fp64(bgc_matrix3x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0;
|
matrix->r1c1 = 0.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -31,7 +31,7 @@ inline void matrix3x2_reset_fp64(matrix3x2_fp64_t* matrix)
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void matrix3x2_copy_fp32(const matrix3x2_fp32_t* from, matrix3x2_fp32_t* to)
|
inline void bgc_matrix3x2_copy_fp32(const bgc_matrix3x2_fp32_t* from, bgc_matrix3x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -42,7 +42,7 @@ inline void matrix3x2_copy_fp32(const matrix3x2_fp32_t* from, matrix3x2_fp32_t*
|
||||||
to->r2c3 = from->r2c3;
|
to->r2c3 = from->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_copy_fp64(const matrix3x2_fp64_t* from, matrix3x2_fp64_t* to)
|
inline void bgc_matrix3x2_copy_fp64(const bgc_matrix3x2_fp64_t* from, bgc_matrix3x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -55,7 +55,7 @@ inline void matrix3x2_copy_fp64(const matrix3x2_fp64_t* from, matrix3x2_fp64_t*
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void matrix3x2_swap_fp32(matrix3x2_fp32_t* matrix1, matrix3x2_fp32_t* matrix2)
|
inline void bgc_matrix3x2_swap_fp32(bgc_matrix3x2_fp32_t* matrix1, bgc_matrix3x2_fp32_t* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matrix2->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matrix2->r1c2;
|
||||||
|
@ -82,7 +82,7 @@ inline void matrix3x2_swap_fp32(matrix3x2_fp32_t* matrix1, matrix3x2_fp32_t* mat
|
||||||
matrix1->r2c3 = r2c3;
|
matrix1->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_swap_fp64(matrix3x2_fp64_t* matrix1, matrix3x2_fp64_t* matrix2)
|
inline void bgc_matrix3x2_swap_fp64(bgc_matrix3x2_fp64_t* matrix1, bgc_matrix3x2_fp64_t* matrix2)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matrix2->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matrix2->r1c2;
|
||||||
|
@ -111,7 +111,7 @@ inline void matrix3x2_swap_fp64(matrix3x2_fp64_t* matrix1, matrix3x2_fp64_t* mat
|
||||||
|
|
||||||
// ============= Set from twin type ============= //
|
// ============= Set from twin type ============= //
|
||||||
|
|
||||||
inline void matrix3x2_convert_fp64_to_fp32(const matrix3x2_fp64_t* from, matrix3x2_fp32_t* to)
|
inline void bgc_matrix3x2_convert_fp64_to_fp32(const bgc_matrix3x2_fp64_t* from, bgc_matrix3x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = (float) from->r1c1;
|
to->r1c1 = (float) from->r1c1;
|
||||||
to->r1c2 = (float) from->r1c2;
|
to->r1c2 = (float) from->r1c2;
|
||||||
|
@ -122,7 +122,7 @@ inline void matrix3x2_convert_fp64_to_fp32(const matrix3x2_fp64_t* from, matrix3
|
||||||
to->r2c3 = (float) from->r2c3;
|
to->r2c3 = (float) from->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_convert_fp32_to_fp64(const matrix3x2_fp32_t* from, matrix3x2_fp64_t* to)
|
inline void bgc_matrix3x2_convert_fp32_to_fp64(const bgc_matrix3x2_fp32_t* from, bgc_matrix3x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -135,7 +135,7 @@ inline void matrix3x2_convert_fp32_to_fp64(const matrix3x2_fp32_t* from, matrix3
|
||||||
|
|
||||||
// =============== Set transposed =============== //
|
// =============== Set transposed =============== //
|
||||||
|
|
||||||
inline void matrix3x2_set_transposed_fp32(const matrix2x3_fp32_t* from, matrix3x2_fp32_t* to)
|
inline void bgc_matrix3x2_set_transposed_fp32(const bgc_matrix2x3_fp32_t* from, bgc_matrix3x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r2c1;
|
to->r1c2 = from->r2c1;
|
||||||
|
@ -146,7 +146,7 @@ inline void matrix3x2_set_transposed_fp32(const matrix2x3_fp32_t* from, matrix3x
|
||||||
to->r2c3 = from->r3c2;
|
to->r2c3 = from->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_set_transposed_fp64(const matrix2x3_fp64_t* from, matrix3x2_fp64_t* to)
|
inline void bgc_matrix3x2_set_transposed_fp64(const bgc_matrix2x3_fp64_t* from, bgc_matrix3x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r2c1;
|
to->r1c2 = from->r2c1;
|
||||||
|
@ -159,7 +159,7 @@ inline void matrix3x2_set_transposed_fp64(const matrix2x3_fp64_t* from, matrix3x
|
||||||
|
|
||||||
// =============== Set transposed =============== //
|
// =============== Set transposed =============== //
|
||||||
|
|
||||||
inline void matrix3x2_set_transposed_fp32_fp64(const matrix2x3_fp64_t* from, matrix3x2_fp32_t* to)
|
inline void bgc_matrix3x2_set_transposed_fp32_fp64(const bgc_matrix2x3_fp64_t* from, bgc_matrix3x2_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = (float) from->r1c1;
|
to->r1c1 = (float) from->r1c1;
|
||||||
to->r1c2 = (float) from->r2c1;
|
to->r1c2 = (float) from->r2c1;
|
||||||
|
@ -170,7 +170,7 @@ inline void matrix3x2_set_transposed_fp32_fp64(const matrix2x3_fp64_t* from, mat
|
||||||
to->r2c3 = (float) from->r3c2;
|
to->r2c3 = (float) from->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_set_transposed_fp64_fp32(const matrix2x3_fp32_t* from, matrix3x2_fp64_t* to)
|
inline void bgc_matrix3x2_set_transposed_fp64_fp32(const bgc_matrix2x3_fp32_t* from, bgc_matrix3x2_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r2c1;
|
to->r1c2 = from->r2c1;
|
||||||
|
@ -183,14 +183,14 @@ inline void matrix3x2_set_transposed_fp64_fp32(const matrix2x3_fp32_t* from, mat
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
inline void matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, matrix3x2_fp32_t* matrix)
|
inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, bgc_matrix3x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
matrix->r1c3 = c3;
|
matrix->r1c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, matrix3x2_fp64_t* matrix)
|
inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, bgc_matrix3x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
|
@ -199,14 +199,14 @@ inline void matrix3x2_set_row1_fp64(const double c1, const double c2, const doub
|
||||||
|
|
||||||
// ================= Set Row 2 ================== //
|
// ================= Set Row 2 ================== //
|
||||||
|
|
||||||
inline void matrix3x2_set_row2_fp32(const float c1, const float c2, const float c3, matrix3x2_fp32_t* matrix)
|
inline void bgc_matrix3x2_set_row2_fp32(const float c1, const float c2, const float c3, bgc_matrix3x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
matrix->r2c3 = c3;
|
matrix->r2c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_set_row2_fp64(const double c1, const double c2, const double c3, matrix3x2_fp64_t* matrix)
|
inline void bgc_matrix3x2_set_row2_fp64(const double c1, const double c2, const double c3, bgc_matrix3x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
|
@ -215,13 +215,13 @@ inline void matrix3x2_set_row2_fp64(const double c1, const double c2, const doub
|
||||||
|
|
||||||
// ================ Set Column 1 ================ //
|
// ================ Set Column 1 ================ //
|
||||||
|
|
||||||
inline void matrix3x2_set_column1_fp32(const float r1, const float r2, matrix3x2_fp32_t* matrix)
|
inline void bgc_matrix3x2_set_column1_fp32(const float r1, const float r2, bgc_matrix3x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_set_column1_fp64(const double r1, const double r2, matrix3x2_fp64_t* matrix)
|
inline void bgc_matrix3x2_set_column1_fp64(const double r1, const double r2, bgc_matrix3x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
|
@ -229,13 +229,13 @@ inline void matrix3x2_set_column1_fp64(const double r1, const double r2, matrix3
|
||||||
|
|
||||||
// ================ Set Column 2 ================ //
|
// ================ Set Column 2 ================ //
|
||||||
|
|
||||||
inline void matrix3x2_set_column2_fp32(const float r1, const float r2, matrix3x2_fp32_t* matrix)
|
inline void bgc_matrix3x2_set_column2_fp32(const float r1, const float r2, bgc_matrix3x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_set_column2_fp64(const double r1, const double r2, matrix3x2_fp64_t* matrix)
|
inline void bgc_matrix3x2_set_column2_fp64(const double r1, const double r2, bgc_matrix3x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
|
@ -243,45 +243,21 @@ inline void matrix3x2_set_column2_fp64(const double r1, const double r2, matrix3
|
||||||
|
|
||||||
// ================ Set Column 3 ================ //
|
// ================ Set Column 3 ================ //
|
||||||
|
|
||||||
inline void matrix3x2_set_column3_fp32(const float r1, const float r2, matrix3x2_fp32_t* matrix)
|
inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, bgc_matrix3x2_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = r1;
|
matrix->r1c3 = r1;
|
||||||
matrix->r2c3 = r2;
|
matrix->r2c3 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_set_column3_fp64(const double r1, const double r2, matrix3x2_fp64_t* matrix)
|
inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, bgc_matrix3x2_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = r1;
|
matrix->r1c3 = r1;
|
||||||
matrix->r2c3 = r2;
|
matrix->r2c3 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Append scaled =============== //
|
|
||||||
|
|
||||||
inline void matrix3x2_add_scaled_fp32(matrix3x2_fp32_t* basic_vector, const matrix3x2_fp32_t* scalable_vector, const float scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
basic_vector->r1c3 += scalable_vector->r1c3 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
basic_vector->r2c3 += scalable_vector->r2c3 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void matrix3x2_add_scaled_fp64(matrix3x2_fp64_t* basic_vector, const matrix3x2_fp64_t* scalable_vector, const double scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
basic_vector->r1c3 += scalable_vector->r1c3 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
basic_vector->r2c3 += scalable_vector->r2c3 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// ================== Addition ================== //
|
||||||
|
|
||||||
inline void matrix3x2_add_fp32(const matrix3x2_fp32_t* matrix1, const matrix3x2_fp32_t* matrix2, matrix3x2_fp32_t* sum)
|
inline void bgc_matrix3x2_add_fp32(const bgc_matrix3x2_fp32_t* matrix1, const bgc_matrix3x2_fp32_t* matrix2, bgc_matrix3x2_fp32_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -292,7 +268,7 @@ inline void matrix3x2_add_fp32(const matrix3x2_fp32_t* matrix1, const matrix3x2_
|
||||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_add_fp64(const matrix3x2_fp64_t* matrix1, const matrix3x2_fp64_t* matrix2, matrix3x2_fp64_t* sum)
|
inline void bgc_matrix3x2_add_fp64(const bgc_matrix3x2_fp64_t* matrix1, const bgc_matrix3x2_fp64_t* matrix2, bgc_matrix3x2_fp64_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -303,9 +279,33 @@ inline void matrix3x2_add_fp64(const matrix3x2_fp64_t* matrix1, const matrix3x2_
|
||||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================= Add scaled ================= //
|
||||||
|
|
||||||
|
inline void bgc_matrix3x2_add_scaled_fp32(const bgc_matrix3x2_fp32_t* basic_matrix, const bgc_matrix3x2_fp32_t* scalable_matrix, const float scale, bgc_matrix3x2_fp32_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix3x2_add_scaled_fp64(const bgc_matrix3x2_fp64_t* basic_matrix, const bgc_matrix3x2_fp64_t* scalable_matrix, const double scale, bgc_matrix3x2_fp64_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
// ================ Subtraction ================= //
|
// ================ Subtraction ================= //
|
||||||
|
|
||||||
inline void matrix3x2_subtract_fp32(const matrix3x2_fp32_t* minuend, const matrix3x2_fp32_t* subtrahend, matrix3x2_fp32_t* difference)
|
inline void bgc_matrix3x2_subtract_fp32(const bgc_matrix3x2_fp32_t* minuend, const bgc_matrix3x2_fp32_t* subtrahend, bgc_matrix3x2_fp32_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -316,7 +316,7 @@ inline void matrix3x2_subtract_fp32(const matrix3x2_fp32_t* minuend, const matri
|
||||||
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
|
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_subtract_fp64(const matrix3x2_fp64_t* minuend, const matrix3x2_fp64_t* subtrahend, matrix3x2_fp64_t* difference)
|
inline void bgc_matrix3x2_subtract_fp64(const bgc_matrix3x2_fp64_t* minuend, const bgc_matrix3x2_fp64_t* subtrahend, bgc_matrix3x2_fp64_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -329,7 +329,7 @@ inline void matrix3x2_subtract_fp64(const matrix3x2_fp64_t* minuend, const matri
|
||||||
|
|
||||||
// =============== Multiplication =============== //
|
// =============== Multiplication =============== //
|
||||||
|
|
||||||
inline void matrix3x2_multiply_fp32(const matrix3x2_fp32_t* multiplicand, const float multiplier, matrix3x2_fp32_t* product)
|
inline void bgc_matrix3x2_multiply_fp32(const bgc_matrix3x2_fp32_t* multiplicand, const float multiplier, bgc_matrix3x2_fp32_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -340,7 +340,7 @@ inline void matrix3x2_multiply_fp32(const matrix3x2_fp32_t* multiplicand, const
|
||||||
product->r2c3 = multiplicand->r2c3 * multiplier;
|
product->r2c3 = multiplicand->r2c3 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_multiply_fp64(const matrix3x2_fp64_t* multiplicand, const double multiplier, matrix3x2_fp64_t* product)
|
inline void bgc_matrix3x2_multiply_fp64(const bgc_matrix3x2_fp64_t* multiplicand, const double multiplier, bgc_matrix3x2_fp64_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -353,26 +353,26 @@ inline void matrix3x2_multiply_fp64(const matrix3x2_fp64_t* multiplicand, const
|
||||||
|
|
||||||
// ================== Division ================== //
|
// ================== Division ================== //
|
||||||
|
|
||||||
inline void matrix3x2_divide_fp32(const matrix3x2_fp32_t* dividend, const float divisor, matrix3x2_fp32_t* quotient)
|
inline void bgc_matrix3x2_divide_fp32(const bgc_matrix3x2_fp32_t* dividend, const float divisor, bgc_matrix3x2_fp32_t* quotient)
|
||||||
{
|
{
|
||||||
matrix3x2_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
bgc_matrix3x2_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_fp64_divide(const matrix3x2_fp64_t* dividend, const double divisor, matrix3x2_fp64_t* quotient)
|
inline void bgc_matrix3x2_divide_fp64(const bgc_matrix3x2_fp64_t* dividend, const double divisor, bgc_matrix3x2_fp64_t* quotient)
|
||||||
{
|
{
|
||||||
matrix3x2_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
bgc_matrix3x2_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void matrix3x2_left_product_fp32(const vector2_fp32_t* vector, const matrix3x2_fp32_t* matrix, vector3_fp32_t* result)
|
inline void bgc_matrix3x2_left_product_fp32(const bgc_vector2_fp32_t* vector, const bgc_matrix3x2_fp32_t* matrix, bgc_vector3_fp32_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_left_product_fp64(const vector2_fp64_t* vector, const matrix3x2_fp64_t* matrix, vector3_fp64_t* result)
|
inline void bgc_matrix3x2_left_product_fp64(const bgc_vector2_fp64_t* vector, const bgc_matrix3x2_fp64_t* matrix, bgc_vector3_fp64_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
@ -381,13 +381,13 @@ inline void matrix3x2_left_product_fp64(const vector2_fp64_t* vector, const matr
|
||||||
|
|
||||||
// ============ Right Vector Product ============ //
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
inline void matrix3x2_right_product_fp32(const matrix3x2_fp32_t* matrix, const vector3_fp32_t* vector, vector2_fp32_t* result)
|
inline void bgc_matrix3x2_right_product_fp32(const bgc_matrix3x2_fp32_t* matrix, const bgc_vector3_fp32_t* vector, bgc_vector2_fp32_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||||
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x2_right_product_fp64(const matrix3x2_fp64_t* matrix, const vector3_fp64_t* vector, vector2_fp64_t* result)
|
inline void bgc_matrix3x2_right_product_fp64(const bgc_matrix3x2_fp64_t* matrix, const bgc_vector3_fp64_t* vector, bgc_vector2_fp64_t* result)
|
||||||
{
|
{
|
||||||
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||||
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
// ================= Inversion ================== //
|
// ================= Inversion ================== //
|
||||||
|
|
||||||
int matrix3x3_invert_fp32(matrix3x3_fp32_t* matrix)
|
int bgc_matrix3x3_invert_fp32(bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
const float determinant = matrix3x3_get_determinant_fp32(matrix);
|
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
if (-FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON) {
|
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ int matrix3x3_invert_fp32(matrix3x3_fp32_t* matrix)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int matrix3x3_invert_fp64(matrix3x3_fp64_t* matrix)
|
int bgc_matrix3x3_invert_fp64(bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
const double determinant = matrix3x3_get_determinant_fp64(matrix);
|
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
if (-FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON) {
|
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +78,11 @@ int matrix3x3_invert_fp64(matrix3x3_fp64_t* matrix)
|
||||||
|
|
||||||
// ================ Make Inverted =============== //
|
// ================ Make Inverted =============== //
|
||||||
|
|
||||||
int matrix3x3_set_inverted_fp32(const matrix3x3_fp32_t* matrix, matrix3x3_fp32_t* result)
|
int bgc_matrix3x3_set_inverted_fp32(const bgc_matrix3x3_fp32_t* matrix, bgc_matrix3x3_fp32_t* result)
|
||||||
{
|
{
|
||||||
const float determinant = matrix3x3_get_determinant_fp32(matrix);
|
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
if (-FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON) {
|
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,11 +115,11 @@ int matrix3x3_set_inverted_fp32(const matrix3x3_fp32_t* matrix, matrix3x3_fp32_t
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int matrix3x3_set_inverted_fp64(const matrix3x3_fp64_t* matrix, matrix3x3_fp64_t* result)
|
int bgc_matrix3x3_set_inverted_fp64(const bgc_matrix3x3_fp64_t* matrix, bgc_matrix3x3_fp64_t* result)
|
||||||
{
|
{
|
||||||
const double determinant = matrix3x3_get_determinant_fp64(matrix);
|
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
if (-FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON) {
|
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef _BASIC_GEOMETRY_MATRIX3X3_H_
|
#ifndef _BGC_MATRIX3X3_H_
|
||||||
#define _BASIC_GEOMETRY_MATRIX3X3_H_
|
#define _BGC_MATRIX3X3_H_
|
||||||
|
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
#include "matrixes.h"
|
#include "matrixes.h"
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
inline void matrix3x3_reset_fp32(matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_reset_fp32(bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0f;
|
matrix->r1c1 = 0.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -21,7 +21,7 @@ inline void matrix3x3_reset_fp32(matrix3x3_fp32_t* matrix)
|
||||||
matrix->r3c3 = 0.0f;
|
matrix->r3c3 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_reset_fp64(matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_reset_fp64(bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0;
|
matrix->r1c1 = 0.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -38,7 +38,7 @@ inline void matrix3x3_reset_fp64(matrix3x3_fp64_t* matrix)
|
||||||
|
|
||||||
// ================== Identity ================== //
|
// ================== Identity ================== //
|
||||||
|
|
||||||
inline void matrix3x3_set_to_identity_fp32(matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_to_identity_fp32(bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 1.0f;
|
matrix->r1c1 = 1.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -53,7 +53,7 @@ inline void matrix3x3_set_to_identity_fp32(matrix3x3_fp32_t* matrix)
|
||||||
matrix->r3c3 = 1.0f;
|
matrix->r3c3 = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_to_identity_fp64(matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_to_identity_fp64(bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 1.0;
|
matrix->r1c1 = 1.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -70,7 +70,7 @@ inline void matrix3x3_set_to_identity_fp64(matrix3x3_fp64_t* matrix)
|
||||||
|
|
||||||
// ================ Make Diagonal =============== //
|
// ================ Make Diagonal =============== //
|
||||||
|
|
||||||
inline void matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const float d3, matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const float d3, bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
@ -85,7 +85,7 @@ inline void matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const
|
||||||
matrix->r3c3 = d2;
|
matrix->r3c3 = d2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, const double d3, matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, const double d3, bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
@ -102,7 +102,7 @@ inline void matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, con
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void matrix3x3_copy_fp32(const matrix3x3_fp32_t* from, matrix3x3_fp32_t* to)
|
inline void bgc_matrix3x3_copy_fp32(const bgc_matrix3x3_fp32_t* from, bgc_matrix3x3_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -117,7 +117,7 @@ inline void matrix3x3_copy_fp32(const matrix3x3_fp32_t* from, matrix3x3_fp32_t*
|
||||||
to->r3c3 = from->r3c3;
|
to->r3c3 = from->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_copy_fp64(const matrix3x3_fp64_t* from, matrix3x3_fp64_t* to)
|
inline void bgc_matrix3x3_copy_fp64(const bgc_matrix3x3_fp64_t* from, bgc_matrix3x3_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -134,7 +134,7 @@ inline void matrix3x3_copy_fp64(const matrix3x3_fp64_t* from, matrix3x3_fp64_t*
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void matrix3x3_swap_fp32(matrix3x3_fp32_t* matrix1, matrix3x3_fp32_t* matrix2)
|
inline void bgc_matrix3x3_swap_fp32(bgc_matrix3x3_fp32_t* matrix1, bgc_matrix3x3_fp32_t* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matrix2->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matrix2->r1c2;
|
||||||
|
@ -173,7 +173,7 @@ inline void matrix3x3_swap_fp32(matrix3x3_fp32_t* matrix1, matrix3x3_fp32_t* mat
|
||||||
matrix1->r3c3 = r3c3;
|
matrix1->r3c3 = r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_swap_fp64(matrix3x3_fp64_t* matrix1, matrix3x3_fp64_t* matrix2)
|
inline void bgc_matrix3x3_swap_fp64(bgc_matrix3x3_fp64_t* matrix1, bgc_matrix3x3_fp64_t* matrix2)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matrix2->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matrix2->r1c2;
|
||||||
|
@ -214,7 +214,7 @@ inline void matrix3x3_swap_fp64(matrix3x3_fp64_t* matrix1, matrix3x3_fp64_t* mat
|
||||||
|
|
||||||
// ============= Set from twin type ============= //
|
// ============= Set from twin type ============= //
|
||||||
|
|
||||||
inline void matrix3x3_convert_fp64_to_fp32(const matrix3x3_fp64_t* from, matrix3x3_fp32_t* to)
|
inline void bgc_matrix3x3_convert_fp64_to_fp32(const bgc_matrix3x3_fp64_t* from, bgc_matrix3x3_fp32_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = (float) from->r1c1;
|
to->r1c1 = (float) from->r1c1;
|
||||||
to->r1c2 = (float) from->r1c2;
|
to->r1c2 = (float) from->r1c2;
|
||||||
|
@ -229,7 +229,7 @@ inline void matrix3x3_convert_fp64_to_fp32(const matrix3x3_fp64_t* from, matrix3
|
||||||
to->r3c3 = (float) from->r3c3;
|
to->r3c3 = (float) from->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_convert_fp32_to_fp64(const matrix3x3_fp32_t* from, matrix3x3_fp64_t* to)
|
inline void bgc_matrix3x3_convert_fp32_to_fp64(const bgc_matrix3x3_fp32_t* from, bgc_matrix3x3_fp64_t* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
@ -246,14 +246,14 @@ inline void matrix3x3_convert_fp32_to_fp64(const matrix3x3_fp32_t* from, matrix3
|
||||||
|
|
||||||
// ================ Determinant ================= //
|
// ================ Determinant ================= //
|
||||||
|
|
||||||
inline float matrix3x3_get_determinant_fp32(const matrix3x3_fp32_t* matrix)
|
inline float bgc_matrix3x3_get_determinant_fp32(const bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
|
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
|
||||||
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
|
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
|
||||||
+ matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1);
|
+ matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double matrix3x3_get_determinant_fp64(const matrix3x3_fp64_t* matrix)
|
inline double bgc_matrix3x3_get_determinant_fp64(const bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
|
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
|
||||||
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
|
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
|
||||||
|
@ -262,29 +262,29 @@ inline double matrix3x3_get_determinant_fp64(const matrix3x3_fp64_t* matrix)
|
||||||
|
|
||||||
// ================== Singular ================== //
|
// ================== Singular ================== //
|
||||||
|
|
||||||
inline int matrix3x3_is_singular_fp32(const matrix3x3_fp32_t* matrix)
|
inline int bgc_matrix3x3_is_singular_fp32(const bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
const float determinant = matrix3x3_get_determinant_fp32(matrix);
|
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
return -FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON;
|
return -BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int matrix3x3_is_singular_fp64(const matrix3x3_fp64_t* matrix)
|
inline int bgc_matrix3x3_is_singular_fp64(const bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
const double determinant = matrix3x3_get_determinant_fp64(matrix);
|
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
return -FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON;
|
return -BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Inversion ================== //
|
// ================= Inversion ================== //
|
||||||
|
|
||||||
int matrix3x3_invert_fp32(matrix3x3_fp32_t* matrix);
|
int bgc_matrix3x3_invert_fp32(bgc_matrix3x3_fp32_t* matrix);
|
||||||
|
|
||||||
int matrix3x3_invert_fp64(matrix3x3_fp64_t* matrix);
|
int bgc_matrix3x3_invert_fp64(bgc_matrix3x3_fp64_t* matrix);
|
||||||
|
|
||||||
// =============== Transposition ================ //
|
// =============== Transposition ================ //
|
||||||
|
|
||||||
inline void matrix3x3_transpose_fp32(matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_transpose_fp32(bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
float tmp = matrix->r1c2;
|
float tmp = matrix->r1c2;
|
||||||
matrix->r1c2 = matrix->r2c1;
|
matrix->r1c2 = matrix->r2c1;
|
||||||
|
@ -299,7 +299,7 @@ inline void matrix3x3_transpose_fp32(matrix3x3_fp32_t* matrix)
|
||||||
matrix->r3c2 = tmp;
|
matrix->r3c2 = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_transpose_fp64(matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_transpose_fp64(bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
double tmp = matrix->r1c2;
|
double tmp = matrix->r1c2;
|
||||||
matrix->r1c2 = matrix->r2c1;
|
matrix->r1c2 = matrix->r2c1;
|
||||||
|
@ -316,16 +316,16 @@ inline void matrix3x3_transpose_fp64(matrix3x3_fp64_t* matrix)
|
||||||
|
|
||||||
// ================ Make Inverted =============== //
|
// ================ Make Inverted =============== //
|
||||||
|
|
||||||
int matrix3x3_set_inverted_fp32(const matrix3x3_fp32_t* matrix, matrix3x3_fp32_t* result);
|
int bgc_matrix3x3_set_inverted_fp32(const bgc_matrix3x3_fp32_t* matrix, bgc_matrix3x3_fp32_t* result);
|
||||||
|
|
||||||
int matrix3x3_set_inverted_fp64(const matrix3x3_fp64_t* matrix, matrix3x3_fp64_t* result);
|
int bgc_matrix3x3_set_inverted_fp64(const bgc_matrix3x3_fp64_t* matrix, bgc_matrix3x3_fp64_t* result);
|
||||||
|
|
||||||
// =============== Make Transposed ============== //
|
// =============== Make Transposed ============== //
|
||||||
|
|
||||||
inline void matrix3x3_set_transposed_fp32(const matrix3x3_fp32_t* matrix, matrix3x3_fp32_t* result)
|
inline void bgc_matrix3x3_set_transposed_fp32(const bgc_matrix3x3_fp32_t* matrix, bgc_matrix3x3_fp32_t* result)
|
||||||
{
|
{
|
||||||
if (matrix == result) {
|
if (matrix == result) {
|
||||||
matrix3x3_transpose_fp32(result);
|
bgc_matrix3x3_transpose_fp32(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,10 +342,10 @@ inline void matrix3x3_set_transposed_fp32(const matrix3x3_fp32_t* matrix, matrix
|
||||||
result->r3c3 = matrix->r3c3;
|
result->r3c3 = matrix->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_transposed_fp64(const matrix3x3_fp64_t* matrix, matrix3x3_fp64_t* result)
|
inline void bgc_matrix3x3_set_transposed_fp64(const bgc_matrix3x3_fp64_t* matrix, bgc_matrix3x3_fp64_t* result)
|
||||||
{
|
{
|
||||||
if (matrix == result) {
|
if (matrix == result) {
|
||||||
matrix3x3_transpose_fp64(result);
|
bgc_matrix3x3_transpose_fp64(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,14 +364,14 @@ inline void matrix3x3_set_transposed_fp64(const matrix3x3_fp64_t* matrix, matrix
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
inline void matrix3x3_set_row1_fp32(const float c1, const float c2, const float c3, matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_row1_fp32(const float c1, const float c2, const float c3, bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
matrix->r1c3 = c3;
|
matrix->r1c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_row1_fp64(const double c1, const double c2, const double c3, matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_row1_fp64(const double c1, const double c2, const double c3, bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
|
@ -380,14 +380,14 @@ inline void matrix3x3_set_row1_fp64(const double c1, const double c2, const doub
|
||||||
|
|
||||||
// ================= Set Row 2 ================== //
|
// ================= Set Row 2 ================== //
|
||||||
|
|
||||||
inline void matrix3x3_set_row2_fp32(const float c1, const float c2, const float c3, matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_row2_fp32(const float c1, const float c2, const float c3, bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
matrix->r2c3 = c3;
|
matrix->r2c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_row2_fp64(const double c1, const double c2, const double c3, matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_row2_fp64(const double c1, const double c2, const double c3, bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
|
@ -396,14 +396,14 @@ inline void matrix3x3_set_row2_fp64(const double c1, const double c2, const doub
|
||||||
|
|
||||||
// ================= Set Row 3 ================== //
|
// ================= Set Row 3 ================== //
|
||||||
|
|
||||||
inline void matrix3x3_set_row3_fp32(const float c1, const float c2, const float c3, matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_row3_fp32(const float c1, const float c2, const float c3, bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r3c1 = c1;
|
matrix->r3c1 = c1;
|
||||||
matrix->r3c2 = c2;
|
matrix->r3c2 = c2;
|
||||||
matrix->r3c3 = c3;
|
matrix->r3c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_row3_fp64(const double c1, const double c2, const double c3, matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_row3_fp64(const double c1, const double c2, const double c3, bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r3c1 = c1;
|
matrix->r3c1 = c1;
|
||||||
matrix->r3c2 = c2;
|
matrix->r3c2 = c2;
|
||||||
|
@ -412,14 +412,14 @@ inline void matrix3x3_set_row3_fp64(const double c1, const double c2, const doub
|
||||||
|
|
||||||
// ================ Set Column 1 ================ //
|
// ================ Set Column 1 ================ //
|
||||||
|
|
||||||
inline void matrix3x3_set_column1_fp32(const float r1, const float r2, const float r3, matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_column1_fp32(const float r1, const float r2, const float r3, bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
matrix->r3c1 = r3;
|
matrix->r3c1 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_column1_fp64(const double r1, const double r2, const double r3, matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_column1_fp64(const double r1, const double r2, const double r3, bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
|
@ -428,14 +428,14 @@ inline void matrix3x3_set_column1_fp64(const double r1, const double r2, const d
|
||||||
|
|
||||||
// ================ Set Column 2 ================ //
|
// ================ Set Column 2 ================ //
|
||||||
|
|
||||||
inline void matrix3x3_set_column2_fp32(const float r1, const float r2, const float r3, matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_column2_fp32(const float r1, const float r2, const float r3, bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
matrix->r3c2 = r3;
|
matrix->r3c2 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_column2_fp64(const double r1, const double r2, const double r3, matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_column2_fp64(const double r1, const double r2, const double r3, bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
|
@ -444,55 +444,23 @@ inline void matrix3x3_set_column2_fp64(const double r1, const double r2, const d
|
||||||
|
|
||||||
// ================ Set Column 3 ================ //
|
// ================ Set Column 3 ================ //
|
||||||
|
|
||||||
inline void matrix3x3_set_column3_fp32(const float r1, const float r2, const float r3, matrix3x3_fp32_t* matrix)
|
inline void bgc_matrix3x3_set_column3_fp32(const float r1, const float r2, const float r3, bgc_matrix3x3_fp32_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = r1;
|
matrix->r1c3 = r1;
|
||||||
matrix->r2c3 = r2;
|
matrix->r2c3 = r2;
|
||||||
matrix->r3c3 = r3;
|
matrix->r3c3 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_set_column3_fp64(const double r1, const double r2, const double r3, matrix3x3_fp64_t* matrix)
|
inline void bgc_matrix3x3_set_column3_fp64(const double r1, const double r2, const double r3, bgc_matrix3x3_fp64_t* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = r1;
|
matrix->r1c3 = r1;
|
||||||
matrix->r2c3 = r2;
|
matrix->r2c3 = r2;
|
||||||
matrix->r3c3 = r3;
|
matrix->r3c3 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Append scaled =============== //
|
|
||||||
|
|
||||||
inline void matrix3x3_add_scaled_fp32(matrix3x3_fp32_t* basic_vector, const matrix3x3_fp32_t* scalable_vector, const float scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
basic_vector->r1c3 += scalable_vector->r1c3 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
basic_vector->r2c3 += scalable_vector->r2c3 * scale;
|
|
||||||
|
|
||||||
basic_vector->r3c1 += scalable_vector->r3c1 * scale;
|
|
||||||
basic_vector->r3c2 += scalable_vector->r3c2 * scale;
|
|
||||||
basic_vector->r3c3 += scalable_vector->r3c3 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void matrix3x3_add_scaled_fp64(matrix3x3_fp64_t* basic_vector, const matrix3x3_fp64_t* scalable_vector, const double scale)
|
|
||||||
{
|
|
||||||
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
|
||||||
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
|
||||||
basic_vector->r1c3 += scalable_vector->r1c3 * scale;
|
|
||||||
|
|
||||||
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
|
||||||
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
|
||||||
basic_vector->r2c3 += scalable_vector->r2c3 * scale;
|
|
||||||
|
|
||||||
basic_vector->r3c1 += scalable_vector->r3c1 * scale;
|
|
||||||
basic_vector->r3c2 += scalable_vector->r3c2 * scale;
|
|
||||||
basic_vector->r3c3 += scalable_vector->r3c3 * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// ================== Addition ================== //
|
||||||
|
|
||||||
inline void matrix3x3_add_fp32(const matrix3x3_fp32_t* matrix1, const matrix3x3_fp32_t* matrix2, matrix3x3_fp32_t* sum)
|
inline void bgc_matrix3x3_add_fp32(const bgc_matrix3x3_fp32_t* matrix1, const bgc_matrix3x3_fp32_t* matrix2, bgc_matrix3x3_fp32_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -507,7 +475,7 @@ inline void matrix3x3_add_fp32(const matrix3x3_fp32_t* matrix1, const matrix3x3_
|
||||||
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
|
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_add_fp64(const matrix3x3_fp64_t* matrix1, const matrix3x3_fp64_t* matrix2, matrix3x3_fp64_t* sum)
|
inline void bgc_matrix3x3_add_fp64(const bgc_matrix3x3_fp64_t* matrix1, const bgc_matrix3x3_fp64_t* matrix2, bgc_matrix3x3_fp64_t* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
@ -522,9 +490,41 @@ inline void matrix3x3_add_fp64(const matrix3x3_fp64_t* matrix1, const matrix3x3_
|
||||||
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
|
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================= Add scaled ================= //
|
||||||
|
|
||||||
|
inline void bgc_matrix3x3_add_scaled_fp32(const bgc_matrix3x3_fp32_t* basic_matrix, const bgc_matrix3x3_fp32_t* scalable_matrix, const float scale, bgc_matrix3x3_fp32_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
|
||||||
|
|
||||||
|
sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale;
|
||||||
|
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
|
||||||
|
sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix3x3_add_scaled_fp64(const bgc_matrix3x3_fp64_t* basic_matrix, const bgc_matrix3x3_fp64_t* scalable_matrix, const double scale, bgc_matrix3x3_fp64_t* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale;
|
||||||
|
|
||||||
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
|
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
|
||||||
|
|
||||||
|
sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale;
|
||||||
|
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
|
||||||
|
sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
// ================ Subtraction ================= //
|
// ================ Subtraction ================= //
|
||||||
|
|
||||||
inline void matrix3x3_subtract_fp32(const matrix3x3_fp32_t* minuend, const matrix3x3_fp32_t* subtrahend, matrix3x3_fp32_t* difference)
|
inline void bgc_matrix3x3_subtract_fp32(const bgc_matrix3x3_fp32_t* minuend, const bgc_matrix3x3_fp32_t* subtrahend, bgc_matrix3x3_fp32_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -539,7 +539,7 @@ inline void matrix3x3_subtract_fp32(const matrix3x3_fp32_t* minuend, const matri
|
||||||
difference->r3c3 = minuend->r3c3 - subtrahend->r3c3;
|
difference->r3c3 = minuend->r3c3 - subtrahend->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_subtract_fp64(const matrix3x3_fp64_t* minuend, const matrix3x3_fp64_t* subtrahend, matrix3x3_fp64_t* difference)
|
inline void bgc_matrix3x3_subtract_fp64(const bgc_matrix3x3_fp64_t* minuend, const bgc_matrix3x3_fp64_t* subtrahend, bgc_matrix3x3_fp64_t* difference)
|
||||||
{
|
{
|
||||||
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
@ -556,7 +556,7 @@ inline void matrix3x3_subtract_fp64(const matrix3x3_fp64_t* minuend, const matri
|
||||||
|
|
||||||
// =============== Multiplication =============== //
|
// =============== Multiplication =============== //
|
||||||
|
|
||||||
inline void matrix3x3_multiply_fp32(const matrix3x3_fp32_t* multiplicand, const float multiplier, matrix3x3_fp32_t* product)
|
inline void bgc_matrix3x3_multiply_fp32(const bgc_matrix3x3_fp32_t* multiplicand, const float multiplier, bgc_matrix3x3_fp32_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -571,7 +571,7 @@ inline void matrix3x3_multiply_fp32(const matrix3x3_fp32_t* multiplicand, const
|
||||||
product->r3c3 = multiplicand->r3c3 * multiplier;
|
product->r3c3 = multiplicand->r3c3 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_multiply_fp64(const matrix3x3_fp64_t* multiplicand, const double multiplier, matrix3x3_fp64_t* product)
|
inline void bgc_matrix3x3_multiply_fp64(const bgc_matrix3x3_fp64_t* multiplicand, const double multiplier, bgc_matrix3x3_fp64_t* product)
|
||||||
{
|
{
|
||||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
@ -588,19 +588,19 @@ inline void matrix3x3_multiply_fp64(const matrix3x3_fp64_t* multiplicand, const
|
||||||
|
|
||||||
// ================== Division ================== //
|
// ================== Division ================== //
|
||||||
|
|
||||||
inline void matrix3x3_divide_fp32(const matrix3x3_fp32_t* dividend, const float divisor, matrix3x3_fp32_t* quotient)
|
inline void bgc_matrix3x3_divide_fp32(const bgc_matrix3x3_fp32_t* dividend, const float divisor, bgc_matrix3x3_fp32_t* quotient)
|
||||||
{
|
{
|
||||||
matrix3x3_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
bgc_matrix3x3_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_fp64_divide(const matrix3x3_fp64_t* dividend, const double divisor, matrix3x3_fp64_t* quotient)
|
inline void bgc_matrix3x3_divide_fp64(const bgc_matrix3x3_fp64_t* dividend, const double divisor, bgc_matrix3x3_fp64_t* quotient)
|
||||||
{
|
{
|
||||||
matrix3x3_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
bgc_matrix3x3_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void matrix3x3_left_product_fp32(const vector3_fp32_t* vector, const matrix3x3_fp32_t* matrix, vector3_fp32_t* result)
|
inline void bgc_matrix3x3_left_product_fp32(const bgc_vector3_fp32_t* vector, const bgc_matrix3x3_fp32_t* matrix, bgc_vector3_fp32_t* result)
|
||||||
{
|
{
|
||||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||||
|
@ -611,7 +611,7 @@ inline void matrix3x3_left_product_fp32(const vector3_fp32_t* vector, const matr
|
||||||
result->x3 = x3;
|
result->x3 = x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_left_product_fp64(const vector3_fp64_t* vector, const matrix3x3_fp64_t* matrix, vector3_fp64_t* result)
|
inline void bgc_matrix3x3_left_product_fp64(const bgc_vector3_fp64_t* vector, const bgc_matrix3x3_fp64_t* matrix, bgc_vector3_fp64_t* result)
|
||||||
{
|
{
|
||||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||||
|
@ -624,7 +624,7 @@ inline void matrix3x3_left_product_fp64(const vector3_fp64_t* vector, const matr
|
||||||
|
|
||||||
// ============ Right Vector Product ============ //
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
inline void matrix3x3_right_product_fp32(const matrix3x3_fp32_t* matrix, const vector3_fp32_t* vector, vector3_fp32_t* result)
|
inline void bgc_matrix3x3_right_product_fp32(const bgc_matrix3x3_fp32_t* matrix, const bgc_vector3_fp32_t* vector, bgc_vector3_fp32_t* result)
|
||||||
{
|
{
|
||||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||||
|
@ -635,7 +635,7 @@ inline void matrix3x3_right_product_fp32(const matrix3x3_fp32_t* matrix, const v
|
||||||
result->x3 = x3;
|
result->x3 = x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix3x3_right_product_fp64(const matrix3x3_fp64_t* matrix, const vector3_fp64_t* vector, vector3_fp64_t* result)
|
inline void bgc_matrix3x3_right_product_fp64(const bgc_matrix3x3_fp64_t* matrix, const bgc_vector3_fp64_t* vector, bgc_vector3_fp64_t* result)
|
||||||
{
|
{
|
||||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 3x2 ========= //
|
// ========== Matrix Product 2x2 at 3x2 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_2x2_at_3x2(const matrix2x2_fp32_t* matrix1, const matrix3x2_fp32_t* matrix2, matrix3x2_fp32_t* result)
|
void bgc_matrix_product_2x2_at_3x2_fp32(const bgc_matrix2x2_fp32_t* matrix1, const bgc_matrix3x2_fp32_t* matrix2, bgc_matrix3x2_fp32_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -21,7 +21,7 @@ void matrix_fp32_product_2x2_at_3x2(const matrix2x2_fp32_t* matrix1, const matri
|
||||||
result->r2c3 = r2c3;
|
result->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_fp64_product_2x2_at_3x2(const matrix2x2_fp64_t* matrix1, const matrix3x2_fp64_t* matrix2, matrix3x2_fp64_t* result)
|
void bgc_matrix_product_2x2_at_3x2_fp64(const bgc_matrix2x2_fp64_t* matrix1, const bgc_matrix3x2_fp64_t* matrix2, bgc_matrix3x2_fp64_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -42,7 +42,7 @@ void matrix_fp64_product_2x2_at_3x2(const matrix2x2_fp64_t* matrix1, const matri
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 2x2 ========= //
|
// ========== Matrix Product 2x3 at 2x2 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_2x3_at_2x2(const matrix2x3_fp32_t* matrix1, const matrix2x2_fp32_t* matrix2, matrix2x3_fp32_t* result)
|
void bgc_matrix_product_2x3_at_2x2_fp32(const bgc_matrix2x3_fp32_t* matrix1, const bgc_matrix2x2_fp32_t* matrix2, bgc_matrix2x3_fp32_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -63,7 +63,7 @@ void matrix_fp32_product_2x3_at_2x2(const matrix2x3_fp32_t* matrix1, const matri
|
||||||
result->r3c2 = r3c2;
|
result->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_fp64_product_2x3_at_2x2(const matrix2x3_fp64_t* matrix1, const matrix2x2_fp64_t* matrix2, matrix2x3_fp64_t* result)
|
void bgc_matrix_product_2x3_at_2x2_fp64(const bgc_matrix2x3_fp64_t* matrix1, const bgc_matrix2x2_fp64_t* matrix2, bgc_matrix2x3_fp64_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -86,7 +86,7 @@ void matrix_fp64_product_2x3_at_2x2(const matrix2x3_fp64_t* matrix1, const matri
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 3x2 ========= //
|
// ========== Matrix Product 2x3 at 3x2 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_2x3_at_3x2(const matrix2x3_fp32_t* matrix1, const matrix3x2_fp32_t* matrix2, matrix3x3_fp32_t* result)
|
void bgc_matrix_product_2x3_at_3x2_fp32(const bgc_matrix2x3_fp32_t* matrix1, const bgc_matrix3x2_fp32_t* matrix2, bgc_matrix3x3_fp32_t* result)
|
||||||
{
|
{
|
||||||
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
|
@ -101,7 +101,7 @@ void matrix_fp32_product_2x3_at_3x2(const matrix2x3_fp32_t* matrix1, const matri
|
||||||
result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_fp64_product_2x3_at_3x2(const matrix2x3_fp64_t* matrix1, const matrix3x2_fp64_t* matrix2, matrix3x3_fp64_t* result)
|
void bgc_matrix_product_2x3_at_3x2_fp64(const bgc_matrix2x3_fp64_t* matrix1, const bgc_matrix3x2_fp64_t* matrix2, bgc_matrix3x3_fp64_t* result)
|
||||||
{
|
{
|
||||||
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
|
@ -118,7 +118,7 @@ void matrix_fp64_product_2x3_at_3x2(const matrix2x3_fp64_t* matrix1, const matri
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_3x2_at_2x3(const matrix3x2_fp32_t* matrix1, const matrix2x3_fp32_t* matrix2, matrix2x2_fp32_t* result)
|
void bgc_matrix_product_3x2_at_2x3_fp32(const bgc_matrix3x2_fp32_t* matrix1, const bgc_matrix2x3_fp32_t* matrix2, bgc_matrix2x2_fp32_t* result)
|
||||||
{
|
{
|
||||||
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
@ -127,7 +127,7 @@ void matrix_fp32_product_3x2_at_2x3(const matrix3x2_fp32_t* matrix1, const matri
|
||||||
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_fp64_product_3x2_at_2x3(const matrix3x2_fp64_t* matrix1, const matrix2x3_fp64_t* matrix2, matrix2x2_fp64_t* result)
|
void bgc_matrix_product_3x2_at_2x3_fp64(const bgc_matrix3x2_fp64_t* matrix1, const bgc_matrix2x3_fp64_t* matrix2, bgc_matrix2x2_fp64_t* result)
|
||||||
{
|
{
|
||||||
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
@ -138,7 +138,7 @@ void matrix_fp64_product_3x2_at_2x3(const matrix3x2_fp64_t* matrix1, const matri
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 3x3 ========= //
|
// ========== Matrix Product 3x2 at 3x3 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_3x2_at_3x3(const matrix3x2_fp32_t* matrix1, const matrix3x3_fp32_t* matrix2, matrix3x2_fp32_t* result)
|
void bgc_matrix_product_3x2_at_3x3_fp32(const bgc_matrix3x2_fp32_t* matrix1, const bgc_matrix3x3_fp32_t* matrix2, bgc_matrix3x2_fp32_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -157,7 +157,7 @@ void matrix_fp32_product_3x2_at_3x3(const matrix3x2_fp32_t* matrix1, const matri
|
||||||
result->r2c3 = r2c3;
|
result->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_fp64_product_3x2_at_3x3(const matrix3x2_fp64_t* matrix1, const matrix3x3_fp64_t* matrix2, matrix3x2_fp64_t* result)
|
void bgc_matrix_product_3x2_at_3x3_fp64(const bgc_matrix3x2_fp64_t* matrix1, const bgc_matrix3x3_fp64_t* matrix2, bgc_matrix3x2_fp64_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -178,7 +178,7 @@ void matrix_fp64_product_3x2_at_3x3(const matrix3x2_fp64_t* matrix1, const matri
|
||||||
|
|
||||||
// ========== Matrix Product 3x3 at 2x3 ========= //
|
// ========== Matrix Product 3x3 at 2x3 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_3x3_at_2x3(const matrix3x3_fp32_t* matrix1, const matrix2x3_fp32_t* matrix2, matrix2x3_fp32_t* result)
|
void bgc_matrix_product_3x3_at_2x3_fp32(const bgc_matrix3x3_fp32_t* matrix1, const bgc_matrix2x3_fp32_t* matrix2, bgc_matrix2x3_fp32_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -199,7 +199,7 @@ void matrix_fp32_product_3x3_at_2x3(const matrix3x3_fp32_t* matrix1, const matri
|
||||||
result->r3c2 = r3c2;
|
result->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_fp64_product_3x3_at_2x3(const matrix3x3_fp64_t* matrix1, const matrix2x3_fp64_t* matrix2, matrix2x3_fp64_t* result)
|
void bgc_matrix_product_3x3_at_2x3_fp64(const bgc_matrix3x3_fp64_t* matrix1, const bgc_matrix2x3_fp64_t* matrix2, bgc_matrix2x3_fp64_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -222,7 +222,7 @@ void matrix_fp64_product_3x3_at_2x3(const matrix3x3_fp64_t* matrix1, const matri
|
||||||
|
|
||||||
// ========== Matrix Product 3x3 at 3x3 ========= //
|
// ========== Matrix Product 3x3 at 3x3 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_3x3_at_3x3(const matrix3x3_fp32_t* matrix1, const matrix3x3_fp32_t* matrix2, matrix3x3_fp32_t* result)
|
void bgc_matrix_product_3x3_at_3x3_fp32(const bgc_matrix3x3_fp32_t* matrix1, const bgc_matrix3x3_fp32_t* matrix2, bgc_matrix3x3_fp32_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -249,7 +249,7 @@ void matrix_fp32_product_3x3_at_3x3(const matrix3x3_fp32_t* matrix1, const matri
|
||||||
result->r3c3 = r3c3;
|
result->r3c3 = r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_fp64_product_3x3_at_3x3(const matrix3x3_fp64_t* matrix1, const matrix3x3_fp64_t* matrix2, matrix3x3_fp64_t* result)
|
void bgc_matrix_product_3x3_at_3x3_fp64(const bgc_matrix3x3_fp64_t* matrix1, const bgc_matrix3x3_fp64_t* matrix2, bgc_matrix3x3_fp64_t* result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#ifndef _BASIC_GEOMETRY_MATRIX_TYPES_H_
|
#ifndef _BGC_MATRIX_TYPES_H_
|
||||||
#define _BASIC_GEOMETRY_MATRIX_TYPES_H_
|
#define _BGC_MATRIX_TYPES_H_
|
||||||
|
|
||||||
// ================== Matrix2x2 ================= //
|
// ================== Matrix2x2 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float r1c1, r1c2;
|
float r1c1, r1c2;
|
||||||
float r2c1, r2c2;
|
float r2c1, r2c2;
|
||||||
} matrix2x2_fp32_t;
|
} bgc_matrix2x2_fp32_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2;
|
double r1c1, r1c2;
|
||||||
double r2c1, r2c2;
|
double r2c1, r2c2;
|
||||||
} matrix2x2_fp64_t;
|
} bgc_matrix2x2_fp64_t;
|
||||||
|
|
||||||
// ================== Matrix2x3 ================= //
|
// ================== Matrix2x3 ================= //
|
||||||
|
|
||||||
|
@ -19,25 +19,25 @@ typedef struct {
|
||||||
float r1c1, r1c2;
|
float r1c1, r1c2;
|
||||||
float r2c1, r2c2;
|
float r2c1, r2c2;
|
||||||
float r3c1, r3c2;
|
float r3c1, r3c2;
|
||||||
} matrix2x3_fp32_t;
|
} bgc_matrix2x3_fp32_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2;
|
double r1c1, r1c2;
|
||||||
double r2c1, r2c2;
|
double r2c1, r2c2;
|
||||||
double r3c1, r3c2;
|
double r3c1, r3c2;
|
||||||
} matrix2x3_fp64_t;
|
} bgc_matrix2x3_fp64_t;
|
||||||
|
|
||||||
// ================== Matrix3x2 ================= //
|
// ================== Matrix3x2 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float r1c1, r1c2, r1c3;
|
float r1c1, r1c2, r1c3;
|
||||||
float r2c1, r2c2, r2c3;
|
float r2c1, r2c2, r2c3;
|
||||||
} matrix3x2_fp32_t;
|
} bgc_matrix3x2_fp32_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2, r1c3;
|
double r1c1, r1c2, r1c3;
|
||||||
double r2c1, r2c2, r2c3;
|
double r2c1, r2c2, r2c3;
|
||||||
} matrix3x2_fp64_t;
|
} bgc_matrix3x2_fp64_t;
|
||||||
|
|
||||||
// ================== Matrix3x3 ================= //
|
// ================== Matrix3x3 ================= //
|
||||||
|
|
||||||
|
@ -45,17 +45,17 @@ typedef struct {
|
||||||
float r1c1, r1c2, r1c3;
|
float r1c1, r1c2, r1c3;
|
||||||
float r2c1, r2c2, r2c3;
|
float r2c1, r2c2, r2c3;
|
||||||
float r3c1, r3c2, r3c3;
|
float r3c1, r3c2, r3c3;
|
||||||
} matrix3x3_fp32_t;
|
} bgc_matrix3x3_fp32_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double r1c1, r1c2, r1c3;
|
double r1c1, r1c2, r1c3;
|
||||||
double r2c1, r2c2, r2c3;
|
double r2c1, r2c2, r2c3;
|
||||||
double r3c1, r3c2, r3c3;
|
double r3c1, r3c2, r3c3;
|
||||||
} matrix3x3_fp64_t;
|
} bgc_matrix3x3_fp64_t;
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 2x2 ========= //
|
// ========== Matrix Product 2x2 at 2x2 ========= //
|
||||||
|
|
||||||
inline void matrix_fp32_product_2x2_at_2x2(const matrix2x2_fp32_t* matrix1, const matrix2x2_fp32_t* matrix2, matrix2x2_fp32_t* result)
|
inline void bgc_matrix_product_2x2_at_2x2_fp32(const bgc_matrix2x2_fp32_t* matrix1, const bgc_matrix2x2_fp32_t* matrix2, bgc_matrix2x2_fp32_t* result)
|
||||||
{
|
{
|
||||||
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 matrix_fp32_product_2x2_at_2x2(const matrix2x2_fp32_t* matrix1, cons
|
||||||
result->r2c2 = r2c2;
|
result->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void matrix_fp64_product_2x2_at_2x2(const matrix2x2_fp64_t* matrix1, const matrix2x2_fp64_t* matrix2, matrix2x2_fp64_t* result)
|
inline void bgc_matrix_product_2x2_at_2x2_fp64(const bgc_matrix2x2_fp64_t* matrix1, const bgc_matrix2x2_fp64_t* matrix2, bgc_matrix2x2_fp64_t* result)
|
||||||
{
|
{
|
||||||
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,44 +87,44 @@ inline void matrix_fp64_product_2x2_at_2x2(const matrix2x2_fp64_t* matrix1, cons
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 3x2 ========= //
|
// ========== Matrix Product 2x2 at 3x2 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_2x2_at_3x2(const matrix2x2_fp32_t* matrix1, const matrix3x2_fp32_t* matrix2, matrix3x2_fp32_t* result);
|
void bgc_matrix_product_2x2_at_3x2_fp32(const bgc_matrix2x2_fp32_t* matrix1, const bgc_matrix3x2_fp32_t* matrix2, bgc_matrix3x2_fp32_t* result);
|
||||||
|
|
||||||
void matrix_fp64_product_2x2_at_3x2(const matrix2x2_fp64_t* matrix1, const matrix3x2_fp64_t* matrix2, matrix3x2_fp64_t* result);
|
void bgc_matrix_product_2x2_at_3x2_fp64(const bgc_matrix2x2_fp64_t* matrix1, const bgc_matrix3x2_fp64_t* matrix2, bgc_matrix3x2_fp64_t* result);
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 2x2 ========= //
|
// ========== Matrix Product 2x3 at 2x2 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_2x3_at_2x2(const matrix2x3_fp32_t* matrix1, const matrix2x2_fp32_t* matrix2, matrix2x3_fp32_t* result);
|
void bgc_matrix_product_2x3_at_2x2_fp32(const bgc_matrix2x3_fp32_t* matrix1, const bgc_matrix2x2_fp32_t* matrix2, bgc_matrix2x3_fp32_t* result);
|
||||||
|
|
||||||
void matrix_fp64_product_2x3_at_2x2(const matrix2x3_fp64_t* matrix1, const matrix2x2_fp64_t* matrix2, matrix2x3_fp64_t* result);
|
void bgc_matrix_product_2x3_at_2x2_fp64(const bgc_matrix2x3_fp64_t* matrix1, const bgc_matrix2x2_fp64_t* matrix2, bgc_matrix2x3_fp64_t* result);
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 3x2 ========= //
|
// ========== Matrix Product 2x3 at 3x2 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_2x3_at_3x2(const matrix2x3_fp32_t* matrix1, const matrix3x2_fp32_t* matrix2, matrix3x3_fp32_t* result);
|
void bgc_matrix_product_2x3_at_3x2_fp32(const bgc_matrix2x3_fp32_t* matrix1, const bgc_matrix3x2_fp32_t* matrix2, bgc_matrix3x3_fp32_t* result);
|
||||||
|
|
||||||
void matrix_fp64_product_2x3_at_3x2(const matrix2x3_fp64_t* matrix1, const matrix3x2_fp64_t* matrix2, matrix3x3_fp64_t* result);
|
void bgc_matrix_product_2x3_at_3x2_fp64(const bgc_matrix2x3_fp64_t* matrix1, const bgc_matrix3x2_fp64_t* matrix2, bgc_matrix3x3_fp64_t* result);
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_3x2_at_2x3(const matrix3x2_fp32_t* matrix1, const matrix2x3_fp32_t* matrix2, matrix2x2_fp32_t* result);
|
void bgc_matrix_product_3x2_at_2x3_fp32(const bgc_matrix3x2_fp32_t* matrix1, const bgc_matrix2x3_fp32_t* matrix2, bgc_matrix2x2_fp32_t* result);
|
||||||
|
|
||||||
void matrix_fp64_product_3x2_at_2x3(const matrix3x2_fp64_t* matrix1, const matrix2x3_fp64_t* matrix2, matrix2x2_fp64_t* result);
|
void bgc_matrix_product_3x2_at_2x3_fp64(const bgc_matrix3x2_fp64_t* matrix1, const bgc_matrix2x3_fp64_t* matrix2, bgc_matrix2x2_fp64_t* result);
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 3x3 ========= //
|
// ========== Matrix Product 3x2 at 3x3 ========= //
|
||||||
|
|
||||||
void matrix_fp32_product_3x2_at_3x3(const matrix3x2_fp32_t* matrix1, const matrix3x3_fp32_t* matrix2, matrix3x2_fp32_t* result);
|
void bgc_matrix_product_3x2_at_3x3_fp32(const bgc_matrix3x2_fp32_t* matrix1, const bgc_matrix3x3_fp32_t* matrix2, bgc_matrix3x2_fp32_t* result);
|
||||||
|
|
||||||