Реорганизация проекта: перенос определения всех типов в один файл, перегруппировка функций в файлах
This commit is contained in:
parent
c7d9263154
commit
053af33444
45 changed files with 1001 additions and 980 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#include "affine2.h"
|
||||
#include "./affine2.h"
|
||||
|
||||
extern inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2* affine);
|
||||
extern inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2* affine);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
#ifndef _BGC_AFFINE2_H_INCLUDED_
|
||||
#define _BGC_AFFINE2_H_INCLUDED_
|
||||
|
||||
#include "vector2.h"
|
||||
#include "matrices.h"
|
||||
#include "matrix2x2.h"
|
||||
|
||||
// ==================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Matrix2x2 distortion;
|
||||
BGC_FP32_Vector2 shift;
|
||||
} BGC_FP32_Affine2;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Matrix2x2 distortion;
|
||||
BGC_FP64_Vector2 shift;
|
||||
} BGC_FP64_Affine2;
|
||||
#include "./vector2.h"
|
||||
#include "./types.h"
|
||||
#include "./matrix2x2.h"
|
||||
|
||||
// ==================== Reset ==================== //
|
||||
|
||||
|
|
@ -96,7 +84,7 @@ inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine)
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp32_matrix2x2_multiply_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp32_vector2_revert(&affine->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -108,7 +96,7 @@ inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine)
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp64_matrix2x2_multiply_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp64_vector2_revert(&affine->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -122,7 +110,7 @@ inline int bgc_fp32_affine2_get_inverse(BGC_FP32_Affine2* inverse, const BGC_FP3
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
|
||||
bgc_fp32_matrix2x2_multiply_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
|
||||
bgc_fp32_vector2_revert(&inverse->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -134,7 +122,7 @@ inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP6
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
|
||||
bgc_fp64_matrix2x2_multiply_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
|
||||
bgc_fp64_vector2_revert(&inverse->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -145,16 +133,16 @@ inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP6
|
|||
inline void bgc_fp32_affine2_combine(BGC_FP32_Affine2* combination, const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second)
|
||||
{
|
||||
BGC_FP32_Vector2 first_shift;
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp32_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp32_matrix2x2_multiply_by_vector2(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp32_matrix2x2_multiply_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp32_vector2_add(&combination->shift, &second->shift, &first_shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine2_combine(BGC_FP64_Affine2* combination, const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second)
|
||||
{
|
||||
BGC_FP64_Vector2 first_shift;
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp64_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp64_matrix2x2_multiply_by_vector2(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp64_matrix2x2_multiply_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp64_vector2_add(&combination->shift, &second->shift, &first_shift);
|
||||
}
|
||||
|
||||
|
|
@ -163,14 +151,14 @@ inline void bgc_fp64_affine2_combine(BGC_FP64_Affine2* combination, const BGC_FP
|
|||
inline void bgc_fp32_affine2_transform_point(BGC_FP32_Vector2* transformed_point, const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point)
|
||||
{
|
||||
BGC_FP32_Vector2 distorted;
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp32_matrix2x2_multiply_by_vector2(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp32_vector2_add(transformed_point, &affine->shift, &distorted);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine2_transform_point(BGC_FP64_Vector2* transformed_point, const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point)
|
||||
{
|
||||
BGC_FP64_Vector2 distorted;
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp64_matrix2x2_multiply_by_vector2(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp64_vector2_add(transformed_point, &affine->shift, &distorted);
|
||||
}
|
||||
|
||||
|
|
@ -178,12 +166,12 @@ inline void bgc_fp64_affine2_transform_point(BGC_FP64_Vector2* transformed_point
|
|||
|
||||
inline void bgc_fp32_affine2_transform_vector(BGC_FP32_Vector2* transformed_vector, const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector)
|
||||
{
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector);
|
||||
bgc_fp32_matrix2x2_multiply_by_vector2(transformed_vector, &affine->distortion, initial_vector);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine2_transform_vector(BGC_FP64_Vector2* transformed_vector, const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector)
|
||||
{
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector);
|
||||
bgc_fp64_matrix2x2_multiply_by_vector2(transformed_vector, &affine->distortion, initial_vector);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "affine3.h"
|
||||
#include "./affine3.h"
|
||||
|
||||
extern inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3* affine);
|
||||
extern inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3* affine);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
#ifndef _BGC_AFFINE3_H_INCLUDED_
|
||||
#define _BGC_AFFINE3_H_INCLUDED_
|
||||
|
||||
#include "vector3.h"
|
||||
#include "matrices.h"
|
||||
#include "matrix3x3.h"
|
||||
|
||||
// ==================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Matrix3x3 distortion;
|
||||
BGC_FP32_Vector3 shift;
|
||||
} BGC_FP32_Affine3;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Matrix3x3 distortion;
|
||||
BGC_FP64_Vector3 shift;
|
||||
} BGC_FP64_Affine3;
|
||||
#include "./vector3.h"
|
||||
#include "./types.h"
|
||||
#include "./matrix3x3.h"
|
||||
|
||||
// ==================== Reset ==================== //
|
||||
|
||||
|
|
@ -95,7 +83,7 @@ inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine)
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp32_matrix3x3_multiply_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp32_vector3_revert(&affine->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -107,7 +95,7 @@ inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp64_matrix3x3_multiply_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp64_vector3_revert(&affine->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -121,7 +109,7 @@ inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* destination, const BGC
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
|
||||
bgc_fp32_matrix3x3_multiply_by_vector3(&destination->shift, &destination->distortion, &source->shift);
|
||||
bgc_fp32_vector3_revert(&destination->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -133,7 +121,7 @@ inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* destination, const BGC
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
|
||||
bgc_fp64_matrix3x3_multiply_by_vector3(&destination->shift, &destination->distortion, &source->shift);
|
||||
bgc_fp64_vector3_revert(&destination->shift);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
|
|
@ -144,16 +132,16 @@ inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* destination, const BGC
|
|||
inline void bgc_fp32_affine3_combine(BGC_FP32_Affine3* combination, const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second)
|
||||
{
|
||||
BGC_FP32_Vector3 first_shift;
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp32_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp32_matrix3x3_multiply_by_vector3(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp32_matrix3x3_multiply_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp32_vector3_add(&combination->shift, &first_shift, &second->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second)
|
||||
{
|
||||
BGC_FP64_Vector3 first_shift;
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp64_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp64_matrix3x3_multiply_by_vector3(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp64_matrix3x3_multiply_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp64_vector3_add(&combination->shift, &first_shift, &second->shift);
|
||||
}
|
||||
|
||||
|
|
@ -162,14 +150,14 @@ inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP
|
|||
inline void bgc_fp32_affine3_transform_point(BGC_FP32_Vector3* transformed_point, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point)
|
||||
{
|
||||
BGC_FP32_Vector3 distorted;
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp32_matrix3x3_multiply_by_vector3(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp32_vector3_add(transformed_point, &affine->shift, &distorted);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_transform_point(BGC_FP64_Vector3* transformed_point, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point)
|
||||
{
|
||||
BGC_FP64_Vector3 distorted;
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp64_matrix3x3_multiply_by_vector3(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp64_vector3_add(transformed_point, &affine->shift, &distorted);
|
||||
}
|
||||
|
||||
|
|
@ -177,12 +165,12 @@ inline void bgc_fp64_affine3_transform_point(BGC_FP64_Vector3* transformed_point
|
|||
|
||||
inline void bgc_fp32_affine3_transform_vector(BGC_FP32_Vector3* transformed_vector, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector)
|
||||
{
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
|
||||
bgc_fp32_matrix3x3_multiply_by_vector3(transformed_vector, &affine->distortion, initial_vector);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_transform_vector(BGC_FP64_Vector3* transformed_vector, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector)
|
||||
{
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
|
||||
bgc_fp64_matrix3x3_multiply_by_vector3(transformed_vector, &affine->distortion, initial_vector);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
#include "./utilities.h"
|
||||
#include "./angle.h"
|
||||
|
||||
// !================= Radians ==================! //
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define _BGC_ANGLE_H_INCLUDED_
|
||||
|
||||
#include <math.h>
|
||||
#include "utilities.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
#define BGC_FP32_PI 3.1415926536f
|
||||
#define BGC_FP32_TWO_PI 6.2831853072f
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
|
||||
#include "./angle.h"
|
||||
|
||||
#include "./types.h"
|
||||
|
||||
#include "./vector2.h"
|
||||
#include "./vector3.h"
|
||||
|
||||
#include "./matrices.h"
|
||||
#include "./matrix2x2.h"
|
||||
#include "./matrix2x3.h"
|
||||
#include "./matrix3x2.h"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
<ClInclude Include="matrix2x3.h" />
|
||||
<ClInclude Include="matrix3x2.h" />
|
||||
<ClInclude Include="matrix3x3.h" />
|
||||
<ClInclude Include="matrices.h" />
|
||||
<ClInclude Include="types.h" />
|
||||
<ClInclude Include="position2.h" />
|
||||
<ClInclude Include="position3.h" />
|
||||
<ClInclude Include="quaternion.h" />
|
||||
|
|
@ -63,7 +63,6 @@
|
|||
<ClCompile Include="matrix2x3.c" />
|
||||
<ClCompile Include="matrix3x2.c" />
|
||||
<ClCompile Include="matrix3x3.c" />
|
||||
<ClCompile Include="matrices.c" />
|
||||
<ClCompile Include="quaternion.c" />
|
||||
<ClCompile Include="slerp.c" />
|
||||
<ClCompile Include="vector2.c" />
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
<ClInclude Include="matrix3x2.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="matrices.h">
|
||||
<ClInclude Include="types.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="complex.c">
|
||||
|
|
@ -113,9 +113,6 @@
|
|||
<ClCompile Include="quaternion.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="matrices.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="matrix2x3.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -1,20 +1,11 @@
|
|||
#ifndef _BGC_COMPLEX_H_INCLUDED_
|
||||
#define _BGC_COMPLEX_H_INCLUDED_
|
||||
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float real, imaginary;
|
||||
} BGC_FP32_Complex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double real, imaginary;
|
||||
} BGC_FP64_Complex;
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
#include "./angle.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "dual-number.h"
|
||||
#include "./dual-number.h"
|
||||
|
||||
extern inline void bgc_fp32_dual_number_reset(BGC_FP32_DualNumber* number);
|
||||
extern inline void bgc_fp64_dual_number_reset(BGC_FP64_DualNumber* number);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,8 @@
|
|||
#ifndef _BGC_DUAL_NUMBER_H_INCLUDED_
|
||||
#define _BGC_DUAL_NUMBER_H_INCLUDED_
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
// =================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
float real, dual;
|
||||
} BGC_FP32_DualNumber;
|
||||
|
||||
typedef struct {
|
||||
double real, dual;
|
||||
} BGC_FP64_DualNumber;
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "dual-quaternion.h"
|
||||
#include "./dual-quaternion.h"
|
||||
|
||||
extern inline void bgc_fp32_dual_quaternion_reset(BGC_FP32_DualQuaternion* quaternion);
|
||||
extern inline void bgc_fp64_dual_quaternion_reset(BGC_FP64_DualQuaternion* quaternion);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,8 @@
|
|||
#ifndef _BGC_DUAL_QUATERNION_H_INCLUDED_
|
||||
#define _BGC_DUAL_QUATERNION_H_INCLUDED_
|
||||
|
||||
#include "quaternion.h"
|
||||
|
||||
// =================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Quaternion real, dual;
|
||||
} BGC_FP32_DualQuaternion;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Quaternion real, dual;
|
||||
} BGC_FP64_DualQuaternion;
|
||||
#include "./types.h"
|
||||
#include "./quaternion.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,9 @@
|
|||
#ifndef _BGC_DUAL_VECTOR3_H_INCLUDED_
|
||||
#define _BGC_DUAL_VECTOR3_H_INCLUDED_
|
||||
|
||||
#include "./types.h"
|
||||
#include "./vector3.h"
|
||||
|
||||
// =================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Vector3 real, dual;
|
||||
} BGC_FP32_DualVector3;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Vector3 real, dual;
|
||||
} BGC_FP64_DualVector3;
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector)
|
||||
|
|
@ -147,14 +138,14 @@ inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, con
|
|||
|
||||
inline void bgc_fp32_dual_vector3_multiply(BGC_FP32_DualVector3* product, const BGC_FP32_DualVector3* multiplicand, const float multiplier)
|
||||
{
|
||||
bgc_fp32_vector3_multiply(&product->real, &multiplicand->real, multiplier);
|
||||
bgc_fp32_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
|
||||
bgc_fp32_vector3_multiply_by_real(&product->real, &multiplicand->real, multiplier);
|
||||
bgc_fp32_vector3_multiply_by_real(&product->dual, &multiplicand->dual, multiplier);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_dual_vector3_multiply(BGC_FP64_DualVector3* product, const BGC_FP64_DualVector3* multiplicand, const double multiplier)
|
||||
{
|
||||
bgc_fp64_vector3_multiply(&product->real, &multiplicand->real, multiplier);
|
||||
bgc_fp64_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
|
||||
bgc_fp64_vector3_multiply_by_real(&product->real, &multiplicand->real, multiplier);
|
||||
bgc_fp64_vector3_multiply_by_real(&product->dual, &multiplicand->dual, multiplier);
|
||||
}
|
||||
|
||||
// =================== Divide =================== //
|
||||
|
|
@ -167,8 +158,8 @@ inline int bgc_fp32_dual_vector3_divide(BGC_FP32_DualVector3* quotient, const BG
|
|||
|
||||
const float multiplier = 1.0f / divisor;
|
||||
|
||||
bgc_fp32_vector3_multiply("ient->real, ÷nd->real, multiplier);
|
||||
bgc_fp32_vector3_multiply("ient->dual, ÷nd->dual, multiplier);
|
||||
bgc_fp32_vector3_multiply_by_real("ient->real, ÷nd->real, multiplier);
|
||||
bgc_fp32_vector3_multiply_by_real("ient->dual, ÷nd->dual, multiplier);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
|
@ -181,8 +172,8 @@ inline int bgc_fp64_dual_vector3_divide(BGC_FP64_DualVector3* quotient, const BG
|
|||
|
||||
const double multiplier = 1.0 / divisor;
|
||||
|
||||
bgc_fp64_vector3_multiply("ient->real, ÷nd->real, multiplier);
|
||||
bgc_fp64_vector3_multiply("ient->dual, ÷nd->dual, multiplier);
|
||||
bgc_fp64_vector3_multiply_by_real("ient->real, ÷nd->real, multiplier);
|
||||
bgc_fp64_vector3_multiply_by_real("ient->dual, ÷nd->dual, multiplier);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "hg-matrix3x3.h"
|
||||
#include "./hg-matrix3x3.h"
|
||||
|
||||
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix);
|
||||
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix);
|
||||
|
|
|
|||
|
|
@ -1,28 +1,10 @@
|
|||
#ifndef _BGC_HG_MATRIX3X3_H_INCLUDED_
|
||||
#define _BGC_HG_MATRIX3X3_H_INCLUDED_
|
||||
|
||||
#include "vector3.h"
|
||||
#include "matrices.h"
|
||||
#include "./vector3.h"
|
||||
#include "./types.h"
|
||||
|
||||
#include "hg-vector3.h"
|
||||
|
||||
// =================== Types ==================== //
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float r1c1, r1c2, r1c3, r1d0;
|
||||
float r2c1, r2c2, r2c3, r2d0;
|
||||
float r3c1, r3c2, r3c3, r3d0;
|
||||
float d0c1, d0c2, d0c3, d0d0;
|
||||
} BGC_FP32_HgMatrix3x3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double r1c1, r1c2, r1c3, r1d0;
|
||||
double r2c1, r2c2, r2c3, r2d0;
|
||||
double r3c1, r3c2, r3c3, r3d0;
|
||||
double d0c1, d0c2, d0c3, d0d0;
|
||||
} BGC_FP64_HgMatrix3x3;
|
||||
#include "./hg-vector3.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,8 @@
|
|||
#ifndef _BGC_HG_VECTOR3_H_INCLUDED_
|
||||
#define _BGC_HG_VECTOR3_H_INCLUDED_
|
||||
|
||||
#include "./vector3.h"
|
||||
|
||||
// ================== Vector3 =================== //
|
||||
|
||||
// Homogeneous 3D Vector
|
||||
typedef struct
|
||||
{
|
||||
float x1, x2, x3, d0;
|
||||
} BGC_FP32_HgVector3;
|
||||
|
||||
// Homogeneous 3D Vector
|
||||
typedef struct
|
||||
{
|
||||
double x1, x2, x3, d0;
|
||||
} BGC_FP64_HgVector3;
|
||||
#include "./types.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
// ================ Reset Point ================= //
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#include "matrices.h"
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2);
|
||||
extern inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2);
|
||||
|
|
@ -1,364 +0,0 @@
|
|||
#ifndef _BGC_MATRICES_H_INCLUDED_
|
||||
#define _BGC_MATRICES_H_INCLUDED_
|
||||
|
||||
// ================== Matrix2x2 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2;
|
||||
float r2c1, r2c2;
|
||||
} BGC_FP32_Matrix2x2;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2;
|
||||
double r2c1, r2c2;
|
||||
} BGC_FP64_Matrix2x2;
|
||||
|
||||
// ================== Matrix2x3 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2;
|
||||
float r2c1, r2c2;
|
||||
float r3c1, r3c2;
|
||||
} BGC_FP32_Matrix2x3;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2;
|
||||
double r2c1, r2c2;
|
||||
double r3c1, r3c2;
|
||||
} BGC_FP64_Matrix2x3;
|
||||
|
||||
// ================== Matrix3x2 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2, r1c3;
|
||||
float r2c1, r2c2, r2c3;
|
||||
} BGC_FP32_Matrix3x2;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2, r1c3;
|
||||
double r2c1, r2c2, r2c3;
|
||||
} BGC_FP64_Matrix3x2;
|
||||
|
||||
// ================== Matrix3x3 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2, r1c3;
|
||||
float r2c1, r2c2, r2c3;
|
||||
float r3c1, r3c2, r3c3;
|
||||
} BGC_FP32_Matrix3x3;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2, r1c3;
|
||||
double r2c1, r2c2, r2c3;
|
||||
double r3c1, r3c2, r3c3;
|
||||
} BGC_FP64_Matrix3x3;
|
||||
|
||||
// ========== Matrix Product 2x2 at 2x2 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 2x2 at 3x2 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 2x3 at 2x2 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 2x3 at 3x2 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 3x2 at 3x3 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 3x3 at 2x3 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
|
||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
|
||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 3x3 at 3x3 ========= //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
product->r3c3 = r3c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
product->r3c3 = r3c3;
|
||||
}
|
||||
|
||||
#endif // _BGC_MATRIX_TYPES_H_
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "matrix2x2.h"
|
||||
#include "./matrix2x2.h"
|
||||
|
||||
extern inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix);
|
||||
extern inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix);
|
||||
|
|
@ -66,17 +66,20 @@ extern inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const
|
|||
extern inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend);
|
||||
extern inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier);
|
||||
extern inline void bgc_fp32_matrix2x2_multiply_by_real(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix2x2_multiply_by_real(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier);
|
||||
|
||||
extern inline int bgc_fp32_matrix2x2_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor);
|
||||
extern inline void bgc_fp32_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector);
|
||||
extern inline void bgc_fp64_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2);
|
||||
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2);
|
||||
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2);
|
||||
|
||||
extern inline int bgc_fp32_matrix2x2_divide_by_real(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix2x2_divide_by_real(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase);
|
||||
extern inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector);
|
||||
extern inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector);
|
||||
|
||||
extern inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix);
|
||||
extern inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#ifndef _BGC_MATRIX2X2_H_INCLUDED_
|
||||
#define _BGC_MATRIX2X2_H_INCLUDED_
|
||||
|
||||
#include "angle.h"
|
||||
#include "vector2.h"
|
||||
#include "matrices.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
#include "./angle.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
@ -537,7 +539,7 @@ inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BG
|
|||
|
||||
// ================== Multiply ================== //
|
||||
|
||||
inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier)
|
||||
inline void bgc_fp32_matrix2x2_multiply_by_real(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -546,7 +548,7 @@ inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_F
|
|||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier)
|
||||
inline void bgc_fp64_matrix2x2_multiply_by_real(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -555,25 +557,117 @@ inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_F
|
|||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector)
|
||||
{
|
||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector)
|
||||
{
|
||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 2x2 at 2x2 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 2x2 at 3x2 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline int bgc_fp32_matrix2x2_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor)
|
||||
inline int bgc_fp32_matrix2x2_divide_by_real(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_matrix2x2_multiply(quotient, dividend, 1.0f / divisor);
|
||||
bgc_fp32_matrix2x2_multiply_by_real(quotient, dividend, 1.0f / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor)
|
||||
inline int bgc_fp64_matrix2x2_divide_by_real(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_matrix2x2_multiply(quotient, dividend, 1.0 / divisor);
|
||||
bgc_fp64_matrix2x2_multiply_by_real(quotient, dividend, 1.0 / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -601,44 +695,4 @@ inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, co
|
|||
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector)
|
||||
{
|
||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector)
|
||||
{
|
||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix)
|
||||
{
|
||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix)
|
||||
{
|
||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "matrix2x3.h"
|
||||
#include "./matrix2x3.h"
|
||||
|
||||
extern inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix);
|
||||
extern inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix);
|
||||
|
|
@ -36,17 +36,20 @@ extern inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* sum, const
|
|||
extern inline void bgc_fp32_matrix2x3_subtract(BGC_FP32_Matrix2x3* difference, const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend);
|
||||
extern inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier);
|
||||
extern inline void bgc_fp32_matrix2x3_multiply_by_real(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix2x3_multiply_by_real(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier);
|
||||
|
||||
extern inline int bgc_fp32_matrix2x3_divide(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix2x3_divide(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor);
|
||||
extern inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector);
|
||||
extern inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2);
|
||||
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2);
|
||||
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2);
|
||||
|
||||
extern inline int bgc_fp32_matrix2x3_divide_by_real(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix2x3_divide_by_real(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor);
|
||||
|
||||
extern inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase);
|
||||
extern inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase);
|
||||
|
||||
extern inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix);
|
||||
extern inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector);
|
||||
extern inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#ifndef _BGC_MATRIX2X3_H_INCLUDED_
|
||||
#define _BGC_MATRIX2X3_H_INCLUDED_
|
||||
|
||||
#include "vector2.h"
|
||||
#include "vector3.h"
|
||||
#include "matrices.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
@ -411,7 +412,7 @@ inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BG
|
|||
|
||||
// ================== Multiply ================== //
|
||||
|
||||
inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier)
|
||||
inline void bgc_fp32_matrix2x3_multiply_by_real(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -423,7 +424,7 @@ inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_F
|
|||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier)
|
||||
inline void bgc_fp64_matrix2x3_multiply_by_real(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -435,25 +436,118 @@ inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_F
|
|||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
||||
}
|
||||
|
||||
|
||||
// ========== Matrix Product 2x3 at 2x2 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
|
||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 2x3 at 3x2 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||
|
||||
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||
}
|
||||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline int bgc_fp32_matrix2x3_divide(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor)
|
||||
inline int bgc_fp32_matrix2x3_divide_by_real(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_matrix2x3_multiply(quotient, dividend, 1.0f / divisor);
|
||||
bgc_fp32_matrix2x3_multiply_by_real(quotient, dividend, 1.0f / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_matrix2x3_divide(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor)
|
||||
inline int bgc_fp64_matrix2x3_divide_by_real(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_matrix2x3_multiply(quotient, dividend, 1.0 / divisor);
|
||||
bgc_fp64_matrix2x3_multiply_by_real(quotient, dividend, 1.0 / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -487,34 +581,4 @@ inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, co
|
|||
interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "matrix3x2.h"
|
||||
#include "./matrix3x2.h"
|
||||
|
||||
extern inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix);
|
||||
extern inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix);
|
||||
|
|
@ -36,17 +36,20 @@ extern inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* sum, const
|
|||
extern inline void bgc_fp32_matrix3x2_subtract(BGC_FP32_Matrix3x2* difference, const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend);
|
||||
extern inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier);
|
||||
extern inline void bgc_fp32_matrix3x2_multiply_by_real(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix3x2_multiply_by_real(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier);
|
||||
|
||||
extern inline int bgc_fp32_matrix3x2_divide(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix3x2_divide(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor);
|
||||
extern inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector);
|
||||
extern inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2);
|
||||
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2);
|
||||
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2);
|
||||
|
||||
extern inline int bgc_fp32_matrix3x2_divide_by_real(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix3x2_divide_by_real(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase);
|
||||
extern inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase);
|
||||
|
||||
extern inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix);
|
||||
extern inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector);
|
||||
extern inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#ifndef _BGC_MATRIX3X2_H_INCLUDED_
|
||||
#define _BGC_MATRIX3X2_H_INCLUDED_
|
||||
|
||||
#include "vector2.h"
|
||||
#include "vector3.h"
|
||||
#include "matrices.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
@ -421,7 +422,7 @@ inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BG
|
|||
|
||||
// ================== Multiply ================== //
|
||||
|
||||
inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier)
|
||||
inline void bgc_fp32_matrix3x2_multiply_by_real(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -432,7 +433,7 @@ inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_F
|
|||
product->r2c3 = multiplicand->r2c3 * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier)
|
||||
inline void bgc_fp64_matrix3x2_multiply_by_real(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -443,25 +444,99 @@ inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_F
|
|||
product->r2c3 = multiplicand->r2c3 * multiplier;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
||||
{
|
||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 3x2 at 3x3 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline int bgc_fp32_matrix3x2_divide(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor)
|
||||
inline int bgc_fp32_matrix3x2_divide_by_real(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_matrix3x2_multiply(quotient, dividend, 1.0f / divisor);
|
||||
bgc_fp32_matrix3x2_multiply_by_real(quotient, dividend, 1.0f / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_matrix3x2_divide(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor)
|
||||
inline int bgc_fp64_matrix3x2_divide_by_real(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_matrix3x2_multiply(quotient, dividend, 1.0 / divisor);
|
||||
bgc_fp64_matrix3x2_multiply_by_real(quotient, dividend, 1.0 / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -493,34 +568,4 @@ inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, co
|
|||
interpolation->r2c3 = first->r2c3 * couter_phase + second->r2c3 * phase;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "matrix3x3.h"
|
||||
#include "./matrix3x3.h"
|
||||
|
||||
extern inline void bgc_fp32_matrix3x3_reset(BGC_FP32_Matrix3x3* matrix);
|
||||
extern inline void bgc_fp64_matrix3x3_reset(BGC_FP64_Matrix3x3* matrix);
|
||||
|
|
@ -60,21 +60,24 @@ extern inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* sum, const
|
|||
extern inline void bgc_fp32_matrix3x3_subtract(BGC_FP32_Matrix3x3* difference, const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend);
|
||||
extern inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier);
|
||||
extern inline void bgc_fp32_matrix3x3_multiply_by_real(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_matrix3x3_multiply_by_real(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier);
|
||||
|
||||
extern inline int bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor);
|
||||
extern inline void bgc_fp32_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector);
|
||||
extern inline void bgc_fp64_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2);
|
||||
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2);
|
||||
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2);
|
||||
|
||||
extern inline int bgc_fp32_matrix3x3_divide_by_real(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_matrix3x3_divide_by_real(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor);
|
||||
|
||||
extern inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase);
|
||||
extern inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase);
|
||||
|
||||
extern inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix);
|
||||
extern inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix);
|
||||
|
||||
extern inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector);
|
||||
extern inline void bgc_fp64_multiply_matrix3x3_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector);
|
||||
|
||||
// ================ Get Inverse ================= //
|
||||
|
||||
int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_Matrix3x3* matrix)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#ifndef _BGC_MATRIX3X3_H_INCLUDED_
|
||||
#define _BGC_MATRIX3X3_H_INCLUDED_
|
||||
|
||||
#include "vector3.h"
|
||||
#include "matrices.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
@ -752,7 +754,7 @@ inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, const BG
|
|||
|
||||
// ================== Multiply ================== //
|
||||
|
||||
inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier)
|
||||
inline void bgc_fp32_matrix3x3_multiply_by_real(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -767,7 +769,7 @@ inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_F
|
|||
product->r3c3 = multiplicand->r3c3 * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier)
|
||||
inline void bgc_fp64_matrix3x3_multiply_by_real(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
|
@ -782,25 +784,150 @@ inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_F
|
|||
product->r3c3 = multiplicand->r3c3 * multiplier;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
const float x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
const double x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
|
||||
// ========== Matrix Product 3x3 at 2x3 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
|
||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
|
||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
// ========== Matrix Product 3x3 at 3x3 ========= //
|
||||
|
||||
inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
product->r3c3 = r3c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||
|
||||
product->r1c1 = r1c1;
|
||||
product->r1c2 = r1c2;
|
||||
product->r1c3 = r1c3;
|
||||
|
||||
product->r2c1 = r2c1;
|
||||
product->r2c2 = r2c2;
|
||||
product->r2c3 = r2c3;
|
||||
|
||||
product->r3c1 = r3c1;
|
||||
product->r3c2 = r3c2;
|
||||
product->r3c3 = r3c3;
|
||||
}
|
||||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline int bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor)
|
||||
inline int bgc_fp32_matrix3x3_divide_by_real(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_matrix3x3_multiply(quotient, dividend, 1.0f / divisor);
|
||||
bgc_fp32_matrix3x3_multiply_by_real(quotient, dividend, 1.0f / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor)
|
||||
inline int bgc_fp64_matrix3x3_divide_by_real(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_matrix3x3_multiply(quotient, dividend, 1.0 / divisor);
|
||||
bgc_fp64_matrix3x3_multiply_by_real(quotient, dividend, 1.0 / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -840,52 +967,4 @@ inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, co
|
|||
interpolation->r3c3 = first->r3c3 * counter_phase + second->r3c3 * phase;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix)
|
||||
{
|
||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
const float x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix)
|
||||
{
|
||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
const double x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
const float x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_multiply_matrix3x3_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
const double x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "position2.h"
|
||||
#include "./position2.h"
|
||||
|
||||
extern inline void bgc_fp32_position2_reset(BGC_FP32_Position2* node);
|
||||
extern inline void bgc_fp64_position2_reset(BGC_FP64_Position2* node);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef _BGC_POSITION2_H_INCLUDED_
|
||||
#define _BGC_POSITION2_H_INCLUDED_
|
||||
|
||||
#include "vector2.h"
|
||||
#include "affine2.h"
|
||||
#include "turn2.h"
|
||||
#include "./vector2.h"
|
||||
#include "./affine2.h"
|
||||
#include "./turn2.h"
|
||||
|
||||
// ==================== Types ==================== //
|
||||
|
||||
|
|
@ -187,14 +187,14 @@ inline void bgc_fp64_position2_get_outward_affine(BGC_FP64_Affine2* outward_affi
|
|||
inline void bgc_fp32_position2_get_inward_affine(BGC_FP32_Affine2* inward_affine_map, const BGC_FP32_Position2 * position)
|
||||
{
|
||||
bgc_fp32_turn2_get_reverse_matrix(&inward_affine_map->distortion, &position->turn);
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp32_matrix2x2_multiply_by_vector2(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp32_vector2_revert(&inward_affine_map->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_position2_get_inward_affine(BGC_FP64_Affine2* inward_affine_map, const BGC_FP64_Position2 * position)
|
||||
{
|
||||
bgc_fp64_turn2_get_reverse_matrix(&inward_affine_map->distortion, &position->turn);
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp64_matrix2x2_multiply_by_vector2(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp64_vector2_revert(&inward_affine_map->shift);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "position3.h"
|
||||
#include "./position3.h"
|
||||
|
||||
extern inline void bgc_fp32_position3_reset(BGC_FP32_Position3 * node);
|
||||
extern inline void bgc_fp64_position3_reset(BGC_FP64_Position3 * node);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef _BGC_POSITION3_H_INCLUDED_
|
||||
#define _BGC_POSITION3_H_INCLUDED_
|
||||
|
||||
#include "vector3.h"
|
||||
#include "affine3.h"
|
||||
#include "turn3.h"
|
||||
#include "./vector3.h"
|
||||
#include "./affine3.h"
|
||||
#include "./turn3.h"
|
||||
|
||||
// ==================== Types ==================== //
|
||||
|
||||
|
|
@ -186,14 +186,14 @@ inline void bgc_fp64_position3_get_outward_affine(BGC_FP64_Affine3* outward_affi
|
|||
inline void bgc_fp32_position3_get_inward_affine(BGC_FP32_Affine3* inward_affine_map, const BGC_FP32_Position3 * position)
|
||||
{
|
||||
bgc_fp32_turn3_get_reverse_matrix(&inward_affine_map->distortion, &position->turn);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp32_matrix3x3_multiply_by_vector3(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp32_vector3_revert(&inward_affine_map->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_position3_get_inward_affine(BGC_FP64_Affine3* inward_affine_map, const BGC_FP64_Position3 * position)
|
||||
{
|
||||
bgc_fp64_turn3_get_reverse_matrix(&inward_affine_map->distortion, &position->turn);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp64_matrix3x3_multiply_by_vector3(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift);
|
||||
bgc_fp64_vector3_revert(&inward_affine_map->shift);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <math.h>
|
||||
#include "quaternion.h"
|
||||
#include "./quaternion.h"
|
||||
|
||||
extern inline void bgc_fp32_quaternion_reset(BGC_FP32_Quaternion* quaternion);
|
||||
extern inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* quaternion);
|
||||
|
|
|
|||
|
|
@ -3,18 +3,10 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
#include "vector3.h"
|
||||
#include "matrix3x3.h"
|
||||
|
||||
typedef struct {
|
||||
float s0, x1, x2, x3;
|
||||
} BGC_FP32_Quaternion;
|
||||
|
||||
typedef struct {
|
||||
double s0, x1, x2, x3;
|
||||
} BGC_FP64_Quaternion;
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
#include "./angle.h"
|
||||
#include "./matrix3x3.h"
|
||||
|
||||
// ==================== Reset =================== //
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
#include "./slerp.h"
|
||||
|
||||
extern inline void bgc_fp32_slerp_reset(BGC_FP32_Slerp* slerp);
|
||||
extern inline void bgc_fp64_slerp_reset(BGC_FP64_Slerp* slerp);
|
||||
extern inline void bgc_fp32_slerp_reset(BGC_FP32_Turn3Slerp* slerp);
|
||||
extern inline void bgc_fp64_slerp_reset(BGC_FP64_Turn3Slerp* slerp);
|
||||
|
||||
extern inline void bgc_fp32_slerp_make_full(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end);
|
||||
extern inline void bgc_fp64_slerp_make_full(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end);
|
||||
extern inline void bgc_fp32_slerp_make_full(BGC_FP32_Turn3Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end);
|
||||
extern inline void bgc_fp64_slerp_make_full(BGC_FP64_Turn3Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end);
|
||||
|
||||
extern inline void bgc_fp32_slerp_make_shortened(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end);
|
||||
extern inline void bgc_fp64_slerp_make_shortened(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end);
|
||||
extern inline void bgc_fp32_slerp_make_shortened(BGC_FP32_Turn3Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end);
|
||||
extern inline void bgc_fp64_slerp_make_shortened(BGC_FP64_Turn3Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end);
|
||||
|
||||
extern inline void bgc_fp32_slerp_get_phase_versor(BGC_FP32_Turn3* versor, const BGC_FP32_Slerp* slerp, const float phase);
|
||||
extern inline void bgc_fp64_slerp_get_phase_versor(BGC_FP64_Turn3* versor, const BGC_FP64_Slerp* slerp, const double phase);
|
||||
extern inline void bgc_fp32_slerp_get_phase_versor(BGC_FP32_Turn3* versor, const BGC_FP32_Turn3Slerp* slerp, const float phase);
|
||||
extern inline void bgc_fp64_slerp_get_phase_versor(BGC_FP64_Turn3* versor, const BGC_FP64_Turn3Slerp* slerp, const double phase);
|
||||
|
||||
void bgc_fp32_slerp_make(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* augment)
|
||||
void bgc_fp32_slerp_make(BGC_FP32_Turn3Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* augment)
|
||||
{
|
||||
const float square_vector = augment->_versor.x1 * augment->_versor.x1 + augment->_versor.x2 * augment->_versor.x2 + augment->_versor.x3 * augment->_versor.x3;
|
||||
|
||||
|
|
@ -22,15 +22,15 @@ void bgc_fp32_slerp_make(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, con
|
|||
}
|
||||
|
||||
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
|
||||
slerp->s0_cos_weight = start->_versor.s0;
|
||||
slerp->x1_cos_weight = start->_versor.x1;
|
||||
slerp->x2_cos_weight = start->_versor.x2;
|
||||
slerp->x3_cos_weight = start->_versor.x3;
|
||||
slerp->_s0_cos_weight = start->_versor.s0;
|
||||
slerp->_x1_cos_weight = start->_versor.x1;
|
||||
slerp->_x2_cos_weight = start->_versor.x2;
|
||||
slerp->_x3_cos_weight = start->_versor.x3;
|
||||
|
||||
slerp->s0_sin_weight = 0.0f;
|
||||
slerp->x1_sin_weight = 0.0f;
|
||||
slerp->x2_sin_weight = 0.0f;
|
||||
slerp->x3_sin_weight = 0.0f;
|
||||
slerp->_s0_sin_weight = 0.0f;
|
||||
slerp->_x1_sin_weight = 0.0f;
|
||||
slerp->_x2_sin_weight = 0.0f;
|
||||
slerp->_x3_sin_weight = 0.0f;
|
||||
|
||||
slerp->radians = 0.0f;
|
||||
return;
|
||||
|
|
@ -42,18 +42,18 @@ void bgc_fp32_slerp_make(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, con
|
|||
|
||||
const float multiplier = 1.0f / vector_modulus;
|
||||
|
||||
slerp->s0_cos_weight = start->_versor.s0;
|
||||
slerp->x1_cos_weight = start->_versor.x1;
|
||||
slerp->x2_cos_weight = start->_versor.x2;
|
||||
slerp->x3_cos_weight = start->_versor.x3;
|
||||
slerp->_s0_cos_weight = start->_versor.s0;
|
||||
slerp->_x1_cos_weight = start->_versor.x1;
|
||||
slerp->_x2_cos_weight = start->_versor.x2;
|
||||
slerp->_x3_cos_weight = start->_versor.x3;
|
||||
|
||||
slerp->s0_sin_weight = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
|
||||
slerp->x1_sin_weight = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
|
||||
slerp->x2_sin_weight = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
|
||||
slerp->x3_sin_weight = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
|
||||
slerp->_s0_sin_weight = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
|
||||
slerp->_x1_sin_weight = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
|
||||
slerp->_x2_sin_weight = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
|
||||
slerp->_x3_sin_weight = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
|
||||
}
|
||||
|
||||
void bgc_fp64_slerp_make(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* augment)
|
||||
void bgc_fp64_slerp_make(BGC_FP64_Turn3Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* augment)
|
||||
{
|
||||
const double square_vector = augment->_versor.x1 * augment->_versor.x1 + augment->_versor.x2 * augment->_versor.x2 + augment->_versor.x3 * augment->_versor.x3;
|
||||
|
||||
|
|
@ -63,15 +63,15 @@ void bgc_fp64_slerp_make(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, con
|
|||
}
|
||||
|
||||
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
|
||||
slerp->s0_cos_weight = start->_versor.s0;
|
||||
slerp->x1_cos_weight = start->_versor.x1;
|
||||
slerp->x2_cos_weight = start->_versor.x2;
|
||||
slerp->x3_cos_weight = start->_versor.x3;
|
||||
slerp->_s0_cos_weight = start->_versor.s0;
|
||||
slerp->_x1_cos_weight = start->_versor.x1;
|
||||
slerp->_x2_cos_weight = start->_versor.x2;
|
||||
slerp->_x3_cos_weight = start->_versor.x3;
|
||||
|
||||
slerp->s0_sin_weight = 0.0;
|
||||
slerp->x1_sin_weight = 0.0;
|
||||
slerp->x2_sin_weight = 0.0;
|
||||
slerp->x3_sin_weight = 0.0;
|
||||
slerp->_s0_sin_weight = 0.0;
|
||||
slerp->_x1_sin_weight = 0.0;
|
||||
slerp->_x2_sin_weight = 0.0;
|
||||
slerp->_x3_sin_weight = 0.0;
|
||||
|
||||
slerp->radians = 0.0;
|
||||
return;
|
||||
|
|
@ -83,13 +83,13 @@ void bgc_fp64_slerp_make(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, con
|
|||
|
||||
const double multiplier = 1.0 / vector_modulus;
|
||||
|
||||
slerp->s0_cos_weight = start->_versor.s0;
|
||||
slerp->x1_cos_weight = start->_versor.x1;
|
||||
slerp->x2_cos_weight = start->_versor.x2;
|
||||
slerp->x3_cos_weight = start->_versor.x3;
|
||||
slerp->_s0_cos_weight = start->_versor.s0;
|
||||
slerp->_x1_cos_weight = start->_versor.x1;
|
||||
slerp->_x2_cos_weight = start->_versor.x2;
|
||||
slerp->_x3_cos_weight = start->_versor.x3;
|
||||
|
||||
slerp->s0_sin_weight = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
|
||||
slerp->x1_sin_weight = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
|
||||
slerp->x2_sin_weight = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
|
||||
slerp->x3_sin_weight = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
|
||||
slerp->_s0_sin_weight = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
|
||||
slerp->_x1_sin_weight = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
|
||||
slerp->_x2_sin_weight = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
|
||||
slerp->_x3_sin_weight = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,62 +1,47 @@
|
|||
#ifndef _BGC_SLERP_H_INCLUDED_
|
||||
#define _BGC_SLERP_H_INCLUDED_
|
||||
|
||||
#include "./types.h"
|
||||
#include "./turn3.h"
|
||||
|
||||
typedef struct {
|
||||
float s0_cos_weight, s0_sin_weight;
|
||||
float x1_cos_weight, x1_sin_weight;
|
||||
float x2_cos_weight, x2_sin_weight;
|
||||
float x3_cos_weight, x3_sin_weight;
|
||||
float radians;
|
||||
} BGC_FP32_Slerp;
|
||||
|
||||
typedef struct {
|
||||
double s0_cos_weight, s0_sin_weight;
|
||||
double x1_cos_weight, x1_sin_weight;
|
||||
double x2_cos_weight, x2_sin_weight;
|
||||
double x3_cos_weight, x3_sin_weight;
|
||||
double radians;
|
||||
} BGC_FP64_Slerp;
|
||||
|
||||
inline void bgc_fp32_slerp_reset(BGC_FP32_Slerp* slerp)
|
||||
inline void bgc_fp32_slerp_reset(BGC_FP32_Turn3Slerp* slerp)
|
||||
{
|
||||
slerp->s0_cos_weight = 1.0f;
|
||||
slerp->s0_sin_weight = 0.0f;
|
||||
slerp->_s0_cos_weight = 1.0f;
|
||||
slerp->_s0_sin_weight = 0.0f;
|
||||
|
||||
slerp->x1_cos_weight = 0.0f;
|
||||
slerp->x1_sin_weight = 0.0f;
|
||||
slerp->_x1_cos_weight = 0.0f;
|
||||
slerp->_x1_sin_weight = 0.0f;
|
||||
|
||||
slerp->x2_cos_weight = 0.0f;
|
||||
slerp->x2_sin_weight = 0.0f;
|
||||
slerp->_x2_cos_weight = 0.0f;
|
||||
slerp->_x2_sin_weight = 0.0f;
|
||||
|
||||
slerp->x3_cos_weight = 0.0f;
|
||||
slerp->x3_sin_weight = 0.0f;
|
||||
slerp->_x3_cos_weight = 0.0f;
|
||||
slerp->_x3_sin_weight = 0.0f;
|
||||
|
||||
slerp->radians = 0.0f;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_slerp_reset(BGC_FP64_Slerp* slerp)
|
||||
inline void bgc_fp64_slerp_reset(BGC_FP64_Turn3Slerp* slerp)
|
||||
{
|
||||
slerp->s0_cos_weight = 1.0;
|
||||
slerp->s0_sin_weight = 0.0;
|
||||
slerp->_s0_cos_weight = 1.0;
|
||||
slerp->_s0_sin_weight = 0.0;
|
||||
|
||||
slerp->x1_cos_weight = 0.0;
|
||||
slerp->x1_sin_weight = 0.0;
|
||||
slerp->_x1_cos_weight = 0.0;
|
||||
slerp->_x1_sin_weight = 0.0;
|
||||
|
||||
slerp->x2_cos_weight = 0.0;
|
||||
slerp->x2_sin_weight = 0.0;
|
||||
slerp->_x2_cos_weight = 0.0;
|
||||
slerp->_x2_sin_weight = 0.0;
|
||||
|
||||
slerp->x3_cos_weight = 0.0;
|
||||
slerp->x3_sin_weight = 0.0;
|
||||
slerp->_x3_cos_weight = 0.0;
|
||||
slerp->_x3_sin_weight = 0.0;
|
||||
|
||||
slerp->radians = 0.0;
|
||||
}
|
||||
|
||||
void bgc_fp32_slerp_make(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* augment);
|
||||
void bgc_fp64_slerp_make(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* augment);
|
||||
void bgc_fp32_slerp_make(BGC_FP32_Turn3Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* augment);
|
||||
void bgc_fp64_slerp_make(BGC_FP64_Turn3Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* augment);
|
||||
|
||||
inline void bgc_fp32_slerp_make_full(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end)
|
||||
inline void bgc_fp32_slerp_make_full(BGC_FP32_Turn3Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end)
|
||||
{
|
||||
BGC_FP32_Turn3 augment;
|
||||
|
||||
|
|
@ -65,7 +50,7 @@ inline void bgc_fp32_slerp_make_full(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3
|
|||
bgc_fp32_slerp_make(slerp, start, &augment);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_slerp_make_full(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end)
|
||||
inline void bgc_fp64_slerp_make_full(BGC_FP64_Turn3Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end)
|
||||
{
|
||||
BGC_FP64_Turn3 augment;
|
||||
|
||||
|
|
@ -74,7 +59,7 @@ inline void bgc_fp64_slerp_make_full(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3
|
|||
bgc_fp64_slerp_make(slerp, start, &augment);
|
||||
}
|
||||
|
||||
inline void bgc_fp32_slerp_make_shortened(BGC_FP32_Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end)
|
||||
inline void bgc_fp32_slerp_make_shortened(BGC_FP32_Turn3Slerp* slerp, const BGC_FP32_Turn3* start, const BGC_FP32_Turn3* end)
|
||||
{
|
||||
BGC_FP32_Turn3 augment;
|
||||
|
||||
|
|
@ -84,7 +69,7 @@ inline void bgc_fp32_slerp_make_shortened(BGC_FP32_Slerp* slerp, const BGC_FP32_
|
|||
bgc_fp32_slerp_make(slerp, start, &augment);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_slerp_make_shortened(BGC_FP64_Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end)
|
||||
inline void bgc_fp64_slerp_make_shortened(BGC_FP64_Turn3Slerp* slerp, const BGC_FP64_Turn3* start, const BGC_FP64_Turn3* end)
|
||||
{
|
||||
BGC_FP64_Turn3 augment;
|
||||
|
||||
|
|
@ -94,7 +79,7 @@ inline void bgc_fp64_slerp_make_shortened(BGC_FP64_Slerp* slerp, const BGC_FP64_
|
|||
bgc_fp64_slerp_make(slerp, start, &augment);
|
||||
}
|
||||
|
||||
inline void bgc_fp32_slerp_get_phase_versor(BGC_FP32_Turn3* versor, const BGC_FP32_Slerp* slerp, const float phase)
|
||||
inline void bgc_fp32_slerp_get_phase_versor(BGC_FP32_Turn3* versor, const BGC_FP32_Turn3Slerp* slerp, const float phase)
|
||||
{
|
||||
const float angle = slerp->radians * phase;
|
||||
const float cosine = cosf(angle);
|
||||
|
|
@ -102,14 +87,14 @@ inline void bgc_fp32_slerp_get_phase_versor(BGC_FP32_Turn3* versor, const BGC_FP
|
|||
|
||||
bgc_fp32_turn3_set_raw_values(
|
||||
versor,
|
||||
slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine,
|
||||
slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine,
|
||||
slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine,
|
||||
slerp->x3_cos_weight * cosine + slerp->x3_sin_weight * sine
|
||||
slerp->_s0_cos_weight * cosine + slerp->_s0_sin_weight * sine,
|
||||
slerp->_x1_cos_weight * cosine + slerp->_x1_sin_weight * sine,
|
||||
slerp->_x2_cos_weight * cosine + slerp->_x2_sin_weight * sine,
|
||||
slerp->_x3_cos_weight * cosine + slerp->_x3_sin_weight * sine
|
||||
);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_slerp_get_phase_versor(BGC_FP64_Turn3* versor, const BGC_FP64_Slerp* slerp, const double phase)
|
||||
inline void bgc_fp64_slerp_get_phase_versor(BGC_FP64_Turn3* versor, const BGC_FP64_Turn3Slerp* slerp, const double phase)
|
||||
{
|
||||
const double angle = slerp->radians * phase;
|
||||
const double cosine = cos(angle);
|
||||
|
|
@ -117,10 +102,10 @@ inline void bgc_fp64_slerp_get_phase_versor(BGC_FP64_Turn3* versor, const BGC_FP
|
|||
|
||||
bgc_fp64_turn3_set_raw_values(
|
||||
versor,
|
||||
slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine,
|
||||
slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine,
|
||||
slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine,
|
||||
slerp->x3_cos_weight * cosine + slerp->x3_sin_weight * sine
|
||||
slerp->_s0_cos_weight * cosine + slerp->_s0_sin_weight * sine,
|
||||
slerp->_x1_cos_weight * cosine + slerp->_x1_sin_weight * sine,
|
||||
slerp->_x2_cos_weight * cosine + slerp->_x2_sin_weight * sine,
|
||||
slerp->_x3_cos_weight * cosine + slerp->_x3_sin_weight * sine
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,22 +3,9 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
#include "vector2.h"
|
||||
#include "matrix2x2.h"
|
||||
|
||||
// =================== Types ==================== //
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float _cos, _sin;
|
||||
} BGC_FP32_Turn2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double _cos, _sin;
|
||||
} BGC_FP64_Turn2;
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
#include "./angle.h"
|
||||
|
||||
// ================= Constants ================== //
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "angle.h"
|
||||
#include "turn3.h"
|
||||
#include "./angle.h"
|
||||
#include "./vector3.h"
|
||||
#include "./turn3.h"
|
||||
|
||||
const BGC_FP32_Turn3 BGC_FP32_IDLE_TURN3 = {{ 1.0f, 0.0f, 0.0f, 0.0f }};
|
||||
|
||||
|
|
@ -308,7 +309,7 @@ static inline int _bgc_fp32_turn3_get_orthogonal_pair(BGC_FP32_Vector3* unit_mai
|
|||
return _BGC_ERROR_TURN3_EMPTY_BRANCH;
|
||||
}
|
||||
|
||||
bgc_fp32_vector3_multiply(unit_main, main, sqrtf(1.0f / main_square_modulus));
|
||||
bgc_fp32_vector3_multiply_by_real(unit_main, main, sqrtf(1.0f / main_square_modulus));
|
||||
|
||||
bgc_fp32_vector3_add_scaled(unit_branch, branch, unit_main, -bgc_fp32_vector3_get_dot_product(branch, unit_main));
|
||||
|
||||
|
|
@ -318,7 +319,7 @@ static inline int _bgc_fp32_turn3_get_orthogonal_pair(BGC_FP32_Vector3* unit_mai
|
|||
return _BGC_ERROR_TURN3_PAIR_PARALLEL;
|
||||
}
|
||||
|
||||
bgc_fp32_vector3_multiply(unit_branch, unit_branch, sqrtf(1.0f / orthogonal_square_modulus));
|
||||
bgc_fp32_vector3_multiply_by_real(unit_branch, unit_branch, sqrtf(1.0f / orthogonal_square_modulus));
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
|
@ -337,7 +338,7 @@ static inline int _bgc_fp64_turn3_get_orthogonal_pair(BGC_FP64_Vector3* unit_mai
|
|||
return _BGC_ERROR_TURN3_EMPTY_BRANCH;
|
||||
}
|
||||
|
||||
bgc_fp64_vector3_multiply(unit_main, main, sqrt(1.0 / main_square_modulus));
|
||||
bgc_fp64_vector3_multiply_by_real(unit_main, main, sqrt(1.0 / main_square_modulus));
|
||||
|
||||
bgc_fp64_vector3_add_scaled(unit_branch, branch, unit_main, -bgc_fp64_vector3_get_dot_product(branch, unit_main));
|
||||
|
||||
|
|
@ -347,7 +348,7 @@ static inline int _bgc_fp64_turn3_get_orthogonal_pair(BGC_FP64_Vector3* unit_mai
|
|||
return _BGC_ERROR_TURN3_PAIR_PARALLEL;
|
||||
}
|
||||
|
||||
bgc_fp64_vector3_multiply(unit_branch, unit_branch, sqrt(1.0 / orthogonal_square_modulus));
|
||||
bgc_fp64_vector3_multiply_by_real(unit_branch, unit_branch, sqrt(1.0 / orthogonal_square_modulus));
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
#include "vector3.h"
|
||||
#include "matrix3x3.h"
|
||||
#include "quaternion.h"
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
#include "./angle.h"
|
||||
#include "./quaternion.h"
|
||||
|
||||
#define BGC_ERROR_TURN3_FIRST_VECTOR_ZERO -3010
|
||||
#define BGC_ERROR_TURN3_SECOND_VECTOR_ZERO -3011
|
||||
|
|
@ -27,16 +26,6 @@
|
|||
#define BGC_ERROR_TURN3_SECOND_PAIR_ZERO_BRANCH -3032
|
||||
#define BGC_ERROR_TURN3_SECOND_PAIR_PARALLEL -3033
|
||||
|
||||
// =================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Quaternion _versor;
|
||||
} BGC_FP32_Turn3;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Quaternion _versor;
|
||||
} BGC_FP64_Turn3;
|
||||
|
||||
// ================= Constants ================== //
|
||||
|
||||
extern const BGC_FP32_Turn3 BGC_FP32_IDLE_TURN3;
|
||||
|
|
|
|||
230
basic-geometry/types.h
Normal file
230
basic-geometry/types.h
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
#ifndef _BGC_TYPES_H_INCLUDED_
|
||||
#define _BGC_TYPES_H_INCLUDED_
|
||||
|
||||
// =================== Vector2 ================== //
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x1, x2;
|
||||
} BGC_FP32_Vector2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x1, x2;
|
||||
} BGC_FP64_Vector2;
|
||||
|
||||
// ================== Vector3 =================== //
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x1, x2, x3;
|
||||
} BGC_FP32_Vector3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x1, x2, x3;
|
||||
} BGC_FP64_Vector3;
|
||||
|
||||
// ================== Matrix2x2 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2;
|
||||
float r2c1, r2c2;
|
||||
} BGC_FP32_Matrix2x2;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2;
|
||||
double r2c1, r2c2;
|
||||
} BGC_FP64_Matrix2x2;
|
||||
|
||||
// ================== Matrix2x3 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2;
|
||||
float r2c1, r2c2;
|
||||
float r3c1, r3c2;
|
||||
} BGC_FP32_Matrix2x3;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2;
|
||||
double r2c1, r2c2;
|
||||
double r3c1, r3c2;
|
||||
} BGC_FP64_Matrix2x3;
|
||||
|
||||
// ================== Matrix3x2 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2, r1c3;
|
||||
float r2c1, r2c2, r2c3;
|
||||
} BGC_FP32_Matrix3x2;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2, r1c3;
|
||||
double r2c1, r2c2, r2c3;
|
||||
} BGC_FP64_Matrix3x2;
|
||||
|
||||
// ================== Matrix3x3 ================= //
|
||||
|
||||
typedef struct {
|
||||
float r1c1, r1c2, r1c3;
|
||||
float r2c1, r2c2, r2c3;
|
||||
float r3c1, r3c2, r3c3;
|
||||
} BGC_FP32_Matrix3x3;
|
||||
|
||||
typedef struct {
|
||||
double r1c1, r1c2, r1c3;
|
||||
double r2c1, r2c2, r2c3;
|
||||
double r3c1, r3c2, r3c3;
|
||||
} BGC_FP64_Matrix3x3;
|
||||
|
||||
// ================ Affine Map 2D ================ //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Matrix2x2 distortion;
|
||||
BGC_FP32_Vector2 shift;
|
||||
} BGC_FP32_Affine2;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Matrix2x2 distortion;
|
||||
BGC_FP64_Vector2 shift;
|
||||
} BGC_FP64_Affine2;
|
||||
|
||||
// ================ Affine Map 3D ================ //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Matrix3x3 distortion;
|
||||
BGC_FP32_Vector3 shift;
|
||||
} BGC_FP32_Affine3;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Matrix3x3 distortion;
|
||||
BGC_FP64_Vector3 shift;
|
||||
} BGC_FP64_Affine3;
|
||||
|
||||
// =============== Complex Number =============== //
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float real, imaginary;
|
||||
} BGC_FP32_Complex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double real, imaginary;
|
||||
} BGC_FP64_Complex;
|
||||
|
||||
// =================== Turn2 ==================== //
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float _cos, _sin;
|
||||
} BGC_FP32_Turn2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double _cos, _sin;
|
||||
} BGC_FP64_Turn2;
|
||||
|
||||
// ================= Quaternion ================= //
|
||||
|
||||
typedef struct {
|
||||
float s0, x1, x2, x3;
|
||||
} BGC_FP32_Quaternion;
|
||||
|
||||
typedef struct {
|
||||
double s0, x1, x2, x3;
|
||||
} BGC_FP64_Quaternion;
|
||||
|
||||
// =================== Turn3 ==================== //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Quaternion _versor;
|
||||
} BGC_FP32_Turn3;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Quaternion _versor;
|
||||
} BGC_FP64_Turn3;
|
||||
|
||||
// ================ Turn3 Slerp ================= //
|
||||
|
||||
typedef struct {
|
||||
float _s0_cos_weight, _s0_sin_weight;
|
||||
float _x1_cos_weight, _x1_sin_weight;
|
||||
float _x2_cos_weight, _x2_sin_weight;
|
||||
float _x3_cos_weight, _x3_sin_weight;
|
||||
float radians;
|
||||
} BGC_FP32_Turn3Slerp;
|
||||
|
||||
typedef struct {
|
||||
double _s0_cos_weight, _s0_sin_weight;
|
||||
double _x1_cos_weight, _x1_sin_weight;
|
||||
double _x2_cos_weight, _x2_sin_weight;
|
||||
double _x3_cos_weight, _x3_sin_weight;
|
||||
double radians;
|
||||
} BGC_FP64_Turn3Slerp;
|
||||
|
||||
// =========== Homogeneous 3D Vector ============ //
|
||||
|
||||
// Homogeneous 3D Vector
|
||||
typedef struct
|
||||
{
|
||||
float x1, x2, x3, d0;
|
||||
} BGC_FP32_HgVector3;
|
||||
|
||||
// Homogeneous 3D Vector
|
||||
typedef struct
|
||||
{
|
||||
double x1, x2, x3, d0;
|
||||
} BGC_FP64_HgVector3;
|
||||
|
||||
// =========== Homogeneous Matrix3x3 ============ //
|
||||
|
||||
// Homogeneous Matrix3x3 based on float type
|
||||
typedef struct
|
||||
{
|
||||
float r1c1, r1c2, r1c3, r1d0;
|
||||
float r2c1, r2c2, r2c3, r2d0;
|
||||
float r3c1, r3c2, r3c3, r3d0;
|
||||
float d0c1, d0c2, d0c3, d0d0;
|
||||
} BGC_FP32_HgMatrix3x3;
|
||||
|
||||
// Homogeneous Matrix3x3 based on double type
|
||||
typedef struct
|
||||
{
|
||||
double r1c1, r1c2, r1c3, r1d0;
|
||||
double r2c1, r2c2, r2c3, r2d0;
|
||||
double r3c1, r3c2, r3c3, r3d0;
|
||||
double d0c1, d0c2, d0c3, d0d0;
|
||||
} BGC_FP64_HgMatrix3x3;
|
||||
|
||||
// ================ Dual Number ================= //
|
||||
|
||||
typedef struct {
|
||||
float real, dual;
|
||||
} BGC_FP32_DualNumber;
|
||||
|
||||
typedef struct {
|
||||
double real, dual;
|
||||
} BGC_FP64_DualNumber;
|
||||
|
||||
// ================ Dual Vector ================= //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Vector3 real, dual;
|
||||
} BGC_FP32_DualVector3;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Vector3 real, dual;
|
||||
} BGC_FP64_DualVector3;
|
||||
|
||||
// ============== Dual Quaternion =============== //
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Quaternion real, dual;
|
||||
} BGC_FP32_DualQuaternion;
|
||||
|
||||
typedef struct {
|
||||
BGC_FP64_Quaternion real, dual;
|
||||
} BGC_FP64_DualQuaternion;
|
||||
|
||||
#endif // _BGC_MATRIX_TYPES_H_
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "utilities.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
extern inline int bgc_is_correct_axis(const int axis);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "vector2.h"
|
||||
#include "./vector2.h"
|
||||
|
||||
extern inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* vector);
|
||||
extern inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* vector);
|
||||
|
|
@ -36,11 +36,17 @@ extern inline void bgc_fp64_vector2_add_scaled(BGC_FP64_Vector2* sum, const BGC_
|
|||
extern inline void bgc_fp32_vector2_subtract(BGC_FP32_Vector2* difference, const BGC_FP32_Vector2* minuend, const BGC_FP32_Vector2* subtrahend);
|
||||
extern inline void bgc_fp64_vector2_subtract(BGC_FP64_Vector2* difference, const BGC_FP64_Vector2* minuend, const BGC_FP64_Vector2* subtrahend);
|
||||
|
||||
extern inline void bgc_fp32_vector2_multiply(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_vector2_multiply(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* multiplicand, const double multiplier);
|
||||
extern inline void bgc_fp32_vector2_multiply_by_real(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_vector2_multiply_by_real(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* multiplicand, const double multiplier);
|
||||
|
||||
extern inline int bgc_fp32_vector2_divide(BGC_FP32_Vector2* quotient, const BGC_FP32_Vector2* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_vector2_divide(BGC_FP64_Vector2* quotient, const BGC_FP64_Vector2* dividend, const double divisor);
|
||||
extern inline void bgc_fp32_vector2_multiply_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix);
|
||||
extern inline void bgc_fp64_vector2_multiply_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix);
|
||||
|
||||
extern inline void bgc_fp32_vector2_multiply_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix);
|
||||
extern inline void bgc_fp64_vector2_multiply_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix);
|
||||
|
||||
extern inline int bgc_fp32_vector2_divide_by_real(BGC_FP32_Vector2* quotient, const BGC_FP32_Vector2* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_vector2_divide_by_real(BGC_FP64_Vector2* quotient, const BGC_FP64_Vector2* dividend, const double divisor);
|
||||
|
||||
extern inline void bgc_fp32_vector2_get_mean2(BGC_FP32_Vector2* mean, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
|
||||
extern inline void bgc_fp64_vector2_get_mean2(BGC_FP64_Vector2* mean, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
|
||||
|
|
|
|||
|
|
@ -1,20 +1,11 @@
|
|||
#ifndef _BGC_VECTOR2_H_INCLUDED_
|
||||
#define _BGC_VECTOR2_H_INCLUDED_
|
||||
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x1, x2;
|
||||
} BGC_FP32_Vector2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x1, x2;
|
||||
} BGC_FP64_Vector2;
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
#include "./angle.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
@ -186,38 +177,74 @@ inline void bgc_fp64_vector2_subtract(BGC_FP64_Vector2* difference, const BGC_FP
|
|||
|
||||
// ================== Multiply ================== //
|
||||
|
||||
inline void bgc_fp32_vector2_multiply(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* multiplicand, const float multiplier)
|
||||
inline void bgc_fp32_vector2_multiply_by_real(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* multiplicand, const float multiplier)
|
||||
{
|
||||
product->x1 = multiplicand->x1 * multiplier;
|
||||
product->x2 = multiplicand->x2 * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_vector2_multiply(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* multiplicand, const double multiplier)
|
||||
inline void bgc_fp64_vector2_multiply_by_real(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* multiplicand, const double multiplier)
|
||||
{
|
||||
product->x1 = multiplicand->x1 * multiplier;
|
||||
product->x2 = multiplicand->x2 * multiplier;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_vector2_multiply_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix)
|
||||
{
|
||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_vector2_multiply_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix)
|
||||
{
|
||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_vector2_multiply_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_vector2_multiply_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
||||
}
|
||||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline int bgc_fp32_vector2_divide(BGC_FP32_Vector2* quotient, const BGC_FP32_Vector2* dividend, const float divisor)
|
||||
inline int bgc_fp32_vector2_divide_by_real(BGC_FP32_Vector2* quotient, const BGC_FP32_Vector2* dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_vector2_multiply(quotient, dividend, 1.0f / divisor);
|
||||
bgc_fp32_vector2_multiply_by_real(quotient, dividend, 1.0f / divisor);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_vector2_divide(BGC_FP64_Vector2* quotient, const BGC_FP64_Vector2* dividend, const double divisor)
|
||||
inline int bgc_fp64_vector2_divide_by_real(BGC_FP64_Vector2* quotient, const BGC_FP64_Vector2* dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_vector2_multiply(quotient, dividend, 1.0 / divisor);
|
||||
bgc_fp64_vector2_multiply_by_real(quotient, dividend, 1.0 / divisor);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
|
@ -350,7 +377,7 @@ inline int bgc_fp32_vector2_get_normalized(BGC_FP32_Vector2* normalized, const B
|
|||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
bgc_fp32_vector2_multiply(normalized, vector, sqrtf(1.0f / square_modulus));
|
||||
bgc_fp32_vector2_multiply_by_real(normalized, vector, sqrtf(1.0f / square_modulus));
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -368,7 +395,7 @@ inline int bgc_fp64_vector2_get_normalized(BGC_FP64_Vector2* normalized, const B
|
|||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
bgc_fp64_vector2_multiply(normalized, vector, sqrt(1.0 / square_modulus));
|
||||
bgc_fp64_vector2_multiply_by_real(normalized, vector, sqrt(1.0 / square_modulus));
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "vector3.h"
|
||||
#include "./vector3.h"
|
||||
|
||||
extern inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector);
|
||||
extern inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector);
|
||||
|
|
@ -36,11 +36,17 @@ extern inline void bgc_fp64_vector3_add_scaled(BGC_FP64_Vector3* sum, const BGC_
|
|||
extern inline void bgc_fp32_vector3_subtract(BGC_FP32_Vector3* difference, const BGC_FP32_Vector3* minuend, const BGC_FP32_Vector3* subtrahend);
|
||||
extern inline void bgc_fp64_vector3_subtract(BGC_FP64_Vector3* difference, const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend);
|
||||
|
||||
extern inline void bgc_fp32_vector3_multiply(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_vector3_multiply(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* multiplicand, const double multiplier);
|
||||
extern inline void bgc_fp32_vector3_multiply_by_real(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* multiplicand, const float multiplier);
|
||||
extern inline void bgc_fp64_vector3_multiply_by_real(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* multiplicand, const double multiplier);
|
||||
|
||||
extern inline int bgc_fp32_vector3_divide(BGC_FP32_Vector3* quotient, const BGC_FP32_Vector3* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_vector3_divide(BGC_FP64_Vector3* quotient, const BGC_FP64_Vector3* dividend, const double divisor);
|
||||
extern inline void bgc_fp32_vector3_multiply_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix);
|
||||
extern inline void bgc_fp64_vector3_multiply_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix);
|
||||
|
||||
extern inline void bgc_fp32_vector3_multiply_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix);
|
||||
extern inline void bgc_fp64_vector3_multiply_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix);
|
||||
|
||||
extern inline int bgc_fp32_vector3_divide_by_real(BGC_FP32_Vector3* quotient, const BGC_FP32_Vector3* dividend, const float divisor);
|
||||
extern inline int bgc_fp64_vector3_divide_by_real(BGC_FP64_Vector3* quotient, const BGC_FP64_Vector3* dividend, const double divisor);
|
||||
|
||||
extern inline void bgc_fp32_vector3_get_mean2(BGC_FP32_Vector3* mean, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
|
||||
extern inline void bgc_fp64_vector3_get_mean2(BGC_FP64_Vector3* mean, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
|
||||
|
|
|
|||
|
|
@ -1,22 +1,11 @@
|
|||
#ifndef _BGC_VECTOR3_H_INCLUDED_
|
||||
#define _BGC_VECTOR3_H_INCLUDED_
|
||||
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// ================== Vector3 =================== //
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x1, x2, x3;
|
||||
} BGC_FP32_Vector3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x1, x2, x3;
|
||||
} BGC_FP64_Vector3;
|
||||
#include "./utilities.h"
|
||||
#include "./types.h"
|
||||
#include "./angle.h"
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
|
|
@ -208,40 +197,78 @@ inline void bgc_fp64_vector3_subtract(BGC_FP64_Vector3* difference, const BGC_FP
|
|||
|
||||
// ================== Multiply ================== //
|
||||
|
||||
inline void bgc_fp32_vector3_multiply(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* multiplicand, const float multiplier)
|
||||
inline void bgc_fp32_vector3_multiply_by_real(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* multiplicand, const float multiplier)
|
||||
{
|
||||
product->x1 = multiplicand->x1 * multiplier;
|
||||
product->x2 = multiplicand->x2 * multiplier;
|
||||
product->x3 = multiplicand->x3 * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_vector3_multiply(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* multiplicand, const double multiplier)
|
||||
inline void bgc_fp64_vector3_multiply_by_real(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* multiplicand, const double multiplier)
|
||||
{
|
||||
product->x1 = multiplicand->x1 * multiplier;
|
||||
product->x2 = multiplicand->x2 * multiplier;
|
||||
product->x3 = multiplicand->x3 * multiplier;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_vector3_multiply_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_vector3_multiply_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix)
|
||||
{
|
||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
inline void bgc_fp32_vector3_multiply_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix)
|
||||
{
|
||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
const float x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_vector3_multiply_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix)
|
||||
{
|
||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
const double x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
||||
|
||||
product->x1 = x1;
|
||||
product->x2 = x2;
|
||||
product->x3 = x3;
|
||||
}
|
||||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline int bgc_fp32_vector3_divide(BGC_FP32_Vector3* quotient, const BGC_FP32_Vector3* dividend, const float divisor)
|
||||
inline int bgc_fp32_vector3_divide_by_real(BGC_FP32_Vector3* quotient, const BGC_FP32_Vector3* dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_vector3_multiply(quotient, dividend, 1.0f / divisor);
|
||||
bgc_fp32_vector3_multiply_by_real(quotient, dividend, 1.0f / divisor);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_vector3_divide(BGC_FP64_Vector3* quotient, const BGC_FP64_Vector3* dividend, const double divisor)
|
||||
inline int bgc_fp64_vector3_divide_by_real(BGC_FP64_Vector3* quotient, const BGC_FP64_Vector3* dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_vector3_multiply(quotient, dividend, 1.0 / divisor);
|
||||
bgc_fp64_vector3_multiply_by_real(quotient, dividend, 1.0 / divisor);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
|
@ -386,7 +413,7 @@ inline int bgc_fp32_vector3_get_normalized(BGC_FP32_Vector3* normalized, const B
|
|||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
bgc_fp32_vector3_multiply(normalized, vector, sqrtf(1.0f / square_modulus));
|
||||
bgc_fp32_vector3_multiply_by_real(normalized, vector, sqrtf(1.0f / square_modulus));
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -404,7 +431,7 @@ inline int bgc_fp64_vector3_get_normalized(BGC_FP64_Vector3* normalized, const B
|
|||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
bgc_fp64_vector3_multiply(normalized, vector, sqrt(1.0 / square_modulus));
|
||||
bgc_fp64_vector3_multiply_by_real(normalized, vector, sqrt(1.0 / square_modulus));
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue