Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::math Namespace Reference

Namespaces

 internal
 Internal helper functions.
 

Classes

class  Angle
 A simple class to represent angles. More...
 
class  FieldOfView
 Encapsulates a generalized, asymmetric field of view with four half angles. More...
 
class  Matrix
 The Matrix class defines a square N-dimensional matrix. More...
 
struct  Range1TWrapper
 This struct allows the Endpoint and Size types in a Range<1, T> to be treated like those of higher-dimension Range classes (specifically the use of index operators) to simplify templated functions that use them. More...
 
class  RangeBase
 The RangeBase class makes it possible to treat Ranges with Dimension=1 specially. More...
 
class  RangeBase< 1, T >
 Specialize for Dimension=1. More...
 
class  Range
 The Range class defines an N-dimensional interval defined by minimum and maximum N-dimensional endpoints. More...
 
class  Rotation
 The Rotation class represents a rotation around a 3-dimensional axis. More...
 
class  VectorBase
 VectorBase. More...
 
class  Vector
 Vector. More...
 
class  Point
 Point. More...
 

Typedefs

typedef Angle< float > Anglef
 Type-specific typedefs. More...
 
typedef Angle< double > Angled
 
typedef FieldOfView< float > FieldOfViewf
 
typedef FieldOfView< double > FieldOfViewd
 
typedef Matrix< 2, float > Matrix2f
 Dimension- and type-specific typedefs. More...
 
typedef Matrix< 2, double > Matrix2d
 
typedef Matrix< 3, float > Matrix3f
 
typedef Matrix< 3, double > Matrix3d
 
typedef Matrix< 4, float > Matrix4f
 
typedef Matrix< 4, double > Matrix4d
 
typedef Range< 1, int8 > Range1i8
 Dimension- and type-specific typedefs. More...
 
typedef Range< 1, uint8 > Range1ui8
 
typedef Range< 1, int16 > Range1i16
 
typedef Range< 1, uint16 > Range1ui16
 
typedef Range< 1, int32 > Range1i
 
typedef Range< 1, uint32 > Range1ui
 
typedef Range< 1, float > Range1f
 
typedef Range< 1, double > Range1d
 
typedef Range< 2, int8 > Range2i8
 
typedef Range< 2, uint8 > Range2ui8
 
typedef Range< 2, int16 > Range2i16
 
typedef Range< 2, uint16 > Range2ui16
 
typedef Range< 2, int32 > Range2i
 
typedef Range< 2, uint32 > Range2ui
 
typedef Range< 2, float > Range2f
 
typedef Range< 2, double > Range2d
 
typedef Range< 3, int8 > Range3i8
 
typedef Range< 3, uint8 > Range3ui8
 
typedef Range< 3, int16 > Range3i16
 
typedef Range< 3, uint16 > Range3ui16
 
typedef Range< 3, int32 > Range3i
 
typedef Range< 3, uint32 > Range3ui
 
typedef Range< 3, float > Range3f
 
typedef Range< 3, double > Range3d
 
typedef Range< 4, int8 > Range4i8
 
typedef Range< 4, uint8 > Range4ui8
 
typedef Range< 4, int16 > Range4i16
 
typedef Range< 4, uint16 > Range4ui16
 
typedef Range< 4, int32 > Range4i
 
typedef Range< 4, uint32 > Range4ui
 
typedef Range< 4, float > Range4f
 
typedef Range< 4, double > Range4d
 
typedef Rotation< float > Rotationf
 Type-specific typedefs. More...
 
typedef Rotation< double > Rotationd
 

Functions

template<typename T >
std::ostream & operator<< (std::ostream &out, const Angle< T > &a)
 An Angle is streamed as degrees. More...
 
template<typename T >
std::istream & operator>> (std::istream &in, Angle< T > &a)
 
template<typename T >
Angle< TArcCosine (T v)
 Returns the inverse cosine of the given value. More...
 
template<>
Angle< float > ArcCosine (float v)
 float specialization of ArcCosine. More...
 
template<typename T >
Angle< TArcSine (T v)
 Returns the inverse sine of the given value. More...
 
template<>
Angle< float > ArcSine (float v)
 float specialization of ArcSine. More...
 
template<typename T >
Angle< TArcTangent (T v)
 Returns the inverse tangent of the given value. More...
 
template<>
Angle< float > ArcTangent (float v)
 float specialization of ArcTan. More...
 
template<typename T >
Angle< TArcTangent2 (T y, T x)
 Returns the four-quadrant inverse tangent of the given values. More...
 
template<>
Angle< float > ArcTangent2 (float y, float x)
 float specialization of ArcTangent2. More...
 
template<typename T >
T Cosine (const ion::math::Angle< T > &angle)
 ion::math::Angle specialization of Cosine. More...
 
template<typename T >
T Sine (const ion::math::Angle< T > &angle)
 ion::math::Angle specialization of Sine. More...
 
template<typename T >
T Tangent (const ion::math::Angle< T > &angle)
 ion::math::Angle specialization of Tangent. More...
 
template<int Dimension, typename T >
Angle< TAngleBetween (const ion::math::Vector< Dimension, T > &a, const ion::math::Vector< Dimension, T > &b)
 Returns the angle between two unit vectors. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const FieldOfView< T > &f)
 
template<typename T >
std::istream & operator>> (std::istream &in, FieldOfView< T > &f)
 
template<int Dimension, typename T >
std::ostream & operator<< (std::ostream &out, const Matrix< Dimension, T > &m)
 Prints a Matrix to a stream. More...
 
template<int Dimension, typename T >
std::istream & operator>> (std::istream &in, Matrix< Dimension, T > &m)
 Reads a Matrix from a stream. More...
 
template<int Dimension, typename T >
T Determinant (const Matrix< Dimension, T > &m)
 Public functions. More...
 
template<int Dimension, typename T >
Matrix< Dimension, TCofactorMatrix (const Matrix< Dimension, T > &m)
 Returns the signed cofactor matrix (adjunct) of the matrix. More...
 
template<int Dimension, typename T >
Matrix< Dimension, TAdjugateWithDeterminant (const Matrix< Dimension, T > &m, T *determinant)
 Returns the adjugate of the matrix, which is defined as the transpose of the cofactor matrix. More...
 
template<int Dimension, typename T >
Matrix< Dimension, TInverseWithDeterminant (const Matrix< Dimension, T > &m, T *determinant)
 Returns the inverse of the matrix. More...
 
template<int Dimension, typename T >
bool MatrixAlmostOrthogonal (const Matrix< Dimension, T > &m, T tolerance)
 Returns true if the dot product of all column vector pairs in the matrix is less than a provided tolerance, and if all column vectors have unit length. More...
 
 ION_SPECIALIZE_MATRIX_FUNCS (2, float)
 
 ION_SPECIALIZE_MATRIX_FUNCS (2, double)
 
 ION_SPECIALIZE_MATRIX_FUNCS (3, float)
 
 ION_SPECIALIZE_MATRIX_FUNCS (3, double)
 
 ION_SPECIALIZE_MATRIX_FUNCS (4, float)
 
 ION_SPECIALIZE_MATRIX_FUNCS (4, double)
 
template<int Dimension, typename T >
Matrix< Dimension, TTranspose (const Matrix< Dimension, T > &m)
 Public functions. More...
 
template<int Dimension, typename T >
Vector< Dimension, Toperator* (const Matrix< Dimension, T > &m, const Vector< Dimension, T > &v)
 Multiplies a Matrix and a column Vector of the same Dimension to produce another column Vector. More...
 
template<int Dimension, typename T >
Point< Dimension, Toperator* (const Matrix< Dimension, T > &m, const Point< Dimension, T > &p)
 Multiplies a Matrix and a Point of the same Dimension to produce another Point. More...
 
template<int Dimension, typename T >
Vector< Dimension, TRow (const Matrix< Dimension, T > &m, int row)
 Returns a particular row of a matrix as a vector. More...
 
template<int Dimension, typename T >
Vector< Dimension, TColumn (const Matrix< Dimension, T > &m, int col)
 Returns a particular column of a matrix as a vector. More...
 
template<int Dimension, typename T >
ION_API T Determinant (const Matrix< Dimension, T > &m)
 Returns the determinant of the matrix. More...
 
template<int Dimension, typename T >
ION_API Matrix< Dimension, TCofactorMatrix (const Matrix< Dimension, T > &m)
 Returns the signed cofactor matrix (adjunct) of the matrix. More...
 
template<int Dimension, typename T >
ION_API Matrix< Dimension, TAdjugateWithDeterminant (const Matrix< Dimension, T > &m, T *determinant)
 Returns the adjugate of the matrix, which is defined as the transpose of the cofactor matrix. More...
 
template<int Dimension, typename T >
Matrix< Dimension, TAdjugate (const Matrix< Dimension, T > &m)
 Returns the adjugate of the matrix, which is defined as the transpose of the cofactor matrix. More...
 
template<int Dimension, typename T >
ION_API Matrix< Dimension, TInverseWithDeterminant (const Matrix< Dimension, T > &m, T *determinant)
 Returns the inverse of the matrix. More...
 
template<int Dimension, typename T >
Matrix< Dimension, TInverse (const Matrix< Dimension, T > &m)
 Returns the inverse of the matrix. More...
 
template<typename T >
std::istream & operator>> (std::istream &in, Range1TWrapper< T, 0 > &w)
 
template<int Dimension, typename T >
std::ostream & operator<< (std::ostream &out, const Range< Dimension, T > &r)
 Prints a Range to a stream. More...
 
template<int Dimension, typename T >
std::istream & operator>> (std::istream &in, Range< Dimension, T > &r)
 Reads a Range from a stream. More...
 
template<int Dimension, typename T >
const Range< Dimension, TRangeUnion (const Range< Dimension, T > &r0, const Range< Dimension, T > &r1)
 Returns the union of two Range instances. More...
 
template<int Dimension, typename T >
const Range< Dimension, TRangeIntersection (const Range< Dimension, T > &r0, const Range< Dimension, T > &r1)
 Returns the intersection of two Range instances. More...
 
template<int Dimension, typename T >
T NVolume (const Range< Dimension, T > &r)
 Returns the NVolume of a Range, which is the product of its sizes in all dimensions. More...
 
template<int Dimension, typename T >
bool RangesAlmostEqual (const Range< Dimension, T > &r0, const Range< Dimension, T > &r1, const T threshold)
 Returns true if all dimensions of the two ranges are equal within the threshold. More...
 
template<int Dimension, typename T >
const Range< Dimension, TScaleRange (const Range< Dimension, T > &r, T scale_factor)
 Returns a Range that is the input Range scaled uniformly about its center by the given factor. More...
 
template<int Dimension, typename T >
const Range< Dimension, TScaleRangeNonUniformly (const Range< Dimension, T > &r, const Vector< Dimension, T > scale_factors)
 Returns a Range that is the input Range scaled nonuniformly about its center by the given per-dimension factors. More...
 
template<int Dimension, typename T1 , typename T2 >
const Range< Dimension, T1 > ModulateRange (const Range< Dimension, T1 > &r, const Vector< Dimension, T2 > modulation)
 Modulate a Range by a Vector. More...
 
 ION_INSTANTIATE_ROTATION_FUNCTIONS (double)
 
 ION_INSTANTIATE_ROTATION_FUNCTIONS (float)
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const Rotation< T > &a)
 Prints a Rotation to a stream. More...
 
template<typename T >
std::istream & operator>> (std::istream &in, Rotation< T > &a)
 Reads a Rotation from a stream. More...
 
template<typename T >
const Matrix< 4, TOrthoInverseH (const Matrix< 4, T > &m)
 Public functions. More...
 
template<typename T >
ION_API const Matrix< 4, TRotationMatrixH (const Rotation< T > &r)
 Returns a 4x4 Matrix representing a 3D rotation. More...
 
template<typename T >
ION_API const Matrix< 3, TRotationMatrixNH (const Rotation< T > &r)
 Returns a 3x3 Matrix representing a 3D rotation. More...
 
template<typename T >
ION_API const Matrix< 4, TLookAtMatrixFromCenter (const Point< 3, T > &eye, const Point< 3, T > &center, const Vector< 3, T > &up)
 View matrices. More...
 
template<typename T >
ION_API const Matrix< 4, TLookAtMatrixFromDir (const Point< 3, T > &eye, const Vector< 3, T > &dir, const Vector< 3, T > &up)
 Returns a 4x4 viewing matrix based on the given camera parameters, which use a view direction rather than look at center point. More...
 
template<typename T >
ION_API const Matrix< 4, TOrthographicMatrixFromFrustum (T x_left, T x_right, T y_bottom, T y_top, T z_near, T z_far)
 Projection matrices. More...
 
template<typename T >
ION_API const Matrix< 4, TPerspectiveMatrixFromFrustum (T x_left, T x_right, T y_bottom, T y_top, T z_near, T z_far)
 Returns a 4x4 perspective projection matrix based on the given parameters, which follow the conventions of the old glFrustum() function. More...
 
template<typename T >
ION_API const Matrix< 4, TPerspectiveMatrixFromView (const Angle< T > &fovy, T aspect, T z_near, T z_far)
 Returns a 4x4 perspective projection matrix based on the given parameters, which follow the conventions of the gluPerspective() function. More...
 
template<typename T >
ION_API const Matrix< 4, TPerspectiveMatrixInverse (const Matrix< 4, T > &m)
 Returns the inverse of m iff m is a perspective projection matrix, i.e., iff it has the following form:

[X 0 A 0]
[0 Y B 0]
[0 0 C D]
[0 0 -1 0]

Triggers a DCHECK otherwise. More...

 
 ION_INSTANTIATE_FUNCTIONS (double)
 
 ION_INSTANTIATE_FUNCTIONS (float)
 
template<int Dimension, typename T >
const Vector< Dimension, Toperator* (const Matrix< Dimension+1, T > &m, const Vector< Dimension, T > &v)
 Transforming vectors and points. More...
 
template<int Dimension, typename T >
const Point< Dimension, Toperator* (const Matrix< Dimension+1, T > &m, const Point< Dimension, T > &p)
 Multiplies a Matrix and a Point of one smaller Dimension (the template parameter) to produce another Point. More...
 
template<int Dimension, typename T >
const Point< Dimension, TProjectPoint (const Matrix< Dimension+1, T > &m, const Point< Dimension, T > &p)
 Multiplies a Matrix and a Point of one smaller Dimension (the template parameter) to produce another Point and projects it by dividing by the homogeneous coordinate. More...
 
template<typename T >
Matrix< 3, TNonhomogeneousSubmatrixH (const Matrix< 4, T > &m)
 Homogeneous matrices. More...
 
template<int Dimension, typename T >
const Matrix< Dimension+1, TTranslationMatrix (const VectorBase< Dimension, T > &t)
 Affine transformation matrices. More...
 
template<int Dimension, typename T >
const Matrix< Dimension+1, TScaleMatrixH (const Vector< Dimension, T > &s)
 Returns a Matrix representing a scale by the factors in a Vector whose Dimension is one less than the Dimension of the Matrix. More...
 
template<int Dimension, typename T >
const Matrix< Dimension, TScaleMatrixNH (const Vector< Dimension, T > &s)
 Returns a Matrix representing a scale by the factors in a Vector, which is the same Dimension as the Matrix. More...
 
template<typename T >
const Matrix< 4, TRotationMatrixAxisAngleH (const Vector< 3, T > &axis, const Angle< T > &angle)
 Returns a 4x4 Matrix representing a 3D rotation specified as axis and angle. More...
 
template<typename T >
const Matrix< 3, TRotationMatrixAxisAngleNH (const Vector< 3, T > &axis, const Angle< T > &angle)
 Returns a 3x3 Matrix representing a 3D rotation specified as axis and angle. More...
 
template<typename T >
const Matrix< 4, TPerspectiveMatrixInverse (const Matrix< 4, T > &m)
 Returns the inverse of m iff m is a perspective projection matrix, i.e., iff it has the following form:

[X 0 A 0]
[0 Y B 0]
[0 0 C D]
[0 0 -1 0]

Triggers a DCHECK otherwise. More...

 
template<typename T >
bool IsFinite (T x)
 Tests whether a numeric value is finite. More...
 
template<typename T >
const T Abs (const T &val)
 Returns the absolute value of a number in a type-safe way. More...
 
template<typename T >
const T Square (const T &val)
 Squares a value. More...
 
template<typename T >
T Sqrt (const T &val)
 Returns the square root of a value. More...
 
template<>
float Sqrt (const float &val)
 
template<typename T >
T Cosine (T angle)
 Returns the cosine of the given value. More...
 
template<>
float Cosine (float angle)
 float specialization of Cosine. More...
 
template<typename T >
T Sine (T angle)
 Returns the sine of the given value. More...
 
template<>
float Sine (float angle)
 float specialization of Sine. More...
 
template<typename T >
T Tangent (T angle)
 Returns the tangent of the given value. More...
 
template<>
float Tangent (float angle)
 float specialization of Tangent. More...
 
template<typename T >
T Factorial (int x)
 Returns the factorial (!) of x. More...
 
template<typename T >
T DoubleFactorial (int x)
 Returns the double factorial (!!) of x. More...
 
uint32 NextPowerOf2 (uint32 n)
 Returns the next power of 2 greater than or equal to n. More...
 
uint64 NextPowerOf2 (uint64 n)
 
template<typename T >
T Log2 (T n)
 Returns the base-2 logarithm of n. More...
 
template<>
uint32 Log2 (uint32 n)
 Specialize for integer types. More...
 
template<>
int Log2 (int n)
 
template<>
uint64 Log2 (uint64 n)
 
template<>
int64 Log2 (int64 n)
 
template<typename T >
const T Clamp (const T &val, const T &min_val, const T &max_val)
 Clamps a value to lie between a minimum and maximum, inclusive. More...
 
template<typename T , typename U >
const U Lerp (const U &begin, const U &end, const T &t)
 Linearly interpolates between two values. More...
 
bool IsPowerOfTwo (int value)
 Returns true if a value is a power of two. More...
 
template<int Dimension, typename T >
std::ostream & operator<< (std::ostream &out, const Vector< Dimension, T > &v)
 Prints a Vector to a stream. More...
 
template<int Dimension, typename T >
std::istream & operator>> (std::istream &in, Vector< Dimension, T > &v)
 Reads a Vector from a stream. More...
 
template<int Dimension, typename T >
std::ostream & operator<< (std::ostream &out, const Point< Dimension, T > &p)
 Prints a Point to a stream. More...
 
template<int Dimension, typename T >
std::istream & operator>> (std::istream &in, Point< Dimension, T > &v)
 Reads a Point from a stream. More...
 
 ION_INSTANTIATE_VECTOR_TYPE (VectorBase)
 
 ION_INSTANTIATE_VECTOR_TYPE (Vector)
 
 ION_INSTANTIATE_VECTOR_TYPE (Point)
 
template<int Dimension, typename T >
T Dot (const Vector< Dimension, T > &v0, const Vector< Dimension, T > &v1)
 Returns the dot (inner) product of two Vectors. More...
 
template<typename T >
Vector< 3, TCross (const Vector< 3, T > &v0, const Vector< 3, T > &v1)
 Returns the 3-dimensional cross product of 2 Vectors. More...
 
template<typename T >
T Cross (const Vector< 2, T > &v0, const Vector< 2, T > &v1)
 Returns the cross product of v0 and v1 aka the determinant of the 2x2 matrix described by |v0.x v0.y| |v1.x v1.y|. More...
 
template<int Dimension, typename T >
T LengthSquared (const Vector< Dimension, T > &v)
 Returns the square of the length of a Vector. More...
 
template<int Dimension, typename T >
T Length (const Vector< Dimension, T > &v)
 Returns the geometric length of a Vector. More...
 
template<int Dimension, typename T >
T DistanceSquared (const Point< Dimension, T > &p0, const Point< Dimension, T > &p1)
 Returns the square of the distance between two Points. More...
 
template<int Dimension, typename T >
T Distance (const Point< Dimension, T > &p0, const Point< Dimension, T > &p1)
 Returns the geometric distance between two Points. More...
 
template<int Dimension, typename T >
bool Normalize (Vector< Dimension, T > *v)
 Normalizes a Vector to unit length. More...
 
template<int Dimension, typename T >
const Vector< Dimension, TNormalized (const Vector< Dimension, T > &v)
 Returns a unit-length version of a Vector. More...
 
template<typename T >
const Vector< 2, TOrthogonal (const Vector< 2, T > &v)
 Returns an unnormalized Vector2 that is orthonormal to the passed one. More...
 
template<typename T >
const Vector< 3, TOrthogonal (const Vector< 3, T > &v)
 Returns an unnormalized Vector3 that is orthonormal to the passed one. More...
 
template<int Dimension, typename T >
const Vector< Dimension, TOrthonormal (const Vector< Dimension, T > &v)
 Returns a normalized Vector that is orthonormal to the passed one. More...
 
template<int Dimension, typename T >
const Vector< Dimension, TProjection (const Vector< Dimension, T > &v, const Vector< Dimension, T > &onto_v)
 Returns the Vector resulting from projecting of one Vector onto another. More...
 
template<int Dimension, typename T >
const Vector< Dimension, TRescale (const Vector< Dimension, T > &v, T length)
 Returns a Vector in the same direction as the passed vector but with the passed length. More...
 
template<int Dimension, typename T >
bool VectorsAlmostEqual (const Vector< Dimension, T > &v0, const Vector< Dimension, T > &v1, T tolerance)
 Returns true if all elements of two Vectors are equal within a tolerance. More...
 
template<int Dimension, typename T >
const Point< Dimension, TMinBoundPoint (const Point< Dimension, T > &p0, const Point< Dimension, T > &p1)
 Returns a Point in which each element is the minimum of the corresponding elements of two Points. More...
 
template<int Dimension, typename T >
const Point< Dimension, TMaxBoundPoint (const Point< Dimension, T > &p0, const Point< Dimension, T > &p1)
 Returns a Point in which each element is the maximum of the corresponding elements of two Points. More...
 
template<int Dimension, typename T >
Point< Dimension, TClosestPointOnSegment (const Point< Dimension, T > &p, const Point< Dimension, T > &start, const Point< Dimension, T > &end)
 Returns the closest point to p on the line segment defined by start and end. More...
 
template<int Dimension, typename T >
const T DistanceSquaredToSegment (const Point< Dimension, T > &p, const Point< Dimension, T > &start, const Point< Dimension, T > &end)
 Returns the squared distance from a Point to a line segment described by two Points. More...
 
template<int Dimension, typename T >
const T DistanceToSegment (const Point< Dimension, T > &p, const Point< Dimension, T > &start, const Point< Dimension, T > &end)
 Returns the distance from a Point to a line segment described by two Points. More...
 
template<int Dimension, typename T >
bool PointsAlmostEqual (const Point< Dimension, T > &v0, const Point< Dimension, T > &v1, T tolerance)
 Returns true if all elements of two Points are equal within a tolerance. More...
 
template<int InDimension, int OutDimension, typename T >
bool Swizzle (const VectorBase< InDimension, T > &input, const char *swizzle_string, VectorBase< OutDimension, T > *output)
 Computes the result of swizzling a Vector or Point (or anything else derived from VectorBase). More...
 
template<int Dimension, typename T >
bool IsVectorFinite (const VectorBase< Dimension, T > &v)
 Returns true if all components of VectorBase v are finite, otherwise false. More...
 

Typedef Documentation

typedef Angle<double> ion::math::Angled

Definition at line 157 of file angle.h.

typedef Angle<float> ion::math::Anglef

Type-specific typedefs.

Definition at line 156 of file angle.h.

Definition at line 180 of file fieldofview.h.

Definition at line 179 of file fieldofview.h.

typedef Matrix<2, double> ion::math::Matrix2d

Definition at line 368 of file matrix.h.

typedef Matrix<2, float> ion::math::Matrix2f

Dimension- and type-specific typedefs.

Definition at line 367 of file matrix.h.

typedef Matrix<3, double> ion::math::Matrix3d

Definition at line 370 of file matrix.h.

typedef Matrix<3, float> ion::math::Matrix3f

Definition at line 369 of file matrix.h.

typedef Matrix<4, double> ion::math::Matrix4d

Definition at line 372 of file matrix.h.

typedef Matrix<4, float> ion::math::Matrix4f

Definition at line 371 of file matrix.h.

typedef Range<1, double> ion::math::Range1d

Definition at line 366 of file range.h.

typedef Range<1, float> ion::math::Range1f

Definition at line 365 of file range.h.

typedef Range<1, int32> ion::math::Range1i

Definition at line 363 of file range.h.

typedef Range<1, int16> ion::math::Range1i16

