реорганизация функций проекта, уменьшение дублирующегося кода
This commit is contained in:
parent
6c0ae92ed4
commit
07623b2aa6
10 changed files with 84 additions and 67 deletions
|
@ -68,11 +68,9 @@ inline void bgc_tangent_set_values_fp32(const float x1, const float x2, BgcTange
|
|||
twin->cos = x1;
|
||||
twin->sin = x2;
|
||||
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return;
|
||||
if (!bgc_is_sqare_value_unit_fp32(square_modulus)) {
|
||||
_bgc_tangent_normalize_fp32(square_modulus, twin);
|
||||
}
|
||||
|
||||
_bgc_tangent_normalize_fp32(square_modulus, twin);
|
||||
}
|
||||
|
||||
inline void bgc_tangent_set_values_fp64(const double x1, const double x2, BgcTangentFP64* tangent)
|
||||
|
@ -84,11 +82,9 @@ inline void bgc_tangent_set_values_fp64(const double x1, const double x2, BgcTan
|
|||
twin->cos = x1;
|
||||
twin->sin = x2;
|
||||
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
return;
|
||||
if (!bgc_is_sqare_value_unit_fp64(square_modulus)) {
|
||||
_bgc_tangent_normalize_fp64(square_modulus, twin);
|
||||
}
|
||||
|
||||
_bgc_tangent_normalize_fp64(square_modulus, twin);
|
||||
}
|
||||
|
||||
// ==================== Copy ==================== //
|
||||
|
@ -247,19 +243,19 @@ inline void bgc_tangent_make_reverse_matrix_fp64(const BgcTangentFP64* tangent,
|
|||
|
||||
inline float bgc_tangent_get_angle_fp32(const BgcTangentFP32* tangent, const BgcAngleUnitEnum unit)
|
||||
{
|
||||
if (tangent->cos >= 1.0f - BGC_TWO_EPSYLON_FP32) {
|
||||
if (tangent->cos >= 1.0f - BGC_EPSYLON_FP32) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (tangent->cos <= -1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
if (tangent->cos <= -1.0f + BGC_EPSYLON_FP32) {
|
||||
return bgc_angle_get_half_circle_fp32(unit);
|
||||
}
|
||||
|
||||
if (tangent->sin >= 1.0f - BGC_TWO_EPSYLON_FP32) {
|
||||
if (tangent->sin >= 1.0f - BGC_EPSYLON_FP32) {
|
||||
return bgc_angle_get_quater_circle_fp32(unit);
|
||||
}
|
||||
|
||||
if (tangent->sin <= -1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
if (tangent->sin <= -1.0f + BGC_EPSYLON_FP32) {
|
||||
return 0.75f * bgc_angle_get_full_circle_fp32(unit);
|
||||
}
|
||||
|
||||
|
@ -268,19 +264,19 @@ inline float bgc_tangent_get_angle_fp32(const BgcTangentFP32* tangent, const Bgc
|
|||
|
||||
inline double bgc_tangent_get_angle_fp64(const BgcTangentFP64* tangent, const BgcAngleUnitEnum unit)
|
||||
{
|
||||
if (tangent->cos >= 1.0 - BGC_TWO_EPSYLON_FP64) {
|
||||
if (tangent->cos >= 1.0 - BGC_EPSYLON_FP64) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (tangent->cos <= -1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
if (tangent->cos <= -1.0 + BGC_EPSYLON_FP64) {
|
||||
return bgc_angle_get_half_circle_fp64(unit);
|
||||
}
|
||||
|
||||
if (tangent->sin >= 1.0 - BGC_TWO_EPSYLON_FP64) {
|
||||
if (tangent->sin >= 1.0 - BGC_EPSYLON_FP64) {
|
||||
return bgc_angle_get_quater_circle_fp64(unit);
|
||||
}
|
||||
|
||||
if (tangent->sin <= -1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
if (tangent->sin <= -1.0 + BGC_EPSYLON_FP64) {
|
||||
return 0.75 * bgc_angle_get_full_circle_fp64(unit);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue