OGRE  1.12.13
Object-Oriented Graphics Rendering Engine
Math

Classes

class  Ogre::Affine3
 Transform specialization for 3D Affine - encapsulating a 3x4 Matrix. More...
 
class  Ogre::Angle
 Wrapper class which identifies a value as the currently default angle type, as defined by Math::setAngleUnit. More...
 
class  Ogre::AxisAlignedBox
 A 3D box aligned with the x/y/z axes. More...
 
class  Ogre::Bitwise
 Class for manipulating bit patterns. More...
 
class  Ogre::ConvexBody
 Holds a solid representation of a convex body. More...
 
class  Ogre::Degree
 Wrapper class which indicates a given angle value is in Degrees. More...
 
class  Ogre::DualQuaternion
 Implementation of a dual quaternion, i.e. More...
 
class  Ogre::EdgeData
 This class contains the information required to describe the edge connectivity of a given set of vertices and indexes. More...
 
class  Ogre::EdgeListBuilder
 General utility class for building edge lists for geometry. More...
 
class  Ogre::Math
 Class to provide access to common mathematical functions. More...
 
class  Ogre::Matrix3
 A 3x3 matrix which can represent rotations around axes. More...
 
class  Ogre::Matrix4
 Transform specialization for projective - encapsulating a 4x4 Matrix. More...
 
class  Ogre::NumericSolver
 Provides numeric solvers for Ogre. More...
 
class  Ogre::OptimisedUtil
 Utility class for provides optimised functions. More...
 
class  Ogre::Plane
 Defines a plane in 3D space. More...
 
class  Ogre::PlaneBoundedVolume
 Represents a convex volume bounded by planes. More...
 
class  Ogre::Polygon
 The class represents a polygon in 3D space. More...
 
class  Ogre::Quaternion
 Implementation of a Quaternion, i.e. More...
 
class  Ogre::Radian
 Wrapper class which indicates a given angle value is in Radians. More...
 
class  Ogre::Ray
 Representation of a ray in space, i.e. More...
 
class  Ogre::RotationalSpline
 This class interpolates orientations (rotations) along a spline using derivatives of quaternions. More...
 
class  Ogre::SimpleSpline
 A very simple spline class which implements the Catmull-Rom class of splines. More...
 
class  Ogre::Sphere
 A sphere primitive, mostly used for bounds checking. More...
 
class  Ogre::TangentSpaceCalc
 Class for calculating a tangent space basis. More...
 
class  Ogre::TransformBase< rows, T >
 Class encapsulating a standard 4x4 homogeneous matrix. More...
 
struct  Ogre::TransformBaseReal
 
class  Ogre::Vector< dims, T >
 Standard N-dimensional vector. More...
 
struct  Ogre::VectorBase< dims, T >
 helper class to implement legacy API. Notably x, y, z access More...
 
struct  Ogre::VectorBase< 2, Real >
 
struct  Ogre::VectorBase< 3, Real >
 
struct  Ogre::VectorBase< 4, Real >
 

Typedefs

typedef std::vector< PlaneBoundedVolumeOgre::PlaneBoundedVolumeList
 
typedef std::vector< PlaneOgre::PlaneList
 
typedef std::pair< bool, RealOgre::RayTestResult
 A pair structure where the first element indicates whether an intersection occurs. More...
 

Functions

 Ogre::Radian::Radian (const Degree &d)
 
template<class T >
static void Ogre::advanceRawPointer (const T *&ptr, ptrdiff_t offset)
 Advance the pointer with raw offset. More...
 
template<class T >
static void Ogre::advanceRawPointer (T *&ptr, ptrdiff_t offset)
 
Radian Ogre::VectorBase< 2, Real >::angleTo (const Vector2 &other) const
 Gets the oriented angle between 2 vectors. More...
 
