MathFu
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Friends Groups Pages
mathfu Namespace Reference

Namespace for MathFu library. More...

Classes

class  Vector< T, 2 >
 
struct  VectorPacked< T, 2 >
 
class  Vector< T, 3 >
 
struct  VectorPacked< T, 3 >
 
class  Vector< T, 4 >
 
struct  VectorPacked< T, 4 >
 
class  Vector< float, 4 >
 
class  Matrix
 Matrix stores a set of "rows" by "columns" elements of type T and provides functions that operate on the set of elements. More...
 
class  Constants< float >
 Functions that return constants for float values. More...
 
class  Constants< double >
 Functions that return constants for double values. More...
 
class  Quaternion
 Stores a Quaternion of type T and provides a set of utility operations on each Quaternion. More...
 
class  Rect
 Rect of type T containing position (pos) and width. More...
 
class  simd_allocator
 SIMD-safe memory allocator, for use with STL types like std::vector. More...
 
class  Vector
 Vector of d elements with type T. More...
 
class  VectorPacked
 Packed N-dimensional vector. More...
 

Typedefs

typedef Vector< float, 2 > vec2
 2-dimensional float Vector.
 
typedef Vector< float, 3 > vec3
 3-dimensional float Vector.
 
typedef Vector< float, 4 > vec4
 4-dimensional float Vector.
 
typedef Vector< int, 2 > vec2i
 2-dimensional int Vector.
 
typedef Vector< int, 3 > vec3i
 3-dimensional int Vector.
 
typedef Vector< int, 4 > vec4i
 4-dimensional int Vector.
 
typedef Matrix< float, 2, 2 > mat2
 2x2 float Matrix.
 
typedef Matrix< float, 3, 3 > mat3
 3x3 float Matrix.
 
typedef Matrix< float, 4, 4 > mat4
 3x3 float Matrix.
 
typedef VectorPacked< float, 2 > vec2_packed
 2-dimensional float packed Vector (VectorPacked).
 
typedef VectorPacked< float, 3 > vec3_packed
 3-dimensional float packed Vector (VectorPacked).
 
typedef VectorPacked< float, 4 > vec4_packed
 4-dimensional float packed Vector (VectorPacked).
 
typedef VectorPacked< int, 2 > vec2i_packed
 2-dimensional int packed Vector (VectorPacked).
 
typedef VectorPacked< int, 3 > vec3i_packed
 3-dimensional int packed Vector (VectorPacked).
 
typedef VectorPacked< int, 4 > vec4i_packed
 4-dimensional int packed Vector (VectorPacked).
 
typedef mathfu::Quaternion< float > quat
 
typedef Rect< float > rectf
 Rect composed of type float.
 
typedef Rect< double > rectd
 Rect composed of type double.
 
typedef Rect< int > recti
 Rect composed of type int.
 
typedef Matrix< float, 4, 3 > AffineTransform
 A typedef representing a 4x3 float affine transformation. Since the last row ('w' row) of an affine transformation is fixed, this data type only includes the variable information for the transform.
 

Functions

static const Vector< float, 2 > kZeros2f (0.0f, 0.0f)
 2-dimensional float Vector of zeros.
 
static const Vector< float, 2 > kOnes2f (1.0f, 1.0f)
 2-dimensional float Vector of ones.
 
static const Vector< float, 2 > kAxisX2f (1.0f, 0.0f)
 2-dimensional float unit Vector pointing along the X axis.
 
static const Vector< float, 2 > kAxisY2f (0.0f, 1.0f)
 2-dimensional float unit Vector pointing along the Y axis.
 
static const Vector< float, 3 > kZeros3f (0.0f, 0.0f, 0.0f)
 3-dimensional float Vector of zeros.
 
static const Vector< float, 3 > kOnes3f (1.0f, 1.0f, 1.0f)
 3-dimensional float Vector of ones.
 
static const Vector< float, 3 > kAxisX3f (1.0f, 0.0f, 0.0f)
 3-dimensional float unit Vector pointing along the X axis.
 
static const Vector< float, 3 > kAxisY3f (0.0f, 1.0f, 0.0f)
 3-dimensional float unit Vector pointing along the Y axis.
 
static const Vector< float, 3 > kAxisZ3f (0.0f, 0.0f, 1.0f)
 3-dimensional float unit Vector pointing along the Z axis.
 
