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