Реорганизация проекта: перенос определения всех типов в один файл, перегруппировка функций в файлах
This commit is contained in:
parent
c7d9263154
commit
053af33444
45 changed files with 1001 additions and 980 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue