Добавление базисов как вспомогательной структуры
This commit is contained in:
parent
9d7011e81e
commit
e6a94ab8d9
9 changed files with 345 additions and 14 deletions
|
@ -176,7 +176,49 @@ inline void bgc_vector3_reverse_fp64(const BgcVector3FP64* vector, BgcVector3FP6
|
|||
|
||||
// ================= Normalize ================== //
|
||||
|
||||
inline int bgc_vector3_normalize_fp32(const BgcVector3FP32* vector, BgcVector3FP32* normalized)
|
||||
inline int bgc_vector3_normalize_fp32(BgcVector3FP32* vector)
|
||||
{
|
||||
const float square_modulus = bgc_vector3_get_square_modulus_fp32(vector);
|
||||
|
||||
if (bgc_is_sqare_unit_fp32(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const float multiplicand = sqrtf(1.0f / square_modulus);
|
||||
|
||||
vector->x1 *= multiplicand;
|
||||
vector->x2 *= multiplicand;
|
||||
vector->x3 *= multiplicand;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_normalize_fp64(BgcVector3FP64* vector)
|
||||
{
|
||||
const double square_modulus = bgc_vector3_get_square_modulus_fp64(vector);
|
||||
|
||||
if (bgc_is_sqare_unit_fp64(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const double multiplicand = sqrt(1.0 / square_modulus);
|
||||
|
||||
vector->x1 *= multiplicand;
|
||||
vector->x2 *= multiplicand;
|
||||
vector->x3 *= multiplicand;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_get_normalized_fp32(const BgcVector3FP32* vector, BgcVector3FP32* normalized)
|
||||
{
|
||||
const float square_modulus = bgc_vector3_get_square_modulus_fp32(vector);
|
||||
|
||||
|
@ -200,7 +242,7 @@ inline int bgc_vector3_normalize_fp32(const BgcVector3FP32* vector, BgcVector3FP
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_normalize_fp64(const BgcVector3FP64* vector, BgcVector3FP64* normalized)
|
||||
inline int bgc_vector3_get_normalized_fp64(const BgcVector3FP64* vector, BgcVector3FP64* normalized)
|
||||
{
|
||||
const double square_modulus = bgc_vector3_get_square_modulus_fp64(vector);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue