alternative Standard Libary  0.29.8
std::math-Namensbereichsreferenz

Klassen

class  boundingbox
 a clasd for a BoundingBox Mehr ...
 
class  color
 
class  colors_base
 
class  matrix4x4
 
class  physik
 
class  physik_base
 
class  plane
 
class  quaternion
 
class  ray
 
class  rectangle
 
class  vector2
 
class  vector3
 
class  vector4
 

Typdefinitionen

typedef enum std::math::boundingcontains contains_t
 enum Mehr ...
 
typedef boundingbox< float > bbox
 bbox is a float boundingbox type Mehr ...
 
typedef boundingbox< double > dbox
 dbox is a double boundingbox type Mehr ...
 
typedef color< float > colf
 
typedef color< double > cold
 
typedef colors_base< float > colors_t
 
typedef colors_base< double > colors_d
 
typedef matrix4x4< float > mat4f
 
typedef matrix4x4< double > mat4d
 
typedef physik< float > physiksystem
 
typedef physik_base< float > physiksystem_base
 
typedef physik< double > physiksystemEx
 
typedef physik_base< double > physiksystem_baseEx
 
typedef plane< float > planef
 
typedef plane< double > planed
 
typedef plane< int > planei
 
typedef plane< short > planes
 
typedef quaternion< float > quatf
 
typedef quaternion< double > quatd
 
typedef quaternion< int > quati
 
typedef quaternion< short > quats
 
using vec2f = vector2< float >
 
using vec2d = vector2< double >
 
typedef vector3< float > vec3f
 
typedef vector3< double > vec3d
 
typedef vector4< float > vec4f
 
typedef vector4< double > vec4d
 

Aufzählungen

enum  boundingcontains { Disjoint, Contains, Intersects }
 enum Mehr ...
 

Funktionen

template<typename T >
bool operator== (const boundingbox< T > &a, const boundingbox< T > &b)
 
template<typename T >
bool operator!= (const boundingbox< T > &a, const boundingbox< T > &b)
 
template<typename T >
bool operator<= (const boundingbox< T > &a, const boundingbox< T > &b)
 
template<typename T >
bool operator>= (const boundingbox< T > &a, const boundingbox< T > &b)
 
template<typename T >
bool operator> (const boundingbox< T > &a, const boundingbox< T > &b)
 
template<typename T >
bool operator< (const boundingbox< T > &a, const boundingbox< T > &b)
 
template<typename T >
color< T > operator+ (const color< T > &a, const color< T > &b)
 
template<typename T >
color< T > operator- (const color< T > &a, const color< T > &b)
 
template<typename T >
color< T > operator- (const color< T > &c)
 
template<typename T >
color< T > operator* (const color< T > &a, const color< T > &b)
 
template<typename T >
color< T > operator* (const color< T > &c, const T f)
 
template<typename T >
color< T > operator* (const T f, const color< T > &c)
 
template<typename T >
color< T > operator/ (const color< T > &a, const color< T > &b)
 
template<typename T >
color< T > operator/ (const color< T > &c, const T f)
 
template<typename T >
bool operator== (const color< T > &a, const color< T > &b)
 
template<typename T >
bool operator!= (const color< T > &a, const color< T > &b)
 
template<typename T >
color< T > negate (const color< T > &c)
 
template<typename T >
brightness (const color< T > &c)
 
template<typename T >
color< T > interpolate (const color< T > &c1, const color< T > &c2, const T p)
 
template<typename T >
color< T > _min (const color< T > &c1, const color< T > &c2)
 
template<typename T >
color< T > _max (const color< T > &c1, const color< T > &c2)
 
template<typename T >
color< T > from_yuv (const T y, const T u, const T v)
 
template<typename T >
color< T > from_cmy (const T c, const T m, const T y)
 
template<typename T >
color< T > from_hsv (const T h, const T s, const T v)
 
template<typename T >
matrix4x4< T > tomatrix (const quaternion< T > &v)
 
template<typename T >
quaternion< T > toquaternion (const matrix4x4< T > &mat)
 
template<typename T >
vector3< T > transformcoord (const vector3< T > &v, const matrix4x4< T > &m)
 
template<typename T >
vector3< T > transformnormal (const vector3< T > &v, const matrix4x4< T > &m)
 
template<typename T >
matrix4x4< T > invert (const matrix4x4< T > &mat)
 
template<typename T >
matrix4x4< T > operator+ (const matrix4x4< T > &a, const matrix4x4< T > &b)
 
template<typename T >
matrix4x4< T > operator- (const matrix4x4< T > &a, const matrix4x4< T > &b)
 
template<typename T >
matrix4x4< T > operator- (const matrix4x4< T > &m)
 
template<typename T >
matrix4x4< T > operator* (const matrix4x4< T > &a, const matrix4x4< T > &b)
 
template<typename T >
matrix4x4< T > operator* (const matrix4x4< T > &m, const T f)
 
template<typename T >
matrix4x4< T > operator* (const T f, const matrix4x4< T > &m)
 
template<typename T >
matrix4x4< T > operator/ (const matrix4x4< T > &a, const matrix4x4< T > &b)
 
template<typename T >
matrix4x4< T > operator/ (const matrix4x4< T > &m, const T f)
 
template<typename T >
bool operator== (const matrix4x4< T > &a, const matrix4x4< T > &b)
 
template<typename T >
bool operator!= (const matrix4x4< T > &a, const matrix4x4< T > &b)
 
template<typename T >
matrix4x4< T > matrix4x4_identity ()
 
template<typename T >
matrix4x4< T > translate (const matrix4x4< T > &mat, const vector3< T > &v)
 
template<typename T >
matrix4x4< T > rotate (const matrix4x4< T > &mat, const vector3< T > &v, const T angle)
 
template<typename T >
matrix4x4< T > & rotateX (const matrix4x4< T > mat, const T angle)
 
template<typename T >
matrix4x4< T > & rotateY (const matrix4x4< T > mat, const T angle)
 
template<typename T >
matrix4x4< T > & rotateZ (const matrix4x4< T > mat, const T angle)
 
template<typename T >
matrix4x4< T > transpose (const matrix4x4< T > &mat)
 
template<typename T >
cofactor (T m0, T m1, T m2, T m3, T m4, T m5, T m6, T m7, T m8)
 
template<typename T >
det (const matrix4x4< T > &m)
 
template<typename T >
vector3< T > angle (const matrix4x4< T > &m)
 
template<typename T >
matrix4x4< T > column (const matrix4x4< T > mat, int index, vector3< T > v)
 
template<typename T >
matrix4x4< T > row (const matrix4x4< T > mat, int index, vector3< T > v)
 
template<typename T >
matrix4x4< T > column (const matrix4x4< T > mat, int index, vector4< T > v)
 
template<typename T >
matrix4x4< T > row (const matrix4x4< T > mat, int index, vector4< T > v)
 
template<typename T >
matrix4x4< T > lockat (const vector3< T > position, const vector3< T > &target, const vector3< T > &vUp=vector3< T >(0, 1, 0))
 
template<typename T >
matrix4x4< T > lockat (const matrix4x4< T > m, const vector3< T > &target, const vector3< T > &vUp=vector3< T >(0, 1, 0))
 
template<typename T >
matrix4x4< T > scaling (const vector3< T > &v)
 
template<typename T >
matrix4x4< T > frustum (const T left, const T right, const T bottom, const T top, const T near, const T far)
 
template<typename T >
matrix4x4< T > perspective (const T fov, const T aspect, const T near, const T far)
 
template<typename T >
matrix4x4< T > ortho (const T left, const T right, const T bottom, const T top, const T near, const T far)
 
template<typename T >
bool is_physikcollision (physik< T > *p1, physik< T > *p2)
 
template<typename T >
plane< T > plane_frompointnormal (const vector3< T > &p, const vector3< T > &n)
 
template<typename T >
plane< T > plane_frompoints (const vector3< T > &v1, const vector3< T > &v2, const vector3< T > &v3)
 
