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