static const Vector< float, 4 > kZeros4f (0.0f, 0.0f, 0.0f, 0.0f)
 4-dimensional float Vector of zeros.
 
static const Vector< float, 4 > kOnes4f (1.0f, 1.0f, 1.0f, 1.0f)
 4-dimensional float Vector of ones.
 
static const Vector< float, 4 > kAxisX4f (1.0f, 0.0f, 0.0f, 0.0f)
 4-dimensional float unit Vector pointing along the X axis.
 
static const Vector< float, 4 > kAxisY4f (0.0f, 1.0f, 0.0f, 0.0f)
 4-dimensional float unit Vector pointing along the Y axis.
 
static const Vector< float, 4 > kAxisZ4f (0.0f, 0.0f, 1.0f, 0.0f)
 4-dimensional float unit Vector pointing along the Z axis.
 
static const Vector< float, 4 > kAxisW4f (0.0f, 0.0f, 0.0f, 1.0f)
 4-dimensional float unit Vector pointing along the W axis.
 
static const Vector< double, 2 > kZeros2d (0.0, 0.0)
 2-dimensional double Vector of zeros.
 
static const Vector< double, 2 > kOnes2d (1.0, 1.0)
 2-dimensional double Vector of ones.
 
static const Vector< double, 2 > kAxisX2d (1.0, 0.0)
 2-dimensional double unit Vector pointing along the X axis.
 
static const Vector< double, 2 > kAxisY2d (0.0, 1.0)
 2-dimensional double unit Vector pointing along the Y axis.
 
static const Vector< double, 3 > kZeros3d (0.0, 0.0, 0.0)
 3-dimensional double Vector of zeros.
 
static const Vector< double, 3 > kOnes3d (1.0, 1.0, 1.0)
 3-dimensional double Vector of ones.
 
static const Vector< double, 3 > kAxisX3d (1.0, 0.0, 0.0)
 3-dimensional double unit Vector pointing along the X axis.
 
static const Vector< double, 3 > kAxisY3d (0.0, 1.0, 0.0)
 3-dimensional double unit Vector pointing along the Y axis.
 
static const Vector< double, 3 > kAxisZ3d (0.0, 0.0, 1.0)
 3-dimensional double unit Vector pointing along the Z axis.
 
static const Vector< double, 4 > kZeros4d (0.0, 0.0, 0.0, 0.0)
 4-dimensional double Vector of zeros.
 
static const Vector< double, 4 > kOnes4d (1.0, 1.0, 1.0, 1.0)
 4-dimensional double Vector of ones.
 
static const Vector< double, 4 > kAxisX4d (1.0, 0.0, 0.0, 0.0)
 4-dimensional double unit Vector pointing along the X axis.
 
static const Vector< double, 4 > kAxisY4d (0.0, 1.0, 0.0, 0.0)
 4-dimensional double unit Vector pointing along the Y axis.
 
static const Vector< double, 4 > kAxisZ4d (0.0, 0.0, 1.0, 0.0)
 4-dimensional double unit Vector pointing along the Z axis.
 
static const Vector< double, 4 > kAxisW4d (0.0, 0.0, 0.0, 1.0)
 4-dimensional double unit Vector pointing along the W axis.
 
static const Vector< int, 2 > kOnes2i (1, 1)
 2-dimensional int Vector of zeros.
 
static const Vector< int, 2 > kZeros2i (0, 0)
 2-dimensional int Vector of ones.
 
static const Vector< int, 2 > kAxisX2i (1, 0)
 2-dimensional int unit Vector pointing along the X axis.
 
static const Vector< int, 2 > kAxisY2i (0, 1)
 2-dimensional int unit Vector pointing along the Y axis.
 
static const Vector< int, 3 > kZeros3i (0, 0, 0)
 3-dimensional int Vector of zeros.
 
static const Vector< int, 3 > kOnes3i (1, 1, 1)
 3-dimensional int Vector of ones.
 
static const Vector< int, 3 > kAxisX3i (1, 0, 0)
 3-dimensional int unit Vector pointing along the X axis.
 
static const Vector< int, 3 > kAxisY3i (0, 1, 0)
 3-dimensional int unit Vector pointing along the Y axis.
 
static const Vector< int, 3 > kAxisZ3i (0, 0, 1)
 3-dimensional int unit Vector pointing along the Z axis.
 
static const Vector< int, 4 > kZeros4i (0, 0, 0, 0)
 4-dimensional int Vector of zeros.
 
static const Vector< int, 4 > kOnes4i (1, 1, 1, 1)
 4-dimensional int Vector of ones.
 
static const Vector< int, 4 > kAxisX4i (1, 0, 0, 0)
 4-dimensional int unit Vector pointing along the X axis.
 
static const Vector< int, 4 > kAxisY4i (0, 1, 0, 0)
 4-dimensional int unit Vector pointing along the Z axis.
 
static const Vector< int, 4 > kAxisZ4i (0, 0, 1, 0)
 4-dimensional int unit Vector pointing along the Y axis.
 
static const Vector< int, 4 > kAxisW4i (0, 0, 0, 1)
 4-dimensional int unit Vector pointing along the W axis.
 
static const Quaternion< float > kQuatIdentityf (1.0f, 0.0f, 0.0f, 0.0f)
 Quaternion Identity.
 
static const Quaternion< double > kQuatIdentityd (1.0, 0.0, 0.0, 0.0)
 Quaternion Identity.
 
static const AffineTransform kAffineIdentity (1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f)
 
template<class T >
Vector< T, 3 > cross (const Vector< T, 3 > &v1, const Vector< T, 3 > &v2)
 Calculate the cross product of two 3-dimensional Vectors. More...
 
template<class TV >
TV::Scalar dot (const TV &v1, const TV &v2)
 Calculate the dot product of two N-dimensional Vectors of any type. More...
 
template<class TV >
TV normalize (const TV &v1)
 Normalize an N-dimensional Vector of an arbitrary type. More...
 
static const Vector< float, 4 > kAffineWColumn (0.0f, 0.0f, 0.0f, 1.0f)
 
template<class T >
bool operator== (const Rect< T > &r1, const Rect< T > &r2)
 Check if two rects are identical. More...
 
template<class T >
bool operator!= (const Rect< T > &r1, const Rect< T > &r2)
 Check if two rects are not identical. More...
 
template<class T >
Clamp (const T &x, const T &lower, const T &upper)
 Clamp x within [lower, upper]. More...
 
template<class T , class T2 >
Lerp (const T &range_start, const T &range_end, const T2 &percent)
 Linearly interpolate between range_start and range_end, based on percent. More...
 
template<class T >
Lerp (const T &range_start, const T &range_end, const T &percent)
 Linearly interpolate between range_start and range_end, based on percent. More...
 
template<class T >
bool InRange (T val, T range_start, T range_end)
 Check if val is within [range_start..range_end). More...
 
template<class T >
Random ()
 Generate a random value of type T. More...
 
template<class T >
RandomRange (T range)
 Generate a random value of type T in the range -range...+range. More...
 
template<class T >
RandomInRange (T range_start, T range_end)
 Generate a random number between [range_start, range_end]. More...
 
template<class T >
RoundUpToPowerOf2 (T x)
 Round a value up to the nearest power of 2. More...
 
template<>
int32_t RoundUpToPowerOf2 (int32_t x)
 Specialized version of RoundUpToPowerOf2 for int32_t.
 
template<typename T >
uint32_t RoundUpToTypeBoundary (uint32_t v)
 Round a value up to the type's size boundary. More...
 
void * AllocateAligned (size_t n)
 Allocate an aligned block of memory. More...
 
void FreeAligned (void *p)
 Deallocate a block of memory allocated with AllocateAligned(). More...
 
