Nameless Engine
Loading...
Searching...
No Matches
ne::MathHelpers Class Reference

#include <MathHelpers.hpp>

Static Public Member Functions

static glm::vec3 convertNormalizedDirectionToRollPitchYaw (const glm::vec3 &direction)
 
static glm::vec3 convertRollPitchYawToDirection (const glm::vec3 &rotation)
 
static glm::vec3 convertSphericalToCartesianCoordinates (float radius, float theta, float phi)
 
static void convertCartesianCoordinatesToSpherical (const glm::vec3 &location, float &radius, float &theta, float &phi)
 
static glm::vec3 calculateReciprocalVector (const glm::vec3 &vector)
 
static glm::mat4x4 buildRotationMatrix (const glm::vec3 &rotation)
 
static float normalizeToRange (float value, float min, float max)
 
static glm::vec3 normalizeSafely (const glm::vec3 &vector)
 

Static Private Attributes

static const float smallFloatEpsilon = 0.0000001F
 

Detailed Description

Static helper functions for math.

Member Function Documentation

◆ buildRotationMatrix()

glm::mat4x4 ne::MathHelpers::buildRotationMatrix ( const glm::vec3 &  rotation)
inlinestatic

Builds a rotation matrix in the engine specific way.

Parameters
rotationRotation in degrees where X is roll, Y is pitch and Z is yaw.
Returns
Rotation matrix.

◆ calculateReciprocalVector()

glm::vec3 ne::MathHelpers::calculateReciprocalVector ( const glm::vec3 &  vector)
inlinestatic

Calculates 1 / vector while checking for zero division.

Parameters
vectorInput vector.
Returns
vector 1 / input vector.

◆ convertCartesianCoordinatesToSpherical()

void ne::MathHelpers::convertCartesianCoordinatesToSpherical ( const glm::vec3 &  location,
float &  radius,
float &  theta,
float &  phi 
)
inlinestatic

Converts coordinates from the Cartesian coordinate system to spherical coordinate system.

Parameters
locationLocation in Cartesian coordinate system.
radiusCalculated radius in spherical coordinate system.
thetaCalculated theta in spherical coordinate system (in degrees).
phiCalculated phi in spherical coordinate system (in degrees).

◆ convertNormalizedDirectionToRollPitchYaw()

glm::vec3 ne::MathHelpers::convertNormalizedDirectionToRollPitchYaw ( const glm::vec3 &  direction)
inlinestatic

Converts a direction to rotation angles.

Warning
Expects the specified direction to be normalized.
Parameters
directionNormalized direction to convert.
Returns
Roll (as X), pitch (as Y) and yaw (as Z) in degrees.

◆ convertRollPitchYawToDirection()

glm::vec3 ne::MathHelpers::convertRollPitchYawToDirection ( const glm::vec3 &  rotation)
inlinestatic

Converts rotation angles to a direction.

Parameters
rotationRotation roll (as X), pitch (as Y) and yaw (as Z) in degrees.
Returns
Unit direction vector.

◆ convertSphericalToCartesianCoordinates()

glm::vec3 ne::MathHelpers::convertSphericalToCartesianCoordinates ( float  radius,
float  theta,
float  phi 
)
inlinestatic

Converts coordinates from the spherical coordinate system to the Cartesian coordinate system.

Parameters
radiusRadial distance.
thetaAzimuthal angle (in degrees).
phiPolar angle (in degrees).
Returns
Coordinates in Cartesian coordinate system.

◆ normalizeSafely()

glm::vec3 ne::MathHelpers::normalizeSafely ( const glm::vec3 &  vector)
inlinestatic

Normalizes the specified vector while checking for zero division (to avoid NaNs in the normalized vector).

Parameters
vectorInput vector to normalize.
Returns
Normalized vector.

◆ normalizeToRange()

float ne::MathHelpers::normalizeToRange ( float  value,
float  min,
float  max 
)
inlinestatic

Changes the value to be in the range [min; max].

Example:

normalizeToRange(370.0F, -360.0F, 360.0F); // result is `-350`
normalizeToRange(-730, -360, 360); // result is `-10`
static float normalizeToRange(float value, float min, float max)
Definition: MathHelpers.hpp:229
Parameters
valueValue to normalize.
minMinimum value in range.
maxMaximum value in range.
Returns
Normalized value.

Member Data Documentation

◆ smallFloatEpsilon

const float ne::MathHelpers::smallFloatEpsilon = 0.0000001F
inlinestaticprivate

Default tolerance for floats to use.


The documentation for this class was generated from the following file: