My Project
ParaMath.h
1 #pragma once
2 #include <limits>
3 #include <stdint.h>
4 #include "ParaAngle.h"
5 #include "ParaMathUtility.h"
6 
7 #if !defined(WIN32) && !defined(INT64_C)
8 # define INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
9 # define UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
10 #endif
11 
12 namespace ParaEngine
13 {
14  class CShapeBox;
15  class CShapeSphere;
16  class Matrix4;
17  class DVector3;
18  class Vector3;
19 
21  class Math
22  {
23  public:
29  enum AngleUnit
30  {
31  AU_DEGREE,
32  AU_RADIAN
33  };
34 
35  static const float POS_INFINITY;
36  static const float NEG_INFINITY;
37  static const float PI;
38  static const float TWO_PI;
39  static const float HALF_PI;
40  static const float fDeg2Rad;
41  static const float fRad2Deg;
42 
43  protected:
44  // angle units used by the api
45  static AngleUnit msAngleUnit;
46 
48  static int mTrigTableSize;
49 
51  static float mTrigTableFactor;
52  static float* mSinTable;
53  static float* mTanTable;
54 
57  void buildTrigTables();
58 
59  static float SinTable (float fValue);
60  static float TanTable (float fValue);
61  public:
67  Math(unsigned int trigTableSize = 4096);
68 
71  ~Math();
72 
73  static inline int IAbs (int iValue) { return ( iValue >= 0 ? iValue : -iValue ); }
74  static inline int ICeil (float fValue) { return int(ceil(fValue)); }
75  static inline int IFloor (float fValue) { return int(floor(fValue)); }
76  static int ISign (int iValue);
77 
78  static inline float Abs (float fValue) { return float(fabs(fValue)); }
79  static inline double Abs(double fValue) { return fabs(fValue); }
80  static inline int Abs(int nValue) { return nValue >= 0 ? nValue : -nValue; }
81  static inline Degree Abs (const Degree& dValue) { return Degree(fabs(dValue.valueDegrees())); }
82  static inline Radian Abs (const Radian& rValue) { return Radian(fabs(rValue.valueRadians())); }
83  static Radian ACos (float fValue);
84  static Radian ASin (float fValue);
85  static inline Radian ATan (float fValue) { return Radian(atan(fValue)); }
86  static inline Radian ATan2 (float fY, float fX) { return Radian(atan2(fY,fX)); }
87  static inline float Ceil (float fValue) { return float(ceil(fValue)); }
88 
96  static inline float Cos (const Radian& fValue, bool useTables = false) {
97  return (!useTables) ? float(cos(fValue.valueRadians())) : SinTable(fValue.valueRadians() + HALF_PI);
98  }
106  static inline float Cos (float fValue, bool useTables = false) {
107  return (!useTables) ? float(cos(fValue)) : SinTable(fValue + HALF_PI);
108  }
109 
110  static inline float Exp (float fValue) { return float(exp(fValue)); }
111 
112  static inline float Floor (float fValue) { return float(floor(fValue)); }
113 
114  static inline float Log (float fValue) { return float(log(fValue)); }
115 
116  static inline float Pow (float fBase, float fExponent) { return float(pow(fBase,fExponent)); }
117 
118  static float Sign (float fValue);
119  static inline Radian Sign ( const Radian& rValue )
120  {
121  return Radian(Sign(rValue.valueRadians()));
122  }
123  static inline Degree Sign ( const Degree& dValue )
124  {
125  return Degree(Sign(dValue.valueDegrees()));
126  }
127 
135  static inline float Sin (const Radian& fValue, bool useTables = false) {
136  return (!useTables) ? float(sin(fValue.valueRadians())) : SinTable(fValue.valueRadians());
137  }
145  static inline float Sin (float fValue, bool useTables = false) {
146  return (!useTables) ? float(sin(fValue)) : SinTable(fValue);
147  }
148 
149  static inline float Sqr (float fValue) { return fValue*fValue; }
150  static inline float Sqrt (float fValue) { return float(sqrt(fValue)); }
151 
152  static inline double Sqr(double fValue) { return fValue*fValue; }
153  static inline double Sqrt(double fValue) { return sqrt(fValue); }
154 
155  static inline Radian Sqrt (const Radian& fValue) { return Radian(sqrt(fValue.valueRadians())); }
156 
157  static inline Degree Sqrt (const Degree& fValue) { return Degree(sqrt(fValue.valueDegrees())); }
158 
162  static float InvSqrt(float fValue);
163 
164  static float UnitRandom (); // in [0,1]
165 
166  static float RangeRandom (float fLow, float fHigh); // in [fLow,fHigh]
167 
168  static float SymmetricRandom (); // in [-1,1]
169 
177  static inline float Tan (const Radian& fValue, bool useTables = false) {
178  return (!useTables) ? float(tan(fValue.valueRadians())) : TanTable(fValue.valueRadians());
179  }
187  static inline float Tan (float fValue, bool useTables = false) {
188  return (!useTables) ? float(tan(fValue)) : TanTable(fValue);
189  }
190 
191  static inline float DegreesToRadians(float degrees) { return degrees * fDeg2Rad; }
192  static inline float RadiansToDegrees(float radians) { return radians * fRad2Deg; }
193 
200  static void setAngleUnit(AngleUnit unit);
202  static AngleUnit getAngleUnit(void);
203 
205  static float AngleUnitsToRadians(float units);
207  static float RadiansToAngleUnits(float radians);
209  static float AngleUnitsToDegrees(float units);
211  static float DegreesToAngleUnits(float degrees);
212 
234  static bool pointInTri2D(const Vector2& p, const Vector2& a,
235  const Vector2& b, const Vector2& c);
236 
261  static bool pointInTri3D(const Vector3& p, const Vector3& a,
262  const Vector3& b, const Vector3& c, const Vector3& normal);
264  static std::pair<bool, float> intersects(const Ray& ray, const Plane& plane);
265 
267  static std::pair<bool, float> intersects(const Ray& ray, const Sphere& sphere,
268  bool discardInside = true);
269 
271  static std::pair<bool, float> intersects(const Ray& ray, const AxisAlignedBox& box);
272 
295  static bool intersects(const Ray& ray, const AxisAlignedBox& box,
296  float* d1, float* d2);
297 
322  static std::pair<bool, float> intersects(const Ray& ray, const Vector3& a,
323  const Vector3& b, const Vector3& c, const Vector3& normal,
324  bool positiveSide = true, bool negativeSide = true);
325 
346  static std::pair<bool, float> intersects(const Ray& ray, const Vector3& a,
347  const Vector3& b, const Vector3& c,
348  bool positiveSide = true, bool negativeSide = true);
349 
351  static bool intersects(const Sphere& sphere, const AxisAlignedBox& box);
352  static bool intersects(const CShapeSphere& sphere, const CShapeBox& box);
354  static bool intersects(const Plane& plane, const AxisAlignedBox& box);
355 
361  static std::pair<bool, float> intersects(
362  const Ray& ray, const std::vector<Plane>& planeList,
363  bool normalIsOutside);
369  static std::pair<bool, float> intersects(
370  const Ray& ray, const std::list<Plane>& planeList,
371  bool normalIsOutside);
372 
376  static bool intersects(const Sphere& sphere, const Plane& plane);
377 
380  static bool RealEqual(float a, float b,
381  float tolerance = std::numeric_limits<float>::epsilon());
382 
385  const Vector3& position1, const Vector3& position2, const Vector3& position3,
386  float u1, float v1, float u2, float v2, float u3, float v3);
387 
389  static Matrix4 buildReflectionMatrix(const Plane& p);
391  static Vector4 calculateFaceNormal(const Vector3& v1, const Vector3& v2, const Vector3& v3);
393  static Vector3 calculateBasicFaceNormal(const Vector3& v1, const Vector3& v2, const Vector3& v3);
395  static Vector4 calculateFaceNormalWithoutNormalize(const Vector3& v1, const Vector3& v2, const Vector3& v3);
397  static Vector3 calculateBasicFaceNormalWithoutNormalize(const Vector3& v1, const Vector3& v2, const Vector3& v3);
398 
402  static float gaussianDistribution(float x, float offset = 0.0f, float scale = 1.0f);
403 
405  template< class T >
406  static inline T Clamp(const T X, const T Min, const T Max)
407  {
408  return X < Min ? Min : X < Max ? X : Max;
409  }
410 
411  static Matrix4 makeViewMatrix(const Vector3& position, const Quaternion& orientation,
412  const Matrix4* reflectMatrix = 0);
413 
417  static inline bool IsEquivalent(float f1, float f2) { return f1 - f2 < FLT_TOLERANCE && f2 - f1 < FLT_TOLERANCE; }
418 
423  static inline bool IsEquivalent(float f1, float f2, float tolerance) { return f1 - f2 < tolerance && f2 - f1 < tolerance; }
424 
428  static inline bool IsEquivalent(double f1, double f2) { return f1 - f2 < DBL_TOLERANCE && f2 - f1 < DBL_TOLERANCE; }
429 
434  static inline bool IsEquivalent(double f1, double f2, double tolerance) { return f1 - f2 < tolerance && f2 - f1 < tolerance; }
435 
442  template <class T>
443  static inline bool IsEquivalent(const T* al, size_t acount, const T* bl, size_t bcount)
444  {
445  if (acount != bcount) return false;
446  bool equivalent = true;
447  for (size_t i = 0; i < acount && equivalent; ++i)
448  {
449  equivalent = IsEquivalent(al[i], bl[i]);
450  }
451  return equivalent;
452  }
453 
455  static int log2 (unsigned int x);
456 
458  static int log2_ceil(unsigned int x) {return (log2(x-1) + 1);}
459 
461  template< class T >
462  static inline T Max(const T A, const T B)
463  {
464  return (A >= B) ? A : B;
465  }
467  template< class T >
468  static inline T Min(const T A, const T B)
469  {
470  return (A <= B) ? A : B;
471  }
472 
478  static inline int32 Trunc(float F)
479  {
480  return (int32)F;
481  }
487  static inline float TruncFloat(float F)
488  {
489  return (float)Trunc(F);
490  }
491 
497  static inline float Fractional(float Value)
498  {
499  return Value - TruncFloat(Value);
500  }
501 
503  static inline float GridSnap(float Location, float Grid)
504  {
505  if (Grid == 0.f) return Location;
506  else
507  {
508  return Floor((Location + 0.5f*Grid) / Grid)*Grid;
509  }
510  }
511 
512 
514  template <class T>
515  static inline T DivideAndRoundUp(T Dividend, T Divisor)
516  {
517  return (Dividend + Divisor - 1) / Divisor;
518  }
519 
521  template< class T >
522  static inline T Max3(const T A, const T B, const T C)
523  {
524  return Max(Max(A, B), C);
525  }
526 
528  template< class T >
529  static inline T Min3(const T A, const T B, const T C)
530  {
531  return Min(Min(A, B), C);
532  }
533 
535  template< class T, class U >
536  static inline T Lerp(const T& A, const T& B, const U& Alpha)
537  {
538  return (T)(A + Alpha * (B - A));
539  }
540 
542  static inline int32 Rand() { return rand(); }
543 
545  static inline void RandInit(int32 Seed) { srand(Seed); }
546 
548  static inline float FRand() { return rand() / (float)RAND_MAX; }
549 
551  static void SRandInit(int32 Seed);
552 
554  static float SRand();
555 
570  static inline float FloatSelect(float Comparand, float ValueGEZero, float ValueLTZero)
571  {
572  return Comparand >= 0.f ? ValueGEZero : ValueLTZero;
573  }
574 
576  static bool SmoothMoveFloat1(float& src, const float dest, const float fMaxStep);
577 
579  static bool SmoothMoveAngle1(float& src, const float dest, const float fMaxStep);
580 
585  static bool SmoothMoveVec3(Vector3* result, const Vector3& vPosTarget, const Vector3& vPos, FLOAT fIncrease, FLOAT fTolerance/*=0*/);
586 
588  static float ToStandardAngle(float fAngle);
589  static double ToStandardAngle(double fAngle);
590 
597  static bool MatchString(const std::string& matchPattern, const std::string& matchStr);
598 
603  static bool ComputeFacingTarget(const Vector3& target, const Vector3& source, FLOAT& fFacing);
604  static bool ComputeFacingTarget(const DVector3& target, const DVector3& source, float& fFacing);
609  static inline int Round(float fValue){
610  return int(fValue > 0.0f ? fValue + 0.5f : fValue - 0.5f);
611  }
612 
614  static float MinVec3(const Vector3& v);
616  static float MaxVec3(const Vector3& v);
617 
619  template <class T>
620  static inline bool CompareXZ(const T& a, const T& b)
621  {
622  return (a.x == b.x && a.z == b.z);
623  }
624 
626  template <class T>
627  static bool CompareXZ(const T& a, const T& b, float epsilon)
628  {
629  return (fabs(a.x - b.x) + fabs(a.z - b.z)) < epsilon;
630  }
631 
632  static inline bool FuzzyCompare(double p1, double p2)
633  {
634  return (Math::Abs(p1 - p2) * 1000000000000. <= Math::Min(Math::Abs(p1), Math::Abs(p2)));
635  }
636 
637  static bool FuzzyCompare(float p1, float p2)
638  {
639  return (Math::Abs(p1 - p2) * 100000.f <= Math::Min(Math::Abs(p1), Math::Abs(p2)));
640  }
641 
642  static inline bool FuzzyIsNull(double d)
643  {
644  return Math::Abs(d) <= 0.000000000001;
645  }
646 
647  static inline bool FuzzyIsNull(float f)
648  {
649  return Math::Abs(f) <= 0.00001f;
650  }
651 
652  static inline bool IsNull(double d)
653  {
654  union U {
655  double d;
656  uint64 u;
657  };
658  U val;
659  val.d = d;
660  return (val.u & UINT64_C(0x7fffffffffffffff)) == 0;
661  }
662 
663  /*
664  This function tests a float for a null value. It doesn't
665  check whether the actual value is 0 or close to 0, but whether
666  it is binary 0, disregarding sign.
667  */
668  static bool IsNull(float f)
669  {
670  union U {
671  float f;
672  uint32 u;
673  };
674  U val;
675  val.f = f;
676  return (val.u & 0x7fffffff) == 0;
677  }
678 
680  template<typename T>
681  static inline bool is_nan(T value)
682  {
683  return value != value;
684  }
685 
687  template<typename T>
688  static inline bool is_infinity(T value)
689  {
690  return std::numeric_limits<T>::has_infinity &&
691  value == std::numeric_limits<T>::infinity();
692  }
693 
707  static void GetMatrixScaling(const Matrix4& globalMat, float* fScalingX, float* fScalingY, float* fScalingZ);
708 
716  static Matrix4* CreateBillboardMatrix(Matrix4* pOut, const Matrix4* matModelview, const Vector3* vBillboardPos, bool bAxisAligned = false);
717 
718  // Make a rotation matrix based on the camera's yaw & pitch
719  static void CameraRotMatrixYawPitch(Matrix4& out, float fYaw, float fPitch);
720 
722  static int NextPowerOf2(int x);
723  };
724 }
725 
static bool IsEquivalent(float f1, float f2, float tolerance)
Returns whether two floating-point values are equivalent within a given tolerance.
Definition: ParaMath.h:423
static float RadiansToAngleUnits(float radians)
Convert from radians to the current AngleUnit .
Definition: ParaMath.cpp:184
static int Round(float fValue)
get the closest integer near the specified float number.
Definition: ParaMath.h:609
static float GridSnap(float Location, float Grid)
Snaps a value to the nearest grid multiple.
Definition: ParaMath.h:503
Wrapper class which indicates a given angle value is in Radians.
Definition: ParaAngle.h:10
static Matrix4 buildReflectionMatrix(const Plane &p)
Build a reflection matrix for the passed in plane.
Definition: ParaMath.cpp:893
static float Sin(float fValue, bool useTables=false)
Sine function.
Definition: ParaMath.h:145
3-dimensional vector with double precision.
Definition: ParaDVector3.h:17
static float Sin(const Radian &fValue, bool useTables=false)
Sine function.
Definition: ParaMath.h:135
static int log2(unsigned int x)
this is a fast version of log2.
Definition: ParaMath.cpp:978
static bool CompareXZ(const T &a, const T &b)
return true if equal.
Definition: ParaMath.h:620
4-dimensional homogeneous vector.
Definition: ParaVector4.h:10
static bool IsEquivalent(double f1, double f2, double tolerance)
Returns whether two double-sized floating-point values are equivalent within a given tolerance...
Definition: ParaMath.h:434
static T Min3(const T A, const T B, const T C)
Returns lowest of 3 values.
Definition: ParaMath.h:529
static bool IsEquivalent(double f1, double f2)
Returns whether two double-sized floating-point values are equivalent.
Definition: ParaMath.h:428
static Vector3 calculateBasicFaceNormalWithoutNormalize(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
Calculate a face normal without normalize, no w-information.
Definition: ParaMath.cpp:923
static Vector3 calculateBasicFaceNormal(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
Calculate a face normal, no w-information.
Definition: ParaMath.cpp:909
static float FloatSelect(float Comparand, float ValueGEZero, float ValueLTZero)
Returns value based on comparand.
Definition: ParaMath.h:570
different physics engine has different winding order.
Definition: EventBinding.h:32
static int mTrigTableSize
Size of the trig tables as determined by constructor.
Definition: ParaMath.h:48
static std::pair< bool, float > intersects(const Ray &ray, const Plane &plane)
Ray / plane intersection, returns boolean result and distance.
Definition: ParaMath.cpp:316
Math(unsigned int trigTableSize=4096)
Default constructor.
Definition: ParaMath.cpp:37
static int NextPowerOf2(int x)
get nearest power of two of x
Definition: ParaMath.cpp:1304
static T Clamp(const T X, const T Min, const T Max)
Clamps X to be between Min and Max, inclusive.
Definition: ParaMath.h:406
A sphere primitive, mostly used for bounds checking.
Definition: ParaSphere.h:46
static float mTrigTableFactor
Radian -> index factor value ( mTrigTableSize / 2 * PI )
Definition: ParaMath.h:51
static bool RealEqual(float a, float b, float tolerance=std::numeric_limits< float >::epsilon())
Compare 2 reals, using tolerance for inaccuracies.
Definition: ParaMath.cpp:307
static float Tan(const Radian &fValue, bool useTables=false)
Tangent function.
Definition: ParaMath.h:177
static bool CompareXZ(const T &a, const T &b, float epsilon)
return true if equal.
Definition: ParaMath.h:627
Implementation of a Quaternion, i.e.
Definition: ParaQuaternion.h:10
static bool SmoothMoveVec3(Vector3 *result, const Vector3 &vPosTarget, const Vector3 &vPos, FLOAT fIncrease, FLOAT fTolerance)
linearly (smoothly) move vPos to vPosTarget by the amount fIncrease return true if we have reached th...
Definition: ParaMath.cpp:1051
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
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...
Definition: ParaMath.cpp:211
Definition: minilua.c:225
Wrapper class which indicates a given angle value is in Degrees.
Definition: ParaAngle.h:56
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.
Definition: ParaMath.cpp:259
static int32 Trunc(float F)
Converts a float to an integer with truncation towards zero.
Definition: ParaMath.h:478
static void CameraRotMatrixYawPitch(Matrix4 &out, float fYaw, float fPitch)
Definition: ParaMath.cpp:1289
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
static void setAngleUnit(AngleUnit unit)
These functions used to set the assumed angle units (radians or degrees) expected when using the Angl...
Definition: ParaMath.cpp:165
static float Cos(float fValue, bool useTables=false)
Cosine function.
Definition: ParaMath.h:106
static int32 Rand()
Returns a random integer between 0 and RAND_MAX, inclusive.
Definition: ParaMath.h:542
Definition: ShapeSphere.h:6
void buildTrigTables()
Private function to build trig tables.
Definition: ParaMath.cpp:58
static bool IsEquivalent(const T *al, size_t acount, const T *bl, size_t bcount)
Returns whether two constant-sized arrays are equivalent.
Definition: ParaMath.h:443
static float Tan(float fValue, bool useTables=false)
Tangent function.
Definition: ParaMath.h:187
static float Fractional(float Value)
Returns the fractional part of a float.
Definition: ParaMath.h:497
Representation of a ray in space, i.e.
Definition: ParaRay.h:41
static float AngleUnitsToDegrees(float units)
Convert from the current AngleUnit to degrees.
Definition: ParaMath.cpp:193
AngleUnit
The angular units used by the API.
Definition: ParaMath.h:29
static bool SmoothMoveFloat1(float &src, const float dest, const float fMaxStep)
change src from src to dest, by a maximum of fMaxStep.
Definition: ParaMath.cpp:1015
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
static float DegreesToAngleUnits(float degrees)
Convert from degrees to the current AngleUnit.
Definition: ParaMath.cpp:202
static T Min(const T A, const T B)
Returns lower value in a generic way.
Definition: ParaMath.h:468
Defines a plane in 3D space.
Definition: ParaPlane.h:23
static float AngleUnitsToRadians(float units)
Convert from the current AngleUnit to radians.
Definition: ParaMath.cpp:175
static float ToStandardAngle(float fAngle)
make sure that the angle is in the range (-Pi,Pi]
Definition: ParaMath.cpp:1094
Definition: enum_maker.hpp:46
static bool IsEquivalent(float f1, float f2)
Returns whether two floating-point values are equivalent within a given tolerance.
Definition: ParaMath.h:417
static bool is_nan(T value)
whether value is not a number, T is usually float or double
Definition: ParaMath.h:681
static float Cos(const Radian &fValue, bool useTables=false)
Cosine function.
Definition: ParaMath.h:96
static T DivideAndRoundUp(T Dividend, T Divisor)
Divides two integers and rounds up.
Definition: ParaMath.h:515
static bool MatchString(const std::string &matchPattern, const std::string &matchStr)
check if the matchStr matches the string pattern in matchPattern
Definition: ParaMath.cpp:1116
~Math()
Default destructor.
Definition: ParaMath.cpp:51
static float SRand()
Returns a seeded random float in the range [0,1), using the seed from SRandInit().
Definition: ParaMath.cpp:1003
static float InvSqrt(float fValue)
Inverse square root i.e.
Definition: ParaMath.cpp:142
static AngleUnit getAngleUnit(void)
Get the unit being used for angles.
Definition: ParaMath.cpp:170
static Vector3 calculateTangentSpaceVector(const Vector3 &position1, const Vector3 &position2, const Vector3 &position3, float u1, float v1, float u2, float v2, float u3, float v3)
Calculates the tangent space vector for a given set of positions / texture coords.
Definition: ParaMath.cpp:855
static bool is_infinity(T value)
whether value is infinity, T is usually float or double
Definition: ParaMath.h:688
static bool ComputeFacingTarget(const Vector3 &target, const Vector3 &source, FLOAT &fFacing)
facing target in xz plane fFacing: [out] it is in the range [0, 2PI] return true if target!=source(a...
Definition: ParaMath.cpp:1142
static bool SmoothMoveAngle1(float &src, const float dest, const float fMaxStep)
change src from src to dest, by a maximum of fMaxStep.
Definition: ParaMath.cpp:1032
static float MinVec3(const Vector3 &v)
Returns MIN(x, y, z);.
Definition: ParaMath.cpp:1200
static T Lerp(const T &A, const T &B, const U &Alpha)
Performs a linear interpolation between two values, Alpha ranges from 0-1.
Definition: ParaMath.h:536
A 3D box aligned with the x/y/z axes.
Definition: ParaAxisAlignedBox.h:16
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.
Definition: ParaMath.cpp:902
static float gaussianDistribution(float x, float offset=0.0f, float scale=1.0f)
Generates a value based on the Gaussian (normal) distribution function with the given offset and scal...
Definition: ParaMath.cpp:929
static float FRand()
Returns a random float between 0 and 1, inclusive.
Definition: ParaMath.h:548
static T Max3(const T A, const T B, const T C)
Returns highest of 3 values.
Definition: ParaMath.h:522
static void SRandInit(int32 Seed)
Seeds future calls to SRand()
Definition: ParaMath.cpp:998
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...
Definition: ParaMath.cpp:916
static Matrix4 * CreateBillboardMatrix(Matrix4 *pOut, const Matrix4 *matModelview, const Vector3 *vBillboardPos, bool bAxisAligned=false)
create a billboard matrix
Definition: ParaMath.cpp:1221
standard math lib
Definition: ParaMath.h:21
static void RandInit(int32 Seed)
Seeds global random number functions Rand() and FRand()
Definition: ParaMath.h:545
static int log2_ceil(unsigned int x)
this is a fast version of log2.
Definition: ParaMath.h:458
static float TruncFloat(float F)
Converts a float to an integer value with truncation towards zero.
Definition: ParaMath.h:487
static float MaxVec3(const Vector3 &v)
Returns MAX(x, y, z);.
Definition: ParaMath.cpp:1205
static T Max(const T A, const T B)
Returns higher value in a generic way.
Definition: ParaMath.h:462
static void GetMatrixScaling(const Matrix4 &globalMat, float *fScalingX, float *fScalingY, float *fScalingZ)
Get the scaling factor from globalMat.
Definition: ParaMath.cpp:1210
a min max box.
Definition: ShapeAABB.h:190