|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Math constants and utility functions. More...
Functions | |
| float | toRadians (float degrees) |
| Converts degrees to radians. | |
| float | toDegrees (float radians) |
| Converts radians to degrees. | |
| glm::vec3 | toRadians (const glm::vec3 °rees) |
| Converts a vec3 of degrees to radians. | |
| glm::vec3 | toDegrees (const glm::vec3 &radians) |
| Converts a vec3 of radians to degrees. | |
| template<typename T> | |
| T | lerp (const T &a, const T &b, float t) |
| Linear interpolation between two values. | |
| template<typename T> | |
| T | clamp (const T &value, const T &min, const T &max) |
| Clamps a value between min and max. | |
| bool | approxEqual (float a, float b, float epsilon=EPSILON) |
| Checks if two floats are approximately equal. | |
| bool | approxEqual (const glm::vec3 &a, const glm::vec3 &b, float epsilon=EPSILON) |
| Checks if two vec3s are approximately equal. | |
| glm::mat4 | ortho (float left, float right, float bottom, float top, float nearPlane, float farPlane) |
| Creates an orthographic projection matrix. | |
| glm::mat4 | perspective (float fov, float aspect, float nearPlane, float farPlane) |
| Creates a perspective projection matrix. | |
| glm::mat4 | lookAt (const glm::vec3 &eye, const glm::vec3 ¢er, const glm::vec3 &up) |
| Creates a look-at view matrix. | |
| void | decompose (const glm::mat4 &matrix, glm::vec3 &position, glm::vec3 &rotation, glm::vec3 &scale) |
| Decomposes a transformation matrix into components (Euler angles). | |
| void | decompose (const glm::mat4 &matrix, glm::vec3 &position, glm::quat &rotation, glm::vec3 &scale) |
| Decomposes a transformation matrix into components (quaternion). | |
| glm::quat | eulerToQuat (const glm::vec3 &euler) |
| Converts Euler angles (radians) to quaternion. | |
| glm::vec3 | quatToEuler (const glm::quat &quat) |
| Converts quaternion to Euler angles (radians). | |
| glm::quat | eulerDegreesToQuat (const glm::vec3 °rees) |
| Converts Euler angles (degrees) to quaternion. | |
| glm::vec3 | quatToEulerDegrees (const glm::quat &quat) |
| Converts quaternion to Euler angles (degrees). | |
| glm::mat4 | compose (const glm::vec3 &position, const glm::quat &rotation, const glm::vec3 &scale) |
| Constructs a transformation matrix from TRS components. | |
| glm::mat4 | compose (const glm::vec3 &position, const glm::vec3 &rotation, const glm::vec3 &scale) |
| Constructs a transformation matrix from TRS components (Euler angles). | |
Variables | |
| constexpr float | PI = 3.14159265358979323846f |
| Pi constant. | |
| constexpr float | TWO_PI = 2.0f * PI |
| Two times pi (full circle in radians). | |
| constexpr float | HALF_PI = 0.5f * PI |
| Half pi (quarter circle in radians). | |
| constexpr float | DEG_TO_RAD = PI / 180.0f |
| Degrees to radians conversion factor. | |
| constexpr float | RAD_TO_DEG = 180.0f / PI |
| Radians to degrees conversion factor. | |
| constexpr float | EPSILON = 1e-6f |
| Small epsilon for floating-point comparisons. | |
Math constants and utility functions.
Provides common mathematical constants and helper functions for angles, interpolation, matrix operations, etc.
|
inline |
Checks if two vec3s are approximately equal.
| a | First vector |
| b | Second vector |
| epsilon | Maximum component difference threshold |
Definition at line 181 of file Math.hpp.
References approxEqual(), and EPSILON.
|
inline |
Checks if two floats are approximately equal.
| a | First value |
| b | Second value |
| epsilon | Maximum difference threshold |
Definition at line 170 of file Math.hpp.
References EPSILON.
Referenced by approxEqual().
|
inline |
|
inline |
Constructs a transformation matrix from TRS components.
| position | Translation |
| rotation | Rotation as quaternion |
| scale | Scale factors |
Definition at line 395 of file Math.hpp.
Referenced by esengine::ecs::copyFlatRenderMatrix().
|
inline |
|
inline |
Decomposes a transformation matrix into components (quaternion).
| matrix | The transformation matrix to decompose |
| position | Output: extracted position |
| rotation | Output: extracted rotation as quaternion |
| scale | Output: extracted scale factors |
Definition at line 288 of file Math.hpp.
References EPSILON.
|
inline |
Decomposes a transformation matrix into components (Euler angles).
| matrix | The transformation matrix to decompose |
| position | Output: extracted position |
| rotation | Output: extracted Euler angles (radians) |
| scale | Output: extracted scale factors |
Definition at line 248 of file Math.hpp.
References EPSILON.
Referenced by esengine::ecs::Transform::ensureDecomposed().
|
inline |
Converts Euler angles (degrees) to quaternion.
| degrees | Euler angles in degrees (pitch, yaw, roll / X, Y, Z) |
Definition at line 367 of file Math.hpp.
References toRadians().
|
inline |
Converts Euler angles (radians) to quaternion.
| euler | Euler angles in radians (pitch, yaw, roll / X, Y, Z) |
|
inline |
Linear interpolation between two values.
| T | Value type (float, vec2, vec3, vec4, etc.) |
| a | Start value |
| b | End value |
| t | Interpolation factor (0 = a, 1 = b) |
Definition at line 142 of file Math.hpp.
Referenced by esengine::particle::noise::perlin2(), esengine::particle::sampleColorLut(), and esengine::particle::sampleSizeLut().
|
inline |
|
inline |
Creates an orthographic projection matrix.
| left | Left boundary |
| right | Right boundary |
| bottom | Bottom boundary |
| top | Top boundary |
| near | Near plane distance |
| far | Far plane distance |
Definition at line 201 of file Math.hpp.
Referenced by esengine::renderer_renderMaterialPreview(), and esengine::renderer_renderMeshPreview().
|
inline |
|
inline |
Converts quaternion to Euler angles (radians).
| quat | The quaternion to convert |
|
inline |
Converts quaternion to Euler angles (degrees).
| quat | The quaternion to convert |
Definition at line 376 of file Math.hpp.
References toDegrees().
|
inline |
Converts a vec3 of radians to degrees.
| radians | Euler angles in radians |
Definition at line 120 of file Math.hpp.
References RAD_TO_DEG.
|
inline |
Converts radians to degrees.
| radians | Angle in radians |
Definition at line 102 of file Math.hpp.
References RAD_TO_DEG.
Referenced by quatToEulerDegrees().
|
inline |
Converts a vec3 of degrees to radians.
| degrees | Euler angles in degrees |
Definition at line 111 of file Math.hpp.
References DEG_TO_RAD.
|
inline |
Converts degrees to radians.
| degrees | Angle in degrees |
Definition at line 93 of file Math.hpp.
References DEG_TO_RAD.
Referenced by eulerDegreesToQuat().
|
constexpr |
Degrees to radians conversion factor.
Definition at line 76 of file Math.hpp.
Referenced by esengine::particle::sampleShape(), esengine::GpuParticles::submit(), toRadians(), and toRadians().
|
constexpr |
Small epsilon for floating-point comparisons.
Definition at line 82 of file Math.hpp.
Referenced by approxEqual(), approxEqual(), decompose(), and decompose().
|
constexpr |
Half pi (quarter circle in radians).
Definition at line 73 of file Math.hpp.
Referenced by esengine::particle::sampleShape().
|
constexpr |
Pi constant.
Definition at line 67 of file Math.hpp.
Referenced by esengine::particle::sampleShape().
|
constexpr |
Radians to degrees conversion factor.
Definition at line 79 of file Math.hpp.
Referenced by toDegrees(), and toDegrees().
|
constexpr |
Two times pi (full circle in radians).
Definition at line 70 of file Math.hpp.
Referenced by esengine::particle::coneDirection(), esengine::particle::noise::grad2(), and esengine::particle::sampleShape().