static Vector3 Ogre::Math::calculateBasicFaceNormal (const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
 Calculate a face normal, no w-information. More...
 
static Vector3 Ogre::Math::calculateBasicFaceNormalWithoutNormalize (const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
 Calculate a face normal without normalize, no w-information. More...
 
static Vector4 Ogre::Math::calculateFaceNormal (const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
 Calculate a face normal, including the w component which is the offset from the origin. More...
 
static Vector4 Ogre::Math::calculateFaceNormalWithoutNormalize (const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
 Calculate a face normal without normalize, including the w component which is the offset from the origin. More...
 
Vector3 Ogre::VectorBase< 3, Real >::crossProduct (const Vector3 &rkVector) const
 Calculates the cross-product of 2 vectors, i.e. More...
 
bool Ogre::VectorBase< 3, Real >::directionEquals (const Vector3 &rhs, const Radian &tolerance) const
 Returns whether this vector is within a directional tolerance of another vector. More...
 
Quaternion Ogre::VectorBase< 3, Real >::getRotationTo (const Vector3 &dest, const Vector3 &fallbackAxis=ZERO) const
 Gets the shortest arc quaternion to rotate this vector to the destination vector. More...
 
static bool Ogre::Math::intersects (const Plane &plane, const AxisAlignedBox &box)
 Plane / box intersection test. More...
 
static RayTestResult Ogre::Math::intersects (const Ray &ray, const Plane &plane)
 Ray / plane intersection. More...
 
static RayTestResult Ogre::Math::intersects (const Ray &ray, const Sphere &sphere, bool discardInside=true)
 Ray / sphere intersection. More...
 
static bool Ogre::Math::intersects (const Sphere &sphere, const Plane &plane)
 Sphere / plane intersection test. More...
 
static Matrix3 Ogre::Math::lookRotation (const Vector3 &direction, const Vector3 &yaw)
 Create a rotation matrix from direction and yaw. More...
 
Vector2 Ogre::VectorBase< 2, Real >::midPoint (const Vector2 &vec) const
 Returns a vector at a point half way between this and the passed in vector. More...
 
Vector3 Ogre::VectorBase< 3, Real >::midPoint (const Vector3 &vec) const
 Returns a vector at a point half way between this and the passed in vector. More...
 
 Ogre::Angle::operator Degree () const
 
 Ogre::Angle::operator Radian () const
 
Affine3 Ogre::operator* (const Affine3 &m, const Affine3 &m2)
 
Vector3 Ogre::operator* (const Affine3 &m, const Vector3 &v)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
Vector4 Ogre::operator* (const Affine3 &m, const Vector4 &v)
 
Vector3 Ogre::operator* (const Matrix3 &m, const Vector3 &v)
 Matrix * vector [3x3 * 3x1 = 3x1]. More...
 
Matrix4 Ogre::operator* (const Matrix4 &m, const Matrix4 &m2)
 
Vector3 Ogre::operator* (const Matrix4 &m, const Vector3 &v)
 Vector transformation using '*'. More...
 
Vector4 Ogre::operator* (const Matrix4 &m, const Vector4 &v)
 
Plane Ogre::operator* (const Matrix4 &mat, const Plane &p)
 
Vector4 Ogre::operator* (const Vector4 &v, const Matrix4 &mat)
 
Degree Ogre::operator* (float a, const Degree &b)
 
Radian Ogre::operator* (float a, const Radian &b)
 
Radian Ogre::Radian::operator+ (const Degree &d) const
 
Matrix4 Ogre::operator+ (const Matrix4 &m, const Matrix4 &m2)
 Matrix addition. More...
 
RadianOgre::Radian::operator+= (const Degree &d)
 
Radian Ogre::Radian::operator- (const Degree &d) const
 
Matrix4 Ogre::operator- (const Matrix4 &m, const Matrix4 &m2)
 Matrix subtraction. More...
 
RadianOgre::Radian::operator-= (const Degree &d)
 
Degree Ogre::operator/ (float a, const Degree &b)
 
Radian Ogre::operator/ (float a, const Radian &b)
 
RadianOgre::Radian::operator= (const Degree &d)
 
Vector2 Ogre::VectorBase< 2, Real >::perpendicular (void) const
 Generates a vector perpendicular to this vector (eg an 'up' vector). More...
 
Vector3 Ogre::VectorBase< 3, Real >::perpendicular (void) const
 Generates a vector perpendicular to this vector (eg an 'up' vector). More...
 
bool Ogre::VectorBase< 3, Real >::positionCloses (const Vector3 &rhs, Real tolerance=1e-03f) const
 Returns whether this vector is within a positional tolerance of another vector, also take scale of the vectors into account. More...
 
const Vector3Ogre::VectorBase< 3, Real >::primaryAxis () const
 Extract the primary (dominant) axis from this direction vector. More...
 
Vector3 Ogre::VectorBase< 3, Real >::randomDeviant (const Radian &angle, const Vector3 &up=ZERO) const
 Generates a new random vector which deviates from this vector by a given angle in a random direction. More...
 
Vector2 Ogre::VectorBase< 2, Real >::randomDeviant (Radian angle) const
 Generates a new random vector which deviates from this vector by a given angle in a random direction. More...
 
template<class T >
static const T * Ogre::rawOffsetPointer (const T *ptr, ptrdiff_t offset)
 Returns raw offseted of the given pointer. More...
 
template<class T >
static T * Ogre::rawOffsetPointer (T *ptr, ptrdiff_t offset)
 
Matrix4 Ogre::TransformBaseReal::transpose () const
 
float Ogre::Radian::valueAngleUnits () const
 
float Ogre::Degree::valueAngleUnits () const
 
float Ogre::Radian::valueDegrees () const
 
float Ogre::Degree::valueRadians () const
 

Detailed Description

Typedef Documentation

◆ RayTestResult

typedef std::pair<bool, Real> Ogre::RayTestResult

A pair structure where the first element indicates whether an intersection occurs.

if true, the second element will indicate the distance along the ray at which it intersects. This can be converted to a point in space by calling Ray::getPoint().

◆ PlaneList

typedef std::vector<Plane> Ogre::PlaneList

◆ PlaneBoundedVolumeList

Function Documentation

◆ operator*() [1/11]

Radian Ogre::operator* ( float  a,
const Radian b 
)
inline

◆ operator/() [1/2]

Radian Ogre::operator/ ( float  a,
const Radian b 
)
inline

◆ operator*() [2/11]

Degree Ogre::operator* ( float  a,
const Degree b 
)
inline

◆ operator/() [2/2]

Degree Ogre::operator/ ( float  a,
const Degree b 
)
inline

◆ operator*() [3/11]

Vector3 Ogre::operator* ( const Matrix3 m,
const Vector3 v 
)
inline

Matrix * vector [3x3 * 3x1 = 3x1].

◆ operator*() [4/11]

Matrix4 Ogre::operator* ( const Matrix4 m,
const Matrix4 m2 
)
inline

◆ operator+() [1/2]

Matrix4 Ogre::operator+ ( const Matrix4 m,
const Matrix4 m2 
)
inline

Matrix addition.

◆ operator-() [1/2]

Matrix4 Ogre::operator- ( const Matrix4 m,
const Matrix4 m2 
)
inline

Matrix subtraction.

◆ operator*() [5/11]

Affine3 Ogre::operator* ( const Affine3 m,
const Affine3 m2 
)
inline

◆ operator*() [6/11]

Vector3 Ogre::operator* ( const Matrix4 m,
const Vector3 v 
)
inline

Vector transformation using '*'.

Remarks
Transforms the given 3-D vector by the matrix, projecting the result back into w = 1.
Note
This means that the initial w is considered to be 1.0, and then all the tree elements of the resulting 3-D vector are divided by the resulting w.

◆ operator*() [7/11]

Vector3 Ogre::operator* ( const Affine3 m,
const Vector3 v 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator*() [8/11]

Vector4 Ogre::operator* ( const Matrix4 m,
const Vector4 v 
)
inline

◆ operator*() [9/11]

Vector4 Ogre::operator* ( const Affine3 m,
const Vector4 v 
)
inline

◆ operator*() [10/11]

Vector4 Ogre::operator* ( const Vector4 v,
const Matrix4 mat 
)
inline

◆ rawOffsetPointer() [1/2]

template<class T >
static const T* Ogre::rawOffsetPointer ( const T *  ptr,
ptrdiff_t  offset 
)
inlinestatic

Returns raw offseted of the given pointer.

Note
The offset are in bytes, no matter what type of the pointer.

Referenced by Ogre::advanceRawPointer().

◆ rawOffsetPointer() [2/2]

template<class T >
static T* Ogre::rawOffsetPointer ( T *  ptr,
ptrdiff_t  offset 
)
inlinestatic

◆ advanceRawPointer() [1/2]

template<class T >
static void Ogre::advanceRawPointer ( const T *&  ptr,
ptrdiff_t  offset 
)
inlinestatic

Advance the pointer with raw offset.

Note
The offset are in bytes, no matter what type of the pointer.

References Ogre::rawOffsetPointer().

◆ advanceRawPointer() [2/2]

template<class T >
static void Ogre::advanceRawPointer ( T *&  ptr,
ptrdiff_t  offset 
)
inlinestatic

◆ operator*() [11/11]

◆ Radian()

Ogre::Radian::Radian ( const Degree d)
inline

◆ operator=()

Radian & Ogre::Radian::operator= ( const Degree d)
inline

◆ operator+() [2/2]

Radian Ogre::Radian::operator+ ( const Degree d) const
inline

◆ operator+=()

Radian & Ogre::Radian::operator+= ( const Degree d)
inline

◆ operator-() [2/2]

Radian Ogre::Radian::operator- ( const Degree d) const
inline

◆ operator-=()

Radian & Ogre::Radian::operator-= ( const Degree d)
inline

◆ valueDegrees()

◆ valueAngleUnits() [1/2]

float Ogre::Radian::valueAngleUnits ( ) const
inline

◆ valueRadians()

◆ valueAngleUnits() [2/2]

float Ogre::Degree::valueAngleUnits ( ) const
inline

◆ operator Radian()

Ogre::Angle::operator Radian ( ) const
inline

◆ operator Degree()

Ogre::Angle::operator Degree ( ) const
inline

◆ lookRotation()

Matrix3 Ogre::Math::lookRotation ( const Vector3 direction,
const Vector3 yaw 
)
inlinestatic

Create a rotation matrix from direction and yaw.

Parameters
directionthe direction to look in. Must be normalised.
yawthe yaw axis to use

References Ogre::Matrix3::FromAxes(), and Ogre::Vector< dims, T >::normalisedCopy().

◆ transpose()

Matrix4 Ogre::TransformBaseReal::transpose ( ) const
inline

Referenced by Ogre::operator*().

◆ intersects() [1/4]

bool Ogre::Math::intersects ( const Plane plane,
const AxisAlignedBox box 
)
inlinestatic

Plane / box intersection test.

References Ogre::Plane::BOTH_SIDE, and Ogre::Plane::getSide().

◆ intersects() [2/4]

RayTestResult Ogre::Math::intersects ( const Ray ray,
const Plane plane 
)
inlinestatic

◆ intersects() [3/4]

RayTestResult Ogre::Math::intersects ( const Ray ray,
const Sphere sphere,
bool  discardInside = true 
)
inlinestatic

Ray / sphere intersection.

References Ogre::Ray::intersects().

◆ intersects() [4/4]

bool Ogre::Math::intersects ( const Sphere sphere,
const Plane plane 
)
inlinestatic

Sphere / plane intersection test.

Remarks
NB just do a plane.getDistance(sphere.getCenter()) for more detail!

References Ogre::Sphere::intersects().

◆ midPoint() [1/2]

Vector2 Ogre::VectorBase< 2, Real >::midPoint ( const Vector2 vec) const
inline

Returns a vector at a point half way between this and the passed in vector.

◆ randomDeviant() [1/2]

Vector2 Ogre::VectorBase< 2, Real >::randomDeviant ( Radian  angle) const
inline

Generates a new random vector which deviates from this vector by a given angle in a random direction.

Remarks
This method assumes that the random number generator has already been seeded appropriately.
Parameters
angleThe angle at which to deviate in radians
Returns
A random vector which deviates from this vector by angle. This vector will not be normalised, normalise it if you wish afterwards.

References Ogre::Math::Cos(), Ogre::Math::RangeRandom(), and Ogre::Math::Sin().

◆ angleTo()

Radian Ogre::VectorBase< 2, Real >::angleTo ( const Vector2 other) const
inline

Gets the oriented angle between 2 vectors.

Remarks
Vectors do not have to be unit-length but must represent directions. The angle is comprised between 0 and 2 PI.

References Ogre::Math::TWO_PI.

◆ perpendicular() [1/2]

Vector2 Ogre::VectorBase< 2, Real >::perpendicular ( void  ) const
inline

Generates a vector perpendicular to this vector (eg an 'up' vector).

Remarks
This method will return a vector which is perpendicular to this vector. There are an infinite number of possibilities but this method will guarantee to generate one of them. If you need more control you should use the Quaternion class.

◆ perpendicular() [2/2]

Vector3 Ogre::VectorBase< 3, Real >::perpendicular ( void  ) const
inline

Generates a vector perpendicular to this vector (eg an 'up' vector).

Remarks
This method will return a vector which is perpendicular to this vector. There are an infinite number of possibilities but this method will guarantee to generate one of them. If you need more control you should use the Quaternion class.

References Ogre::Math::Abs(), and Ogre::Vector< dims, T >::normalisedCopy().

◆ crossProduct()

Vector3 Ogre::VectorBase< 3, Real >::crossProduct ( const Vector3 rkVector) const
inline

Calculates the cross-product of 2 vectors, i.e.

the vector that lies perpendicular to them both.

Remarks
The cross-product is normally used to calculate the normal vector of a plane, by calculating the cross-product of 2 non-equivalent vectors which lie on the plane (e.g. 2 edges of a triangle).
Parameters
rkVectorVector which, together with this one, will be used to calculate the cross-product.
Returns
A vector which is the result of the cross-product. This vector will NOT be normalised, to maximise efficiency
  • call Vector3::normalise on the result if you wish this to be done. As for which side the resultant vector will be on, the returned vector will be on the side from which the arc from 'this' to rkVector is anticlockwise, e.g. UNIT_Y.crossProduct(UNIT_Z) = UNIT_X, whilst UNIT_Z.crossProduct(UNIT_Y) = -UNIT_X. This is because OGRE uses a right-handed coordinate system.
For a clearer explanation, look a the left and the bottom edges of your monitor's screen. Assume that the first vector is the left edge and the second vector is the bottom edge, both of them starting from the lower-left corner of the screen. The resulting vector is going to be perpendicular to both of them and will go inside the screen, towards the cathode tube (assuming you're using a CRT monitor, of course).

◆ midPoint() [2/2]

Vector3 Ogre::VectorBase< 3, Real >::midPoint ( const Vector3 vec) const
inline

Returns a vector at a point half way between this and the passed in vector.

◆ randomDeviant() [2/2]

Vector3 Ogre::VectorBase< 3, Real >::randomDeviant ( const Radian angle,
const Vector3 up = ZERO 
) const
inline

Generates a new random vector which deviates from this vector by a given angle in a random direction.

Remarks
This method assumes that the random number generator has already been seeded appropriately.
Parameters
angleThe angle at which to deviate
upAny vector perpendicular to this one (which could generated by cross-product of this vector and any other non-colinear vector). If you choose not to provide this the function will derive one on it's own, however if you provide one yourself the function will be faster (this allows you to reuse up vectors if you call this method more than once)
Returns
A random vector which deviates from this vector by angle. This vector will not be normalised, normalise it if you wish afterwards.

References Ogre::Quaternion::FromAngleAxis(), Ogre::Math::TWO_PI, and Ogre::Math::UnitRandom().

◆ getRotationTo()

Quaternion Ogre::VectorBase< 3, Real >::getRotationTo ( const Vector3 dest,
const Vector3 fallbackAxis = ZERO 
) const
inline

Gets the shortest arc quaternion to rotate this vector to the destination vector.

Remarks
If you call this with a dest vector that is close to the inverse of this vector, we will rotate 180 degrees around the 'fallbackAxis' (if specified, or a generated axis if not) since in this case ANY axis of rotation is valid.

References Ogre::Math::Abs(), Ogre::Vector< dims, T >::dotProduct(), Ogre::Quaternion::IDENTITY, Ogre::Quaternion::normalise(), Ogre::Math::RealEqual(), Ogre::Math::Sqrt(), and Ogre::Vector< dims, T >::squaredLength().

◆ positionCloses()

bool Ogre::VectorBase< 3, Real >::positionCloses ( const Vector3 rhs,
Real  tolerance = 1e-03f 
) const
inline

Returns whether this vector is within a positional tolerance of another vector, also take scale of the vectors into account.

Parameters
rhsThe vector to compare with
toleranceThe amount (related to the scale of vectors) that distance of the vector may vary by and still be considered close

References Ogre::Vector< dims, T >::squaredLength().

◆ directionEquals()

bool Ogre::VectorBase< 3, Real >::directionEquals ( const Vector3 rhs,
const Radian tolerance 
) const
inline

Returns whether this vector is within a directional tolerance of another vector.

Parameters
rhsThe vector to compare with
toleranceThe maximum angle by which the vectors may vary and still be considered equal
Note
Both vectors should be normalised.

References Ogre::Math::Abs(), Ogre::Math::ACos(), Ogre::Vector< dims, T >::dotProduct(), and Ogre::Radian::valueRadians().

◆ primaryAxis()

const Vector3 & Ogre::VectorBase< 3, Real >::primaryAxis ( ) const
inline

Extract the primary (dominant) axis from this direction vector.

References Ogre::Math::Abs().

◆ calculateBasicFaceNormal()

Vector3 Ogre::Math::calculateBasicFaceNormal ( const Vector3 v1,
const Vector3 v2,
const Vector3 v3 
)
inlinestatic

◆ calculateFaceNormal()

Vector4 Ogre::Math::calculateFaceNormal ( const Vector3 v1,
const Vector3 v2,
const Vector3 v3 
)
inlinestatic

Calculate a face normal, including the w component which is the offset from the origin.

References Ogre::Math::calculateBasicFaceNormal(), and Ogre::Vector< dims, T >::dotProduct().

◆ calculateBasicFaceNormalWithoutNormalize()

Vector3 Ogre::Math::calculateBasicFaceNormalWithoutNormalize ( const Vector3 v1,
const Vector3 v2,
const Vector3 v3 
)
inlinestatic

Calculate a face normal without normalize, no w-information.

Referenced by Ogre::Math::calculateFaceNormalWithoutNormalize().

◆ calculateFaceNormalWithoutNormalize()

Vector4 Ogre::Math::calculateFaceNormalWithoutNormalize ( const Vector3 v1,
const Vector3 v2,
const Vector3 v3 
)
inlinestatic

Calculate a face normal without normalize, including the w component which is the offset from the origin.

References Ogre::Math::calculateBasicFaceNormalWithoutNormalize(), and Ogre::Vector< dims, T >::dotProduct().