Реорганизация методов для версоров и тангентов
This commit is contained in:
parent
0027924f86
commit
e39765b733
5 changed files with 147 additions and 247 deletions
|
@ -55,54 +55,40 @@ inline void bgc_tangent_reset_fp64(BgcTangentFP64* tangent)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
void _bgc_tangent_normalize_fp32(const float square_modulus, _BgcDarkTwinTangentFP32* twin);
|
||||
|
||||
void _bgc_tangent_normalize_fp64(const double square_modulus, _BgcDarkTwinTangentFP64* twin);
|
||||
|
||||
inline void bgc_tangent_set_values_fp32(const float x1, const float x2, BgcTangentFP32* tangent)
|
||||
{
|
||||
const float square_module = x1 * x1 + x2 * x2;
|
||||
const float square_modulus = x1 * x1 + x2 * x2;
|
||||
|
||||
_BgcDarkTwinTangentFP32* twin = (_BgcDarkTwinTangentFP32*)tangent;
|
||||
|
||||
twin->cos = x1;
|
||||
twin->sin = x2;
|
||||
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_module && square_module <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (square_module <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
twin->cos = 1.0f;
|
||||
twin->sin = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
const float multiplier = sqrtf(1.0f / square_module);
|
||||
|
||||
twin->cos = x1 * multiplier;
|
||||
twin->sin = x2 * multiplier;
|
||||
_bgc_tangent_normalize_fp32(square_modulus, twin);
|
||||
}
|
||||
|
||||
inline void bgc_tangent_set_values_fp64(const double x1, const double x2, BgcTangentFP64* tangent)
|
||||
{
|
||||
const double square_module = x1 * x1 + x2 * x2;
|
||||
const double square_modulus = x1 * x1 + x2 * x2;
|
||||
|
||||
_BgcDarkTwinTangentFP64* twin = (_BgcDarkTwinTangentFP64*)tangent;
|
||||
|
||||
twin->cos = x1;
|
||||
twin->sin = x2;
|
||||
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_module && square_module <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (square_module <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
twin->cos = 1.0;
|
||||
twin->sin = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
const double multiplier = sqrt(1.0 / square_module);
|
||||
|
||||
twin->cos = x1 * multiplier;
|
||||
twin->sin = x2 * multiplier;
|
||||
_bgc_tangent_normalize_fp64(square_modulus, twin);
|
||||
}
|
||||
|
||||
// ==================== Copy ==================== //
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue