Реорганизация методов для версоров и тангентов
This commit is contained in:
parent
0027924f86
commit
e39765b733
5 changed files with 147 additions and 247 deletions
|
@ -3,3 +3,35 @@
|
|||
const BgcTangentFP32 BGC_IDLE_TANGENT_FP32 = { 1.0f, 0.0f };
|
||||
|
||||
const BgcTangentFP64 BGC_IDLE_TANGENT_FP64 = { 1.0, 0.0 };
|
||||
|
||||
void _bgc_tangent_normalize_fp32(const float square_modulus, _BgcDarkTwinTangentFP32* twin)
|
||||
{
|
||||
// (square_modulus != square_modulus) is true when square_modulus is NaN
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
|
||||
twin->cos = 1.0f;
|
||||
twin->sin = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
const float multiplier = sqrtf(1.0f / square_modulus);
|
||||
|
||||
twin->cos *= multiplier;
|
||||
twin->sin *= multiplier;
|
||||
}
|
||||
|
||||
void _bgc_tangent_normalize_fp64(const double square_modulus, _BgcDarkTwinTangentFP64* twin)
|
||||
{
|
||||
// (square_modulus != square_modulus) is true when square_modulus is NaN
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
|
||||
twin->cos = 1.0;
|
||||
twin->sin = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
const double multiplier = sqrt(1.0 / square_modulus);
|
||||
|
||||
twin->cos *= multiplier;
|
||||
twin->sin *= multiplier;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue