Loading...
Searching...
No Matches
Math Namespace Reference

Namespace for (new) math code. More...

## Classes

struct | half
| half-precision floating point type More...
struct | IntPoint
| 2D Point with integer coords More...
struct | Matrix
| 4x4 matrix More...
struct | Point
| 2D point More...
struct | Sphere
struct | Vector
| 3D (3x1) vector More...

## Functions

bool | IsEqual (float a, float b, float tolerance=Math::TOLERANCE)
| Compares a and b within tolerance.
bool | IsZero (float a, float tolerance=Math::TOLERANCE)
| Compares a to zero within tolerance.
float | Min (float a, float b)
| Minimum.
float | Min (float a, float b, float c)
float | Min (float a, float b, float c, float d)
float | Min (float a, float b, float c, float d, float e)
float | Max (float a, float b)
| Maximum.
float | Max (float a, float b, float c)
float | Max (float a, float b, float c, float d)
float | Max (float a, float b, float c, float d, float e)
template<typename T>
T | Clamp (T value, T min, T max)
| Clamps the value to a range specified by min and max.
float | Norm (float a)
| Returns the normalized value (0 .. 1).
void | Swap (int &a, int &b)
| Swaps two integers.
void | Swap (float &a, float &b)
| Swaps two real numbers.
float | Mod (float a, float m)
| Returns the modulo of a floating point number.
float | Rand ()
| Returns a random value between 0 and 1.
bool | IsPowerOfTwo (unsigned int x)
| Returns whether x is an even power of 2.
int | NextPowerOfTwo (int x)
| Returns the next nearest power of two to x.
float | NormAngle (float angle)
| Returns a normalized angle, that is in other words between 0 and 2 * PI.
bool | TestAngle (float angle, float min, float max)
| Test if a angle is between two terminals.
float | PropAngle (float a, float b, float p)
| Calculates a value (radians) proportional between a and b (degrees).
float | Direction (float a, float g)
| Calculates the angle to rotate the angle a to the angle g.
float | Neutral (float value, float dead)
| Managing the dead zone of a joystick.
float | Smooth (float actual, float hope, float time)
| Gently advances a desired value from its current value.
float | Bounce (float progress, float middle=0.3f, float bounce=0.4f)
| Bounces any movement.
float | MidPoint (const Math::Point &a, const Math::Point &b, float px)
| Returns py up on the line a - b.
bool | IsInsideTriangle (Math::Point a, Math::Point b, Math::Point c, Math::Point p)
| Tests whether the point p is inside the triangle (a,b,c).
Math::Point | RotatePoint (const Math::Point &center, float angle, const Math::Point &p)
| Rotates a point around a center.
Math::Point | RotatePoint (float angle, const Math::Point &p)
| Rotates a point around the origin (0,0).
Math::Point | RotatePoint (float angle, float dist)
| Rotates a vector (dist, 0).
void | RotatePoint (float cx, float cy, float angle, float &px, float &py)
| Rotates a point around a center on 2D plane.
void | RotatePoint (const Math::Vector &center, float angleH, float angleV, Math::Vector &p)
| Rotates a point around a center in space.
void | RotatePoint2 (const Math::Vector center, float angleH, float angleV, Math::Vector &p)
| Rotates a point around a center in space.
float | RotateAngle (float x, float y)
| Returns the angle between point (x,y) and (0,0).
float | RotateAngle (const Math::Point &center, const Math::Point &p1, const Math::Point &p2)
| Calculates the angle between two points and a center.
void | LoadViewMatrix (Math::Matrix &mat, const Math::Vector &from, const Math::Vector &at, const Math::Vector &worldUp)
| Loads view matrix from the given vectors.
void | LoadProjectionMatrix (Math::Matrix &mat, float fov=Math::PI/2.0f, float aspect=1.0f, float nearPlane=1.0f, float farPlane=1000.0f)
| Loads a perspective projection matrix.
void | LoadOrthoProjectionMatrix (Math::Matrix &mat, float left, float right, float bottom, float top, float zNear=-1.0f, float zFar=1.0f)
| Loads an othogonal projection matrix.
void | LoadTranslationMatrix (Math::Matrix &mat, const Math::Vector &trans)
| Loads a translation matrix from given vector.
void | LoadScaleMatrix (Math::Matrix &mat, const Math::Vector &scale)
| Loads a scaling matrix fom given vector.
void | LoadRotationXMatrix (Math::Matrix &mat, float angle)
| Loads a rotation matrix along the X axis.
void | LoadRotationYMatrix (Math::Matrix &mat, float angle)
| Loads a rotation matrix along the Y axis.
void | LoadRotationZMatrix (Math::Matrix &mat, float angle)
| Loads a rotation matrix along the Z axis.
void | LoadRotationMatrix (Math::Matrix &mat, const Math::Vector &dir, float angle)
| Loads a rotation matrix along the given axis.
void | LoadRotationXZYMatrix (Math::Matrix &mat, const Math::Vector &angles)
| Calculates the matrix to make three rotations in the order X, Z and Y.
void | LoadRotationZXYMatrix (Math::Matrix &mat, const Math::Vector &angles)
| Calculates the matrix to make three rotations in the order Z, X and Y.
float | DistanceProjected (const Math::Vector &a, const Math::Vector &b)
| Returns the distance between projections on XZ plane of two vectors.
Math::Vector | NormalToPlane (const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3)
| Returns the normal vector to a plane.
Math::Vector | SegmentPoint (const Math::Vector &p1, const Math::Vector &p2, float dist)
| Returns a point on the line p1 - p2, in dist distance from p1.
float | DistanceToPlane (const Math::Vector &a, const Math::Vector &b, const Math::Vector &c, const Math::Vector &p)
| Returns the distance between given point and a plane.
bool | IsSamePlane (const Math::Vector(&plane1)[3], const Math::Vector(&plane2)[3])
| Checks if two planes defined by three points are the same.
bool | Intersect (const Math::Vector &a, const Math::Vector &b, const Math::Vector &c, const Math::Vector &d, const Math::Vector &e, Math::Vector &i)
| Calculates the intersection "i" right "of" the plane "abc" (TODO: ?).
bool | IntersectY (const Math::Vector &a, const Math::Vector &b, const Math::Vector &c, Math::Vector &p)
| Calculates the intersection of the straight line passing through p (x, z).
Math::Vector | LookatPoint (const Math::Vector &eye, float angleH, float angleV, float length)
| Calculates the end point.
Math::Vector | Transform (const Math::Matrix &m, const Math::Vector &p)
| Transforms the point p by matrix m.
Math::Vector | Projection (const Math::Vector &a, const Math::Vector &b, const Math::Vector &p)
| Calculates the projection of the point p on a straight line a to b.
Math::Vector | RotateView (Math::Vector center, float angleH, float angleV, float dist)
| Calculates point of view to look at a center two angles and a distance.
uint16_t | FloatToHalf (float value)
| Converts float to half-float.
float | HaltToFloat (uint16_t value)
| Converts half-float to float.
bool | MatricesEqual (const Matrix &m1, const Matrix &m2, float tolerance=TOLERANCE)
| Checks if two matrices are equal within given tolerance.
Math::Matrix | Transpose (const Math::Matrix &m)
| Convenience function for getting transposed matrix.
Math::Matrix | MultiplyMatrices (const Math::Matrix &left, const Math::Matrix &right)
| Convenience function for multiplying a matrix.
Math::Vector | MatrixVectorMultiply (const Math::Matrix &m, const Math::Vector &v, bool wDivide=false)
| Calculates the result of multiplying m * v.
bool | PointsEqual (const Point &a, const Point &b, float tolerance=TOLERANCE)
| Checks if two vectors are equal within given tolerance.
void | Swap (Point &a, Point &b)
| Permutes two points.
float | Distance (const Point &a, const Point &b)
| Returns the distance between two points.
float | DistanceToSphere (const Vector &point, const Sphere &sphere)
| Compute distance between given point and sphere.
float | DistanceBetweenSpheres (const Sphere &sphere1, const Sphere &sphere2)
Sphere | BoundingSphereForBox (Vector mins, Vector maxs)
bool | VectorsEqual (const Math::Vector &a, const Math::Vector &b, float tolerance=TOLERANCE)
| Checks if two vectors are equal within given tolerance.
Vector | Normalize (const Math::Vector &v)
| Convenience function for getting normalized vector.
float | DotProduct (const Math::Vector &left, const Math::Vector &right)
| Convenience function for calculating dot product.
Vector | CrossProduct (const Math::Vector &left, const Math::Vector &right)
| Convenience function for calculating cross product.
float | Angle (const Math::Vector &a, const Math::Vector &b)
| Convenience function for calculating angle (in radians) between two vectors.
float | Distance (const Math::Vector &a, const Math::Vector &b)
| Returns the distance between the ends of two vectors.
float | DistanceSquared (const Math::Vector &a, const Math::Vector &b)
| Returns the squared distance between the ends of two vectors.
Vector | Clamp (const Vector &vec, const Vector &min, const Vector &max)
| Clamps the vector vec to range between min and max.

## Variables

const float | TOLERANCE = 1e-6f
| Tolerance level – minimum accepted float value.
const float | VERY_SMALL_NUM = 1e-6f
| Very small number (used in testing/returning some values).
const float | VERY_BIG_NUM = 1e6f
| Very big number (used in testing/returning some values).
const float | HUGE_NUM = 1.0e+38f
| Huge number.
const float | PI = 3.14159265358979323846f
| PI.
const float | DEG_TO_RAD = 0.01745329251994329547f
| Degrees to radians multiplier.
const float | RAD_TO_DEG = 57.29577951308232286465f
| Radians to degrees multiplier.
const float | LOG_2 = log(2.0f)
| Natural logarithm of 2.

## Detailed Description

Namespace for (new) math code.

This namespace was created to avoid clashing with old code, but now it still serves, defining a border between math and non-math-related code.

## Function Documentation

## IsEqual()

bool Math::IsEqual | ( | float | a,
|  | float | b,
|  | float | tolerance = Math::TOLERANCE )

inline

Compares a and b within tolerance.

## IsZero()

bool Math::IsZero | ( | float | a,
|  | float | tolerance = Math::TOLERANCE )

inline

Compares a to zero within tolerance.

## Min()

float Math::Min | ( | float | a,
|  | float | b )

inline

Minimum.

## Max()

float Math::Max | ( | float | a,
|  | float | b )

inline

Maximum.

## Clamp() [1/2]

template<typename T>

T Math::Clamp | ( | T | value,
|  | T | min,
|  | T | max )

inline

Clamps the value to a range specified by min and max.

## Norm()

float Math::Norm | ( | float | a | ) |

inline

Returns the normalized value (0 .. 1).

## Swap() [1/3]

void Math::Swap | ( | int & | a,
|  | int & | b )

inline

Swaps two integers.

## Swap() [2/3]

void Math::Swap | ( | float & | a,
|  | float & | b )

inline

Swaps two real numbers.

## Mod()

float Math::Mod | ( | float | a,
|  | float | m )

inline

Returns the modulo of a floating point number.

Mod(8.1, 4) = 0.1 Mod(n, 1) = fractional part of n

## Rand()

float Math::Rand | ( |  | ) |

inline

Returns a random value between 0 and 1.

## IsPowerOfTwo()

bool Math::IsPowerOfTwo | ( | unsigned int | x | ) |

inline

Returns whether x is an even power of 2.

## NextPowerOfTwo()

int Math::NextPowerOfTwo | ( | int | x | ) |

inline

Returns the next nearest power of two to x.

## NormAngle()

float Math::NormAngle | ( | float | angle | ) |

inline

Returns a normalized angle, that is in other words between 0 and 2 * PI.

## TestAngle()

bool Math::TestAngle | ( | float | angle,
|  | float | min,
|  | float | max )

inline

Test if a angle is between two terminals.

## PropAngle()

float Math::PropAngle | ( | float | a,
|  | float | b,
|  | float | p )

inline

Calculates a value (radians) proportional between a and b (degrees).

## Direction()

float Math::Direction | ( | float | a,
|  | float | g )

inline

Calculates the angle to rotate the angle a to the angle g.

A positive angle is counterclockwise (CCW).

## Neutral()

float Math::Neutral | ( | float | value,
|  | float | dead )

inline

Managing the dead zone of a joystick.

    in:   -1            0            1
    --|-------|----o----|-------|-->
                 <---->
                  dead
    out:  -1       0         0       1

## Smooth()

float Math::Smooth | ( | float | actual,
|  | float | hope,
|  | float | time )

inline

Gently advances a desired value from its current value.

Over time, the progression is more rapid.

## Bounce()

float Math::Bounce | ( | float | progress,
|  | float | middle = 0.3f,
|  | float | bounce = 0.4f )

inline

Bounces any movement.

    out
     |
    1+------o-------o---
     |    o | o   o |  | bounce
     |   o  |   o---|---
     |  o   |       |
     | o    |       |
    -o------|-------+----> progress
    0|      |       1
     |<---->|middle

## MidPoint()

float Math::MidPoint | ( | const Math::Point & | a,
|  | const Math::Point & | b,
|  | float | px )

inline

Returns py up on the line a - b.

## IsInsideTriangle()

bool Math::IsInsideTriangle | ( | Math::Point | a,
|  | Math::Point | b,
|  | Math::Point | c,
|  | Math::Point | p )

inline

Tests whether the point p is inside the triangle (a,b,c).

## RotatePoint() [1/5]

Math::Point Math::RotatePoint | ( | const Math::Point & | center,
|  | float | angle,
|  | const Math::Point & | p )

inline

Rotates a point around a center.

Parameters

  center | center of rotation
  angle | angle [radians] (positive is CCW)
  p | the point to be rotated

## RotatePoint() [2/5]

Math::Point Math::RotatePoint | ( | float | angle,
|  | const Math::Point & | p )

inline

Rotates a point around the origin (0,0).

Parameters

  angle | angle [radians] (positive is CCW)
  p | the point to be rotated

## RotatePoint() [3/5]

Math::Point Math::RotatePoint | ( | float | angle,
|  | float | dist )

inline

Rotates a vector (dist, 0).

Parameters

  angle | angle [radians] (positive is CCW)
  dist | distance to origin

## RotatePoint() [4/5]

void Math::RotatePoint | ( | float | cx,
|  | float | cy,
|  | float | angle,
|  | float & | px,
|  | float & | py )

inline

Rotates a point around a center on 2D plane.

Parameters

  cx,cy | center of rotation
  angle | angle of rotation [radians] (positive is CCW)
  px,py | point coordinates to rotate

## RotatePoint() [5/5]

void Math::RotatePoint | ( | const Math::Vector & | center,
|  | float | angleH,
|  | float | angleV,
|  | Math::Vector & | p )

inline

Rotates a point around a center in space.

angleH is rotation along Y axis (heading) while angleV is rotation along X axis (TODO: ?).

Parameters

  center | center of rotation
  angleH,angleV | rotation angles [radians] (positive is CCW)
  p | the point to be rotated

## RotatePoint2()

void Math::RotatePoint2 | ( | const Math::Vector | center,
|  | float | angleH,
|  | float | angleV,
|  | Math::Vector & | p )

inline

Rotates a point around a center in space.

The rotation is performed first along Y axis (angleH) and then along X axis (angleV).

Parameters

  center | center of rotation
  angleH,angleV | rotation angles [radians] (positive is CCW)
  p | the point to be rotated

## RotateAngle() [1/2]

float Math::RotateAngle | ( | float | x,
|  | float | y )

inline