Definition at line 361 of file range.h.

typedef Range<1, int8> ion::math::Range1i8

Dimension- and type-specific typedefs.

Definition at line 359 of file range.h.

typedef Range<1, uint32> ion::math::Range1ui

Definition at line 364 of file range.h.

typedef Range<1, uint16> ion::math::Range1ui16

Definition at line 362 of file range.h.

typedef Range<1, uint8> ion::math::Range1ui8

Definition at line 360 of file range.h.

typedef Range<2, double> ion::math::Range2d

Definition at line 374 of file range.h.

typedef Range<2, float> ion::math::Range2f

Definition at line 373 of file range.h.

typedef Range<2, int32> ion::math::Range2i

Definition at line 371 of file range.h.

typedef Range<2, int16> ion::math::Range2i16

Definition at line 369 of file range.h.

typedef Range<2, int8> ion::math::Range2i8

Definition at line 367 of file range.h.

typedef Range<2, uint32> ion::math::Range2ui

Definition at line 372 of file range.h.

typedef Range<2, uint16> ion::math::Range2ui16

Definition at line 370 of file range.h.

typedef Range<2, uint8> ion::math::Range2ui8

Definition at line 368 of file range.h.

typedef Range<3, double> ion::math::Range3d

Definition at line 382 of file range.h.

typedef Range<3, float> ion::math::Range3f

Definition at line 381 of file range.h.

typedef Range<3, int32> ion::math::Range3i

Definition at line 379 of file range.h.

typedef Range<3, int16> ion::math::Range3i16

Definition at line 377 of file range.h.

typedef Range<3, int8> ion::math::Range3i8

Definition at line 375 of file range.h.

typedef Range<3, uint32> ion::math::Range3ui

Definition at line 380 of file range.h.

typedef Range<3, uint16> ion::math::Range3ui16

Definition at line 378 of file range.h.

typedef Range<3, uint8> ion::math::Range3ui8

Definition at line 376 of file range.h.

typedef Range<4, double> ion::math::Range4d

Definition at line 390 of file range.h.

typedef Range<4, float> ion::math::Range4f

Definition at line 389 of file range.h.

typedef Range<4, int32> ion::math::Range4i

Definition at line 387 of file range.h.

typedef Range<4, int16> ion::math::Range4i16

Definition at line 385 of file range.h.

typedef Range<4, int8> ion::math::Range4i8

Definition at line 383 of file range.h.

typedef Range<4, uint32> ion::math::Range4ui

Definition at line 388 of file range.h.

typedef Range<4, uint16> ion::math::Range4ui16

Definition at line 386 of file range.h.

typedef Range<4, uint8> ion::math::Range4ui8

Definition at line 384 of file range.h.

typedef Rotation<double> ion::math::Rotationd

Definition at line 213 of file rotation.h.

Type-specific typedefs.

Definition at line 212 of file rotation.h.

Function Documentation

template<typename T >
const T ion::math::Abs ( const T val)
inline
template<int Dimension, typename T >
Matrix<Dimension, T> ion::math::Adjugate ( const Matrix< Dimension, T > &  m)

Returns the adjugate of the matrix, which is defined as the transpose of the cofactor matrix.

This function is defined for all the typedef'ed Matrix types.

Definition at line 134 of file matrixutils.h.

template<int Dimension, typename T >
ION_API Matrix<Dimension, T> ion::math::AdjugateWithDeterminant ( const Matrix< Dimension, T > &  m,
T determinant 
)

Returns the adjugate of the matrix, which is defined as the transpose of the cofactor matrix.

This function is defined for all the typedef'ed Matrix types. The determinant of the matrix is computed as a side effect, so it is returned in the determinant parameter if it is not NULL.

Definition at line 237 of file matrixutils.cc.

References DCHECK.

Referenced by InverseWithDeterminant().

template<int Dimension, typename T >
Matrix<Dimension, T> ion::math::AdjugateWithDeterminant ( const Matrix< Dimension, T > &  m,
T determinant 
)

Returns the adjugate of the matrix, which is defined as the transpose of the cofactor matrix.

This function is defined for all the typedef'ed Matrix types. The determinant of the matrix is computed as a side effect, so it is returned in the determinant parameter if it is not NULL.

Definition at line 237 of file matrixutils.cc.

References DCHECK.

Referenced by InverseWithDeterminant().

template<int Dimension, typename T >
Angle<T> ion::math::AngleBetween ( const ion::math::Vector< Dimension, T > &  a,
const ion::math::Vector< Dimension, T > &  b 
)
inline

Returns the angle between two unit vectors.

Definition at line 98 of file angleutils.h.

References Abs(), ArcCosine(), Clamp(), DCHECK_LE, Dot(), and LengthSquared().

template<typename T >
Angle<T> ion::math::ArcCosine ( T  v)
inline

Returns the inverse cosine of the given value.

Definition at line 36 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

Referenced by AngleBetween(), ion::math::Rotation< T >::GetAxisAndAngle(), and ion::math::Rotation< T >::Slerp().

template<>
Angle<float> ion::math::ArcCosine ( float  v)
inline

float specialization of ArcCosine.

Definition at line 41 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

template<typename T >
Angle<T> ion::math::ArcSine ( T  v)
inline

Returns the inverse sine of the given value.

Definition at line 47 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

template<>
Angle<float> ion::math::ArcSine ( float  v)
inline

float specialization of ArcSine.

Definition at line 52 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

template<typename T >
Angle<T> ion::math::ArcTangent ( T  v)
inline

Returns the inverse tangent of the given value.

Definition at line 58 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

template<>
Angle<float> ion::math::ArcTangent ( float  v)
inline

float specialization of ArcTan.

Definition at line 63 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

template<typename T >
Angle<T> ion::math::ArcTangent2 ( T  y,
T  x 
)
inline

Returns the four-quadrant inverse tangent of the given values.

Definition at line 69 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

template<>
Angle<float> ion::math::ArcTangent2 ( float  y,
float  x 
)
inline

float specialization of ArcTangent2.

Definition at line 74 of file angleutils.h.

References ion::math::Angle< T >::FromRadians().

template<typename T >
const T ion::math::Clamp ( const T val,
const T min_val,
const T max_val 
)
inline

Clamps a value to lie between a minimum and maximum, inclusive.

This is supported for any type for which std::min() and std::max() are implemented.

Definition at line 204 of file utils.h.

Referenced by AngleBetween(), and ion::math::Rotation< T >::Slerp().

template<int Dimension, typename T >
Point<Dimension, T> ion::math::ClosestPointOnSegment ( const Point< Dimension, T > &  p,
const Point< Dimension, T > &  start,
const Point< Dimension, T > &  end 
)

Returns the closest point to p on the line segment defined by start and end.

Definition at line 197 of file vectorutils.h.

References Dot(), and LengthSquared().

Referenced by DistanceSquaredToSegment(), and DistanceToSegment().

template<int Dimension, typename T >
ION_API Matrix<Dimension, T> ion::math::CofactorMatrix ( const Matrix< Dimension, T > &  m)

Returns the signed cofactor matrix (adjunct) of the matrix.

This function is defined for all the typedef'ed Matrix types.

Definition at line 232 of file matrixutils.cc.

References DCHECK.

template<int Dimension, typename T >
Matrix<Dimension, T> ion::math::CofactorMatrix ( const Matrix< Dimension, T > &  m)

Returns the signed cofactor matrix (adjunct) of the matrix.

This function is defined for all the typedef'ed Matrix types.

Definition at line 232 of file matrixutils.cc.

References DCHECK.

template<int Dimension, typename T >
Vector<Dimension, T> ion::math::Column ( const Matrix< Dimension, T > &  m,
int  col 
)

Returns a particular column of a matrix as a vector.

Definition at line 103 of file matrixutils.h.

Referenced by MatrixAlmostOrthogonal().

template<typename T >
T ion::math::Cosine ( T  angle)
inline

Returns the cosine of the given value.

Definition at line 69 of file utils.h.

template<>
float ion::math::Cosine ( float  angle)
inline

float specialization of Cosine.

Definition at line 74 of file utils.h.

template<typename T >
T ion::math::Cosine ( const ion::math::Angle< T > &  angle)
inline

ion::math::Angle specialization of Cosine.

Definition at line 80 of file angleutils.h.

References ion::math::Angle< T >::Radians().

