Classes | |
| struct | tuple |
| struct | tuple_mixin |
| This class provides basic operators. More... | |
| struct | vector_mixin |
| this class implements vector common member More... | |
| struct | vec2 |
| struct | vec3 |
| struct | vec4 |
| struct | matrix_mixin |
| this class implements matrix common member More... | |
| struct | mat2 |
| struct | mat3 |
| struct | mat4 |
| struct | CofactorCalc |
| struct | DetCalc |
| struct | InverseCalc |
| struct | quat |
Functions | |
| template<size_t Size> float | dot (const tuple< Size > &a, const tuple< Size > &b) |
| inner product, dot product | |
| template<size_t Size> float | length (const tuple< Size > &a) |
| get length | |
| template<typename GenType> GenType | normalize (const GenType &a) |
| template<size_t Size> float | distance (const tuple< Size > &a, const tuple< Size > &b) |
| distance between a, b | |
| vec3 | cross (const vec3 &x, const vec3 &y) |
| same as GLSLangSpec.Full.1.10.59.pdf '8.4 Geometric Functions'. | |
| float | det (const mat2 &m) |
| float | cofactor (const mat2 &m, mat2::size_type col, mat2::size_type row) |
| mat2 | inverse (const mat2 &m) |
| float | cofactor (const mat3 &m, mat3::size_type col, mat3::size_type row) |
| float | det (const mat3 &m) |
| mat3 | inverse (const mat3 &m) |
| float | cofactor (const mat4 &m, mat3::size_type col, mat3::size_type row) |
| float | det (const mat4 &m) |
| mat4 | inverse (const mat4 &m) |
| template<typename Mat> Mat | transpose (const Mat &m) |
| quat | conj (const quat &q) |
| quat | inverse (const quat &q) |
| float | radians (float deg) |
| Converts degrees to radians and returns the result, i.e., result = PI/180*degrees. | |
| float | degrees (float rad) |
| Converts radians to degrees and returns the result, i.e., result = 180/PI*radians. | |
| template<typename GenType> GenType | lerp (const GenType &a, const GenType &b, float blendRate) |
| quat | log (const quat &q) |
| This function is from Game Programming Gems 2.9. | |
| quat | exp (const quat &q) |
| This function is from Game Programming Gems 2.9. | |
| quat | slerp (const quat &q1, const quat &q2, float t) |
| This function is from Game Programming Gems 2.9. | |
| quat | slerpNoInvert (const quat &q1, const quat &q2, float t) |
| This function is from Game Programming Gems 2.9. | |
| quat | squad (const quat &q1, const quat &q2, const quat &a, const quat &b, float t) |
| This function is from Game Programming Gems 2.9. | |
| quat | spline (const quat &qnm1, const quat &qn, const quat &qnp1) |
| This function is from Game Programming Gems 2.9. | |
|
||||||||||||||||
|
Definition at line 685 of file glsl_math.h.
00685 {
00686 return CofactorCalc< mat4, mat3 >::calc( m, col, row );
00687 }
|
|
||||||||||||||||
|
Definition at line 675 of file glsl_math.h.
00675 {
00676 return CofactorCalc< mat3, mat2 >::calc( m, col, row );
00677 }
|
|
||||||||||||||||
|
Definition at line 625 of file glsl_math.h. Referenced by gslib::glsl_math::InverseCalc< Mat >::calc(), and gslib::glsl_math::DetCalc< Mat >::calc().
00625 {
00626 return m[ col ? 0 : 1 ][ row ? 0 : 1 ];
00627 }
|
|
|
Definition at line 803 of file glsl_math.h.
00805 {
00806 return quat(
00807 -q.x,
00808 -q.y,
00809 -q.z,
|
|
||||||||||||
|
same as GLSLangSpec.Full.1.10.59.pdf '8.4 Geometric Functions'.
Definition at line 428 of file glsl_math.h. Referenced by BOOST_AUTO_UNIT_TEST().
00428 {
00429 return vec3(
00430 x[ 1 ] * y[ 2 ] - y[ 1 ] * x[ 2 ],
00431 x[ 2 ] * y[ 0 ] - y[ 2 ] * x[ 0 ],
00432 x[ 0 ] * y[ 1 ] - y[ 0 ] * x[ 1 ] );
00433 }
|
|
|
Converts radians to degrees and returns the result, i.e., result = 180/PI*radians.
Definition at line 822 of file glsl_math.h.
00824 {
00825 const float pi = 3.14159265358979323846264338327950288419716939937510582;
|
|
|
Definition at line 688 of file glsl_math.h.
00688 {
00689 return DetCalc< mat4 >::calc( m );
00690 }
|
|
|
Definition at line 678 of file glsl_math.h.
00678 {
00679 return DetCalc< mat3 >::calc( m );
00680 }
|
|
|
Definition at line 622 of file glsl_math.h. Referenced by gslib::glsl_math::InverseCalc< Mat >::calc(), and gslib::glsl_math::CofactorCalc< Mat, SmallMat >::calc().
00622 {
00623 return m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ];
00624 }
|
|
||||||||||||||||
|
distance between a, b
Definition at line 172 of file glsl_math.h. Referenced by isNearEqual().
00172 {
00173 float result = 0.0f;
00174 for ( size_t i = 0; i < Size; ++i ) {
00175 float diff = a[ i ] - b[ i ];
00176 result += diff * diff;
00177 }
00178 return sqrtf( result );
00179 }
|
|
||||||||||||||||
|
inner product, dot product
Definition at line 148 of file glsl_math.h. References gslib::glsl_math::tuple< Size >::begin(), and gslib::glsl_math::tuple< Size >::end(). Referenced by length().
|
Here is the call graph for this function:

|
|
This function is from Game Programming Gems 2.9. This function has not been tested yet. e^quaternion given as: exp(v*a) = [cos(a),vsin(a)] Definition at line 872 of file glsl_math.h.
00874 {
00875 float a = static_cast< float >( sqrtf( q.x*q.x + q.y*q.y + q.z*q.z ) );
00876 float sina = static_cast< float >( sinf( a ) );
00877 float cosa = static_cast< float >( cosf( a ) );
00878 quat ret;
00879 ret.w = cosa;
00880 if ( a > 0 ) {
00881 ret.xyz() = q.xyz() * ( sina / a );
00882 /* ret.x = sina * q.x / a;
00883 ret.y = sina * q.y / a;
00884 ret.z = sina * q.z / a;*/
00885 } else {
00886 ret.x = ret.y = ret.z = 0;
00887 }
00888
|
|
|
Definition at line 811 of file glsl_math.h.
00813 {
|
|
|
Definition at line 691 of file glsl_math.h.
00691 {
00692 return InverseCalc< mat4 >::calc( m );
00693 }
|
|
|
Definition at line 681 of file glsl_math.h.
00681 {
00682 return InverseCalc< mat3 >::calc( m );
00683 }
|
|
|
Definition at line 671 of file glsl_math.h. Referenced by BOOST_AUTO_UNIT_TEST().
00671 {
00672 return InverseCalc< mat2 >::calc( m );
00673 }
|
|
||||||||||
|
get length
Definition at line 154 of file glsl_math.h. References dot(). Referenced by BOOST_AUTO_UNIT_TEST(), and normalize().
00154 {
00155 return sqrtf( dot( a, a ) );
00156 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 835 of file glsl_math.h. Referenced by BOOST_AUTO_UNIT_TEST().
00837 {
00838 BOOST_ASSERT( 0 <= blendRate && blendRate <= 1 );
|
|
|
This function is from Game Programming Gems 2.9. This function has not been tested yet. Logarithm of a quaternion, given as: log(q) = v*a where q = [cos(a),v*sin(a)] Definition at line 848 of file glsl_math.h.
00850 {
00851 float a = static_cast<float>(acosf(q.w));
00852 float sina = static_cast<float>(sinf(a));
00853 quat ret;
00854 ret.w = 0;
00855 if (sina > 0) {
00856 /* ret.x = a*q.x/sina;
00857 ret.y = a*q.y/sina;
00858 ret.z = a*q.z/sina;*/
00859 ret.xyz() = q.xyz() * ( a / sina );
00860 } else {
00861 ret.x=ret.y=ret.z=0;
00862 }
|
|
||||||||||
|
Definition at line 164 of file glsl_math.h. References length().
00164 {
00165 GenType result( a );
00166 float invLen = 1.0f / length( a );
00167 return a * invLen;
00168 }
|
Here is the call graph for this function:

|
|
Converts degrees to radians and returns the result, i.e., result = PI/180*degrees.
Definition at line 816 of file glsl_math.h.
00818 {
00819 const float pi = 3.14159265358979323846264338327950288419716939937510582;
|
|
||||||||||||||||
|
This function is from Game Programming Gems 2.9. This function has not been tested yet. Definition at line 895 of file glsl_math.h.
00897 {
00898 quat q3;
00899 float d = dot( q1, q2 );
00900
00901 /*
00902 dot = cos(theta)
00903 if (dot < 0), q1 and q2 are more than 90 degrees apart,
00904 so we can invert one to reduce spinning
00905 */
00906 if ( d < 0 ) {
00907 d = -d;
00908 q3 = -q2;
00909 }
00910 else
00911 {
00912 q3 = q2;
00913 }
00914
00915
00916 if ( d < 0.95f ) {
00917 float angle = static_cast<float>(acosf(d));
00918 float sina,sinat,sinaomt;
00919 sina = static_cast<float>(sinf(angle));
00920 sinat = static_cast<float>(sinf(angle*t));
00921 sinaomt = static_cast<float>(sinf(angle*(1-t)));
00922 return (q1*sinaomt+q3*sinat)/sina;
00923 } else {
00924 // if the angle is small, use linear interpolation
00925 return lerp(q1,q3,t);
|
|
||||||||||||||||
|
This function is from Game Programming Gems 2.9. This function has not been tested yet. Definition at line 932 of file glsl_math.h.
00934 {
00935 float d = dot( q1, q2 );
00936
00937 if (d > -0.95f && d < 0.95f)
00938 {
00939 float angle = static_cast<float>(acosf(d));
00940 float sina,sinat,sinaomt;
00941 sina = static_cast<float>(sinf(angle));
00942 sinat = static_cast<float>(sinf(angle*t));
00943 sinaomt = static_cast<float>(sinf(angle*(1-t)));
00944 return (q1*sinaomt+q2*sinat)/sina;
00945 }
00946 /*
00947 if the angle is small, use linear interpolation
00948 */
00949 else
00950 {
00951 return lerp(q1,q2,t);
|
|
||||||||||||||||
|
This function is from Game Programming Gems 2.9. This function has not been tested yet. Definition at line 972 of file glsl_math.h.
00974 {
00975 quat qni = conj( qn );
|
|
||||||||||||||||||||||||
|
This function is from Game Programming Gems 2.9. This function has not been tested yet. Definition at line 959 of file glsl_math.h.
00961 {
00962 quat c,d;
00963 c = slerpNoInvert(q1,q2,t);
00964 d = slerpNoInvert(a,b,t);
|
|
||||||||||
|
Definition at line 696 of file glsl_math.h.
00696 {
00697 Mat result;
00698 for ( size_type i = 0; i < m.colSize(); ++i ) {
00699 for ( size_type j = 0; j < m.rowSize(); ++j ) {
00700 result[ j ][ i ] = m[ i ][ j ];
00701 }
00702 }
00703 return result;
00704 }
|
1.3.6