Returns the angle between point (x,y) and (0,0).

## RotateAngle() [2/2]

float Math::RotateAngle | ( | const Math::Point & | center,
|  | const Math::Point & | p1,
|  | const Math::Point & | p2 )

inline

Calculates the angle between two points and a center.

Parameters

  center | the center point
  p1,p2 | the two points

Returns
  the angle [radians] (positive is CCW)

## LoadViewMatrix()

void Math::LoadViewMatrix | ( | Math::Matrix & | mat,
|  | const Math::Vector & | from,
|  | const Math::Vector & | at,
|  | const Math::Vector & | worldUp )

inline

Loads view matrix from the given vectors.

Parameters

  mat | result matrix
  from | origin
  at | view direction
  worldUp | up vector

## LoadProjectionMatrix()

void Math::LoadProjectionMatrix | ( | Math::Matrix & | mat,
|  | float | fov = Math::PI / 2.0f,
|  | float | aspect = 1.0f,
|  | float | nearPlane = 1.0f,
|  | float | farPlane = 1000.0f )

inline

Loads a perspective projection matrix.

Parameters

  mat | result matrix
  fov | field of view in radians
  aspect | aspect ratio (width / height)
  nearPlane | distance to near cut plane
  farPlane | distance to far cut plane

## LoadOrthoProjectionMatrix()

void Math::LoadOrthoProjectionMatrix | ( | Math::Matrix & | mat,
|  | float | left,
|  | float | right,
|  | float | bottom,
|  | float | top,
|  | float | zNear = -1.0f,
|  | float | zFar = 1.0f )

inline

Loads an othogonal projection matrix.

Parameters

  mat | result matrix
  left,right | coordinates for left and right vertical clipping planes
  bottom,top | coordinates for bottom and top horizontal clipping planes
  zNear,zFar | distance to nearer and farther depth clipping planes

## LoadTranslationMatrix()

void Math::LoadTranslationMatrix | ( | Math::Matrix & | mat,
|  | const Math::Vector & | trans )

inline

Loads a translation matrix from given vector.

Parameters

  mat | result matrix
  trans | vector of translation

## LoadScaleMatrix()

void Math::LoadScaleMatrix | ( | Math::Matrix & | mat,
|  | const Math::Vector & | scale )

inline

Loads a scaling matrix fom given vector.

Parameters

  mat | result matrix
  scale | vector with scaling factors for X, Y, Z

## LoadRotationXMatrix()

void Math::LoadRotationXMatrix | ( | Math::Matrix & | mat,
|  | float | angle )

inline

Loads a rotation matrix along the X axis.

Parameters

  mat | result matrix
  angle | angle [radians]

## LoadRotationYMatrix()

void Math::LoadRotationYMatrix | ( | Math::Matrix & | mat,
|  | float | angle )

inline

Loads a rotation matrix along the Y axis.

Parameters

  mat | result matrix
  angle | angle [radians]

## LoadRotationZMatrix()

void Math::LoadRotationZMatrix | ( | Math::Matrix & | mat,
|  | float | angle )

inline

Loads a rotation matrix along the Z axis.

Parameters

  mat | result matrix
  angle | angle [radians]

## LoadRotationMatrix()

void Math::LoadRotationMatrix | ( | Math::Matrix & | mat,
|  | const Math::Vector & | dir,
|  | float | angle )

inline

Loads a rotation matrix along the given axis.

Parameters

  mat | result matrix
  dir | axis of rotation
  angle | angle [radians]

## LoadRotationXZYMatrix()

void Math::LoadRotationXZYMatrix | ( | Math::Matrix & | mat,
|  | const Math::Vector & | angles )

inline

Calculates the matrix to make three rotations in the order X, Z and Y.

## LoadRotationZXYMatrix()

void Math::LoadRotationZXYMatrix | ( | Math::Matrix & | mat,
|  | const Math::Vector & | angles )

inline

Calculates the matrix to make three rotations in the order Z, X and Y.

## DistanceProjected()