Referenced by ion::math::Rotation< T >::SetAxisAndAngle(), and ion::math::Rotation< T >::Slerp().

template<typename T >
Vector<3, T> ion::math::Cross ( const Vector< 3, T > &  v0,
const Vector< 3, T > &  v1 
)

Returns the 3-dimensional cross product of 2 Vectors.

Note that this is defined only for 3-dimensional Vectors.

Definition at line 48 of file vectorutils.h.

Referenced by LookAtMatrixFromDir(), Orthogonal(), and ion::math::Rotation< T >::RotateInto().

template<typename T >
T ion::math::Cross ( const Vector< 2, T > &  v0,
const Vector< 2, T > &  v1 
)

Returns the cross product of v0 and v1 aka the determinant of the 2x2 matrix described by |v0.x v0.y| |v1.x v1.y|.

Definition at line 58 of file vectorutils.h.

template<int Dimension, typename T >
ION_API T ion::math::Determinant ( const Matrix< Dimension, T > &  m)

Returns the determinant of the matrix.

This function is defined for all the typedef'ed Matrix types.

Returns the determinant of the matrix.

Partial specialization of template functions is not allowed in C++, so these functions are implemented using fully-specialized functions that invoke helper functions that operate on matrices of a specific size. The unspecialized versions should never be called.

Definition at line 227 of file matrixutils.cc.

References DCHECK.

template<int Dimension, typename T >
T ion::math::Determinant ( const Matrix< Dimension, T > &  m)

Public functions.

Returns the determinant of the matrix.

Partial specialization of template functions is not allowed in C++, so these functions are implemented using fully-specialized functions that invoke helper functions that operate on matrices of a specific size. The unspecialized versions should never be called.

Definition at line 227 of file matrixutils.cc.

References DCHECK.

template<int Dimension, typename T >
T ion::math::Distance ( const Point< Dimension, T > &  p0,
const Point< Dimension, T > &  p1 
)

Returns the geometric distance between two Points.

Definition at line 83 of file vectorutils.h.

References Length().

Referenced by DistanceToSegment().

template<int Dimension, typename T >
T ion::math::DistanceSquared ( const Point< Dimension, T > &  p0,
const Point< Dimension, T > &  p1 
)

Returns the square of the distance between two Points.

Definition at line 76 of file vectorutils.h.

References LengthSquared().

Referenced by DistanceSquaredToSegment().

template<int Dimension, typename T >
const T ion::math::DistanceSquaredToSegment ( const Point< Dimension, T > &  p,
const Point< Dimension, T > &  start,
const Point< Dimension, T > &  end 
)

Returns the squared distance from a Point to a line segment described by two Points.

Definition at line 220 of file vectorutils.h.

References ClosestPointOnSegment(), and DistanceSquared().

template<int Dimension, typename T >
const T ion::math::DistanceToSegment ( const Point< Dimension, T > &  p,
const Point< Dimension, T > &  start,
const Point< Dimension, T > &  end 
)

Returns the distance from a Point to a line segment described by two Points.

Definition at line 228 of file vectorutils.h.

References ClosestPointOnSegment(), and Distance().

template<int Dimension, typename T >
T ion::math::Dot ( const Vector< Dimension, T > &  v0,
const Vector< Dimension, T > &  v1 
)
template<typename T >
T ion::math::DoubleFactorial ( int  x)
inline

Returns the double factorial (!!) of x.

For odd x: 1 * 3 * 5 * ... * (x - 2) * x For even x: 2 * 4 * 6 * ... * (x - 2) * x If x < 0, it returns 0.

Definition at line 115 of file utils.h.

template<typename T >
T ion::math::Factorial ( int  x)
inline

Returns the factorial (!) of x.

If x < 0, it returns 0.

Definition at line 103 of file utils.h.

template<int Dimension, typename T >
Matrix<Dimension, T> ion::math::Inverse ( const Matrix< Dimension, T > &  m)
inline

Returns the inverse of the matrix.

This function is defined for all the typedef'ed Matrix types. If the determinant of the matrix is 0, the returned matrix has all zeroes.

Definition at line 150 of file matrixutils.h.

template<int Dimension, typename T >
ION_API Matrix<Dimension, T> ion::math::InverseWithDeterminant ( const Matrix< Dimension, T > &  m,
T determinant 
)

Returns the inverse of the matrix.

This function is defined for all the typedef'ed Matrix types. The determinant of the matrix is computed as a side effect, so it is returned in the determinant parameter if it is not NULL. If the determinant is 0, the returned matrix has all zeroes.

Definition at line 243 of file matrixutils.cc.

References AdjugateWithDeterminant(), and ion::math::Matrix< Dimension, T >::Zero().

template<int Dimension, typename T >
Matrix<Dimension, T> ion::math::InverseWithDeterminant ( const Matrix< Dimension, T > &  m,
T determinant 
)

Returns the inverse of the matrix.

This function is defined for all the typedef'ed Matrix types. The determinant of the matrix is computed as a side effect, so it is returned in the determinant parameter if it is not NULL. If the determinant is 0, the returned matrix has all zeroes.

Definition at line 243 of file matrixutils.cc.

References AdjugateWithDeterminant(), and ion::math::Matrix< Dimension, T >::Zero().

ion::math::ION_INSTANTIATE_FUNCTIONS ( double  )
ion::math::ION_INSTANTIATE_FUNCTIONS ( float  )
ion::math::ION_INSTANTIATE_ROTATION_FUNCTIONS ( double  )
ion::math::ION_INSTANTIATE_ROTATION_FUNCTIONS ( float  )
ion::math::ION_INSTANTIATE_VECTOR_TYPE ( VectorBase  )
ion::math::ION_INSTANTIATE_VECTOR_TYPE ( Vector  )
ion::math::ION_INSTANTIATE_VECTOR_TYPE ( Point  )
ion::math::ION_SPECIALIZE_MATRIX_FUNCS ( ,
float   
)
ion::math::ION_SPECIALIZE_MATRIX_FUNCS ( ,
double   
)
ion::math::ION_SPECIALIZE_MATRIX_FUNCS ( ,
float   
)
ion::math::ION_SPECIALIZE_MATRIX_FUNCS ( ,
double   
)
ion::math::ION_SPECIALIZE_MATRIX_FUNCS ( ,
float   
)
ion::math::ION_SPECIALIZE_MATRIX_FUNCS ( ,
double   
)
template<typename T >
bool ion::math::IsFinite ( T  x)
inline

Tests whether a numeric value is finite.

Definition at line 34 of file utils.h.

Referenced by IsVectorFinite().

bool ion::math::IsPowerOfTwo ( int  value)
inline

Returns true if a value is a power of two.

Definition at line 216 of file utils.h.

template<int Dimension, typename T >
bool ion::math::IsVectorFinite ( const VectorBase< Dimension, T > &  v)

Returns true if all components of VectorBase v are finite, otherwise false.

Definition at line 297 of file vectorutils.h.

References IsFinite().

template<int Dimension, typename T >
T ion::math::Length ( const Vector< Dimension, T > &  v)

Returns the geometric length of a Vector.

Definition at line 70 of file vectorutils.h.

References LengthSquared(), and Sqrt().

Referenced by Distance(), Normalize(), and Orthogonal().

template<int Dimension, typename T >
T ion::math::LengthSquared ( const Vector< Dimension, T > &  v)
template<typename T , typename U >
const U ion::math::Lerp ( const U &  begin,
const U &  end,
const T t 
)
inline

Linearly interpolates between two values.

T must have multiplication and addition operators defined. Performs extrapolation for t outside [0, 1].

Definition at line 211 of file utils.h.

template<typename T >
T ion::math::Log2 ( T  n)
inline

Returns the base-2 logarithm of n.

Definition at line 148 of file utils.h.

Referenced by ion::gfx::Texture::ExpectedDimensionsForMipmap(), and Log2().

template<>
uint32 ion::math::Log2 ( uint32  n)
inline

Specialize for integer types.

See http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious for details. These implementations are in the public domain.

Definition at line 156 of file utils.h.

template<>
int ion::math::Log2 ( int  n)
inline

Definition at line 170 of file utils.h.

References Log2().

template<>
uint64 ion::math::Log2 ( uint64  n)
inline

Definition at line 177 of file utils.h.

template<>
int64 ion::math::Log2 ( int64  n)
inline

Definition at line 194 of file utils.h.

References Log2().

template<typename T >
ION_API const Matrix< 4, T > ion::math::LookAtMatrixFromCenter ( const Point< 3, T > &  eye,
const Point< 3, T > &  center,
const Vector< 3, T > &  up 
)

View matrices.

Returns a 4x4 viewing matrix based on the given camera parameters, which follow the conventions of the old gluLookAt() function (eye aka camera points at center aka look_at with camera roll defined by up). If the parameters cannot form an orthonormal basis then this returns an identity matrix.

Definition at line 138 of file transformutils.cc.

References LookAtMatrixFromDir().

template<typename T >
ION_API const Matrix< 4, T > ion::math::LookAtMatrixFromDir ( const Point< 3, T > &  eye,
const Vector< 3, T > &  dir,
const Vector< 3, T > &  up 
)

Returns a 4x4 viewing matrix based on the given camera parameters, which use a view direction rather than look at center point.

If the parameters cannot form an orthonormal basis then this returns an identity matrix.

Definition at line 146 of file transformutils.cc.

References Cross(), DCHECK, DCHECK_GE, LengthSquared(), Normalized(), and TranslationMatrix().

Referenced by LookAtMatrixFromCenter().

template<int Dimension, typename T >
bool ion::math::MatrixAlmostOrthogonal ( const Matrix< Dimension, T > &  m,
T  tolerance 
)

Returns true if the dot product of all column vector pairs in the matrix is less than a provided tolerance, and if all column vectors have unit length.

Return false otherwise.

Definition at line 257 of file matrixutils.cc.

References Abs(), Column(), Dot(), and LengthSquared().

Referenced by OrthoInverseH().

template<int Dimension, typename T >
const Point<Dimension, T> ion::math::MaxBoundPoint ( const Point< Dimension, T > &  p0,
const Point< Dimension, T > &  p1 
)

Returns a Point in which each element is the maximum of the corresponding elements of two Points.

This is useful for computing bounding boxes.

Definition at line 187 of file vectorutils.h.

template<int Dimension, typename T >
const Point<Dimension, T> ion::math::MinBoundPoint ( const Point< Dimension, T > &  p0,
const Point< Dimension, T > &  p1 
)

Returns a Point in which each element is the minimum of the corresponding elements of two Points.

This is useful for computing bounding boxes.

Definition at line 176 of file vectorutils.h.

template<int Dimension, typename T1 , typename T2 >
const Range<Dimension, T1> ion::math::ModulateRange ( const Range< Dimension, T1 > &  r,
const Vector< Dimension, T2 >  modulation 
)

Modulate a Range by a Vector.

Each dimension of the Range is modulated by the corresponding dimension in the Vector. The modulation is done using the multiplication operator defined for the Vector, in the space of the Vector's type. For example, if an integral Range is scaled by a floating point Vector, the modulation will occur using floating point multiply. If any factor is not positive, this returns an empty Range.

Definition at line 149 of file rangeutils.h.

References ion::math::Range< Dimension, T >::GetMaxPoint(), ion::math::Range< Dimension, T >::GetMinPoint(), and ion::math::Range< Dimension, T >::IsEmpty().

uint32 ion::math::NextPowerOf2 ( uint32  n)
inline

Returns the next power of 2 greater than or equal to n.

This works only for unsigned 32-bit or 64-bit integers.

Definition at line 124 of file utils.h.

uint64 ion::math::NextPowerOf2 ( uint64  n)
inline

Definition at line 134 of file utils.h.

template<typename T >
Matrix<3, T> ion::math::NonhomogeneousSubmatrixH ( const Matrix< 4, T > &  m)
inline

Homogeneous matrices.

Returns the upper left 3x3 matrix of a homogeneous 4x4 matrix.

Definition at line 118 of file transformutils.h.

Referenced by OrthoInverseH().

template<int Dimension, typename T >
bool ion::math::Normalize ( Vector< Dimension, T > *  v)

Normalizes a Vector to unit length.

If the vector has no length, this leaves the Vector untouched and returns false.

Definition at line 90 of file vectorutils.h.

References DCHECK, and Length().

Referenced by Normalized(), and ion::math::Rotation< T >::SetAxisAndAngle().

template<int Dimension, typename T >
const Vector<Dimension, T> ion::math::Normalized ( const Vector< Dimension, T > &  v)

Returns a unit-length version of a Vector.

If the given Vector has no length, this returns a Zero() Vector.

Definition at line 104 of file vectorutils.h.

References Normalize(), and ion::math::Vector< Dimension, T >::Zero().

Referenced by LookAtMatrixFromDir(), Orthonormal(), Rescale(), ion::math::Rotation< T >::SetQuaternion(), and ion::math::Rotation< T >::Slerp().

template<int Dimension, typename T >
T ion::math::NVolume ( const Range< Dimension, T > &  r)

Returns the NVolume of a Range, which is the product of its sizes in all dimensions.

Returns 0 if the Range is empty.

Definition at line 69 of file rangeutils.h.

References ion::math::Range< Dimension, T >::GetSize(), and ion::math::Range< Dimension, T >::IsEmpty().

template<int Dimension, typename T >
const Vector<Dimension, T> ion::math::operator* ( const Matrix< Dimension+1, T > &  m,
const Vector< Dimension, T > &  v 
)

Transforming vectors and points.

Multiplies a Matrix and a column Vector of one smaller Dimension (the template parameter) to produce another column Vector. This assumes the homogeneous coordinate of the Vector is 0, so any translation component of the Matrix is ignored.

Definition at line 60 of file transformutils.h.

References ion::math::Vector< Dimension, T >::Zero().

template<int Dimension, typename T >
const Point<Dimension, T> ion::math::operator* ( const Matrix< Dimension+1, T > &  m,
const Point< Dimension, T > &  p 
)

Multiplies a Matrix and a Point of one smaller Dimension (the template parameter) to produce another Point.

This assumes the homogeneous coordinate of the Point is and stays 1 after the transformation. Thus this will include translation. but not divide by the homogeneous coordinate; use ProjectPoint(), below, for general projections.

Definition at line 76 of file transformutils.h.

References ion::math::Point< Dimension, T >::Zero().

template<int Dimension, typename T >
Vector<Dimension, T> ion::math::operator* ( const Matrix< Dimension, T > &  m,
const Vector< Dimension, T > &  v 
)
inline

Multiplies a Matrix and a column Vector of the same Dimension to produce another column Vector.

Definition at line 77 of file matrixutils.h.

References ion::math::internal::MultiplyMatrixAndVector().

template<int Dimension, typename T >
Point<Dimension, T> ion::math::operator* ( const Matrix< Dimension, T > &  m,
const Point< Dimension, T > &  p 
)
inline

Multiplies a Matrix and a Point of the same Dimension to produce another Point.

Definition at line 85 of file matrixutils.h.

References ion::math::internal::MultiplyMatrixAndVector().

template<typename T >
std::ostream& ion::math::operator<< ( std::ostream &  out,
const Angle< T > &  a 
)

An Angle is streamed as degrees.

Definition at line 130 of file angle.h.

template<int Dimension, typename T >
std::ostream& ion::math::operator<< ( std::ostream &  out,
const Matrix< Dimension, T > &  m 
)

Prints a Matrix to a stream.

Definition at line 149 of file matrix.h.

template<typename T >
std::ostream& ion::math::operator<< ( std::ostream &  out,
const Rotation< T > &  a 
)

Prints a Rotation to a stream.

Definition at line 185 of file rotation.h.

template<int Dimension, typename T >
std::ostream& ion::math::operator<< ( std::ostream &  out,
const Range< Dimension, T > &  r 
)

Prints a Range to a stream.

Definition at line 220 of file range.h.

template<int Dimension, typename T >
std::ostream& ion::math::operator<< ( std::ostream &  out,
const Vector< Dimension, T > &  v 
)

Prints a Vector to a stream.

Definition at line 276 of file vector.h.

References ion::math::VectorBase< Dimension, T >::Print().

template<int Dimension, typename T >
std::ostream& ion::math::operator<< ( std::ostream &  out,
const Point< Dimension, T > &  p 
)

Prints a Point to a stream.

Definition at line 400 of file vector.h.

template<typename T >
std::ostream& ion::math::operator<< ( std::ostream &  out,
const FieldOfView< T > &  f 
)
inline

Definition at line 464 of file fieldofview.h.

References ion::math::FieldOfView< T >::Print().

