12#ifndef JAU_MATH_FLOAT_UTIL_HPP_
13#define JAU_MATH_FLOAT_UTIL_HPP_
47 return z * z / ( zNear * float( 1 << zBits ) - z );
64 constexpr int getZBufferValue(
int zBits,
float z,
float zNear,
float zFar)
noexcept {
65 const float a = zFar / ( zFar - zNear );
66 const float b = zFar * zNear / ( zNear - zFar );
67 return (
int) ( float(1<<zBits) * ( a + b / z ) );
74 constexpr float getOrthoWinZ(
float orthoZ,
float zNear,
float zFar)
noexcept {
75 return (1.0f/zNear-1.0f/orthoZ) / (1.0f/zNear-1.0f/zFar);
84 constexpr float half_pi = std::numbers::pi_v<float>/2.0f;
85 const float x_rot = std::abs(eulerRotation.x);
86 const float y_rot = std::abs(eulerRotation.y);
87 const float z_rot = std::abs(eulerRotation.z);
89 half_pi <= y_rot && y_rot <= 3*half_pi ? -1 : 1,
90 half_pi <= x_rot && x_rot <= 3*half_pi ? -1 : 1,
91 half_pi <= z_rot && z_rot <= 3*half_pi ? -1 : 1);
constexpr float getOrthoWinZ(float orthoZ, float zNear, float zFar) noexcept
Returns orthogonal distance (1f/zNear-1f/orthoZ) / (1f/zNear-1f/zFar);.
constexpr float getZBufferEpsilon(int zBits, float z, float zNear) noexcept
Returns resolution of Z buffer of given parameter, see Love Your Z-Buffer.
constexpr jau::math::Vec3f getEulerAngleOrientation(const jau::math::Vec3f &eulerRotation) noexcept
Returns an orientation vector for given eurler X/Y/Z angles in radians.
constexpr int getZBufferValue(int zBits, float z, float zNear, float zFar) noexcept
Returns Z buffer value of given parameter, see Love Your Z-Buffer.