template<typename T >
bool operator== (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
bool operator!= (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
bool operator<= (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
bool operator>= (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
bool operator< (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
bool operator> (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
quaternion identy ()
 
template<typename T >
lenght (const quaternion< T > &v)
 
template<typename T >
lenghtSq (const quaternion< T > &v)
 
template<typename T >
quaternion< T > invert (const quaternion< T > &q)
 
template<typename T >
quaternion< T > exp (const quaternion< T > &v)
 
template<typename T >
quaternion< T > log (const quaternion< T > &v)
 
template<typename T >
quaternion< T > normalize (const quaternion< T > &v)
 
template<typename T >
quaternion< T > conjugate (const quaternion< T > &v)
 
template<typename T >
quaternion< T > pow (const quaternion< T > &v, const T exp)
 
template<typename T >
dot (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
quaternion< T > power (const quaternion< T > &qu, T degree)
 
template<typename T >
quaternion< T > raQuaternionSin (const quaternion< T > &q)
 
template<typename T >
quaternion< T > raQuaternionCos (const quaternion< T > &q)
 
template<typename T >
quaternion< T > tan (const quaternion< T > &q)
 
template<typename T >
quaternion< T > ctan (const quaternion< T > &q)
 
template<typename T >
quaternion< T > operator* (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
quaternion< T > operator* (const quaternion< T > &a, const float b)
 
template<typename T >
quaternion< T > operator+ (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
quaternion< T > operator- (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
quaternion< T > operator- (const quaternion< T > &a)
 
template<typename T >
quaternion< T > operator/ (const quaternion< T > &a, const quaternion< T > &b)
 
template<typename T >
quaternion< T > operator/ (const quaternion< T > &a, const float b)
 
template<typename T >
quaternion< T > quaternion_fromaxis (const float angle, vector3< T > axis)
 
template<typename T >
bool operator== (ray< T > a, ray< T > b)
 
template<typename T >
bool operator!= (ray< T > a, ray< T > b)
 
template<typename T >
bool operator== (rectangle< T > a, rectangle< T > b)
 
template<typename T >
bool operator!= (rectangle< T > a, rectangle< T > b)
 
template<typename T >
factorial (T p)
 
template<typename T >
barycentric (T value1, T value2, T value3, T amount1, T amount2)
 
template<typename T >
catmullrom (T value1, T value2, T value3, T value4, T amount)
 
template<typename T >
clamp (T value, T min, T max)
 
template<typename T >
hermite (T value1, T tangent1, T value2, T tangent2, T amount)
 
template<typename T >
Lerp (T value1, T value2, T amount)
 
template<typename T >
SmoothStep (T value1, T value2, T amount)
 
template<typename T >
degrees (T radians)
 
template<typename T >
float radians (float degrees)
 
template<typename T >
vector2< T > operator+ (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
vector2< T > operator- (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
vector2< T > operator* (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
vector2< T > operator/ (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
vector2< T > operator+ (const float &f, const vector2< T > &b)
 
template<typename T >
vector2< T > operator- (const float &f, const vector2< T > &b)
 
template<typename T >
vector2< T > operator* (const float &f, const vector2< T > &b)
 
template<typename T >
vector2< T > operator/ (const float &f, const vector2< T > &b)
 
template<typename T >
vector2< T > operator- (const vector2< T > &a, const float &f)
 
template<typename T >
vector2< T > operator/ (const vector2< T > &a, const float &f)
 
template<typename T >
bool operator== (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
bool operator!= (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
bool operator<= (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
bool operator>= (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
bool operator< (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
bool operator> (const vector2< T > &a, const vector2< T > &b)
 
template<typename T >
lenght (const vector2< T > &v)
 
template<typename T >
lenghtSq (const vector2< T > &v)
 
template<typename T >
vector2< T > normalize (const vector2< T > &v)
 
template<typename T >
vector2< T > normalizeEx (const vector2< T > &v)
 
template<typename T >
dot (const vector2< T > &v1, const vector2< T > &v2)
 
template<typename T >
angle (const vector2< T > &v1, const vector2< T > &v2)
 
template<typename T >
vector2< T > interpolate_coords (const vector2< T > &v1, const vector2< T > &v2, const T p)
 
template<typename T >
vector2< T > interpolate_normal (const vector2< T > &v1, const vector2< T > &v2, const T p)
 
template<typename T >
bool nearEqual (const vector2< T > &v1, vector2< T > &v2, const vector2< T > &epsilon)
 
template<typename T >
vector2< T > _min (const vector2< T > &c1, const vector2< T > &c2)
 
template<typename T >
vector2< T > _max (const vector2< T > &c1, const vector2< T > &c2)
 
template<typename T >
vector2< T > scale (const vector2< T > &v, const float s)
 
template<typename T >
vector3< T > operator+ (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
vector3< T > operator- (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
vector3< T > operator- (const vector3< T > &a)
 
template<typename T >
vector3< T > operator* (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
vector3< T > operator* (const vector3< T > &a, const T &b)
 
template<typename T >
vector3< T > operator* (const T &a, const vector3< T > &b)
 
template<typename T >
vector3< T > operator/ (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
vector3< T > operator/ (const T &a, const vector3< T > &b)
 
template<typename T >
vector3< T > operator/ (const vector3< T > &a, const T &b)
 
template<typename T >
bool operator== (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
bool operator!= (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
bool operator<= (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
bool operator>= (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
bool operator< (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
bool operator> (const vector3< T > &a, const vector3< T > &b)
 
template<typename T >
lenghtSq (const vector3< T > &v)
 
template<typename T >
lenght (const vector3< T > &v)
 
template<typename T >
vector3< T > normalize (const vector3< T > &v)
 
template<typename T >
vector3< T > normalizex (const vector3< T > &v)
 
template<typename T >
vector3< T > cross (const vector3< T > &v1, vector3< T > &v2)
 
template<typename T >
dot (const vector3< T > &v1, const vector3< T > &v2)
 
template<typename T >
angle (const vector3< T > &v1, const vector3< T > &v2)
 
template<typename T >
vector3< T > interpolate_coords (const vector3< T > &v1, const vector3< T > &v2, const float p)
 
template<typename T >
vector3< T > interpolate_normal (const vector3< T > &v1, const vector3< T > &v2, const float p)
 
template<typename T >
bool nearequal (const vector3< T > &v1, vector3< T > &v2, const vector2< T > &epsilon)
 
template<typename T >
vector3< T > _min (const vector3< T > &c1, const vector3< T > &c2)
 
template<typename T >
vector3< T > _max (const vector3< T > &c1, const vector3< T > &c2)
 
template<typename T >
vector3< T > scale (const vector3< T > &v, const float s)
 
template<typename T >
vector4< T > operator+ (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
vector4< T > operator- (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
vector4< T > operator- (const vector4< T > &v)
 
template<typename T >
vector4< T > operator* (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
vector4< T > operator* (const vector4< T > &a, const T &b)
 
template<typename T >
vector4< T > operator* (const T &a, const vector4< T > &b)
 
template<typename T >
vector4< T > operator/ (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
vector4< T > operator/ (const T &a, const vector4< T > &b)
 
template<typename T >
vector4< T > operator/ (const vector4< T > &a, const T &b)
 
template<typename T >
bool operator== (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
bool operator!= (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
bool operator<= (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
bool operator>= (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
bool operator< (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
bool operator> (const vector4< T > &a, const vector4< T > &b)
 
template<typename T >
lenghtSq (const vector4< T > &v)
 
template<typename T >
lenght (const vector4< T > &v)
 
template<typename T >
vector4< T > normalize (const vector4< T > &v)
 
template<typename T >
vector4< T > normalizex (const vector4< T > &v)
 
template<typename T >
dot (const vector4< T > &v1, const vector4< T > &v2)
 
template<typename T >
angle (const vector4< T > &v1, const vector4< T > &v2)
 
template<typename T >
vector4< T > interpolate_coords (const vector4< T > &v1, const vector4< T > &v2, const T p)
 
template<typename T >
vector4< T > interpolate_normal (const vector4< T > &v1, const vector4< T > &v2, const T p)
 
template<typename T >
bool near_equal (const vector4< T > &v1, vector4< T > &v2, const vector2< T > &epsilon)
 
template<typename T >
vector4< T > scale (const vector4< T > &v, const float s)
 

Dokumentation der benutzerdefinierten Typen

◆ bbox

typedef boundingbox<float> std::math::bbox

bbox is a float boundingbox type

◆ cold

typedef color<double> std::math::cold

◆ colf

typedef color<float> std::math::colf

◆ colors_d

◆ colors_t

◆ contains_t

◆ dbox

typedef boundingbox<double> std::math::dbox

dbox is a double boundingbox type

◆ mat4d

typedef matrix4x4<double> std::math::mat4d

◆ mat4f

typedef matrix4x4<float> std::math::mat4f

◆ physiksystem

◆ physiksystem_base

◆ physiksystem_baseEx

◆ physiksystemEx

◆ planed

typedef plane<double> std::math::planed

◆ planef

typedef plane<float> std::math::planef

◆ planei

typedef plane<int> std::math::planei

◆ planes

typedef plane<short> std::math::planes

◆ quatd

typedef quaternion<double> std::math::quatd

◆ quatf

typedef quaternion<float> std::math::quatf

◆ quati

◆ quats

typedef quaternion<short> std::math::quats

◆ vec2d

using std::math::vec2d = typedef vector2<double>

◆ vec2f

using std::math::vec2f = typedef vector2<float>

◆ vec3d

typedef vector3<double> std::math::vec3d

◆ vec3f

typedef vector3<float> std::math::vec3f

◆ vec4d

typedef vector4<double> std::math::vec4d

◆ vec4f

typedef vector4<float> std::math::vec4f

Dokumentation der Aufzählungstypen

◆ boundingcontains

enum

Aufzählungswerte
Disjoint 
Contains 
Intersects 
43  {
44  Disjoint,
45  Contains,
47  }contains_t;
Definition: boundingbox.hpp:46
enum std::math::boundingcontains contains_t
enum
Definition: boundingbox.hpp:45
Definition: boundingbox.hpp:44

Dokumentation der Funktionen

◆ _max() [1/3]

template<typename T >
color<T> std::math::_max ( const color< T > &  c1,
const color< T > &  c2 
)
inline
152  {return color<T>(std::_max<T>(c1.r, c2.r), std::_max<T>(c1.g, c2.g), std::_max<T>(c1.b, c2.b), std::_max<T>(c1.a, c2.a));}

◆ _max() [2/3]

template<typename T >
vector3<T> std::math::_max ( const vector3< T > &  c1,
const vector3< T > &  c2 
)
inline
182  {return vector3<T>(std::_max<T>(c1.x, c2.x), std::_max<T>(c1.y, c2.y), std::_max<T>(c1.z, c2.z));}

◆ _max() [3/3]

template<typename T >
vector2<T> std::math::_max ( const vector2< T > &  c1,
const vector2< T > &  c2 
)
inline
187  {return vector2<T>(std::_max<T>(c1.x, c2.x), std::_max<T>(c1.y, c2.y));}

◆ _min() [1/3]

template<typename T >
color<T> std::math::_min ( const color< T > &  c1,
const color< T > &  c2 
)
inline
149  {return color<T>(std::_min<T>(c1.r, c2.r), std::_min<T>(c1.g, c2.g), std::_min<T>(c1.b, c2.b), std::_min<T>(c1.a, c2.a));}

◆ _min() [2/3]

template<typename T >
vector3<T> std::math::_min ( const vector3< T > &  c1,
const vector3< T > &  c2 
)
inline
179  {return vector3<T>(std::_min<T>(c1.x, c2.x), std::_min<T>(c1.y, c2.y), std::_min<T>(c1.z, c2.z));}

◆ _min() [3/3]

template<typename T >
vector2<T> std::math::_min ( const vector2< T > &  c1,
const vector2< T > &  c2 
)
inline
184  {return vector2<T>(std::_min<T>(c1.x, c2.x), std::_min<T>(c1.y, c2.y));}

◆ angle() [1/4]

template<typename T >
T std::math::angle ( const vector3< T > &  v1,
const vector3< T > &  v2 
)
inline
165  { return (T)(acos(double((v1.x * v2.x + v1.y * v2.y + v1.z * v2.z)) /
166  sqrt((double)((v1.x * v1.x + v1.y * v1.y + v1.z * v1.z)) * T((v2.x * v2.x + v2.y * v2.y + v2.z * v2.z))))); }

◆ angle() [2/4]

template<typename T >
T std::math::angle ( const vector4< T > &  v1,
const vector4< T > &  v2 
)
inline
166  { return (T)acosf((v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w) /
167  (T)sqrtf((v1.x * v1.x + v1.y * v1.y + v1.z * v1.z + v1.w * v1.w) * (v2.x * v2.x + v2.y * v2.y + v2.z * v2.z + v2.w * v2.w))); }

◆ angle() [3/4]

template<typename T >
T std::math::angle ( const vector2< T > &  v1,
const vector2< T > &  v2 
)
inline
170  { return (T)acos((v1.x * v2.x + v1.y * v2.y ) /
171  (T)sqrt((v1.x * v1.x + v1.y * v1.y ) * (v2.x * v2.x + v2.y * v2.y))); }

◆ angle() [4/4]

template<typename T >
vector3<T> std::math::angle ( const matrix4x4< T > &  m)
inline
409  {
410  T pitch, yaw, roll; // 3 angles
411 
412  yaw = (RAD2DEG * (T)asin(m.n[8]));
413  if(m.n[10] < 0)
414  {
415  if(yaw >= 0) yaw = 180.0f - yaw;
416  else yaw =-180.0f - yaw;
417  }
418 
419  if(m.n[0] > -EPSILON && m.n[0] < EPSILON)
420  {
421  roll = 0;
422  pitch = (RAD2DEG * atan2(m.n[1], m.n[5]));
423  }
424  else
425  {
426  roll = (RAD2DEG * atan2(-m.n[4], m.n[0]));
427  pitch = (RAD2DEG * atan2(-m.n[9], m.n[10]));
428  }
429 
430  return vector3<T>(pitch, yaw, roll);
431  }
#define EPSILON
Definition: utils.hpp:37
#define RAD2DEG
Definition: utils.hpp:36

◆ barycentric()

template<typename T >
T std::math::barycentric ( value1,
value2,
value3,
amount1,
amount2 
)
inline
66  {
67  return value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2;
68  }

◆ brightness()

template<typename T >
T std::math::brightness ( const color< T > &  c)
inline
143  {return c.r * 0.299f + c.g * 0.587f + c.b * 0.114f;}

◆ catmullrom()

template<typename T >
T std::math::catmullrom ( value1,
value2,
value3,
value4,
amount 
)
inline
71  {
72  float amountSq = amount * amount;
73  float amountCube = amountSq * amount;
74  return (( T(2.0) * value2 +
75  (-value1 + value3) * amount +
76  ((T)2.0 * value1 - (T)5.0 * value2 + (T)4.0 * value3 - value4) * amountSq +
77  ((T)3.0 * value2 - (T)3.0 * value3 - value1 + value4) * amountCube) * (T)0.5);
78  }

◆ clamp()

template<typename T >
T std::math::clamp ( value,
min,
max 
)
inline
81  {
82  return std::_min<T> (std::_max<T> (min, value), max);
83  }

◆ cofactor()

template<typename T >
T std::math::cofactor ( m0,
m1,
m2,
m3,
m4,
m5,
m6,
m7,
m8 
)
inline
393  {
394  return m0 * (m4 * m8 - m5 * m7) -
395  m1 * (m3 * m8 - m5 * m6) +
396  m2 * (m3 * m7 - m4 * m6);
397  }

◆ column() [1/2]

template<typename T >
matrix4x4<T> std::math::column ( const matrix4x4< T >  mat,
int  index,
vector3< T >  v 
)
inline
434  {
435  matrix4x4<T> m = mat;
436  m.n[index*4] = v.x; m.n[index*4 + 1] = v.y; m.n[index*4 + 2] = v.z;
437  return m;
438  }

◆ column() [2/2]

template<typename T >
matrix4x4<T> std::math::column ( const matrix4x4< T >  mat,
int  index,
vector4< T >  v 
)
inline
448  {
449  matrix4x4<T> m = mat;
450  m.n[index*4] = v.x; m.n[index*4 + 1] = v.y; m.n[index*4 + 2] = v.z;
451  m.n[index*4 + 3] = v.w;
452  return m;
453  }

◆ conjugate()

template<typename T >
quaternion<T> std::math::conjugate ( const quaternion< T > &  v)
inline
182  {
183  quaternion<T> temp = v;
184 
185  temp.s = -temp.s;
186  temp.v = -temp.v;
187 
188  return temp;
189  }

◆ cross()

template<typename T >
vector3<T> std::math::cross ( const vector3< T > &  v1,
vector3< T > &  v2 
)
inline
159  { return vector3<T>(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); }

◆ ctan()

template<typename T >
quaternion<T> std::math::ctan ( const quaternion< T > &  q)
inline
253  {
254  if ( lenghtSq(q) == 0 ) return quaternion<T>(1.0, 0.0, 0.0, 0.0) ;
255  return cos( q ) / sin( q ) ;
256  }
T lenghtSq(const quaternion< T > &v)
Definition: quaternion.hpp:125

◆ degrees()

template<typename T >
T std::math::degrees ( radians)
inline
110  {
111  return radians * (180/ PI);
112  }
#define PI
Definition: utils.hpp:41
float radians(float degrees)
Definition: utils.hpp:114

◆ det()

template<typename T >
T std::math::det ( const matrix4x4< T > &  m)
inline
400  {
401 
402  return m.n[0] * cofactor<T>(m.n[5],m.n[6],m.n[7], m.n[9],m.n[10],m.n[11], m.n[13],m.n[14],m.n[15]) -
403  m.n[1] * cofactor<T>(m.n[4],m.n[6],m.n[7], m.n[8],m.n[10],m.n[11], m.n[12],m.n[14],m.n[15]) +
404  m.n[2] * cofactor<T>(m.n[4],m.n[5],m.n[7], m.n[8],m.n[9], m.n[11], m.n[12],m.n[13],m.n[15]) -
405  m.n[3] * cofactor<T>(m.n[4],m.n[5],m.n[6], m.n[8],m.n[9], m.n[10], m.n[12],m.n[13],m.n[14]);
406  }

◆ dot() [1/4]

template<typename T >
T std::math::dot ( const vector3< T > &  v1,
const vector3< T > &  v2 
)
inline
162  { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;}

◆ dot() [2/4]

template<typename T >
T std::math::dot ( const vector4< T > &  v1,
const vector4< T > &  v2 
)
inline
163  { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;}

◆ dot() [3/4]

template<typename T >
T std::math::dot ( const vector2< T > &  v1,
const vector2< T > &  v2 
)
inline
167  { return (T)(v1.x * v2.x + v1.y * v2.y);}

◆ dot() [4/4]

template<typename T >
T std::math::dot ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
208  {
209  return a.s*b.s + a.v.x*b.v.x + a.v.y*b.v.y + a.v.z*b.v.z;
210  }

◆ exp()

template<typename T >
quaternion<T> std::math::exp ( const quaternion< T > &  v)
inline
132  {
133  T Mul;
134  quaternion<T> temp = v;
135  T Length = lenght(temp.v);
136 
137  if (Length > 1.0e-4) Mul = sin(Length)/Length;
138  else Mul = 1.0;
139 
140  temp.s = cos(Length);
141 
142  temp.v.x *= Mul;
143  temp.v.y *= Mul;
144  temp.v.z *= Mul;
145  return temp;
146  }
T lenght(const quaternion< T > &v)
Definition: quaternion.hpp:122

◆ factorial()

template<typename T >
T std::math::factorial ( p)
inline
55  {
56  if ( p == 0 || p == 1 ) return 1;
57  else if ( p < 0 ) return 0;
58 
59  T f = 1;
60  for(; p > 1; p--) f *= p;
61 
62  return f;
63  }

◆ from_cmy()

template<typename T >
color<T> std::math::from_cmy ( const T  c,
const T  m,
const T  y 
)
161  {
162  return color<T>( T(1.0 - c), T(1.0 - m), T(1.0 - y));
163  }

◆ from_hsv()

template<typename T >
color<T> std::math::from_hsv ( const T  h,
const T  s,
const T  v 
)
165  {
166  if( s == 0 ) return color<T>(v,v,v);
167 
168  T i, f, p, q, t;
169 
170  h /= 60; // sector 0 to 5
171  i = floor( h );
172  f = h - i; // factorial part of h
173  p = v * ( 1 - s );
174  q = v * ( 1 - s * f );
175  t = v * ( 1 - s * ( 1 - f ) );
176 
177  if(i == 0) return color<T>(v, t, p);
178  if(i == 1) return color<T>(q, v, p);
179  if(i == 2) return color<T>(p, v, t);
180  if(i == 3) return color<T>(p, q, v);
181  if(i == 4) return color<T>(t, p, v);
182 
183  return raColor(v, p, q);
184  }

◆ from_yuv()

template<typename T >
color<T> std::math::from_yuv ( const T  y,
const T  u,
const T  v 
)
155  {
156  return color<T>(T(1.164 * (y - 16) + 1.596*(v - 128)),
157  T(1.164 * (y - 16) - 0.813*(v - 128) - 0.391*(u - 128)),
158  T(1.164 * (y - 16) + 2.018*(u - 128)));
159  }

◆ frustum()

template<typename T >
matrix4x4<T> std::math::frustum ( const T  left,
const T  right,
const T  bottom,
const T  top,
const T  near,
const T  far 
)
528  {
529  matrix4x4<T> m = matrix4x4_identity<T>();
530  m.n[0] = 2 * near / (right - left);
531  m.n[5] = 2 * near / (top - bottom);
532  m.n[8] = (right + left) / (right - left);
533  m.n[9] = (top + bottom) / (top - bottom);
534  m.n[10] = -(far + near) / (far - near);
535  m.n[11] = -1;
536  m.n[14] = -(2 * far * near) / (far - near);
537  m.n[15] = 0;
538  return m;
539  }

◆ hermite()

template<typename T >
T std::math::hermite ( value1,
tangent1,
value2,
tangent2,
amount 
)
inline
86  {
87  T s = amount;
88  T s2 = s * s;
89  T s3 = s2 * s;
90  T h1 = 2 * s3 - 3 * s2 + 1;
91  T h2 = -2 * s3 + 3 * s2;
92  T h3 = s3 - 2 * s2 + s;
93  T h4 = s3 - s2;
94  return value1 * h1 + value2 * h2 + tangent1 * h3 + tangent2 * h4;
95  }

◆ identy()

template<typename T >
quaternion std::math::identy ( )
inline
120  { return quaternion<T>(1.0f, 0.0f, 0.0f, 0.0f); }

◆ interpolate()

template<typename T >
color<T> std::math::interpolate ( const color< T > &  c1,
const color< T > &  c2,
const T  p 
)
inline
146  {return c1 + p * (c2 - c1);}

◆ interpolate_coords() [1/3]

template<typename T >
vector3<T> std::math::interpolate_coords ( const vector3< T > &  v1,
const vector3< T > &  v2,
const float  p 
)
inline
169  { return v1 + p * (v2 - v1); }

◆ interpolate_coords() [2/3]

template<typename T >
vector4<T> std::math::interpolate_coords ( const vector4< T > &  v1,
const vector4< T > &  v2,
const T  p 
)
inline
170  { return v1 + p * (v2 - v1); }

◆ interpolate_coords() [3/3]

template<typename T >
vector2<T> std::math::interpolate_coords ( const vector2< T > &  v1,
const vector2< T > &  v2,
const T  p 
)
inline
174  { return v1 + p * (v2 - v1); }

◆ interpolate_normal() [1/3]

template<typename T >
vector3<T> std::math::interpolate_normal ( const vector3< T > &  v1,
const vector3< T > &  v2,
const float  p 
)
inline
172  { return normalize(v1 + p * (v2 - v1)); }
vector3< T > normalize(const vector3< T > &v)
Definition: vector3.hpp:152

◆ interpolate_normal() [2/3]

template<typename T >
vector4<T> std::math::interpolate_normal ( const vector4< T > &  v1,
const vector4< T > &  v2,
const T  p 
)
inline
173  { return normalize(v1 + p * (v2 - v1)); }
vector4< T > normalize(const vector4< T > &v)
Definition: vector4.hpp:155

◆ interpolate_normal() [3/3]

template<typename T >
vector2<T> std::math::interpolate_normal ( const vector2< T > &  v1,
const vector2< T > &  v2,
const T  p 
)
inline
177  { return normalize(v1 + p * (v2 - v1)); }
vector2< T > normalize(const vector2< T > &v)
Definition: vector2.hpp:159

◆ invert() [1/2]

template<typename T >
matrix4x4< T > std::math::invert ( const matrix4x4< T > &  mat)
inline
491  {
492  T fInvDet = det<T>(m);
493  if(fInvDet == 0) return matrix4x4_identity<T>();
494  fInvDet = 1 / fInvDet;
495 
496  matrix4x4<T> mResult;
497  mResult.m11 = fInvDet * (m.m22 * m.m33 - m.m23 * m.m32);
498  mResult.m12 = -fInvDet * (m.m12 * m.m33 - m.m13 * m.m32);
499  mResult.m13 = fInvDet * (m.m12 * m.m23 - m.m13 * m.m22);
500  mResult.m14 = 0;
501  mResult.m21 = -fInvDet * (m.m21 * m.m33 - m.m23 * m.m31);
502  mResult.m22 = fInvDet * (m.m11 * m.m33 - m.m13 * m.m31);
503  mResult.m23 = -fInvDet * (m.m11 * m.m23 - m.m13 * m.m21);
504  mResult.m24 = 0;
505  mResult.m31 = fInvDet * (m.m21 * m.m32 - m.m22 * m.m31);
506  mResult.m32 = -fInvDet * (m.m11 * m.m32 - m.m12 * m.m31);
507  mResult.m33 = fInvDet * (m.m11 * m.m22 - m.m12 * m.m21);
508  mResult.m34 = 0;
509  mResult.m41 = -(m.m41 * mResult.m11 + m.m42 * mResult.m21 + m.m43 * mResult.m31);
510  mResult.m42 = -(m.m41 * mResult.m12 + m.m42 * mResult.m22 + m.m43 * mResult.m32);
511  mResult.m43 = -(m.m41 * mResult.m13 + m.m42 * mResult.m23 + m.m43 * mResult.m33);
512  mResult.m44 = 1.0;
513 
514  return mResult;
515 
516  }

◆ invert() [2/2]

template<typename T >
quaternion<T> std::math::invert ( const quaternion< T > &  q)
inline
129  { T temp = lenghtSq(q); quaternion<T> tq = q; tq.s /= temp; tq.v /= -temp; return q; }
T lenghtSq(const quaternion< T > &v)
Definition: quaternion.hpp:125

◆ is_physikcollision()

template<typename T >
bool std::math::is_physikcollision ( physik< T > *  p1,
physik< T > *  p2 
)
181  {
182  vector3<T> dist;
183  dist = p1->position() - p2->position();
184  bool col = lenght(dist) <= p1->getBoundingsphereRadius() + p2->getBoundingsphereRadius();
185  if(col)
186  {
187  vector3<T> v1 = p1->velocity();
188  vector3<T> v2 = p2->velocity();
189 
190  T m1 = p1->mass();
191  T m2 = p2->mass();
192 
193  vector3<T> v1New, v2New, a, n, b;
194  a = normalize(dist);
195  n = cross(v1, v2);
196 
197  if(n.x == n.y && n.x == n.z && n.x == 0.0f) {
198  v1New = ((m1 - m2) * v1 + 2 * m2 * v2) / (m1 + m2);
199  v2New = ((m2 - m1) * v2 + 2 * m1 * v1) / (m1 + m2);
200  } else {
201  n = normalize(n);
202  b = cross(n, a);
203 
204  T ab = dot(a, b);
205  T v11 = (dot(v1, a) - dot(v1, b) * ab) / ( 1 - ab * ab);
206  T v12 = (dot(v1, b) - dot(v1, a) * ab) / ( 1 - ab * ab);
207  T v21 = (dot(v2, a) - dot(v2, b) * ab) / ( 1 - ab * ab);
208  T v22 = (dot(v2, b) - dot(v2, a) * ab) / ( 1 - ab * ab);
209 
210  v1New = a * ((m1 - m2) * v11 + 2 * m2 * v21) / (m1 + m2) + b * v12;
211  v2New = a * ((m2 - m1) * v21 + 2 * m1 * v11) / (m1 + m2) + b * v22;
212  }
213  p1->set_velocity(v1New);
214  p2->set_velocity(v2New);
215  }
216  return col;
217  }
vector3< T > cross(const vector3< T > &v1, vector3< T > &v2)
Definition: vector3.hpp:158
T dot(const quaternion< T > &a, const quaternion< T > &b)
Definition: quaternion.hpp:208
quaternion< T > normalize(const quaternion< T > &v)
Definition: quaternion.hpp:164
T lenght(const quaternion< T > &v)
Definition: quaternion.hpp:122

◆ lenght() [1/4]

template<typename T >
T std::math::lenght ( const quaternion< T > &  v)
inline
123  { return (T)sqrt((double)(v.s * v.s + v.v.x * v.v.x + v.v.y * v.v.y + v.v.z * v.v.z)); }

◆ lenght() [2/4]

template<typename T >
T std::math::lenght ( const vector3< T > &  v)
inline
150  { return sqrtf(v.x * v.x + v.y * v.y + v.z * v.z); }

◆ lenght() [3/4]

template<typename T >
T std::math::lenght ( const vector4< T > &  v)
inline
153  { return sqrtf(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w); }

◆ lenght() [4/4]

template<typename T >
T std::math::lenght ( const vector2< T > &  v)
inline
154  { return (T)(v.x * v.x + v.y * v.y ); }

◆ lenghtSq() [1/4]

template<typename T >
T std::math::lenghtSq ( const quaternion< T > &  v)
inline
126  { return (v.s * v.s + (T)v.v.x * (T)v.v.x + (T)v.v.y * (T)v.v.y + (T)v.v.z * (T)v.v.z); }

◆ lenghtSq() [2/4]

template<typename T >
T std::math::lenghtSq ( const vector3< T > &  v)
inline
147  { return (v.x * v.x + v.y * v.y + v.z * v.z); }

◆ lenghtSq() [3/4]

template<typename T >
T std::math::lenghtSq ( const vector4< T > &  v)
inline
150  { return (v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w); }

◆ lenghtSq() [4/4]

template<typename T >
T std::math::lenghtSq ( const vector2< T > &  v)
inline
157  { return (T)sqrt(v.x * v.x + v.y * v.y ); }

◆ Lerp()

template<typename T >
T std::math::Lerp ( value1,
value2,
amount 
)
inline
99  {
100  return value1 + (value2 - value1) * amount;
101  }

◆ lockat() [1/2]

template<typename T >
matrix4x4<T> std::math::lockat ( const vector3< T >  position,
const vector3< T > &  target,
const vector3< T > &  vUp = vector3<T>(0,1,0) 
)
inline
466  {
467  vector3<T> forward = target - position;
468  forward = normalize(forward);
469 
470  vector3<T> left = cross(vUp, forward);
471  left = normalize(left);
472 
473  vector3<T> up = cross(forward, left);
474  up = normalize(up);
475 
476  matrix4x4<T> m = matrix4x4_identity<T>();
477  m.m11 = left.x; m.m12 = left.y; m.m13 = left.z;
478  m.m21 = up.x; m.m22 = up.y; m.m23 = up.z;
479  m.m31 = forward.x; m.m32 = forward.y; m.m33 = forward.z;
480 
481  return m;
482  }
vector3< T > cross(const vector3< T > &v1, vector3< T > &v2)
Definition: vector3.hpp:158
quaternion< T > normalize(const quaternion< T > &v)
Definition: quaternion.hpp:164

◆ lockat() [2/2]

template<typename T >
matrix4x4<T> std::math::lockat ( const matrix4x4< T >  m,
const vector3< T > &  target,
const vector3< T > &  vUp = vector3<T>(0,1,0) 
)
inline
486  {
487  return lockat<T>(vector3<T>(m.n[12], m.n[13], m.n[14]), target, vUp);
488  }

◆ log()

template<typename T >
quaternion<T> std::math::log ( const quaternion< T > &  v)
inline
148  {
149  T Length;
150  quaternion<T> temp = v;
151 
152  Length = lenght(temp.v);
153  Length = atan(Length/temp.s);
154 
155  temp.s = 0.0;
156 
157  temp.v.x *= Length;
158  temp.v.y *= Length;
159  temp.v.z *= Length;
160 
161  return temp;
162  }
T lenght(const quaternion< T > &v)
Definition: quaternion.hpp:122

◆ matrix4x4_identity()

template<typename T >
matrix4x4<T> std::math::matrix4x4_identity ( )
inline
262 {return matrix4x4<T>(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);}

◆ near_equal()

template<typename T >
bool std::math::near_equal ( const vector4< T > &  v1,
vector4< T > &  v2,
const vector2< T > &  epsilon 
)
inline
176  { return ( abs((v1.x - v2.x) ) <= epsilon && ( abs(((v1.y - v2.y)) <= epsilon) )&& (abs((v1.z - v2.z)) <= epsilon) && (abs((v1.w - v2.w)) <= epsilon)); }
T abs(const T &t)
Definition: algorithm.hpp:182

◆ nearequal()

template<typename T >
bool std::math::nearequal ( const vector3< T > &  v1,
vector3< T > &  v2,
const vector2< T > &  epsilon 
)
inline
175  { return ( abs(float(v1.x - v2.x )) <= epsilon && ( abs(float(v1.y - v2.y)) <= epsilon) && (abs(float(v1.z - v2.z)) <= epsilon)); }
T abs(const T &t)
Definition: algorithm.hpp:182

◆ nearEqual()

template<typename T >
bool std::math::nearEqual ( const vector2< T > &  v1,
vector2< T > &  v2,
const vector2< T > &  epsilon 
)
inline
180  { return (( abs((T)(v1.x - v2.x )) <= epsilon) && (abs((T)(v1.y - v2.y)) <= epsilon)); }
T abs(const T &t)
Definition: algorithm.hpp:182

◆ negate()

template<typename T >
color<T> std::math::negate ( const color< T > &  c)
inline
140  {return color<T>(1.0f - c.r, 1.0f - c.g, 1.0f - c.b, 1.0f - c.a);}

◆ normalize() [1/4]

template<typename T >
vector3<T> std::math::normalize ( const vector3< T > &  v)
inline
153  { return v / (T)sqrt(double(v.x * v.x + v.y * v.y + v.z * v.z)); }

◆ normalize() [2/4]

template<typename T >
vector4<T> std::math::normalize ( const vector4< T > &  v)
inline
156  { return v / sqrtf(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w); }

◆ normalize() [3/4]

template<typename T >
vector2<T> std::math::normalize ( const vector2< T > &  v)
inline
160  { return v / (T)sqrt(v.x * v.x + v.y * v.y ); }

◆ normalize() [4/4]

template<typename T >
quaternion<T> std::math::normalize ( const quaternion< T > &  v)
inline
164  {
165  T norme = lenght(v);
166  quaternion<T> temp = v;
167 
168  if (norme == 0.0) {
169  temp.s = 1.0;
170  temp.v = 0.0;
171  } else {
172  float recip = 1.0/norme;
173 
174  temp.s *= recip;
175  temp.v.x *= recip;
176  temp.v.y *= recip;
177  temp.v.z *= recip;
178  }
179  return temp;
180  }
T lenght(const quaternion< T > &v)
Definition: quaternion.hpp:122

◆ normalizeEx()

template<typename T >
vector2<T> std::math::normalizeEx ( const vector2< T > &  v)
inline
163  { return v / (T)sqrt((v.x * v.x + v.y * v.y ) + 0.0001f); }

◆ normalizex() [1/2]

template<typename T >
vector3<T> std::math::normalizex ( const vector3< T > &  v)
inline
156  { return v / (T)(sqrt(double(v.x * v.x + v.y * v.y + v.z * v.z)) + 0.0001); }

◆ normalizex() [2/2]

template<typename T >
vector4<T> std::math::normalizex ( const vector4< T > &  v)
inline
159  { return v / (sqrtf(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w) + 0.0001); }

◆ operator!=() [1/9]

template<typename T >
bool std::math::operator!= ( ray< T >  a,
ray< T >  b 
)
inline
82  {
83  return a.direction() != b.direction() &&
84  a.position() != b.position();
85  }

◆ operator!=() [2/9]

template<typename T >
bool std::math::operator!= ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
104  { return !(a==b); }

◆ operator!=() [3/9]

template<typename T >
bool std::math::operator!= ( rectangle< T >  a,
rectangle< T >  b 
)
inline
128  {
129  return a.x != b.x && a.y != b.y && a.width != b.width && a.height != b.height;
130  }

◆ operator!=() [4/9]

template<typename T >
bool std::math::operator!= ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
132  { return ((a.x != b.x) && (a.y != b.y) && (a.z != b.z)); }

◆ operator!=() [5/9]

template<typename T >
bool std::math::operator!= ( const color< T > &  a,
const color< T > &  b 
)
inline
134  {if(a.r != b.r) return true; if(a.g != b.g) return true; if(a.b != b.b) return true; return a.a != b.a;}

◆ operator!=() [6/9]

template<typename T >
bool std::math::operator!= ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
134  { return ((a.x != b.x) && (a.y != b.y) && (a.z != b.z) && (a.w != b.w)); }

◆ operator!=() [7/9]

template<typename T >
bool std::math::operator!= ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
138  { return ((a.x != b.x) && (a.y != b.y)); }

◆ operator!=() [8/9]

template<typename T >
bool std::math::operator!= ( const boundingbox< T > &  a,
const boundingbox< T > &  b 
)
141  {
142  return a.getmin() != b.getmin() && a.getmax() != b.getmax();
143  }

◆ operator!=() [9/9]

template<typename T >
bool std::math::operator!= ( const matrix4x4< T > &  a,
const matrix4x4< T > &  b 
)
inline
243  {
244  if(a.m11 != b.m11) return true;
245  if(a.m12 != b.m12) return true;
246  if(a.m13 != b.m13) return true;
247  if(a.m14 != b.m14) return true;
248  if(a.m21 != b.m21) return true;
249  if(a.m22 != b.m22) return true;
250  if(a.m23 != b.m23) return true;
251  if(a.m24 != b.m24) return true;
252  if(a.m31 != b.m31) return true;
253  if(a.m32 != b.m32) return true;
254  if(a.m33 != b.m33) return true;
255  if(a.m34 != b.m34) return true;
256  if(a.m41 != b.m41) return true;
257  if(a.m42 != b.m42) return true;
258  if(a.m43 != b.m43) return true;
259  return a.m44 != b.m44;
260  }

◆ operator*() [1/16]

template<typename T >
vector3<T> std::math::operator* ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
110  { return vector3<T> (a.x * b.x, a.y * b.y, a.z * b.z); }

◆ operator*() [2/16]

template<typename T >
vector2<T> std::math::operator* ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
110  { return vector2<T>(a.x * b.x, a.y * b.y); }

◆ operator*() [3/16]

template<typename T >
vector4<T> std::math::operator* ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
112  { return vector4<T> (a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); }

◆ operator*() [4/16]

template<typename T >
vector3<T> std::math::operator* ( const vector3< T > &  a,
const T &  b 
)
inline
113  { return vector3<T> (a.x * b, a.y * b, a.z * b); }

◆ operator*() [5/16]

template<typename T >
color<T> std::math::operator* ( const color< T > &  a,
const color< T > &  b 
)
inline
114  {return color<T>(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a);}

◆ operator*() [6/16]

template<typename T >
vector4<T> std::math::operator* ( const vector4< T > &  a,
const T &  b 
)
inline
115  { return vector4<T> (a.x * b, a.y * b, a.z * b, a.w * b); }

◆ operator*() [7/16]

template<typename T >
vector3<T> std::math::operator* ( const T &  a,
const vector3< T > &  b 
)
inline
116  { return vector3<T> (a * b.x, a * b.y, a * b.z); }

◆ operator*() [8/16]

template<typename T >
color<T> std::math::operator* ( const color< T > &  c,
const T  f 
)
inline
117  {return color<T>(c.r * f, c.g * f, c.b * f, c.a * f);}

◆ operator*() [9/16]

template<typename T >
vector4<T> std::math::operator* ( const T &  a,
const vector4< T > &  b 
)
inline
118  { return vector4<T> (a * b.x, a * b.y, a * b.z, a * b.w); }

◆ operator*() [10/16]

template<typename T >
color<T> std::math::operator* ( const T  f,
const color< T > &  c 
)
inline
120  {return color<T>(c.r * f, c.g * f, c.b * f, c.a * f);}

◆ operator*() [11/16]

template<typename T >
vector2<T> std::math::operator* ( const float &  f,
const vector2< T > &  b 
)
inline
122  { return vector2<T>(f * b.x, f * b.y); }

◆ operator*() [12/16]

template<typename T >
matrix4x4<T> std::math::operator* ( const matrix4x4< T > &  a,
const matrix4x4< T > &  b 
)
inline
175  {
176  return matrix4x4<T>(b.m11 * a.m11 + b.m21 * a.m12 + b.m31 * a.m13 + b.m41 * a.m14,
177  b.m12 * a.m11 + b.m22 * a.m12 + b.m32 * a.m13 + b.m42 * a.m14,
178  b.m13 * a.m11 + b.m23 * a.m12 + b.m33 * a.m13 + b.m43 * a.m14,
179  b.m14 * a.m11 + b.m24 * a.m12 + b.m34 * a.m13 + b.m44 * a.m14,
180  b.m11 * a.m21 + b.m21 * a.m22 + b.m31 * a.m23 + b.m41 * a.m24,
181  b.m12 * a.m21 + b.m22 * a.m22 + b.m32 * a.m23 + b.m42 * a.m24,
182  b.m13 * a.m21 + b.m23 * a.m22 + b.m33 * a.m23 + b.m43 * a.m24,
183  b.m14 * a.m21 + b.m24 * a.m22 + b.m34 * a.m23 + b.m44 * a.m24,
184  b.m11 * a.m31 + b.m21 * a.m32 + b.m31 * a.m33 + b.m41 * a.m34,
185  b.m12 * a.m31 + b.m22 * a.m32 + b.m32 * a.m33 + b.m42 * a.m34,
186  b.m13 * a.m31 + b.m23 * a.m32 + b.m33 * a.m33 + b.m43 * a.m34,
187  b.m14 * a.m31 + b.m24 * a.m32 + b.m34 * a.m33 + b.m44 * a.m34,
188  b.m11 * a.m41 + b.m21 * a.m42 + b.m31 * a.m43 + b.m41 * a.m44,
189  b.m12 * a.m41 + b.m22 * a.m42 + b.m32 * a.m43 + b.m42 * a.m44,
190  b.m13 * a.m41 + b.m23 * a.m42 + b.m33 * a.m43 + b.m43 * a.m44,
191  b.m14 * a.m41 + b.m24 * a.m42 + b.m34 * a.m43 + b.m44 * a.m44);
192  }

◆ operator*() [13/16]

template<typename T >
matrix4x4<T> std::math::operator* ( const matrix4x4< T > &  m,
const T  f 
)
inline
195  {
196  return matrix4x4<T>(m.m11 * f, m.m12 * f, m.m13 * f, m.m14 * f,
197  m.m21 * f, m.m22 * f, m.m23 * f, m.m24 * f,
198  m.m31 * f, m.m32 * f, m.m33 * f, m.m34 * f,
199  m.m41 * f, m.m42 * f, m.m43 * f, m.m44 * f);
200  }

◆ operator*() [14/16]

template<typename T >
matrix4x4<T> std::math::operator* ( const T  f,
const matrix4x4< T > &  m 
)
inline
203  {
204  return matrix4x4<T>(m.m11 * f, m.m12 * f, m.m13 * f, m.m14 * f,
205  m.m21 * f, m.m22 * f, m.m23 * f, m.m24 * f,
206  m.m31 * f, m.m32 * f, m.m33 * f, m.m34 * f,
207  m.m41 * f, m.m42 * f, m.m43 * f, m.m44 * f);
208  }

◆ operator*() [15/16]

template<typename T >
quaternion<T> std::math::operator* ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
260  {
261  quaternion<T> q;
262  q.s = ((a.s * b.s) - (a.v.x * b.v.x) - (a.v.y * b.v.z) - (a.v.z * b.v.z));
263  q.v.x = ((a.s * b.v.x) + (a.v.x * b.s) + (a.v.y * b.v.y) - (a.v.z * b.v.y));
264  q.v.y = ((a.s * b.v.y) - (a.v.x * b.v.z) + (a.v.y * b.s) + (a.v.z * b.v.x));
265  q.v.z = ((a.s * b.v.z) + (a.v.x * b.v.y) - (a.v.y * b.v.x) + (a.v.z * b.s));
266  return q;
267  }

◆ operator*() [16/16]

template<typename T >
quaternion<T> std::math::operator* ( const quaternion< T > &  a,
const float  b 
)
inline
270  { return quaternion<T>(a.s * b, a.v * b); }

◆ operator+() [1/7]

template<typename T >
vector3<T> std::math::operator+ ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
101  { return vector3<T> (a.x + b.x, a.y + b.y, a.z + b.z); }

◆ operator+() [2/7]

template<typename T >
vector4<T> std::math::operator+ ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
103  { return vector4<T> (a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); }

◆ operator+() [3/7]

template<typename T >
vector2<T> std::math::operator+ ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
104  { return vector2<T>(a.x + b.x, a.y + b.y); }

◆ operator+() [4/7]

template<typename T >
color<T> std::math::operator+ ( const color< T > &  a,
const color< T > &  b 
)
inline
105  {return color<T>(a.r + b.r, a.g + b.g, a.b + b.b, a.a + b.a);}

◆ operator+() [5/7]

template<typename T >
vector2<T> std::math::operator+ ( const float &  f,
const vector2< T > &  b 
)
inline
116  { return vector2<T>(f + b.x, f + b.y); }

◆ operator+() [6/7]

template<typename T >
matrix4x4<T> std::math::operator+ ( const matrix4x4< T > &  a,
const matrix4x4< T > &  b 
)
inline
166  {return matrix4x4<T>(a.m11 + b.m11, a.m12 + b.m12, a.m13 + b.m13, a.m14 + b.m14, a.m21 + b.m21, a.m22 + b.m22, a.m23 + b.m23, a.m24 + b.m24, a.m31 + b.m31, a.m32 + b.m32, a.m33 + b.m33, a.m34 + b.m34, a.m41 + b.m41, a.m42 + b.m42, a.m43 + b.m43, a.m44 + b.m44);}

◆ operator+() [7/7]

template<typename T >
quaternion<T> std::math::operator+ ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
273  { return quaternion<T>(a.s + b.s, a.v + b.v); }

◆ operator-() [1/13]

template<typename T >
vector3<T> std::math::operator- ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
104  { return vector3<T> (a.x - b.x, a.y - b.y, a.z - b.z); }

◆ operator-() [2/13]

template<typename T >
vector4<T> std::math::operator- ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
106  { return vector4<T> (a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); }

◆ operator-() [3/13]

template<typename T >
vector2<T> std::math::operator- ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
107  { return vector2<T>(a.x - b.x, a.y - b.y); }

◆ operator-() [4/13]

template<typename T >
vector3<T> std::math::operator- ( const vector3< T > &  a)
inline
107  { return vector3<T> (-a.x, -a.y, -a.z); }

◆ operator-() [5/13]

template<typename T >
color<T> std::math::operator- ( const color< T > &  a,
const color< T > &  b 
)
inline
108  {return color<T>(a.r - b.r, a.g - b.g, a.b - b.b, a.a - b.a);}

◆ operator-() [6/13]

template<typename T >
vector4<T> std::math::operator- ( const vector4< T > &  v)
inline
109  { return vector4<T> (-v.x, -v.y, -v.x, -v.w); }

◆ operator-() [7/13]

template<typename T >
color<T> std::math::operator- ( const color< T > &  c)
inline
111  {return color<T>(-c.r, -c.g, -c.b, c.a);}

◆ operator-() [8/13]

template<typename T >
vector2<T> std::math::operator- ( const float &  f,
const vector2< T > &  b 
)
inline
119  { return vector2<T>(f - b.x, f - b.y); }

◆ operator-() [9/13]

template<typename T >
vector2<T> std::math::operator- ( const vector2< T > &  a,
const float &  f 
)
inline
128  { return vector2<T>(a.x - f, a.y - f); }

◆ operator-() [10/13]

template<typename T >
matrix4x4<T> std::math::operator- ( const matrix4x4< T > &  a,
const matrix4x4< T > &  b 
)
inline
169  {return matrix4x4<T>(a.m11 - b.m11, a.m12 - b.m12, a.m13 - b.m13, a.m14 - b.m14, a.m21 - b.m21, a.m22 - b.m22, a.m23 - b.m23, a.m24 - b.m24, a.m31 - b.m31, a.m32 - b.m32, a.m33 - b.m33, a.m34 - b.m34, a.m41 - b.m41, a.m42 - b.m42, a.m43 - b.m43, a.m44 - b.m44);}

◆ operator-() [11/13]

template<typename T >
matrix4x4<T> std::math::operator- ( const matrix4x4< T > &  m)
inline
172  {return matrix4x4<T>(-m.m11, -m.m12, -m.m13, -m.m14, -m.m21, -m.m22, -m.m23, -m.m24, -m.m31, -m.m32, -m.m33, -m.m34, -m.m41, -m.m42, -m.m43, -m.m44);}

◆ operator-() [12/13]

template<typename T >
quaternion<T> std::math::operator- ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
276  { return quaternion<T>(a.s - b.s, a.v - b.v); }

◆ operator-() [13/13]

template<typename T >
quaternion<T> std::math::operator- ( const quaternion< T > &  a)
inline
279  { return invert(a); }
quaternion< T > invert(const quaternion< T > &q)
Definition: quaternion.hpp:128

◆ operator/() [1/15]

template<typename T >
vector2<T> std::math::operator/ ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
113  { return vector2<T>(a.x / b.x, a.y / b.y); }

◆ operator/() [2/15]

template<typename T >
vector3<T> std::math::operator/ ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
119  { return vector3<T> (a.x / b.x, a.y / b.y, a.z / b.z); }

◆ operator/() [3/15]

template<typename T >
vector4<T> std::math::operator/ ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
121  { return vector4<T> (a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); }

◆ operator/() [4/15]

template<typename T >
vector3<T> std::math::operator/ ( const T &  a,
const vector3< T > &  b 
)
inline
122  { return vector3<T> (a / b.x, a / b.y, a / b.z); }

◆ operator/() [5/15]

template<typename T >
color<T> std::math::operator/ ( const color< T > &  a,
const color< T > &  b 
)
inline
123  {return color<T>(a.r / b.r, a.g / b.g, a.b / b.b, a.a / b.a);}

◆ operator/() [6/15]

template<typename T >
vector4<T> std::math::operator/ ( const T &  a,
const vector4< T > &  b 
)
inline
124  { return vector4<T> (a / b.x, a / b.y, a / b.z, a / b.w); }

◆ operator/() [7/15]

template<typename T >
vector3<T> std::math::operator/ ( const vector3< T > &  a,
const T &  b 
)
inline
125  { return vector3<T> (a.x / b, a.y / b, a.z / b); }

◆ operator/() [8/15]

template<typename T >
vector2<T> std::math::operator/ ( const float &  f,
const vector2< T > &  b 
)
inline
125  { return vector2<T>(f / b.x, f / b.y); }

◆ operator/() [9/15]

template<typename T >
color<T> std::math::operator/ ( const color< T > &  c,
const T  f 
)
inline
126  {return color<T>(c.r / f, c.g / f, c.b / f, c.a / f);}

◆ operator/() [10/15]

template<typename T >
vector4<T> std::math::operator/ ( const vector4< T > &  a,
const T &  b 
)
inline
127  { return vector4<T> (a.x / b, a.y / b, a.z / b, a.w / b); }

◆ operator/() [11/15]

template<typename T >
vector2<T> std::math::operator/ ( const vector2< T > &  a,
const float &  f 
)
inline
131  { return vector2<T>(a.x / f, a.y / f); }

◆ operator/() [12/15]

template<typename T >
matrix4x4<T> std::math::operator/ ( const matrix4x4< T > &  a,
const matrix4x4< T > &  b 
)
inline
211  {return a * invert(b);}
matrix4x4< T > invert(const matrix4x4< T > &mat)
Definition: matrix4x4.hpp:490

◆ operator/() [13/15]

template<typename T >
matrix4x4<T> std::math::operator/ ( const matrix4x4< T > &  m,
const T  f 
)
inline
214  {
215  return matrix4x4<T>(m.m11 / f, m.m12 / f, m.m13 / f, m.m14 / f,
216  m.m21 / f, m.m22 / f, m.m23 / f, m.m24 / f,
217  m.m31 / f, m.m32 / f, m.m33 / f, m.m34 / f,
218  m.m41 / f, m.m42 / f, m.m43 / f, m.m44 / f);
219  }

◆ operator/() [14/15]

template<typename T >
quaternion<T> std::math::operator/ ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
282  { return a * invert(b); }
quaternion< T > invert(const quaternion< T > &q)
Definition: quaternion.hpp:128

◆ operator/() [15/15]

template<typename T >
quaternion<T> std::math::operator/ ( const quaternion< T > &  a,
const float  b 
)
inline
285  { return quaternion<T>(a.s / b, a.v / b); }

◆ operator<() [1/5]

template<typename T >
bool std::math::operator< ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
113  { return ((a.v < b.v) && (a.s < b.s)); }

◆ operator<() [2/5]

template<typename T >
bool std::math::operator< ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
141  { return ((a.x < b.x) && (a.y < b.y) && (a.z < b.z)); }

◆ operator<() [3/5]

template<typename T >
bool std::math::operator< ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
143  { return ((a.x < b.x) && (a.y < b.y) && (a.z < b.z) && (a.w < b.w)); }

◆ operator<() [4/5]

template<typename T >
bool std::math::operator< ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
147  { return ((a.x < b.x) && (a.y < b.x)); }

◆ operator<() [5/5]

template<typename T >
bool std::math::operator< ( const boundingbox< T > &  a,
const boundingbox< T > &  b 
)
157  {
158  return a.getmin() < b.getmin() && a.getmax() < b.getmax();
159  }

◆ operator<=() [1/5]

template<typename T >
bool std::math::operator<= ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
107  { return ((a.v <= b.v) && (a.s <= b.s)); }

◆ operator<=() [2/5]

template<typename T >
bool std::math::operator<= ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
135  { return ((a.x <= b.x) && (a.y <= b.y) && (a.z <= b.z)); }

◆ operator<=() [3/5]

template<typename T >
bool std::math::operator<= ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
137  { return ((a.x <= b.x) && (a.y <= b.y) && (a.z <= b.z) && (a.w <= b.w)); }

◆ operator<=() [4/5]

template<typename T >
bool std::math::operator<= ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
141  { return ((a.x <= b.x) && (a.y <= b.y)); }

◆ operator<=() [5/5]

template<typename T >
bool std::math::operator<= ( const boundingbox< T > &  a,
const boundingbox< T > &  b 
)
145  {
146  return a.getmin() <= b.getmin() && a.getmax() <= b.getmax();
147  }

◆ operator==() [1/9]

template<typename T >
bool std::math::operator== ( ray< T >  a,
ray< T >  b 
)
inline
76  {
77  return a.direction() == b.direction() &&
78  a.position() == b.position();
79  }

◆ operator==() [2/9]

template<typename T >
bool std::math::operator== ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
101  { return ((a.v == b.v) && (a.s == b.s)); }

◆ operator==() [3/9]

template<typename T >
bool std::math::operator== ( rectangle< T >  a,
rectangle< T >  b 
)
inline
123  {
124  return a.x == b.x && a.y == b.y && a.width == b.width && a.height && b.height;
125  }

◆ operator==() [4/9]

template<typename T >
bool std::math::operator== ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
129  { return ((a.x == b.x) && (a.y == b.y) && (a.z == b.z)); }

◆ operator==() [5/9]

template<typename T >
bool std::math::operator== ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
131  { return ((a.x == b.x) && (a.y == b.y) && (a.z == b.z) && (a.w == b.w)); }

◆ operator==() [6/9]

template<typename T >
bool std::math::operator== ( const color< T > &  a,
const color< T > &  b 
)
inline
131  {if(a.r != b.r) return false; if(a.g != b.g) return false; if(a.b != b.b) return false; return a.a == b.a;}

◆ operator==() [7/9]

template<typename T >
bool std::math::operator== ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
135  { return ((a.x == b.x) && (a.y == b.y)); }

◆ operator==() [8/9]

template<typename T >
bool std::math::operator== ( const boundingbox< T > &  a,
const boundingbox< T > &  b 
)
137  {
138  return a.getmin() == b.getmin() && a.getmax() == b.getmax();
139  }

◆ operator==() [9/9]

template<typename T >
bool std::math::operator== ( const matrix4x4< T > &  a,
const matrix4x4< T > &  b 
)
inline
222  {
223  if(a.m11 != b.m11) return false;
224  if(a.m12 != b.m12) return false;
225  if(a.m13 != b.m13) return false;
226  if(a.m14 != b.m14) return false;
227  if(a.m21 != b.m21) return false;
228  if(a.m22 != b.m22) return false;
229  if(a.m23 != b.m23) return false;
230  if(a.m24 != b.m24) return false;
231  if(a.m31 != b.m31) return false;
232  if(a.m32 != b.m32) return false;
233  if(a.m33 != b.m33) return false;
234  if(a.m34 != b.m34) return false;
235  if(a.m41 != b.m41) return false;
236  if(a.m42 != b.m42) return false;
237  if(a.m43 != b.m43) return false;
238  return a.m44 == b.m44;
239  }

◆ operator>() [1/5]

template<typename T >
bool std::math::operator> ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
116  { return ((a.v > b.v) && (a.s > b.s)); }

◆ operator>() [2/5]

template<typename T >
bool std::math::operator> ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
144  { return ((a.x > b.x) && (a.y > b.y) && (a.z > b.z)); }

◆ operator>() [3/5]

template<typename T >
bool std::math::operator> ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
146  { return ((a.x > b.x) && (a.y > b.y) && (a.z > b.z) && (a.w > b.w)); }

◆ operator>() [4/5]

template<typename T >
bool std::math::operator> ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
150  { return ((a.x > b.x) && (a.y > b.y)); }

◆ operator>() [5/5]

template<typename T >
bool std::math::operator> ( const boundingbox< T > &  a,
const boundingbox< T > &  b 
)
153  {
154  return a.getmin() > b.getmin() && a.getmax() > b.getmax();
155  }

◆ operator>=() [1/5]

template<typename T >
bool std::math::operator>= ( const quaternion< T > &  a,
const quaternion< T > &  b 
)
inline
110  { return ((a.v >= b.v) && (a.s >= b.s)); }

◆ operator>=() [2/5]

template<typename T >
bool std::math::operator>= ( const vector3< T > &  a,
const vector3< T > &  b 
)
inline
138  { return ((a.x >= b.x) && (a.y >= b.y) && (a.z >= b.z)); }

◆ operator>=() [3/5]

template<typename T >
bool std::math::operator>= ( const vector4< T > &  a,
const vector4< T > &  b 
)
inline
140  { return ((a.x >= b.x) && (a.y >= b.y) && (a.z >= b.z) && (a.w >= b.w)); }

◆ operator>=() [4/5]

template<typename T >
bool std::math::operator>= ( const vector2< T > &  a,
const vector2< T > &  b 
)
inline
144  { return ((a.x >= b.x) && (a.y >= b.y)); }

◆ operator>=() [5/5]

template<typename T >
bool std::math::operator>= ( const boundingbox< T > &  a,
const boundingbox< T > &  b 
)
149  {
150  return a.getmin() >= b.getmin() && a.getmax() >= b.getmax();
151  }

◆ ortho()

template<typename T >
matrix4x4<T> std::math::ortho ( const T  left,
const T  right,
const T  bottom,
const T  top,
const T  near,
const T  far 
)
551  {
552  matrix4x4<T> m = matrix4x4_identity<T>();
553  m.n[0] = 2 / (right - left);
554  m.n[5] = 2 / (top - bottom);
555  m.n[10] = -2 / (far - near);
556  m.n[12] = -(right + left) / (right - left);
557  m.n[13] = -(top + bottom) / (top - bottom);
558  m.n[14] = -(far + near) / (far - near);
559  return m;
560  }

◆ perspective()

template<typename T >
matrix4x4<T> std::math::perspective ( const T  fov,
const T  aspect,
const T  near,
const T  far 
)
542  {
543  T t = tan(fov/2 * DEG2RAD);
544  return frustum<T>(-(t * aspect), (t * aspect), -(near * t), (near * t),
545  near, far);
546 
547  }
quaternion< T > tan(const quaternion< T > &q)
Definition: quaternion.hpp:247
#define DEG2RAD
Definition: utils.hpp:35

◆ plane_frompointnormal()

template<typename T >
plane<T> std::math::plane_frompointnormal ( const vector3< T > &  p,
const vector3< T > &  n 
)
inline
77  {return plane<T>(n, -n.x * p.x - n.y * p.y - n.z * p.z);}

◆ plane_frompoints()

template<typename T >
plane<T> std::math::plane_frompoints ( const vector3< T > &  v1,
const vector3< T > &  v2,
const vector3< T > &  v3 
)
inline
80  {return plane_frompointnormal(v1, cross(v3 - v2, v1 - v2));}
vector3< T > cross(const vector3< T > &v1, vector3< T > &v2)
Definition: vector3.hpp:158
plane< T > plane_frompointnormal(const vector3< T > &p, const vector3< T > &n)
Definition: plane.hpp:76

◆ pow()

template<typename T >
quaternion<T> std::math::pow ( const quaternion< T > &  v,
const T  exp 
)
inline
191  {
192  if (fabs(v.s) > .9999)
193  return v;
194 
195  T alpha = acos(v.s);
196  T newAlpha = alpha * exp;
197  quaternion<T> result;
198  result.s = cos(newAlpha);
199 
200  float mult = sin(newAlpha) / sin(alpha);
201  result.v.x = (float)v.v.x * mult;
202  result.v.y = (float)v.v.y * mult;
203  result.v.z = (float)v.v.z * mult;
204 
205  return result;
206  }
quaternion< T > exp(const quaternion< T > &v)
Definition: quaternion.hpp:132

◆ power()

template<typename T >
quaternion<T> std::math::power ( const quaternion< T > &  qu,
degree 
)
inline
212  {
213  if ( degree == 0 ) return quaternion<T>((T)1.0, 0, 0, 0);
214  quaternion<T> tmp_qu = qu ;
215 
216  for ( float f = 1 ; f < abs(degree) ; f++ )
217  tmp_qu *= qu ;
218 
219  if ( degree < 0 )
220  return ( 1.0f / tmp_qu );
221 
222  return tmp_qu ;
223  }
T abs(const T &t)
Definition: algorithm.hpp:182

◆ quaternion_fromaxis()

template<typename T >
quaternion<T> std::math::quaternion_fromaxis ( const float  angle,
vector3< T >  axis 
)
inline
290  {
291  T omega, s = lenght(axis), c;
292  quaternion<T> temp;
293  vector3<T> vt = axis;
294 
295  if (fabs(s) > FLT_EPSILON)
296  {
297  c = 1.0f/s;
298  vt *= c;
299 
300  omega = -0.5f * angle;
301  s = (T)sin(omega);
302 
303  temp.v = vector3<T>(s*axis.x, s*axis.y, s*axis.z);
304  temp.s = cos(omega);
305  } else {
306  temp.v = vector3<T>(0.0f);
307  temp.s = 1;
308  }
309  return normalize(temp);
310  }
vector3< T > angle(const matrix4x4< T > &m)
Definition: matrix4x4.hpp:408
quaternion< T > normalize(const quaternion< T > &v)
Definition: quaternion.hpp:164
T lenght(const quaternion< T > &v)
Definition: quaternion.hpp:122

◆ radians()

template<typename T >
float std::math::radians ( float  degrees)
inline
115  {
116  return degrees * (PI / 180);
117  }
#define PI
Definition: utils.hpp:41
T degrees(T radians)
Definition: utils.hpp:109

◆ raQuaternionCos()

template<typename T >
quaternion<T> std::math::raQuaternionCos ( const quaternion< T > &  q)
inline
237  {
238  quaternion<T> s;
239 
240  for( T n = 1.0f; n <= 6.0f; n++ )
241  s += pow( -1.0f ,n ) * power( q , 2.0f * n ) /
242  factorial<T>( 2.0f * n ) ;
243 
244  return s ;
245  }
quaternion< T > pow(const quaternion< T > &v, const T exp)
Definition: quaternion.hpp:191
quaternion< T > power(const quaternion< T > &qu, T degree)
Definition: quaternion.hpp:212

◆ raQuaternionSin()

template<typename T >
quaternion<T> std::math::raQuaternionSin ( const quaternion< T > &  q)
inline
226  {
227  quaternion<T> s;
228 
229  for( float n = 0; n < 6.0f; n++ )
230  s += pow( -1.0f ,n ) * (power( q , 2.0f * n + 1.0f ) ) /
231  ( factorial<T>( 2.0f * n + 1.0f ) );
232 
233  return s ;
234  }
quaternion< T > pow(const quaternion< T > &v, const T exp)
Definition: quaternion.hpp:191
quaternion< T > power(const quaternion< T > &qu, T degree)
Definition: quaternion.hpp:212

◆ rotate()

template<typename T >
matrix4x4<T> std::math::rotate ( const matrix4x4< T > &  mat,
const vector3< T > &  v,
const T  angle 
)
inline
275  {
276  matrix4x4<T> m = mat;
277  T c = (T)cos(angle * DEG2RAD); // cosine
278  T s = sin(angle * DEG2RAD); // sine
279  T c1 = (T)(1.0) - c; // 1 - c
280  T x = v.x, y = v.y, z = v.z;
281  T m0 = m.n[0], m4 = m.n[4], m8 = m.n[8], m12= m.n[12],
282  m1 = m.n[1], m5 = m.n[5], m9 = m.n[9], m13= m.n[13],
283  m2 = m.n[2], m6 = m.n[6], m10= m.n[10], m14= m.n[14];
284 
285  // build rotation matrix
286  T r0 = x * x * c1 + c;
287  T r1 = x * y * c1 + z * s;
288  T r2 = x * z * c1 - y * s;
289  T r4 = x * y * c1 - z * s;
290  T r5 = y * y * c1 + c;
291  T r6 = y * z * c1 + x * s;
292  T r8 = x * z * c1 + y * s;
293  T r9 = y * z * c1 - x * s;
294  T r10= z * z * c1 + c;
295 
296  m.n[0] = r0 * m0 + r4 * m1 + r8 * m2;
297  m.n[1] = r1 * m0 + r5 * m1 + r9 * m2;
298  m.n[2] = r2 * m0 + r6 * m1 + r10* m2;
299  m.n[4] = r0 * m4 + r4 * m5 + r8 * m6;
300  m.n[5] = r1 * m4 + r5 * m5 + r9 * m6;
301  m.n[6] = r2 * m4 + r6 * m5 + r10* m6;
302  m.n[8] = r0 * m8 + r4 * m9 + r8 * m10;
303  m.n[9] = r1 * m8 + r5 * m9 + r9 * m10;
304  m.n[10]= r2 * m8 + r6 * m9 + r10* m10;
305  m.n[12]= r0 * m12+ r4 * m13+ r8 * m14;
306  m.n[13]= r1 * m12+ r5 * m13+ r9 * m14;
307  m.n[14]= r2 * m12+ r6 * m13+ r10* m14;
308  return m;
309  }
vector3< T > angle(const matrix4x4< T > &m)
Definition: matrix4x4.hpp:408
#define DEG2RAD
Definition: utils.hpp:35

◆ rotateX()

template<typename T >
matrix4x4<T>& std::math::rotateX ( const matrix4x4< T >  mat,
const T  angle 
)
inline
312  {
313  matrix4x4<T> m = mat;
314  T c = (T)cos(angle * DEG2RAD);
315  T s = (T)sin(angle * DEG2RAD);
316  T m1 = m.n[1], m2 = m.n[2],
317  m5 = m.n[5], m6 = m.n[6],
318  m9 = m.n[9], m10= m.n[10],
319  m13= m.n[13], m14= m.n[14];
320 
321  m.n[1] = m1 * c + m2 *-s;
322  m.n[2] = m1 * s + m2 * c;
323  m.n[5] = m5 * c + m6 *-s;
324  m.n[6] = m5 * s + m6 * c;
325  m.n[9] = m9 * c + m10*-s;
326  m.n[10]= m9 * s + m10* c;
327  m.n[13]= m13* c + m14*-s;
328  m.n[14]= m13* s + m14* c;
329 
330  return m;
331  }
vector3< T > angle(const matrix4x4< T > &m)
Definition: matrix4x4.hpp:408
#define DEG2RAD
Definition: utils.hpp:35

◆ rotateY()

template<typename T >
matrix4x4<T>& std::math::rotateY ( const matrix4x4< T >  mat,
const T  angle 
)
inline
334  {
335  matrix4x4<T> m = mat;
336  T c = (T)cos(angle * DEG2RAD);
337  T s = (T)sin(angle * DEG2RAD);
338  T m0 = m.n[0], m2 = m.n[2],
339  m4 = m.n[4], m6 = m.n[6],
340  m8 = m.n[8], m10= m.n[10],
341  m12= m.n[12], m14= m.n[14];
342 
343  m.n[0] = m0 * c + m2 * s;
344  m.n[2] = m0 *-s + m2 * c;
345  m.n[4] = m4 * c + m6 * s;
346  m.n[6] = m4 *-s + m6 * c;
347  m.n[8] = m8 * c + m10* s;
348  m.n[10]= m8 *-s + m10* c;
349  m.n[12]= m12* c + m14* s;
350  m.n[14]= m12*-s + m14* c;
351 
352  return m;
353  }
vector3< T > angle(const matrix4x4< T > &m)
Definition: matrix4x4.hpp:408
#define DEG2RAD
Definition: utils.hpp:35

◆ rotateZ()

template<typename T >
matrix4x4<T>& std::math::rotateZ ( const matrix4x4< T >  mat,
const T  angle 
)
inline
356  {
357  matrix4x4<T> m = mat;
358  T c = (T)cos(angle * DEG2RAD);
359  T s = (T)sin(angle * DEG2RAD);
360  T m0 = m.n[0], m1 = m.n[1],
361  m4 = m.n[4], m5 = m.n[5],
362  m8 = m.n[8], m9 = m.n[9],
363  m12= m.n[12], m13= m.n[13];
364 
365  m.n[0] = m0 * c + m1 *-s;
366  m.n[1] = m0 * s + m1 * c;
367  m.n[4] = m4 * c + m5 *-s;
368  m.n[5] = m4 * s + m5 * c;
369  m.n[8] = m8 * c + m9 *-s;
370  m.n[9] = m8 * s + m9 * c;
371  m.n[12]= m12* c + m13*-s;
372  m.n[13]= m12* s + m13* c;
373 
374  return m;
375  }
vector3< T > angle(const matrix4x4< T > &m)
Definition: matrix4x4.hpp:408
#define DEG2RAD
Definition: utils.hpp:35

◆ row() [1/2]

template<typename T >
matrix4x4<T> std::math::row ( const matrix4x4< T >  mat,
int  index,
vector3< T >  v 
)
inline
441  {
442  matrix4x4<T> m = mat;
443  m.n[index] = v.x; m.n[index + 4] = v.y; m.n[index + 8] = v.z;
444  return m;
445  }

◆ row() [2/2]

template<typename T >
matrix4x4<T> std::math::row ( const matrix4x4< T >  mat,
int  index,
vector4< T >  v 
)
inline
456  {
457  matrix4x4<T> m = mat;
458  m.n[index] = v.x; m.n[index + 4] = v.y; m.n[index + 8] = v.z;
459  m.n[index + 12] = v.w;
460  return m;
461  }

◆ scale() [1/3]

template<typename T >
vector4<T> std::math::scale ( const vector4< T > &  v,
const float  s 
)
inline
179  {return vector4<T>(v.x * s, v.y*s, v.z*s, v.w * s);}

◆ scale() [2/3]

template<typename T >
vector3<T> std::math::scale ( const vector3< T > &  v,
const float  s 
)
inline
185  {return vector3<T>(v.x * s, v.y*s, v.z*s);}

◆ scale() [3/3]

template<typename T >
vector2<T> std::math::scale ( const vector2< T > &  v,
const float  s 
)
inline
190  {return vector2<T>(v.x * s, v.y*s);}

◆ scaling()

template<typename T >
matrix4x4<T> std::math::scaling ( const vector3< T > &  v)
519  {
520  return matrix4x4<T>(v.x, 0.0f, 0.0f, 0.0f,
521  0.0f, v.y, 0.0f, 0.0f,
522  0.0f, 0.0f, v.z, 0.0f,
523  0.0f, 0.0f, 0.0f, 1.0f);
524  }

◆ SmoothStep()

template<typename T >
T std::math::SmoothStep ( value1,
value2,
amount 
)
inline
104  {
105  amount = amount * amount * ((T)3 - (T)2 * amount);
106  return value1 + (value2 - value1) * amount;
107  }

◆ tan()

template<typename T >
quaternion<T> std::math::tan ( const quaternion< T > &  q)
inline
247  {
248  if ( lenghtSq(q) == 0.0 ) return quaternion<T>(1, 0, 0, 0) ;
249  return sin( q ) / cos( q ) ;
250  }
T lenghtSq(const quaternion< T > &v)
Definition: quaternion.hpp:125

◆ tomatrix()

template<typename T >
matrix4x4<T> std::math::tomatrix ( const quaternion< T > &  v)
inline
44  {
45  return matrix4x4<T>(v.s, -v.v.x, -v.v.y, -v.v.z,
46  v.v.x, v.s, -v.v.z, v.v.y,
47  v.v.y, v.v.z, v.s, -v.v.x,
48  v.v.z, -v.v.y, v.v.x, v.s);
49  }

◆ toquaternion()

template<typename T >
quaternion<T> std::math::toquaternion ( const matrix4x4< T > &  mat)
inline
52  {
53  quaternion<T> v;
54  T tmp = fabs(mat(1,1) + mat(2,2) + mat(3,3) + 1);
55  v.s = 0.5f*sqrt(tmp);
56 
57  if(v.s > 0.0000001f)
58  {
59  v.v.x = (mat.n[9]-mat.n[6])/(4*v.s);
60  v.v.y = (mat.n[2]-mat.n[8])/(4*v.s);
61  v.v.z = (mat.n[4]-mat.n[1])/(4*v.s);
62  }
63  else
64  {
65  static int s_iNext[3] = { 2, 3, 1 };
66  int i = 1;
67  if ( mat(2,2) > mat(1,1) )
68  i = 2;
69  if ( mat(3,3) > mat(2,2) )
70  i = 3;
71  int j = s_iNext[i-1];
72  int k = s_iNext[j-1];
73 
74  T fRoot = sqrt(mat(i,i)-mat(j,j)-mat(k,k) + 1.0);
75 
76  T *tmp[3] = { (T*)&v.v.x, (T*)&v.v.y, (T*)&v.v.z };
77  *tmp[i-1] = 0.5*fRoot;
78  fRoot = 0.5/fRoot;
79  v.s = (mat(k,j)-mat(j,k))*fRoot;
80  *tmp[j-1] = (mat(j,i)+mat(i,j))*fRoot;
81  *tmp[k-1] = (mat(k,i)+mat(i,k))*fRoot;
82  }
83  }

◆ transformcoord()

template<typename T >
vector3<T> std::math::transformcoord ( const vector3< T > &  v,
const matrix4x4< T > &  m 
)
86  {
87  T norm = m.m[0][3] * v.x + m.m[1][3] * v.y + m.m[2][3] * v.z + m.m[3][3];
88 
89  if ( norm == 1 )
90  return vector3<T>(
91  (m.m[0][0] * v.x + m.m[1][0] * v.y + m.m[2][0] * v.z + m.m[3][0]) / norm,
92  (m.m[0][1] * v.x + m.m[1][1] * v.y + m.m[2][1] * v.z + m.m[3][1]) / norm,
93  (m.m[0][2] * v.x + m.m[1][2] * v.y + m.m[2][2] * v.z + m.m[3][2]) / norm);
94  else
95  return vector3<T>(0);
96  }

◆ transformnormal()

template<typename T >
vector3<T> std::math::transformnormal ( const vector3< T > &  v,
const matrix4x4< T > &  m 
)
99  {
100  return vector3<T>(
101  m.m[0][0] * v.x + m.m[1][0] * v.y + m.m[2][0] * v.z,
102  m.m[0][1] * v.x + m.m[1][1] * v.y + m.m[2][1] * v.z,
103  m.m[0][2] * v.x + m.m[1][2] * v.y + m.m[2][2] * v.z);
104  }

◆ translate()

template<typename T >
matrix4x4<T> std::math::translate ( const matrix4x4< T > &  mat,
const vector3< T > &  v 
)
inline
265  {
266  matrix4x4<T> m = mat;
267  m.n[0] += m.n[3] * v.x; m.n[4] += m.n[7] * v.x; m.n[8] += m.n[11]* v.x; m.n[12]+= m.n[15]* v.x;
268  m.n[1] += m.n[3] * v.y; m.n[5] += m.n[7] * v.y; m.n[9] += m.n[11]* v.y; m.n[13]+= m.n[15]* v.y;
269  m.n[2] += m.n[3] * v.z; m.n[6] += m.n[7] * v.z; m.n[10]+= m.n[11]* v.z; m.n[14]+= m.n[15]* v.z;
270 
271  return m;
272  }

◆ transpose()

template<typename T >
matrix4x4<T> std::math::transpose ( const matrix4x4< T > &  mat)
inline
378  {
379  matrix4x4<T> m = mat;
380  std::swap<T>(m.n[1], m.n[4]);
381  std::swap<T>(m.n[2], m.n[8]);
382  std::swap<T>(m.n[3], m.n[12]);
383  std::swap<T>(m.n[6], m.n[9]);
384  std::swap<T>(m.n[7], m.n[13]);
385  std::swap<T>(m.n[11], m.n[14]);
386 
387  return m;
388  }