template<typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
Range1TWrapper< T, 0 > &  w 
)

Definition at line 61 of file range.h.

References ion::math::Range1TWrapper< T, N >::t.

template<typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
Angle< T > &  a 
)
template<int Dimension, typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
Matrix< Dimension, T > &  m 
)

Reads a Matrix from a stream.

Definition at line 165 of file matrix.h.

References ion::base::GetExpectedChar(), and ion::base::GetExpectedString().

template<typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
Rotation< T > &  a 
)
template<int Dimension, typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
Range< Dimension, T > &  r 
)

Reads a Range from a stream.

Definition at line 229 of file range.h.

References ion::base::GetExpectedChar(), ion::base::GetExpectedString(), and ion::math::Range< Dimension, T >::Set().

template<int Dimension, typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
Vector< Dimension, T > &  v 
)

Reads a Vector from a stream.

Definition at line 283 of file vector.h.

template<int Dimension, typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
Point< Dimension, T > &  v 
)

Reads a Point from a stream.

Definition at line 407 of file vector.h.

template<typename T >
std::istream& ion::math::operator>> ( std::istream &  in,
FieldOfView< T > &  f 
)
inline

Definition at line 471 of file fieldofview.h.

References ion::math::FieldOfView< T >::Read().

template<typename T >
const Vector<2, T> ion::math::Orthogonal ( const Vector< 2, T > &  v)

Returns an unnormalized Vector2 that is orthonormal to the passed one.

If the passed vector has length 0, then a zero-length vector is returned.

Definition at line 115 of file vectorutils.h.

Referenced by Orthonormal().

template<typename T >
const Vector<3, T> ion::math::Orthogonal ( const Vector< 3, T > &  v)

Returns an unnormalized Vector3 that is orthonormal to the passed one.

If the passed vector has length 0, then a zero-length vector is returned. The returned vector is not guaranteed to be in any particular direction, just that it is perpendicular to v.

Definition at line 124 of file vectorutils.h.

References Cross(), and Length().

template<typename T >
ION_API const Matrix< 4, T > ion::math::OrthographicMatrixFromFrustum ( T  x_left,
T  x_right,
T  y_bottom,
T  y_top,
T  z_near,
T  z_far 
)

Projection matrices.

Returns a 4x4 orthographic projection matrix based on the given parameters, which follow the conventions of the old glOrtho() function. If there are any problems with the parameters (such as 0 sizes in any dimension), this returns an identity matrix.

Definition at line 170 of file transformutils.cc.

References ion::math::Matrix< Dimension, T >::Identity().

template<typename T >
const Matrix< 4, T > ion::math::OrthoInverseH ( const Matrix< 4, T > &  m)

Public functions.

Returns the inverse of m iff m is orthogonal.

Triggers a DCHECK otherwise. This function is much faster than the regular Inverse function as it only performs one matrix-vector multiplication and a few element permutations.

Definition at line 89 of file transformutils.cc.

References DCHECK, MatrixAlmostOrthogonal(), NonhomogeneousSubmatrixH(), Row(), translation, Transpose(), and VectorsAlmostEqual().

template<int Dimension, typename T >
const Vector<Dimension, T> ion::math::Orthonormal ( const Vector< Dimension, T > &  v)

Returns a normalized Vector that is orthonormal to the passed one.

If the passed vector has length 0, then a zero-length vector is returned. The returned vector is not guaranteed to be in any particular direction, just that it is perpendicular to v.

Definition at line 140 of file vectorutils.h.

References Normalized(), and Orthogonal().

template<typename T >
ION_API const Matrix< 4, T > ion::math::PerspectiveMatrixFromFrustum ( T  x_left,
T  x_right,
T  y_bottom,
T  y_top,
T  z_near,
T  z_far 
)

Returns a 4x4 perspective projection matrix based on the given parameters, which follow the conventions of the old glFrustum() function.

If there are any problems with the parameters (such as 0 sizes in any dimension or non-positive near or far values), this returns an identity matrix.

Definition at line 190 of file transformutils.cc.

References ion::math::Matrix< Dimension, T >::Identity().

Referenced by ion::math::FieldOfView< T >::GetProjectionMatrix().

template<typename T >
ION_API const Matrix< 4, T > ion::math::PerspectiveMatrixFromView ( const Angle< T > &  fovy,
T  aspect,
T  z_near,
T  z_far 
)

Returns a 4x4 perspective projection matrix based on the given parameters, which follow the conventions of the gluPerspective() function.

If there are any problems with the parameters (such as non-positive values or z_near equal to z_far), this returns an identity matrix.

Definition at line 212 of file transformutils.cc.

References ion::math::Matrix< Dimension, T >::Identity(), ion::math::Angle< T >::Radians(), and Tangent().

template<typename T >
ION_API const Matrix<4, T> ion::math::PerspectiveMatrixInverse ( const Matrix< 4, T > &  m)

Returns the inverse of m iff m is a perspective projection matrix, i.e., iff it has the following form:

[X 0 A 0]
[0 Y B 0]
[0 0 C D]
[0 0 -1 0]

Triggers a DCHECK otherwise.

This function is much faster than the regular Inverse function as it requires only three divisions and three multiplications.

Definition at line 230 of file transformutils.cc.

References DCHECK_LE.

template<typename T >
const Matrix<4, T> ion::math::PerspectiveMatrixInverse ( const Matrix< 4, T > &  m)

Returns the inverse of m iff m is a perspective projection matrix, i.e., iff it has the following form:

[X 0 A 0]
[0 Y B 0]
[0 0 C D]
[0 0 -1 0]

Triggers a DCHECK otherwise.

This function is much faster than the regular Inverse function as it requires only three divisions and three multiplications.

Definition at line 230 of file transformutils.cc.

References DCHECK_LE.

template<int Dimension, typename T >
bool ion::math::PointsAlmostEqual ( const Point< Dimension, T > &  v0,
const Point< Dimension, T > &  v1,
T  tolerance 
)

Returns true if all elements of two Points are equal within a tolerance.

Definition at line 236 of file vectorutils.h.

References Abs().

template<int Dimension, typename T >
const Vector<Dimension, T> ion::math::Projection ( const Vector< Dimension, T > &  v,
const Vector< Dimension, T > &  onto_v 
)

Returns the Vector resulting from projecting of one Vector onto another.

This will return a Zero() Vector if onto_v has zero length.

Definition at line 147 of file vectorutils.h.

References Dot(), and LengthSquared().

template<int Dimension, typename T >
const Point<Dimension, T> ion::math::ProjectPoint ( const Matrix< Dimension+1, T > &  m,
const Point< Dimension, T > &  p 
)

Multiplies a Matrix and a Point of one smaller Dimension (the template parameter) to produce another Point and projects it by dividing by the homogeneous coordinate.

This assumes that the input Point has a homogeneous coordinate of 1.

Definition at line 92 of file transformutils.h.

References ion::math::Point< Dimension, T >::Zero().

template<int Dimension, typename T >
const Range<Dimension, T> ion::math::RangeIntersection ( const Range< Dimension, T > &  r0,
const Range< Dimension, T > &  r1 
)

Returns the intersection of two Range instances.

If either Range is empty, this returns an empty range. Otherwise, it returns the largest Range contained by both.

Definition at line 48 of file rangeutils.h.

References ion::math::Range< Dimension, T >::GetMaxPoint(), ion::math::Range< Dimension, T >::GetMinPoint(), and ion::math::Range< Dimension, T >::IsEmpty().

template<int Dimension, typename T >
bool ion::math::RangesAlmostEqual ( const Range< Dimension, T > &  r0,
const Range< Dimension, T > &  r1,
const T  threshold 
)

Returns true if all dimensions of the two ranges are equal within the threshold.

Definition at line 85 of file rangeutils.h.

References Abs(), ion::math::Range< Dimension, T >::GetMaxPoint(), ion::math::Range< Dimension, T >::GetMinPoint(), and ion::math::Range< Dimension, T >::IsEmpty().

template<int Dimension, typename T >
const Range<Dimension, T> ion::math::RangeUnion ( const Range< Dimension, T > &  r0,
const Range< Dimension, T > &  r1 
)

Returns the union of two Range instances.

If either Range is empty, this returns the other range. Otherwise, it returns the smallest Range containing both.

Definition at line 37 of file rangeutils.h.