template<class T , int d>
bool operator== (const Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Compare 2 Vectors of the same size for equality. More...
 
template<class T , int d>
bool operator!= (const Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Compare 2 Vectors of the same size for inequality. More...
 
template<class T , int d>
Vector< T, d > operator- (const Vector< T, d > &v)
 Negate all elements of the Vector. More...
 
template<class T , int d>
Vector< T, d > operator* (const Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Multiply a vector by another Vector. More...
 
template<class T , int d>
Vector< T, d > operator/ (const Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Divide a vector by another Vector. More...
 
template<class T , int d>
Vector< T, d > operator+ (const Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Add a vector with another Vector. More...
 
template<class T , int d>
Vector< T, d > operator- (const Vector< T, d > &lhs, const Vector< T, d > &rhs)
 subtract a vector with another Vector. More...
 
template<class T , int d>
Vector< T, d > operator* (const Vector< T, d > &v, const T &s)
 Multiply a vector with a scalar. More...
 
template<class T , int d>
Vector< T, d > operator+ (const Vector< T, d > &v, const T &s)
 Add a scalar to all elements of a vector. More...
 
template<class T , int d>
Vector< T, d > operator- (const Vector< T, d > &v, const T &s)
 Subtract a scalar from all elements of a vector. More...
 
template<class T , int d>
Vector< T, d > & operator*= (Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Multiply (in-place) a vector with another Vector. More...
 
template<class T , int d>
Vector< T, d > & operator/= (Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Divide (in-place) a vector by another Vector. More...
 
template<class T , int d>
Vector< T, d > & operator+= (Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Add (in-place) a vector with another Vector. More...
 
template<class T , int d>
Vector< T, d > & operator-= (Vector< T, d > &lhs, const Vector< T, d > &rhs)
 Subtract (in-place) another Vector from a vector. More...
 
template<class T , int d>
Vector< T, d > & operator*= (Vector< T, d > &v, const T &s)
 Multiply (in-place) each element of a vector with a scalar. More...
 
template<class T , int d>
Vector< T, d > & operator/= (Vector< T, d > &v, const T &s)
 Divide (in-place) each element of a vector by a scalar. More...
 
template<class T , int d>
Vector< T, d > & operator+= (Vector< T, d > &v, const T &s)
 Add (in-place) a scalar to each element of a vector. More...
 
template<class T , int d>
Vector< T, d > & operator-= (Vector< T, d > &v, const T &s)
 Subtract (in-place) a scalar from each element of a vector. More...
 
template<class T , int d>
Vector< T, d > HadamardProductHelper (const Vector< T, d > &v1, const Vector< T, d > &v2)
 Calculate the hadamard or componentwise product of two vectors. More...
 
template<class T >
Vector< T, 3 > CrossProductHelper (const Vector< T, 3 > &v1, const Vector< T, 3 > &v2)
 Calculate the cross product of two vectors. More...
 
template<class T , int d>
LengthSquaredHelper (const Vector< T, d > &v)
 Calculate the squared length of a vector. More...
 
template<class T , int d>
LengthHelper (const Vector< T, d > &v)
 Calculate the length of a vector. More...
 
template<class T , int d>
NormalizeHelper (Vector< T, d > &v)
 Normalize a vector in-place. More...
 
template<class T , int d>
Vector< T, d > NormalizedHelper (const Vector< T, d > &v)
 Calculate the normalized version of a vector. More...
 
template<class T , int d>
Vector< T, d > LerpHelper (const Vector< T, d > &v1, const Vector< T, d > &v2, const T percent)
 Linearly interpolate two vectors. More...
 
template<class T , int d>
Vector< T, d > RandomInRangeHelper (const Vector< T, d > &min, const Vector< T, d > &max)
 Generates a random vector. More...
 
template<class T , int d>
Vector< T, d > MaxHelper (const Vector< T, d > &v1, const Vector< T, d > &v2)
 Compare each component and returns max values. More...
 
template<class T , int d>
Vector< T, d > MinHelper (const Vector< T, d > &v1, const Vector< T, d > &v2)
 Compare each component and returns min values. More...
 
template<class T >
bool InRange2D (const mathfu::Vector< T, 2 > &val, const mathfu::Vector< T, 2 > &range_start, const mathfu::Vector< T, 2 > &range_end)
 Check if val is within [range_start..range_end), denoting a rectangular area. More...
 
template<typename T , int d>
Vector< T, d > RoundUpToPowerOf2 (const Vector< T, d > &v)
 Specialized version of RoundUpToPowerOf2 for vector.
 

Detailed Description

Namespace for MathFu library.

Function Documentation

template<class T >
bool mathfu::operator!= ( const Rect< T > &  r1,
const Rect< T > &  r2 
)

Check if two rects are not identical.

Parameters
r1Rect to be tested.
r2Other rect to be tested.
template<class T >
bool mathfu::operator== ( const Rect< T > &  r1,
const Rect< T > &  r2 
)

Check if two rects are identical.

Parameters
r1Rect to be tested.
r2Other rect to be tested.