Raven Engine v0.1
Loading...
Searching...
No Matches
RangeReduction.inl File Reference

Namespaces

namespace  Crux
namespace  Crux::Detail

Macros

#define RV_FMA(a, b, c)
 Fused-multiply-add: computes (a * b + c) in one operation if supported.
#define RV_RoundToInt(x)
 Round float to nearest int (ties to even) without branches.
#define RV_USE_COS_FROM_QUAD(q)
 True if quadrant q (0-3) indicates we should compute cosine.
#define RV_NEGATE_FROM_QUAD(q)
 True if quadrant q (0-3) indicates the result should be negated.

Local constants for range reduction (float)

void Crux::Detail::ReduceAngle (float x, float &outXr, unsigned int &outQuad) noexcept
 Reduce angle into [-pi/4, pi/4] and extract quadrant.

Macro Definition Documentation

◆ RV_FMA

#define RV_FMA ( a,
b,
c )
Value:
((a) * (b) + (c))

Fused-multiply-add: computes (a * b + c) in one operation if supported.

Parameters
aFirst multiplicand.
bSecond multiplicand.
cAddend.

On MSVC with FMA support, maps to _mm_fmadd_ss; otherwise falls back to (a*b + c).

◆ RV_NEGATE_FROM_QUAD

#define RV_NEGATE_FROM_QUAD ( q)
Value:
(((q) & 2u) != 0u)

True if quadrant q (0-3) indicates the result should be negated.

Parameters
qQuadrant index from ReduceAngle.

◆ RV_RoundToInt

#define RV_RoundToInt ( x)
Value:
__builtin_rintf(x)

Round float to nearest int (ties to even) without branches.

Parameters
xValue to round.

MSVC uses _mm_round_ss + _mm_cvtss_si32; GCC/Clang use __builtin_rintf.

◆ RV_USE_COS_FROM_QUAD

#define RV_USE_COS_FROM_QUAD ( q)
Value:
(((q) & 1u) != 0u)

True if quadrant q (0-3) indicates we should compute cosine.

Parameters
qQuadrant index from ReduceAngle.