References ion::math::Range< Dimension, T >::ExtendByRange().

template<int Dimension, typename T >
const Vector<Dimension, T> ion::math::Rescale ( const Vector< Dimension, T > &  v,
T  length 
)

Returns a Vector in the same direction as the passed vector but with the passed length.

If the input vector has zero length, however, then the returned vector also has zero length.

Definition at line 158 of file vectorutils.h.

References length, and Normalized().

template<typename T >
const Matrix<4, T> ion::math::RotationMatrixAxisAngleH ( const Vector< 3, T > &  axis,
const Angle< T > &  angle 
)

Returns a 4x4 Matrix representing a 3D rotation specified as axis and angle.

This creates a Matrix that works with homogeneous coordinates, so the function name ends in "H".

Definition at line 196 of file transformutils.h.

References RotationMatrixH().

template<typename T >
const Matrix<3, T> ion::math::RotationMatrixAxisAngleNH ( const Vector< 3, T > &  axis,
const Angle< T > &  angle 
)

Returns a 3x3 Matrix representing a 3D rotation specified as axis and angle.

This creates a Matrix that does not work with homogeneous coordinates, so the function name ends in "NH".

Definition at line 205 of file transformutils.h.

References RotationMatrixNH().

template<typename T >
ION_API const Matrix< 4, T > ion::math::RotationMatrixH ( const Rotation< T > &  r)

Returns a 4x4 Matrix representing a 3D rotation.

This creates a Matrix that works with homogeneous coordinates, so the function name ends in "H".

Definition at line 121 of file transformutils.cc.

Referenced by RotationMatrixAxisAngleH().

template<typename T >
ION_API const Matrix< 3, T > ion::math::RotationMatrixNH ( const Rotation< T > &  r)

Returns a 3x3 Matrix representing a 3D rotation.

This creates a Matrix that does not work with homogeneous coordinates, so the function name ends in "NH".

Definition at line 131 of file transformutils.cc.

Referenced by RotationMatrixAxisAngleNH().

template<int Dimension, typename T >
Vector<Dimension, T> ion::math::Row ( const Matrix< Dimension, T > &  m,
int  row 
)

Returns a particular row of a matrix as a vector.

Definition at line 92 of file matrixutils.h.

Referenced by OrthoInverseH().

template<int Dimension, typename T >
const Matrix<Dimension + 1, T> ion::math::ScaleMatrixH ( const Vector< Dimension, T > &  s)

Returns a Matrix representing a scale by the factors in a Vector whose Dimension is one less than the Dimension of the Matrix.

This creates a Matrix that works with homogeneous coordinates, so the function name ends in "H".

Definition at line 155 of file transformutils.h.

template<int Dimension, typename T >
const Matrix<Dimension, T> ion::math::ScaleMatrixNH ( const Vector< Dimension, T > &  s)

Returns a Matrix representing a scale by the factors in a Vector, which is the same Dimension as the Matrix.

This creates a Matrix that does not work with homogeneous coordinates, so the function name ends in "NH".

Definition at line 172 of file transformutils.h.

template<int Dimension, typename T >
const Range<Dimension, T> ion::math::ScaleRange ( const Range< Dimension, T > &  r,
T  scale_factor 
)

Returns a Range that is the input Range scaled uniformly about its center by the given factor.

If the factor is not positive, this returns an empty Range.

Definition at line 107 of file rangeutils.h.

References ion::math::Range< Dimension, T >::GetCenter(), ion::math::Range< Dimension, T >::GetMaxPoint(), ion::math::Range< Dimension, T >::GetMinPoint(), and ion::math::Range< Dimension, T >::IsEmpty().

template<int Dimension, typename T >
const Range<Dimension, T> ion::math::ScaleRangeNonUniformly ( const Range< Dimension, T > &  r,
const Vector< Dimension, T scale_factors 
)

Returns a Range that is the input Range scaled nonuniformly about its center by the given per-dimension factors.

If any factor is not positive, this returns an empty Range.

Definition at line 123 of file rangeutils.h.

References ion::math::Range< Dimension, T >::GetCenter(), ion::math::Range< Dimension, T >::GetMaxPoint(), ion::math::Range< Dimension, T >::GetMinPoint(), ion::math::Range< Dimension, T >::IsEmpty(), and ion::math::VectorBase< Dimension, T >::Set().

template<typename T >
T ion::math::Sine ( T  angle)
inline

Returns the sine of the given value.

Definition at line 80 of file utils.h.

template<>
float ion::math::Sine ( float  angle)
inline

float specialization of Sine.

Definition at line 85 of file utils.h.

template<typename T >
T ion::math::Sine ( const ion::math::Angle< T > &  angle)
inline
template<typename T >
T ion::math::Sqrt ( const T val)
inline

Returns the square root of a value.

There is no standard version of sqrt() for integer types, resulting in ambiguity problems when an integer is passed to it. This is especially annoying in template functions. The Sqrt() function is specialized to avoid these problems.

Definition at line 59 of file utils.h.

Referenced by ion::math::Rotation< T >::FromRotationMatrix(), ion::analytics::Benchmark::VariableAccumulator::Get(), ion::math::Rotation< T >::GetAxisAndAngle(), Length(), and ion::math::Rotation< T >::RotateInto().

template<>
float ion::math::Sqrt ( const float &  val)
inline

Definition at line 63 of file utils.h.

template<typename T >
const T ion::math::Square ( const T val)
inline

Squares a value.

Definition at line 48 of file utils.h.

Referenced by ion::math::Rotation< T >::GetAxisAndAngle().

template<int InDimension, int OutDimension, typename T >
bool ion::math::Swizzle ( const VectorBase< InDimension, T > &  input,
const char *  swizzle_string,
VectorBase< OutDimension, T > *  output 
)

Computes the result of swizzling a Vector or Point (or anything else derived from VectorBase).

The swizzle_string determines the contents of the output vector. Each character in the string must be one of {x,y,z,w} or {r,g,b,a} or {s,t,p,q}, upper- or lower-case, specifying a component of the input vector. Extra components in the string are ignored; missing components in the string result in an error. This returns false on error.

For example: Vec3d v3(1.0, 2.0, 3.0); Vec2d v2; Vec4d v4; Swizzle(v3, "xz", &v2); ///< v2 is set to (1.0, 3.0). Swizzle(v3, "BBYX", &v4); ///< v4 is set to (3.0, 3.0, 2.0, 1.0). Swizzle(v3, "xyz", &v2); ///< v2 is set to (1.0, 2.0); 'z' is ignored. Swizzle(v3, "xw", &v2); ///< Returns false: v3 has no "w" component. Swizzle(v3, "x", &v2); ///< Returns false: string is missing a component.

Definition at line 262 of file vectorutils.h.

template<typename T >
T ion::math::Tangent ( T  angle)
inline

Returns the tangent of the given value.

Definition at line 91 of file utils.h.

template<typename T >
T ion::math::Tangent ( const ion::math::Angle< T > &  angle)
inline

ion::math::Angle specialization of Tangent.

Definition at line 92 of file angleutils.h.

References ion::math::Angle< T >::Radians().

Referenced by PerspectiveMatrixFromView().

template<>
float ion::math::Tangent ( float  angle)
inline

float specialization of Tangent.

Definition at line 96 of file utils.h.

template<int Dimension, typename T >
const Matrix<Dimension + 1, T> ion::math::TranslationMatrix ( const VectorBase< Dimension, T > &  t)

Affine transformation matrices.

Returns a Matrix that represents a translation by a Vector or Point. The Dimension template parameter (which is the dimension of the Vector or Point) is one less than the dimension of the matrix, meaning the matrix has homogeneous coordinates.

Definition at line 141 of file transformutils.h.

Referenced by LookAtMatrixFromDir().

template<int Dimension, typename T >
Matrix<Dimension, T> ion::math::Transpose ( const Matrix< Dimension, T > &  m)

Public functions.

Returns the transpose of a matrix.

Definition at line 65 of file matrixutils.h.

Referenced by OrthoInverseH().

template<int Dimension, typename T >
bool ion::math::VectorsAlmostEqual ( const Vector< Dimension, T > &  v0,
const Vector< Dimension, T > &  v1,
T  tolerance 
)

Returns true if all elements of two Vectors are equal within a tolerance.

Definition at line 164 of file vectorutils.h.

References Abs().

Referenced by OrthoInverseH().