Оптимизация под GNU C компилятор / Optimization for GNU C Compiller
This commit is contained in:
parent
e4d75824f3
commit
081f794eb1
10 changed files with 671 additions and 755 deletions
|
@ -1,41 +1,5 @@
|
|||
#include "vector2.h"
|
||||
|
||||
// =============== Normalization ================ //
|
||||
|
||||
int bg_fp32_vector2_normalize(BgFP32Vector2* vector)
|
||||
{
|
||||
const float square_modulus = bg_fp32_vector2_get_square_modulus(vector);
|
||||
|
||||
if (1.0f - BG_FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + BG_FP32_TWO_EPSYLON) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BG_FP32_SQUARE_EPSYLON) {
|
||||
bg_fp32_vector2_reset(vector);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bg_fp32_vector2_multiply(vector, sqrtf(1.0f / square_modulus), vector);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bg_fp64_vector2_normalize(BgFP64Vector2* vector)
|
||||
{
|
||||
const double square_modulus = bg_fp64_vector2_get_square_modulus(vector);
|
||||
|
||||
if (1.0 - BG_FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + BG_FP64_TWO_EPSYLON) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BG_FP64_SQUARE_EPSYLON) {
|
||||
bg_fp64_vector2_reset(vector);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bg_fp64_vector2_multiply(vector, sqrt(1.0 / square_modulus), vector);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// =================== Angle ==================== //
|
||||
|
||||
float bg_fp32_vector2_get_angle(const BgFP32Vector2* vector1, const BgFP32Vector2* vector2, const angle_unit_t unit)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue