|  | OGRE-Next 3.0.0
    Object-Oriented Graphics Rendering Engine | 
Class to provide access to common mathematical functions. More...
#include <OgreMath.h>
| Classes | |
| class | RandomValueProvider | 
| This class is used to provide an external random value provider.  More... | |
| Public Types | |
| enum | AngleUnit { AU_DEGREE , AU_RADIAN } | 
| The angular units used by the API.  More... | |
| Public Member Functions | |
| Math (unsigned int trigTableSize=4096) | |
| Default constructor. | |
| ~Math () | |
| Default destructor. | |
| Static Public Member Functions | |
| static Degree | Abs (const Degree &dValue) | 
| Absolute value function. | |
| static Radian | Abs (const Radian &rValue) | 
| Absolute value function. | |
| static Real | Abs (Real fValue) | 
| Absolute value function. | |
| static Radian | ACos (Real fValue) | 
| Arc cosine function. | |
| static Real | AngleUnitsToDegrees (Real units) | 
| Convert from the current AngleUnit to degrees. | |
| static Real | AngleUnitsToRadians (Real units) | 
| Convert from the current AngleUnit to radians. | |
| static Radian | ASin (Real fValue) | 
| Arc sine function. | |
| static Radian | ATan (Real fValue) | 
| Arc tangent function. | |
| static Radian | ATan2 (Real fY, Real fX) | 
| Arc tangent between two values function. | |
| static Real | boundingRadiusFromAABB (const AxisAlignedBox &aabb) | 
| Get a bounding radius value from a bounding box. | |
| static Matrix4 | buildReflectionMatrix (const Plane &p) | 
| Build a reflection matrix for the passed in plane. | |
| static Vector3 | calculateBasicFaceNormal (const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) | 
| Calculate a face normal, no w-information. | |
| static Vector3 | calculateBasicFaceNormalWithoutNormalize (const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) | 
| Calculate a face normal without normalize, no w-information. | |
| static Vector4 | 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. | |
| static Vector4 | 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. | |
| static Vector3 | calculateTangentSpaceVector (const Vector3 &position1, const Vector3 &position2, const Vector3 &position3, Real u1, Real v1, Real u2, Real v2, Real u3, Real v3) | 
| Calculates the tangent space vector for a given set of positions / texture coords. | |
| static Real | Ceil (Real fValue) | 
| Ceiling function Returns the smallest following integer. | |
| template<typename T > | |
| static T | Clamp (T val, T minval, T maxval) | 
| Clamp a value within an inclusive range. | |
| static uint32 | ClosestPow2 (uint32 x) | 
| Return closest power of two not smaller than given number. | |
| static Real | Cos (const Radian &fValue, bool useTables=false) | 
| Cosine function. | |
| static Real | Cos (Real fValue, bool useTables=false) | 
| Cosine function. | |
| static Real | DegreesToAngleUnits (Real degrees) | 
| Convert from degrees to the current AngleUnit. | |
| static Real | DegreesToRadians (Real degrees) | 
| static Real | Exp (Real fValue) | 
| static Real | Floor (Real fValue) | 
| Floor function Returns the largest previous integer. | |
| static Real | gaussianDistribution (Real x, Real offset=0.0f, Real scale=1.0f) | 
| Generates a value based on the Gaussian (normal) distribution function with the given offset and scale parameters. | |
| static size_t | gcd (size_t a, size_t b) | 
| Returns Greatest Common Denominator. | |
| static AngleUnit | getAngleUnit () | 
| Get the unit being used for angles. | |
| static int | IAbs (int iValue) | 
| static int | ICeil (float fValue) | 
| static int | IFloor (float fValue) | 
| static bool | intersects (const Plane &plane, const AxisAlignedBox &box) | 
| Plane / box intersection test. | |
| static std::pair< bool, Real > | intersects (const Ray &ray, const AxisAlignedBox &box) | 
| Ray / box intersection, returns boolean result and distance. | |
| static bool | intersects (const Ray &ray, const AxisAlignedBox &box, Real *d1, Real *d2) | 
| Ray / box intersection, returns boolean result and two intersection distance. | |
| static std::pair< bool, Real > | intersects (const Ray &ray, const Plane &plane) | 
| Ray / plane intersection, returns boolean result and distance. | |
| static std::pair< bool, Real > | intersects (const Ray &ray, const Sphere &sphere, bool discardInside=true) | 
| Ray / sphere intersection, returns boolean result and distance. | |
| static std::pair< bool, Real > | intersects (const Ray &ray, const StdList< Plane > &planeList, bool normalIsOutside) | 
| Ray / convex plane list intersection test. | |
| static std::pair< bool, Real > | intersects (const Ray &ray, const StdVector< Plane > &planeList, bool normalIsOutside) | 
| Ray / convex plane list intersection test. | |
| static std::pair< bool, Real > | intersects (const Ray &ray, const Vector3 &a, const Vector3 &b, const Vector3 &c, bool positiveSide=true, bool negativeSide=true) | 
| Ray / triangle intersection, returns boolean result and distance. | |
| static std::pair< bool, Real > | intersects (const Ray &ray, const Vector3 &a, const Vector3 &b, const Vector3 &c, const Vector3 &normal, bool positiveSide=true, bool negativeSide=true) | 
| Ray / triangle intersection, returns boolean result and distance. | |
| static bool | intersects (const Sphere &sphere, const AxisAlignedBox &box) | 
| Sphere / box intersection test. | |
| static bool | intersects (const Sphere &sphere, const Plane &plane) | 
| Sphere / plane intersection test. | |
| static Real | InvSqrt (Real fValue) | 
| Inverse square root i.e. | |
| static int | ISign (int iValue) | 
| static bool | isNaN (Real f) | 
| static size_t | lcm (size_t a, size_t b) | 
| Returns Least Common Multiple. | |
| template<typename T , typename S > | |
| static FORCEINLINE T | lerp (const T &a, const T &b, const S &w) | 
| Linear interpolation. | |
| static Real | Log (Real fValue) | 
| static Real | Log2 (Real fValue) | 
| static Real | LogN (Real base, Real fValue) | 
| static Matrix4 | makeViewMatrix (const Vector3 &position, const Quaternion &orientation, const Matrix4 *reflectMatrix=0) | 
| static Vector3 | octahedronMappingDecode (Vector2 f) | 
| Takes a 2D value in range [0; 1] and returns a unit-length 3D vector. | |
| static Vector2 | octahedronMappingEncode (Vector3 n) | 
| Takes a directional 3D vector n and returns a 2D value in range [0; 1] Vector 'n' doesn't have to be normalized. | |
| static bool | pointInTri2D (const Vector2 &p, const Vector2 &a, const Vector2 &b, const Vector2 &c) | 
| Checks whether a given point is inside a triangle, in a 2-dimensional (Cartesian) space. | |
| static bool | pointInTri3D (const Vector3 &p, const Vector3 &a, const Vector3 &b, const Vector3 &c, const Vector3 &normal) | 
| Checks whether a given 3D point is inside a triangle. | |
| static Real | Pow (Real fBase, Real fExponent) | 
| static Real | RadiansToAngleUnits (Real radians) | 
| Convert from radians to the current AngleUnit . | |
| static Real | RadiansToDegrees (Real radians) | 
| static Real | RangeRandom (Real fLow, Real fHigh) | 
| Generate a random number within the range provided. | |
| static bool | RealEqual (Real a, Real b, Real tolerance=std::numeric_limits< Real >::epsilon()) | 
| Compare 2 reals, using tolerance for inaccuracies. | |
| static double | saturate (double t) | 
| static float | saturate (float t) | 
| static void | setAngleUnit (AngleUnit unit) | 
| These functions used to set the assumed angle units (radians or degrees) expected when using the Angle type. | |
| static void | SetRandomValueProvider (RandomValueProvider *provider) | 
| static Degree | Sign (const Degree &dValue) | 
| static Radian | Sign (const Radian &rValue) | 
| static Real | Sign (Real fValue) | 
| static Real | Sin (const Radian &fValue, bool useTables=false) | 
| Sine function. | |
| static Real | Sin (Real fValue, bool useTables=false) | 
| Sine function. | |
| template<typename T , typename S > | |
| static FORCEINLINE T | smoothstep (const T &edge0, const T &edge1, const S &x) | 
| Performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. | |
| static Real | Sqr (Real fValue) | 
| Squared function. | |
| static Degree | Sqrt (const Degree &fValue) | 
| Square root function. | |
| static Radian | Sqrt (const Radian &fValue) | 
| Square root function. | |
| static Real | Sqrt (Real fValue) | 
| Square root function. | |
| static Real | SymmetricRandom () | 
| Generate a random number in the range [-1,1]. | |
| static Real | Tan (const Radian &fValue, bool useTables=false) | 
| Tangent function. | |
| static Real | Tan (Real fValue, bool useTables=false) | 
| Tangent function. | |
| static Real | UnitRandom () | 
| Generate a random number of unit length. | |
| static Real | Wrap (Real v) | 
| Wraps the value 'v' into the range [0; 1) | |
| Static Public Attributes | |
| static const Real | fDeg2Rad | 
| static const Real | fRad2Deg | 
| static const Real | HALF_PI | 
| static const Real | LOG2 | 
| Stored value of log(2) for frequent use. | |
| static const Real | NEG_INFINITY | 
| static const Real | PI | 
| static const Real | POS_INFINITY | 
| static const Real | TWO_PI | 
Class to provide access to common mathematical functions.
The angular units used by the API.
This functionality is now deprecated in favor of discreet angular unit types ( see Degree and Radian above ). The only place this functionality is actually still used is when parsing files. Search for usage of the Angle class for those instances
| Enumerator | |
|---|---|
| AU_DEGREE | |
| AU_RADIAN | |
| Ogre::Math::Math | ( | unsigned int | trigTableSize = 4096 | ) | 
Default constructor.
| trigTableSize | Optional parameter to set the size of the tables used to implement Sin, Cos, Tan | 
| Ogre::Math::~Math | ( | ) | 
Default destructor.
Absolute value function.
| dValue | The value, in degrees, whose absolute value will be returned. | 
References Ogre::Degree::valueDegrees().
Absolute value function.
| rValue | The value, in radians, whose absolute value will be returned. | 
References Ogre::Radian::valueRadians().
Absolute value function.
| fValue | The value whose absolute value will be returned. | 
Arc cosine function.
| fValue | The value whose arc cosine will be returned. | 
Referenced by Ogre::Vector2::angleBetween().
Convert from the current AngleUnit to degrees.
Referenced by Ogre::Angle::operator Degree().
Convert from the current AngleUnit to radians.
Referenced by Ogre::Angle::operator Radian().
Arc sine function.
| fValue | The value whose arc sine will be returned. | 
Arc tangent function.
| fValue | The value whose arc tangent will be returned. | 
Arc tangent between two values function.
| fY | The first value to calculate the arc tangent with. | 
| fX | The second value to calculate the arc tangent with. | 
| 
 | static | 
