Переименование типов в соответствии со стилем POSIX, отказ от префикса bg_
This commit is contained in:
parent
d2a25823a5
commit
605afabd94
25 changed files with 1109 additions and 1035 deletions
|
|
@ -2,64 +2,64 @@
|
|||
|
||||
// =================== Angle ==================== //
|
||||
|
||||
float bg_fp32_vector3_get_angle(const BgFP32Vector3* vector1, const BgFP32Vector3* vector2, const angle_unit_t unit)
|
||||
float fp32_vector3_get_angle(const fp32_vector3_t* vector1, const fp32_vector3_t* vector2, const angle_unit_t unit)
|
||||
{
|
||||
if (vector1 == 0 || vector2 == 0) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
const float square_modulus1 = bg_fp32_vector3_get_square_modulus(vector1);
|
||||
const float square_modulus1 = fp32_vector3_get_square_modulus(vector1);
|
||||
|
||||
if (square_modulus1 <= BG_FP32_SQUARE_EPSYLON) {
|
||||
if (square_modulus1 <= FP32_SQUARE_EPSYLON) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
const float square_modulus2 = bg_fp32_vector3_get_square_modulus(vector2);
|
||||
const float square_modulus2 = fp32_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus2 <= BG_FP32_SQUARE_EPSYLON) {
|
||||
if (square_modulus2 <= FP32_SQUARE_EPSYLON) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
const float cosine = bg_fp32_vector3_scalar_product(vector1, vector2) / sqrtf(square_modulus1 * square_modulus2);
|
||||
const float cosine = fp32_vector3_scalar_product(vector1, vector2) / sqrtf(square_modulus1 * square_modulus2);
|
||||
|
||||
if (cosine >= 1.0f - BG_FP32_EPSYLON) {
|
||||
if (cosine >= 1.0f - FP32_EPSYLON) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (cosine <= -1.0f + BG_FP32_EPSYLON) {
|
||||
return bg_fp32_angle_get_half_circle(unit);
|
||||
if (cosine <= -1.0f + FP32_EPSYLON) {
|
||||
return fp32_angle_get_half_circle(unit);
|
||||
}
|
||||
|
||||
return bg_fp32_radians_to_units(acosf(cosine), unit);
|
||||
return fp32_radians_to_units(acosf(cosine), unit);
|
||||
}
|
||||
|
||||
double bg_fp64_vector3_get_angle(const BgFP64Vector3* vector1, const BgFP64Vector3* vector2, const angle_unit_t unit)
|
||||
double fp64_vector3_get_angle(const fp64_vector3_t* vector1, const fp64_vector3_t* vector2, const angle_unit_t unit)
|
||||
{
|
||||
if (vector1 == 0 || vector2 == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
const double square_modulus1 = bg_fp64_vector3_get_square_modulus(vector1);
|
||||
const double square_modulus1 = fp64_vector3_get_square_modulus(vector1);
|
||||
|
||||
if (square_modulus1 <= BG_FP64_SQUARE_EPSYLON) {
|
||||
if (square_modulus1 <= FP64_SQUARE_EPSYLON) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
const double square_modulus2 = bg_fp64_vector3_get_square_modulus(vector2);
|
||||
const double square_modulus2 = fp64_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus2 <= BG_FP64_SQUARE_EPSYLON) {
|
||||
if (square_modulus2 <= FP64_SQUARE_EPSYLON) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
const double cosine = bg_fp64_vector3_scalar_product(vector1, vector2) / sqrt(square_modulus1 * square_modulus2);
|
||||
const double cosine = fp64_vector3_scalar_product(vector1, vector2) / sqrt(square_modulus1 * square_modulus2);
|
||||
|
||||
if (cosine >= 1.0 - BG_FP64_EPSYLON) {
|
||||
if (cosine >= 1.0 - FP64_EPSYLON) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (cosine <= -1.0 + BG_FP64_EPSYLON) {
|
||||
return bg_fp64_angle_get_half_circle(unit);
|
||||
if (cosine <= -1.0 + FP64_EPSYLON) {
|
||||
return fp64_angle_get_half_circle(unit);
|
||||
}
|
||||
|
||||
return bg_fp64_radians_to_units(acos(cosine), unit);
|
||||
return fp64_radians_to_units(acos(cosine), unit);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue