OgreMath.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Math_H__
29 #define __Math_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreHeaderPrefix.h"
33 
34 namespace Ogre
35 {
47  class Radian
48  {
50 
51  public:
52  explicit Radian ( Real r=0 ) : mRad(r) {}
53  Radian ( const Degree& d );
54  Radian& operator = ( const Real& f ) { mRad = f; return *this; }
55  Radian& operator = ( const Radian& r ) { mRad = r.mRad; return *this; }
56  Radian& operator = ( const Degree& d );
57 
58  Real valueDegrees() const; // see bottom of this file
59  Real valueRadians() const { return mRad; }
60  Real valueAngleUnits() const;
61 
62  const Radian& operator + () const { return *this; }
63  Radian operator + ( const Radian& r ) const { return Radian ( mRad + r.mRad ); }
64  Radian operator + ( const Degree& d ) const;
65  Radian& operator += ( const Radian& r ) { mRad += r.mRad; return *this; }
66  Radian& operator += ( const Degree& d );
67  Radian operator - () const { return Radian(-mRad); }
68  Radian operator - ( const Radian& r ) const { return Radian ( mRad - r.mRad ); }
69  Radian operator - ( const Degree& d ) const;
70  Radian& operator -= ( const Radian& r ) { mRad -= r.mRad; return *this; }
71  Radian& operator -= ( const Degree& d );
72  Radian operator * ( Real f ) const { return Radian ( mRad * f ); }
73  Radian operator * ( const Radian& f ) const { return Radian ( mRad * f.mRad ); }
74  Radian& operator *= ( Real f ) { mRad *= f; return *this; }
75  Radian operator / ( Real f ) const { return Radian ( mRad / f ); }
76  Radian& operator /= ( Real f ) { mRad /= f; return *this; }
77 
78  bool operator < ( const Radian& r ) const { return mRad < r.mRad; }
79  bool operator <= ( const Radian& r ) const { return mRad <= r.mRad; }
80  bool operator == ( const Radian& r ) const { return mRad == r.mRad; }
81  bool operator != ( const Radian& r ) const { return mRad != r.mRad; }
82  bool operator >= ( const Radian& r ) const { return mRad >= r.mRad; }
83  bool operator > ( const Radian& r ) const { return mRad > r.mRad; }
84 
85  inline _OgreExport friend std::ostream& operator <<
86  ( std::ostream& o, const Radian& v )
87  {
88  o << "Radian(" << v.valueRadians() << ")";
89  return o;
90  }
91  };
92 
98  class Degree
99  {
100  Real mDeg; // if you get an error here - make sure to define/typedef 'Real' first
101 
102  public:
103  explicit Degree ( Real d=0 ) : mDeg(d) {}
104  Degree ( const Radian& r ) : mDeg(r.valueDegrees()) {}
105  Degree& operator = ( const Real& f ) { mDeg = f; return *this; }
106  Degree& operator = ( const Degree& d ) { mDeg = d.mDeg; return *this; }
107  Degree& operator = ( const Radian& r ) { mDeg = r.valueDegrees(); return *this; }
108 
109  Real valueDegrees() const { return mDeg; }
110  Real valueRadians() const; // see bottom of this file
111  Real valueAngleUnits() const;
112 
113  const Degree& operator + () const { return *this; }
114  Degree operator + ( const Degree& d ) const { return Degree ( mDeg + d.mDeg ); }
115  Degree operator + ( const Radian& r ) const { return Degree ( mDeg + r.valueDegrees() ); }
116  Degree& operator += ( const Degree& d ) { mDeg += d.mDeg; return *this; }
117  Degree& operator += ( const Radian& r ) { mDeg += r.valueDegrees(); return *this; }
118  Degree operator - () const { return Degree(-mDeg); }
119  Degree operator - ( const Degree& d ) const { return Degree ( mDeg - d.mDeg ); }
120  Degree operator - ( const Radian& r ) const { return Degree ( mDeg - r.valueDegrees() ); }
121  Degree& operator -= ( const Degree& d ) { mDeg -= d.mDeg; return *this; }
122  Degree& operator -= ( const Radian& r ) { mDeg -= r.valueDegrees(); return *this; }
123  Degree operator * ( Real f ) const { return Degree ( mDeg * f ); }
124  Degree operator * ( const Degree& f ) const { return Degree ( mDeg * f.mDeg ); }
125  Degree& operator *= ( Real f ) { mDeg *= f; return *this; }
126  Degree operator / ( Real f ) const { return Degree ( mDeg / f ); }
127  Degree& operator /= ( Real f ) { mDeg /= f; return *this; }
128 
129  bool operator < ( const Degree& d ) const { return mDeg < d.mDeg; }
130  bool operator <= ( const Degree& d ) const { return mDeg <= d.mDeg; }
131  bool operator == ( const Degree& d ) const { return mDeg == d.mDeg; }
132  bool operator != ( const Degree& d ) const { return mDeg != d.mDeg; }
133  bool operator >= ( const Degree& d ) const { return mDeg >= d.mDeg; }
134  bool operator > ( const Degree& d ) const { return mDeg > d.mDeg; }
135 
136  inline _OgreExport friend std::ostream& operator <<
137  ( std::ostream& o, const Degree& v )
138  {
139  o << "Degree(" << v.valueDegrees() << ")";
140  return o;
141  }
142  };
143 
150  class Angle
151  {
153  public:
154  explicit Angle ( Real angle ) : mAngle(angle) {}
155  operator Radian() const;
156  operator Degree() const;
157  };
158 
159  // these functions could not be defined within the class definition of class
160  // Radian because they required class Degree to be defined
161  inline Radian::Radian ( const Degree& d ) : mRad(d.valueRadians()) {
162  }
163  inline Radian& Radian::operator = ( const Degree& d ) {
164  mRad = d.valueRadians(); return *this;
165  }
166  inline Radian Radian::operator + ( const Degree& d ) const {
167  return Radian ( mRad + d.valueRadians() );
168  }
169  inline Radian& Radian::operator += ( const Degree& d ) {
170  mRad += d.valueRadians();
171  return *this;
172  }
173  inline Radian Radian::operator - ( const Degree& d ) const {
174  return Radian ( mRad - d.valueRadians() );
175  }
176  inline Radian& Radian::operator -= ( const Degree& d ) {
177  mRad -= d.valueRadians();
178  return *this;
179  }
180 
192  {
193  public:
200  {
202  AU_RADIAN
203  };
204 
205 
209  {
210  public:
211  virtual ~RandomValueProvider() {}
213  virtual Real getRandomUnit() = 0;
214  };
215 
216  protected:
219 
221  static int mTrigTableSize;
222 
225  static Real* mSinTable;
226  static Real* mTanTable;
227 
230 
234 
235  static Real SinTable (Real fValue);
236  static Real TanTable (Real fValue);
237  public:
243  Math(unsigned int trigTableSize = 4096);
244 
247  ~Math();
248 
249  static inline int IAbs (int iValue) { return ( iValue >= 0 ? iValue : -iValue ); }
250  static inline int ICeil (float fValue) { return int(ceil(fValue)); }
251  static inline int IFloor (float fValue) { return int(floor(fValue)); }
252  static int ISign (int iValue);
253 
258  static inline Real Abs (Real fValue) { return Real(fabs(fValue)); }
259 
264  static inline Degree Abs (const Degree& dValue) { return Degree(fabs(dValue.valueDegrees())); }
265 
270  static inline Radian Abs (const Radian& rValue) { return Radian(fabs(rValue.valueRadians())); }
271 
276  static Radian ACos (Real fValue);
277 
282  static Radian ASin (Real fValue);
283 
288  static inline Radian ATan (Real fValue) { return Radian(atan(fValue)); }
289 
296  static inline Radian ATan2 (Real fY, Real fX) { return Radian(atan2(fY,fX)); }
297 
304  static inline Real Ceil (Real fValue) { return Real(ceil(fValue)); }
305  static inline bool isNaN(Real f)
306  {
307  // std::isnan() is C99, not supported by all compilers
308  // However NaN always fails this next test, no other number does.
309  return f != f;
310  }
311 
319  static inline Real Cos (const Radian& fValue, bool useTables = false) {
320  return (!useTables) ? Real(cos(fValue.valueRadians())) : SinTable(fValue.valueRadians() + HALF_PI);
321  }
329  static inline Real Cos (Real fValue, bool useTables = false) {
330  return (!useTables) ? Real(cos(fValue)) : SinTable(fValue + HALF_PI);
331  }
332 
333  static inline Real Exp (Real fValue) { return Real(exp(fValue)); }
334 
341  static inline Real Floor (Real fValue) { return Real(floor(fValue)); }
342 
343  static inline Real Log (Real fValue) { return Real(log(fValue)); }
344 
346  static const Real LOG2;
347 
348  static inline Real Log2 (Real fValue) { return Real(log(fValue)/LOG2); }
349 
350  static inline Real LogN (Real base, Real fValue) { return Real(log(fValue)/log(base)); }
351 
352  static inline Real Pow (Real fBase, Real fExponent) { return Real(pow(fBase,fExponent)); }
353 
354  static Real Sign (Real fValue);
355  static inline Radian Sign ( const Radian& rValue )
356  {
357  return Radian(Sign(rValue.valueRadians()));
358  }
359  static inline Degree Sign ( const Degree& dValue )
360  {
361  return Degree(Sign(dValue.valueDegrees()));
362  }
363 
364  //Simulate the shader function saturate that clamps a parameter value between 0 and 1
365  static inline float saturate(float t) { return (t < 0) ? 0 : ((t > 1) ? 1 : t); }
366  static inline double saturate(double t) { return (t < 0) ? 0 : ((t > 1) ? 1 : t); }
367 
368  //Simulate the shader function lerp which performers linear interpolation
369  //given 3 parameters v0, v1 and t the function returns the value of (1 – t)* v0 + t * v1.
370  //where v0 and v1 are matching vector or scalar types and t can be either a scalar or a vector of the same type as a and b.
371  template<typename V, typename T> static V lerp(const V& v0, const V& v1, const T& t) {
372  return v0 * (1 - t) + v1 * t; }
373 
381  static inline Real Sin (const Radian& fValue, bool useTables = false) {
382  return (!useTables) ? Real(sin(fValue.valueRadians())) : SinTable(fValue.valueRadians());
383  }
391  static inline Real Sin (Real fValue, bool useTables = false) {
392  return (!useTables) ? Real(sin(fValue)) : SinTable(fValue);
393  }
394 
399  static inline Real Sqr (Real fValue) { return fValue*fValue; }
400 
405  static inline Real Sqrt (Real fValue) { return Real(sqrt(fValue)); }
406 
413  static inline Radian Sqrt (const Radian& fValue) { return Radian(sqrt(fValue.valueRadians())); }
414 
421  static inline Degree Sqrt (const Degree& fValue) { return Degree(sqrt(fValue.valueDegrees())); }
422 
428  static Real InvSqrt (Real fValue);
429 
434  static Real UnitRandom ();
435 
444  static Real RangeRandom (Real fLow, Real fHigh);
445 
451 
453 
461  static inline Real Tan (const Radian& fValue, bool useTables = false) {
462  return (!useTables) ? Real(tan(fValue.valueRadians())) : TanTable(fValue.valueRadians());
463  }
471  static inline Real Tan (Real fValue, bool useTables = false) {
472  return (!useTables) ? Real(tan(fValue)) : TanTable(fValue);
473  }
474 
475  static inline Real DegreesToRadians(Real degrees) { return degrees * fDeg2Rad; }
476  static inline Real RadiansToDegrees(Real radians) { return radians * fRad2Deg; }
477 
484  static void setAngleUnit(AngleUnit unit);
486  static AngleUnit getAngleUnit(void);
487 
491  static Real RadiansToAngleUnits(Real radians);
495  static Real DegreesToAngleUnits(Real degrees);
496 
518  static bool pointInTri2D(const Vector2& p, const Vector2& a,
519  const Vector2& b, const Vector2& c);
520 
545  static bool pointInTri3D(const Vector3& p, const Vector3& a,
546  const Vector3& b, const Vector3& c, const Vector3& normal);
548  static std::pair<bool, Real> intersects(const Ray& ray, const Plane& plane);
549 
551  static std::pair<bool, Real> intersects(const Ray& ray, const Sphere& sphere,
552  bool discardInside = true);
553 
555  static std::pair<bool, Real> intersects(const Ray& ray, const AxisAlignedBox& box);
556 
579  static bool intersects(const Ray& ray, const AxisAlignedBox& box,
580  Real* d1, Real* d2);
581 
606  static std::pair<bool, Real> intersects(const Ray& ray, const Vector3& a,
607  const Vector3& b, const Vector3& c, const Vector3& normal,
608  bool positiveSide = true, bool negativeSide = true);
609 
630  static std::pair<bool, Real> intersects(const Ray& ray, const Vector3& a,
631  const Vector3& b, const Vector3& c,
632  bool positiveSide = true, bool negativeSide = true);
633 
635  static bool intersects(const Sphere& sphere, const AxisAlignedBox& box);
636 
638  static bool intersects(const Plane& plane, const AxisAlignedBox& box);
639 
645  static std::pair<bool, Real> intersects(
646  const Ray& ray, const vector<Plane>::type& planeList,
647  bool normalIsOutside);
653  static std::pair<bool, Real> intersects(
654  const Ray& ray, const list<Plane>::type& planeList,
655  bool normalIsOutside);
656 
660  static bool intersects(const Sphere& sphere, const Plane& plane);
661 
664  static bool RealEqual(Real a, Real b,
665  Real tolerance = std::numeric_limits<Real>::epsilon());
666 
669  const Vector3& position1, const Vector3& position2, const Vector3& position3,
670  Real u1, Real v1, Real u2, Real v2, Real u3, Real v3);
671 
675  static Vector4 calculateFaceNormal(const Vector3& v1, const Vector3& v2, const Vector3& v3);
677  static Vector3 calculateBasicFaceNormal(const Vector3& v1, const Vector3& v2, const Vector3& v3);
679  static Vector4 calculateFaceNormalWithoutNormalize(const Vector3& v1, const Vector3& v2, const Vector3& v3);
681  static Vector3 calculateBasicFaceNormalWithoutNormalize(const Vector3& v1, const Vector3& v2, const Vector3& v3);
682 
686  static Real gaussianDistribution(Real x, Real offset = 0.0f, Real scale = 1.0f);
687 
689  template <typename T>
690  static T Clamp(T val, T minval, T maxval)
691  {
692  assert (minval <= maxval && "Invalid clamp range");
693  return std::max(std::min(val, maxval), minval);
694  }
695 
696  static Matrix4 makeViewMatrix(const Vector3& position, const Quaternion& orientation,
697  const Matrix4* reflectMatrix = 0);
698 
701 
702 
703 
704  static const Real POS_INFINITY;
705  static const Real NEG_INFINITY;
706  static const Real PI;
707  static const Real TWO_PI;
708  static const Real HALF_PI;
709  static const Real fDeg2Rad;
710  static const Real fRad2Deg;
711 
712  };
713 
714  // these functions must be defined down here, because they rely on the
715  // angle unit conversion functions in class Math:
716 
717  inline Real Radian::valueDegrees() const
718  {
719  return Math::RadiansToDegrees ( mRad );
720  }
721 
723  {
724  return Math::RadiansToAngleUnits ( mRad );
725  }
726 
727  inline Real Degree::valueRadians() const
728  {
729  return Math::DegreesToRadians ( mDeg );
730  }
731 
733  {
734  return Math::DegreesToAngleUnits ( mDeg );
735  }
736 
737  inline Angle::operator Radian() const
738  {
739  return Radian(Math::AngleUnitsToRadians(mAngle));
740  }
741 
742  inline Angle::operator Degree() const
743  {
744  return Degree(Math::AngleUnitsToDegrees(mAngle));
745  }
746 
747  inline Radian operator * ( Real a, const Radian& b )
748  {
749  return Radian ( a * b.valueRadians() );
750  }
751 
752  inline Radian operator / ( Real a, const Radian& b )
753  {
754  return Radian ( a / b.valueRadians() );
755  }
756 
757  inline Degree operator * ( Real a, const Degree& b )
758  {
759  return Degree ( a * b.valueDegrees() );
760  }
761 
762  inline Degree operator / ( Real a, const Degree& b )
763  {
764  return Degree ( a / b.valueDegrees() );
765  }
769 }
770 
771 #include "OgreHeaderSuffix.h"
772 
773 #endif
OgreHeaderSuffix.h
Ogre::Math::RandomValueProvider
This class is used to provide an external random value provider.
Definition: OgreMath.h:209
Ogre::Math::pointInTri2D
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.
Ogre::Math::intersects
static std::pair< bool, Real > intersects(const Ray &ray, const list< Plane >::type &planeList, bool normalIsOutside)
Ray / convex plane list intersection test.
Ogre::Degree::Degree
Degree(Real d=0)
Definition: OgreMath.h:103
Ogre::Radian::operator*=
Radian & operator*=(Real f)
Definition: OgreMath.h:74
Ogre::Radian::valueRadians
Real valueRadians() const
Definition: OgreMath.h:59
Ogre::Math::mSinTable
static Real * mSinTable
Definition: OgreMath.h:225
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::Plane
Defines a plane in 3D space.
Definition: OgrePlane.h:62
Ogre::Math::Sqrt
static Degree Sqrt(const Degree &fValue)
Square root function.
Definition: OgreMath.h:421
Ogre::Math::LOG2
static const Real LOG2
Stored value of log(2) for frequent use.
Definition: OgreMath.h:346
Ogre::Math::TWO_PI
static const Real TWO_PI
Definition: OgreMath.h:707
Ogre::Math::ICeil
static int ICeil(float fValue)
Definition: OgreMath.h:250
Ogre::Math::Tan
static Real Tan(const Radian &fValue, bool useTables=false)
Tangent function.
Definition: OgreMath.h:461
Ogre::Math::RangeRandom
static Real RangeRandom(Real fLow, Real fHigh)
Generate a random number within the range provided.
Ogre::Radian::valueAngleUnits
Real valueAngleUnits() const
Definition: OgreMath.h:722
Ogre::Math::Abs
static Degree Abs(const Degree &dValue)
Absolute value function.
Definition: OgreMath.h:264
Ogre::Math::Sqrt
static Radian Sqrt(const Radian &fValue)
Square root function.
Definition: OgreMath.h:413
Ogre::Math::ACos
static Radian ACos(Real fValue)
Arc cosine function.
Ogre::Math::SetRandomValueProvider
static void SetRandomValueProvider(RandomValueProvider *provider)
Ogre::Degree::operator<=
bool operator<=(const Degree &d) const
Definition: OgreMath.h:130
Ogre::Math::intersects
static std::pair< bool, Real > intersects(const Ray &ray, const Sphere &sphere, bool discardInside=true)
Ray / sphere intersection, returns boolean result and distance.
Ogre::Math::intersects
static bool intersects(const Sphere &sphere, const AxisAlignedBox &box)
Sphere / box intersection test.
Ogre::Radian::operator!=
bool operator!=(const Radian &r) const
Definition: OgreMath.h:81
Ogre::Math::intersects
static std::pair< bool, Real > intersects(const Ray &ray, const AxisAlignedBox &box)
Ray / box intersection, returns boolean result and distance.
Ogre::Math::Cos
static Real Cos(const Radian &fValue, bool useTables=false)
Cosine function.
Definition: OgreMath.h:319
Ogre::Math::Clamp
static T Clamp(T val, T minval, T maxval)
Clamp a value within an inclusive range.
Definition: OgreMath.h:690
Ogre::Degree::Degree
Degree(const Radian &r)
Definition: OgreMath.h:104
Ogre::Math::boundingRadiusFromAABB
static Real boundingRadiusFromAABB(const AxisAlignedBox &aabb)
Get a bounding radius value from a bounding box.
Ogre::Math::Cos
static Real Cos(Real fValue, bool useTables=false)
Cosine function.
Definition: OgreMath.h:329
Ogre::operator*
Radian operator*(Real a, const Radian &b)
Definition: OgreMath.h:747
Ogre::Math::saturate
static double saturate(double t)
Definition: OgreMath.h:366
Ogre::Math::pointInTri3D
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.
Ogre::Math::DegreesToRadians
static Real DegreesToRadians(Real degrees)
Definition: OgreMath.h:475
Ogre::Math::Sign
static Real Sign(Real fValue)
Ogre::Math::Exp
static Real Exp(Real fValue)
Definition: OgreMath.h:333
Ogre::Math::intersects
static bool intersects(const Sphere &sphere, const Plane &plane)
Sphere / plane intersection test.
Ogre::Degree::operator+
const Degree & operator+() const
Definition: OgreMath.h:113
Ogre::Math::RandomValueProvider::~RandomValueProvider
virtual ~RandomValueProvider()
Definition: OgreMath.h:211
Ogre::Radian::mRad
Real mRad
Definition: OgreMath.h:49
Ogre::Math::TanTable
static Real TanTable(Real fValue)
Ogre::Math::gaussianDistribution
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 scal...
Ogre::Math::AU_DEGREE
@ AU_DEGREE
Definition: OgreMath.h:201
Ogre::Degree::operator>=
bool operator>=(const Degree &d) const
Definition: OgreMath.h:133
Ogre::Radian::operator<=
bool operator<=(const Radian &r) const
Definition: OgreMath.h:79
Ogre::Math::intersects
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.
Ogre::operator/
Radian operator/(Real a, const Radian &b)
Definition: OgreMath.h:752
Ogre::Math::buildReflectionMatrix
static Matrix4 buildReflectionMatrix(const Plane &p)
Build a reflection matrix for the passed in plane.
Ogre::Math
Class to provide access to common mathematical functions.
Definition: OgreMath.h:192
Ogre::Degree::operator!=
bool operator!=(const Degree &d) const
Definition: OgreMath.h:132
Ogre::Radian::operator==
bool operator==(const Radian &r) const
Definition: OgreMath.h:80
Ogre::Math::msAngleUnit
static AngleUnit msAngleUnit
Angle units used by the api.
Definition: OgreMath.h:218
Ogre::Math::saturate
static float saturate(float t)
Definition: OgreMath.h:365
Ogre::Math::Log2
static Real Log2(Real fValue)
Definition: OgreMath.h:348
Ogre::Math::mTanTable
static Real * mTanTable
Definition: OgreMath.h:226
Ogre::Math::intersects
static bool intersects(const Ray &ray, const AxisAlignedBox &box, Real *d1, Real *d2)
Ray / box intersection, returns boolean result and two intersection distance.
Ogre::Math::Sign
static Radian Sign(const Radian &rValue)
Definition: OgreMath.h:355
Ogre::Degree::operator+=
Degree & operator+=(const Degree &d)
Definition: OgreMath.h:116
Ogre::Math::Sin
static Real Sin(const Radian &fValue, bool useTables=false)
Sine function.
Definition: OgreMath.h:381
Ogre::Math::intersects
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.
Ogre::Math::intersects
static bool intersects(const Plane &plane, const AxisAlignedBox &box)
Plane / box intersection test.
Ogre::Degree
Wrapper class which indicates a given angle value is in Degrees.
Definition: OgreMath.h:99
Ogre::Math::calculateBasicFaceNormalWithoutNormalize
static Vector3 calculateBasicFaceNormalWithoutNormalize(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
Calculate a face normal without normalize, no w-information.
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:58
Ogre::Math::AngleUnitsToDegrees
static Real AngleUnitsToDegrees(Real units)
Convert from the current AngleUnit to degrees.
Ogre::Angle
Wrapper class which identifies a value as the currently default angle type, as defined by Math::setAn...
Definition: OgreMath.h:151
Ogre::Degree::mDeg
Real mDeg
Definition: OgreMath.h:100
Ogre::Math::Sqrt
static Real Sqrt(Real fValue)
Square root function.
Definition: OgreMath.h:405
OgreHeaderPrefix.h
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
Ogre::Math::RadiansToAngleUnits
static Real RadiansToAngleUnits(Real radians)
Convert from radians to the current AngleUnit .
Ogre::list::type
std::list< T, A > type
Definition: OgrePrerequisites.h:508
Ogre::Radian::operator+=
Radian & operator+=(const Radian &r)
Definition: OgreMath.h:65
Ogre::Radian::operator+
const Radian & operator+() const
Definition: OgreMath.h:62
OgrePrerequisites.h
Ogre::Math::calculateFaceNormalWithoutNormalize
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 ori...
Ogre::Math::ISign
static int ISign(int iValue)
Ogre::Math::IAbs
static int IAbs(int iValue)
Definition: OgreMath.h:249
Ogre::Math::ATan2
static Radian ATan2(Real fY, Real fX)
Arc tangent between two values function.
Definition: OgreMath.h:296
Ogre::Math::RadiansToDegrees
static Real RadiansToDegrees(Real radians)
Definition: OgreMath.h:476
Ogre::Radian::operator/
Radian operator/(Real f) const
Definition: OgreMath.h:75
Ogre::Radian
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:48
Ogre::Angle::Angle
Angle(Real angle)
Definition: OgreMath.h:154
Ogre::Math::fRad2Deg
static const Real fRad2Deg
Definition: OgreMath.h:710
Ogre::Math::DegreesToAngleUnits
static Real DegreesToAngleUnits(Real degrees)
Convert from degrees to the current AngleUnit.
Ogre::Math::InvSqrt
static Real InvSqrt(Real fValue)
Inverse square root i.e.
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:55
Ogre::Math::POS_INFINITY
static const Real POS_INFINITY
Definition: OgreMath.h:704
Ogre::Math::HALF_PI
static const Real HALF_PI
Definition: OgreMath.h:708
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Math::intersects
static std::pair< bool, Real > intersects(const Ray &ray, const vector< Plane >::type &planeList, bool normalIsOutside)
Ray / convex plane list intersection test.
Ogre::Math::makeViewMatrix
static Matrix4 makeViewMatrix(const Vector3 &position, const Quaternion &orientation, const Matrix4 *reflectMatrix=0)
Ogre::Radian::operator*
Radian operator*(Real f) const
Definition: OgreMath.h:72
Ogre::Math::isNaN
static bool isNaN(Real f)
Definition: OgreMath.h:305
Ogre::Degree::valueRadians
Real valueRadians() const
Definition: OgreMath.h:727
Ogre::Math::~Math
~Math()
Default destructor.
Ogre::Sphere
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:52
Ogre::Radian::operator/=
Radian & operator/=(Real f)
Definition: OgreMath.h:76
Ogre::Math::Floor
static Real Floor(Real fValue)
Floor function Returns the largest previous integer.
Definition: OgreMath.h:341
Ogre::Math::mTrigTableFactor
static Real mTrigTableFactor
Radian -> index factor value ( mTrigTableSize / 2 * PI )
Definition: OgreMath.h:224
Ogre::Math::Pow
static Real Pow(Real fBase, Real fExponent)
Definition: OgreMath.h:352
Ogre::Math::PI
static const Real PI
Definition: OgreMath.h:706
Ogre::Degree::operator/
Degree operator/(Real f) const
Definition: OgreMath.h:126
Ogre::Math::Abs
static Radian Abs(const Radian &rValue)
Absolute value function.
Definition: OgreMath.h:270
Ogre::Math::NEG_INFINITY
static const Real NEG_INFINITY
Definition: OgreMath.h:705
Ogre::Math::Log
static Real Log(Real fValue)
Definition: OgreMath.h:343
Ogre::Math::RandomValueProvider::getRandomUnit
virtual Real getRandomUnit()=0
When called should return a random values in the range of [0,1].
Ogre::Degree::operator/=
Degree & operator/=(Real f)
Definition: OgreMath.h:127
Ogre::Angle::mAngle
Real mAngle
Definition: OgreMath.h:152
Ogre::Math::intersects
static std::pair< bool, Real > intersects(const Ray &ray, const Plane &plane)
Ray / plane intersection, returns boolean result and distance.
Ogre::Degree::operator>
bool operator>(const Degree &d) const
Definition: OgreMath.h:134
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:46
Ogre::Degree::operator<
bool operator<(const Degree &d) const
Definition: OgreMath.h:129
Ogre::Radian::operator-=
Radian & operator-=(const Radian &r)
Definition: OgreMath.h:70
Ogre::Math::AngleUnit
AngleUnit
The angular units used by the API.
Definition: OgreMath.h:200
Ogre::Vector2
Standard 2-dimensional vector.
Definition: OgreVector2.h:52
Ogre::Radian::operator>=
bool operator>=(const Radian &r) const
Definition: OgreMath.h:82
Ogre::Math::mRandProvider
static RandomValueProvider * mRandProvider
A random value provider. overriding the default random number generator.
Definition: OgreMath.h:229
Ogre::Math::calculateTangentSpaceVector
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.
Ogre::Math::getAngleUnit
static AngleUnit getAngleUnit(void)
Get the unit being used for angles.
Ogre::Radian::operator>
bool operator>(const Radian &r) const
Definition: OgreMath.h:83
Ogre::Math::Sign
static Degree Sign(const Degree &dValue)
Definition: OgreMath.h:359
Ogre::Degree::valueDegrees
Real valueDegrees() const
Definition: OgreMath.h:109
Ogre::Math::ASin
static Radian ASin(Real fValue)
Arc sine function.
Ogre::Radian::operator=
Radian & operator=(const Real &f)
Definition: OgreMath.h:54
Ogre::Math::AngleUnitsToRadians
static Real AngleUnitsToRadians(Real units)
Convert from the current AngleUnit to radians.
Ogre::Math::buildTrigTables
void buildTrigTables()
Private function to build trig tables.
Ogre::Math::setAngleUnit
static void setAngleUnit(AngleUnit unit)
These functions used to set the assumed angle units (radians or degrees) expected when using the Angl...
Ogre::Math::calculateBasicFaceNormal
static Vector3 calculateBasicFaceNormal(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
Calculate a face normal, no w-information.
Ogre::Math::lerp
static V lerp(const V &v0, const V &v1, const T &t)
Definition: OgreMath.h:371
Ogre::Math::Ceil
static Real Ceil(Real fValue)
Ceiling function Returns the smallest following integer.
Definition: OgreMath.h:304
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Math::IFloor
static int IFloor(float fValue)
Definition: OgreMath.h:251
Ogre::Degree::operator-
Degree operator-() const
Definition: OgreMath.h:118
Ogre::Degree::operator=
Degree & operator=(const Real &f)
Definition: OgreMath.h:105
Ogre::Math::fDeg2Rad
static const Real fDeg2Rad
Definition: OgreMath.h:709
Ogre::Degree::operator==
bool operator==(const Degree &d) const
Definition: OgreMath.h:131
Ogre::Degree::valueAngleUnits
Real valueAngleUnits() const
Definition: OgreMath.h:732
Ogre::Math::RealEqual
static bool RealEqual(Real a, Real b, Real tolerance=std::numeric_limits< Real >::epsilon())
Compare 2 reals, using tolerance for inaccuracies.
Ogre::Math::LogN
static Real LogN(Real base, Real fValue)
Definition: OgreMath.h:350
Ogre::vector
Definition: OgrePrerequisites.h:492
Ogre::Math::Sin
static Real Sin(Real fValue, bool useTables=false)
Sine function.
Definition: OgreMath.h:391
Ogre::Ray
Representation of a ray in space, i.e.
Definition: OgreRay.h:47
Ogre::Math::mTrigTableSize
static int mTrigTableSize
Size of the trig tables as determined by constructor.
Definition: OgreMath.h:221
Ogre::Radian::valueDegrees
Real valueDegrees() const
Definition: OgreMath.h:717
Ogre::Math::UnitRandom
static Real UnitRandom()
Generate a random number of unit length.
Ogre::Degree::operator-=
Degree & operator-=(const Degree &d)
Definition: OgreMath.h:121
Ogre::Radian::operator<
bool operator<(const Radian &r) const
Definition: OgreMath.h:78
Ogre::Math::Abs
static Real Abs(Real fValue)
Absolute value function.
Definition: OgreMath.h:258
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
Ogre::Degree::operator*=
Degree & operator*=(Real f)
Definition: OgreMath.h:125
Ogre::Math::Sqr
static Real Sqr(Real fValue)
Squared function.
Definition: OgreMath.h:399
Ogre::Radian::Radian
Radian(Real r=0)
Definition: OgreMath.h:52
Ogre::Math::SinTable
static Real SinTable(Real fValue)
Ogre::Math::Tan
static Real Tan(Real fValue, bool useTables=false)
Tangent function.
Definition: OgreMath.h:471
Ogre::Math::SymmetricRandom
static Real SymmetricRandom()
Generate a random number in the range [-1,1].
Ogre::Math::Math
Math(unsigned int trigTableSize=4096)
Default constructor.
Ogre::Radian::operator-
Radian operator-() const
Definition: OgreMath.h:67
Ogre::Math::ATan
static Radian ATan(Real fValue)
Arc tangent function.
Definition: OgreMath.h:288
Ogre::Degree::operator*
Degree operator*(Real f) const
Definition: OgreMath.h:123
Ogre::Math::calculateFaceNormal
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.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.