Get a bounding radius value from a bounding box.
Build a reflection matrix for the passed in plane.
| 
 | static | 
Calculate a face normal, no w-information.
| 
 | static | 
Calculate a face normal without normalize, no w-information.
| 
 | static | 
Calculate a face normal, including the w component which is the offset from the origin.
| 
 | static | 
Calculate a face normal without normalize, including the w component which is the offset from the origin.
| 
 | static | 
Calculates the tangent space vector for a given set of positions / texture coords.
Ceiling function Returns the smallest following integer.
(example: Ceil(1.1) = 2)
| fValue | The value to round up to the nearest integer. | 
| 
 | inlinestatic | 
Clamp a value within an inclusive range.
Referenced by Ogre::Vector2::angleBetween(), Ogre::Bitwise::floatToSnorm16(), and Ogre::Bitwise::floatToSnorm8().
Return closest power of two not smaller than given number.
Cosine function.
| fValue | Angle in radians | 
| useTables | If true, uses lookup tables rather than calculation - faster but less accurate. | 
References Ogre::Radian::valueRadians().
Cosine function.
| fValue | Angle in radians | 
| useTables | If true, uses lookup tables rather than calculation - faster but less accurate. | 
Convert from degrees to the current AngleUnit.
Referenced by Ogre::Degree::valueAngleUnits().
References OGRE_ASSERT_HIGH.
Referenced by Ogre::Degree::valueRadians().
Floor function Returns the largest previous integer.
(example: Floor(1.9) = 1)
| fValue | The value to round down to the nearest integer. | 
| 
 | static | 