float Math::DistanceProjected | ( | const Math::Vector & | a,
|  | const Math::Vector & | b )

inline

Returns the distance between projections on XZ plane of two vectors.

## NormalToPlane()

Math::Vector Math::NormalToPlane | ( | const Math::Vector & | p1,
|  | const Math::Vector & | p2,
|  | const Math::Vector & | p3 )

inline

Returns the normal vector to a plane.

Parameters

  p1,p2,p3 | points defining the plane

## SegmentPoint()

Math::Vector Math::SegmentPoint | ( | const Math::Vector & | p1,
|  | const Math::Vector & | p2,
|  | float | dist )

inline

Returns a point on the line p1 - p2, in dist distance from p1.

Parameters

  p1,p2 | line start and end
  dist | scaling factor from p1, relative to distance between p1 and p2

## DistanceToPlane()

float Math::DistanceToPlane | ( | const Math::Vector & | a,
|  | const Math::Vector & | b,
|  | const Math::Vector & | c,
|  | const Math::Vector & | p )

inline

Returns the distance between given point and a plane.

Parameters

  p | the point
  a,b,c | points defining the plane

## IsSamePlane()

bool Math::IsSamePlane | ( | const Math::Vector(&) | plane1[3],
|  | const Math::Vector(&) | plane2[3] )

inline

Checks if two planes defined by three points are the same.

Parameters

  plane1 | array of three vectors defining the first plane
  plane2 | array of three vectors defining the second plane

## Intersect()

bool Math::Intersect | ( | const Math::Vector & | a,
|  | const Math::Vector & | b,
|  | const Math::Vector & | c,
|  | const Math::Vector & | d,
|  | const Math::Vector & | e,
|  | Math::Vector & | i )

inline

Calculates the intersection "i" right "of" the plane "abc" (TODO: ?).

## IntersectY()

bool Math::IntersectY | ( | const Math::Vector & | a,
|  | const Math::Vector & | b,
|  | const Math::Vector & | c,
|  | Math::Vector & | p )

inline

Calculates the intersection of the straight line passing through p (x, z).

Line is parallel to the y axis, with the plane abc. Returns p.y. (TODO: ?)

## LookatPoint()

Math::Vector Math::LookatPoint | ( | const Math::Vector & | eye,
|  | float | angleH,
|  | float | angleV,
|  | float | length )

inline

Calculates the end point.

## Transform()

Math::Vector Math::Transform | ( | const Math::Matrix & | m,
|  | const Math::Vector & | p )

inline

Transforms the point p by matrix m.

Is equal to multiplying the matrix by the vector (of course without perspective divide).

## Projection()

Math::Vector Math::Projection | ( | const Math::Vector & | a,
|  | const Math::Vector & | b,
|  | const Math::Vector & | p )

inline

Calculates the projection of the point p on a straight line a to b.

Parameters

  p | point to project
  a,b | two ends of the line

## RotateView()

Math::Vector Math::RotateView | ( | Math::Vector | center,
|  | float | angleH,
|  | float | angleV,
|  | float | dist )

inline

Calculates point of view to look at a center two angles and a distance.

## FloatToHalf()

uint16_t Math::FloatToHalf | ( | float | value | ) |

Converts float to half-float.

Converts float to half-float binary representation.

## HaltToFloat()

float Math::HaltToFloat | ( | uint16_t | value | ) |

Converts half-float to float.

Converts half-float binary representation to float.

## MatricesEqual()

bool Math::MatricesEqual | ( | const Matrix & | m1,
|  | const Matrix & | m2,
|  | float | tolerance = TOLERANCE )

inline

Checks if two matrices are equal within given tolerance.

## Transpose()

Math::Matrix Math::Transpose | ( | const Math::Matrix & | m | ) |

inline

Convenience function for getting transposed matrix.

## MultiplyMatrices()

Math::Matrix Math::MultiplyMatrices | ( | const Math::Matrix & | left,
|  | const Math::Matrix & | right )

inline