Generates a value based on the Gaussian (normal) distribution function with the given offset and scale parameters.
| 
 | inlinestatic | 
| 
 | static | 
Get the unit being used for angles.
| 
 | inlinestatic | 
| 
 | inlinestatic | 
| 
 | inlinestatic | 
| 
 | static | 
Plane / box intersection test.
| 
 | static | 
Ray / box intersection, returns boolean result and distance.
| 
 | static | 
Ray / box intersection, returns boolean result and two intersection distance.
| ray | The ray. | 
| box | The box. | 
| d1 | A real pointer to retrieve the near intersection distance from the ray origin, maybe null which means don't care about the near intersection distance. | 
| d2 | A real pointer to retrieve the far intersection distance from the ray origin, maybe null which means don't care about the far intersection distance. | 
| 
 | static | 
Ray / plane intersection, returns boolean result and distance.
| 
 | static | 
Ray / sphere intersection, returns boolean result and distance.
| 
 | static | 
Ray / convex plane list intersection test.
| ray | The ray to test with | 
| planeList | List of planes which form a convex volume | 
| normalIsOutside | Does the normal point outside the volume | 
| 
 | static | 
Ray / convex plane list intersection test.
| ray | The ray to test with | 
| planeList | List of planes which form a convex volume | 
| normalIsOutside | Does the normal point outside the volume | 
| 
 | static | 
Ray / triangle intersection, returns boolean result and distance.
| ray | The ray. | 
| a | The triangle's first vertex. | 
| b | The triangle's second vertex. | 
| c | The triangle's third vertex. | 
| positiveSide | Intersect with "positive side" of the triangle | 
| negativeSide | Intersect with "negative side" of the triangle | 
| 
 | static | 
Ray / triangle intersection, returns boolean result and distance.
| ray | The ray. | 
| a | The triangle's first vertex. | 
| b | The triangle's second vertex. | 
| c | The triangle's third vertex. | 
| normal | The triangle plane's normal (passed in rather than calculated on demand since the caller may already have it), doesn't need normalised since we don't care. | 
| positiveSide | Intersect with "positive side" of the triangle | 
| negativeSide | Intersect with "negative side" of the triangle | 
| 
 | static | 
Sphere / plane intersection test.
Inverse square root i.e.
1 / Sqrt(x), good for vector normalisation.
| fValue | The value whose inverse square root will be calculated. | 
| 
 | static | 
| 
 | inlinestatic | 
| 
 | inlinestatic | 
Returns Least Common Multiple.
| 
 | inlinestatic | 
Linear interpolation.
Given 3 parameters a, b and w the function returns the value of (1 – w)* a + w * b. Where a and b are matching vector or scalar types and w can be either a scalar or a vector of the same type as a and b.
| 
 | static | 
Takes a 2D value in range [0; 1] and returns a unit-length 3D vector.
Takes a directional 3D vector n and returns a 2D value in range [0; 1] Vector 'n' doesn't have to be normalized.
| 
 | static | 
Checks whether a given point is inside a triangle, in a 2-dimensional (Cartesian) space.
| p | The point. | 
| a | The triangle's first vertex. | 
| b | The triangle's second vertex. | 
| c | The triangle's third vertex. | 
| 
 | static | 
Checks whether a given 3D point is inside a triangle.
| p | p The point. | 
| a | The triangle's first vertex. | 
| b | The triangle's second vertex. | 
| c | The triangle's third vertex. | 
| normal | The triangle plane's normal (passed in rather than calculated on demand since the caller may already have it) | 
Convert from radians to the current AngleUnit .
Referenced by Ogre::Radian::valueAngleUnits().
References OGRE_ASSERT_HIGH.
Referenced by Ogre::Radian::valueDegrees().
Generate a random number within the range provided.
| fLow | The lower bound of the range. | 
| fHigh | The upper bound of the range. | 
| 
 | inlinestatic | 
Compare 2 reals, using tolerance for inaccuracies.
| 
 | inlinestatic | 
| 
 | inlinestatic | 
| 
 | static | 
| 
 | static | 
References Ogre::Degree::valueDegrees().
References Ogre::Radian::valueRadians().
Sine function.
| fValue | Angle in radians | 
| useTables | If true, uses lookup tables rather than calculation - faster but less accurate. | 
References Ogre::Radian::valueRadians().
Sine function.
| fValue | Angle in radians | 
| useTables | If true, uses lookup tables rather than calculation - faster but less accurate. | 
| 
 | inlinestatic | 
Performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1.
This is useful in cases where a threshold function with a smooth transition is desired.
Squared function.
| fValue | The value to be squared (fValue^2) | 
Square root function.
| fValue | The value, in degrees, whose square root will be calculated. | 
References Ogre::Degree::valueDegrees().
Square root function.
| fValue | The value, in radians, whose square root will be calculated. | 
References Ogre::Radian::valueRadians().
Square root function.
| fValue | The value whose square root will be calculated. | 
Referenced by Ogre::AxisAlignedBox::distance().
| 
 | static | 
Generate a random number in the range [-1,1].
Tangent function.
| fValue | Angle in radians | 
| useTables | If true, uses lookup tables rather than calculation - faster but less accurate. | 
References Ogre::Radian::valueRadians().
Tangent function.
| fValue | Angle in radians | 
| useTables | If true, uses lookup tables rather than calculation - faster but less accurate. | 
| 
 | static | 
Generate a random number of unit length.
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
Stored value of log(2) for frequent use.
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
Referenced by Ogre::Vector2::angleTo().