Convenience function for multiplying a matrix.

left left-hand matrix right right-hand matrix

Returns
  multiplied matrices

## MatrixVectorMultiply()

Math::Vector Math::MatrixVectorMultiply | ( | const Math::Matrix & | m,
|  | const Math::Vector & | v,
|  | bool | wDivide = false )

inline

Calculates the result of multiplying m * v.

The multiplication is performed thus:

    [  m.m[0 ] m.m[4 ] m.m[8 ] m.m[12]  ]   [ v.x ]
    [  m.m[1 ] m.m[5 ] m.m[9 ] m.m[13]  ]   [ v.y ]
    [  m.m[2 ] m.m[6 ] m.m[10] m.m[14]  ] * [ v.z ]
    [  m.m[3 ] m.m[7 ] m.m[11] m.m[15]  ]   [  1  ]

The result, a 4x1 vector is then converted to 3x1 by dividing x,y,z coords by the fourth coord (w).

## PointsEqual()

bool Math::PointsEqual | ( | const Point & | a,
|  | const Point & | b,
|  | float | tolerance = TOLERANCE )

inline

Checks if two vectors are equal within given tolerance.

## Swap() [3/3]

void Math::Swap | ( | Point & | a,
|  | Point & | b )

inline

Permutes two points.

## Distance() [1/2]

float Math::Distance | ( | const Point & | a,
|  | const Point & | b )

inline

Returns the distance between two points.

## DistanceToSphere()

float Math::DistanceToSphere | ( | const Vector & | point,
|  | const Sphere & | sphere )

inline

Compute distance between given point and sphere.

## VectorsEqual()

bool Math::VectorsEqual | ( | const Math::Vector & | a,
|  | const Math::Vector & | b,
|  | float | tolerance = TOLERANCE )

inline

Checks if two vectors are equal within given tolerance.

## Normalize()

Vector Math::Normalize | ( | const Math::Vector & | v | ) |

inline

Convenience function for getting normalized vector.

## DotProduct()

float Math::DotProduct | ( | const Math::Vector & | left,
|  | const Math::Vector & | right )

inline

Convenience function for calculating dot product.

## CrossProduct()

Vector Math::CrossProduct | ( | const Math::Vector & | left,
|  | const Math::Vector & | right )

inline

Convenience function for calculating cross product.

## Angle()

float Math::Angle | ( | const Math::Vector & | a,
|  | const Math::Vector & | b )

inline

Convenience function for calculating angle (in radians) between two vectors.

## Distance() [2/2]

float Math::Distance | ( | const Math::Vector & | a,
|  | const Math::Vector & | b )

inline

Returns the distance between the ends of two vectors.

## DistanceSquared()

float Math::DistanceSquared | ( | const Math::Vector & | a,
|  | const Math::Vector & | b )

inline

Returns the squared distance between the ends of two vectors.

## Clamp() [2/2]

Vector Math::Clamp | ( | const Vector & | vec,
|  | const Vector & | min,
|  | const Vector & | max )

inline

Clamps the vector vec to range between min and max.

## Variable Documentation

## TOLERANCE

const float Math::TOLERANCE = 1e-6f

Tolerance level – minimum accepted float value.

## VERY_SMALL_NUM

const float Math::VERY_SMALL_NUM = 1e-6f

Very small number (used in testing/returning some values).

## VERY_BIG_NUM

const float Math::VERY_BIG_NUM = 1e6f

Very big number (used in testing/returning some values).

## HUGE_NUM

const float Math::HUGE_NUM = 1.0e+38f

Huge number.

## PI

const float Math::PI = 3.14159265358979323846f

PI.

## DEG_TO_RAD

const float Math::DEG_TO_RAD = 0.01745329251994329547f

Degrees to radians multiplier.

## RAD_TO_DEG

const float Math::RAD_TO_DEG = 57.29577951308232286465f

Radians to degrees multiplier.

## LOG_2

const float Math::LOG_2 = log(2.0f)

Natural logarithm of 2.