40#ifndef GLS_MATRIXAFFINE_H 
   41#define GLS_MATRIXAFFINE_H 
   64    DISTI_DEPRECATED( 
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
 
  112#    pragma warning( push ) 
  113#    pragma warning( disable : 4458 )  
  119        static const unsigned int SIZE      = 4 * 4;
 
  122        for( 
unsigned int i = 0; i < SIZE; ++i )
 
  130#    pragma warning( pop ) 
  180    void Scale( Type x, Type y, Type z );
 
  243    using BaseClass::operator*;
 
  251            float( ( M( 0, 0 ) * v.
x ) + ( M( 0, 1 ) * v.
y ) + ( M( 0, 2 ) * v.
z ) + M( 0, 3 ) ),
 
  252            float( ( M( 1, 0 ) * v.
x ) + ( M( 1, 1 ) * v.
y ) + ( M( 1, 2 ) * v.
z ) + M( 1, 3 ) ),
 
  253            float( ( M( 2, 0 ) * v.
x ) + ( M( 2, 1 ) * v.
y ) + ( M( 2, 2 ) * v.
z ) + M( 2, 3 ) ) );
 
  262            float( ( M( 0, 0 ) * v.
x ) + ( M( 0, 1 ) * v.
y ) + ( M( 0, 2 ) * v.
z ) + M( 0, 3 ) ),
 
  263            float( ( M( 1, 0 ) * v.
x ) + ( M( 1, 1 ) * v.
y ) + ( M( 1, 2 ) * v.
z ) + M( 1, 3 ) ),
 
  264            float( ( M( 2, 0 ) * v.
x ) + ( M( 2, 1 ) * v.
y ) + ( M( 2, 2 ) * v.
z ) + M( 2, 3 ) ),
 
  295    const Vector xAxis = 
Vector( 
float( m( 0, 0 ) ), 
float( m( 1, 0 ) ), 
float( m( 2, 0 ) ) );
 
  296    const Vector yAxis = 
Vector( 
float( m( 0, 1 ) ), 
float( m( 1, 1 ) ), 
float( m( 2, 1 ) ) );
 
  297    const Vector zAxis = 
Vector( 
float( m( 0, 2 ) ), 
float( m( 1, 2 ) ), 
float( m( 2, 2 ) ) );
 
  318    if( 0 != scale.
x && 0 != scale.
y && 0 != scale.
z )
 
  320        m( 0, 0 ) /= scale.
x;
 
  321        m( 1, 0 ) /= scale.
x;
 
  322        m( 2, 0 ) /= scale.
x;
 
  323        m( 0, 1 ) /= scale.
y;
 
  324        m( 1, 1 ) /= scale.
y;
 
  325        m( 2, 1 ) /= scale.
y;
 
  326        m( 0, 2 ) /= scale.
z;
 
  327        m( 1, 2 ) /= scale.
z;
 
  328        m( 2, 2 ) /= scale.
z;
 
  347    location = 
Vector( 
float( matrix( 0, 3 ) ), 
float( matrix( 1, 3 ) ), 
float( matrix( 2, 3 ) ) );
 
  396    const double a( 
double( angle ) * 
DEG_TO_RAD );
 
  397    const Type   sina( (Type)sin( a ) );
 
  398    const Type   cosa( (Type)cos( a ) );
 
  414        temp              = _matrix[ 0 ][ 1 ];
 
  415        _matrix[ 0 ][ 1 ] = temp * cosa - _matrix[ 0 ][ 2 ] * sina;
 
  416        _matrix[ 0 ][ 2 ] = temp * sina + _matrix[ 0 ][ 2 ] * cosa;
 
  417        temp              = _matrix[ 1 ][ 1 ];
 
  418        _matrix[ 1 ][ 1 ] = temp * cosa - _matrix[ 1 ][ 2 ] * sina;
 
  419        _matrix[ 1 ][ 2 ] = temp * sina + _matrix[ 1 ][ 2 ] * cosa;
 
  420        temp              = _matrix[ 2 ][ 1 ];
 
  421        _matrix[ 2 ][ 1 ] = temp * cosa - _matrix[ 2 ][ 2 ] * sina;
 
  422        _matrix[ 2 ][ 2 ] = temp * sina + _matrix[ 2 ][ 2 ] * cosa;
 
  423        temp              = _matrix[ 3 ][ 1 ];
 
  424        _matrix[ 3 ][ 1 ] = temp * cosa - _matrix[ 3 ][ 2 ] * sina;
 
  425        _matrix[ 3 ][ 2 ] = temp * sina + _matrix[ 3 ][ 2 ] * cosa;
 
  439        temp              = _matrix[ 0 ][ 0 ];
 
  440        _matrix[ 0 ][ 0 ] = temp * cosa + _matrix[ 0 ][ 2 ] * sina;
 
  441        _matrix[ 0 ][ 2 ] = _matrix[ 0 ][ 2 ] * cosa - temp * sina;
 
  442        temp              = _matrix[ 1 ][ 0 ];
 
  443        _matrix[ 1 ][ 0 ] = temp * cosa + _matrix[ 1 ][ 2 ] * sina;
 
  444        _matrix[ 1 ][ 2 ] = _matrix[ 1 ][ 2 ] * cosa - temp * sina;
 
  445        temp              = _matrix[ 2 ][ 0 ];
 
  446        _matrix[ 2 ][ 0 ] = temp * cosa + _matrix[ 2 ][ 2 ] * sina;
 
  447        _matrix[ 2 ][ 2 ] = _matrix[ 2 ][ 2 ] * cosa - temp * sina;
 
  448        temp              = _matrix[ 3 ][ 0 ];
 
  449        _matrix[ 3 ][ 0 ] = temp * cosa + _matrix[ 3 ][ 2 ] * sina;
 
  450        _matrix[ 3 ][ 2 ] = _matrix[ 3 ][ 2 ] * cosa - temp * sina;
 
  464        temp              = _matrix[ 0 ][ 0 ];
 
  465        _matrix[ 0 ][ 0 ] = temp * cosa - _matrix[ 0 ][ 1 ] * sina;
 
  466        _matrix[ 0 ][ 1 ] = temp * sina + _matrix[ 0 ][ 1 ] * cosa;
 
  467        temp              = _matrix[ 1 ][ 0 ];
 
  468        _matrix[ 1 ][ 0 ] = temp * cosa - _matrix[ 1 ][ 1 ] * sina;
 
  469        _matrix[ 1 ][ 1 ] = temp * sina + _matrix[ 1 ][ 1 ] * cosa;
 
  470        temp              = _matrix[ 2 ][ 0 ];
 
  471        _matrix[ 2 ][ 0 ] = temp * cosa - _matrix[ 2 ][ 1 ] * sina;
 
  472        _matrix[ 2 ][ 1 ] = temp * sina + _matrix[ 2 ][ 1 ] * cosa;
 
  473        temp              = _matrix[ 3 ][ 0 ];
 
  474        _matrix[ 3 ][ 0 ] = temp * cosa - _matrix[ 3 ][ 1 ] * sina;
 
  475        _matrix[ 3 ][ 1 ] = temp * sina + _matrix[ 3 ][ 1 ] * cosa;
 
  484    const Vector&                        centerOfRotation,
 
  493    const double a( 
double( angle ) * 
DEG_TO_RAD );
 
  494    const Type   sina( (Type)sin( a ) );
 
  495    const Type   cosa( (Type)cos( a ) );
 
  513        const Type T11( cosa ), T12( -sina ), T21( sina ), T22( cosa ),
 
  515            T13( centerOfRotation.
y - ( cosa * centerOfRotation.
y - sina * centerOfRotation.
z ) ),
 
  516            T23( centerOfRotation.
z - ( sina * centerOfRotation.
y + cosa * centerOfRotation.
z ) );
 
  520        temp              = _matrix[ 0 ][ 1 ];
 
  521        _matrix[ 0 ][ 1 ] = temp * T11 + _matrix[ 0 ][ 2 ] * T12 + _matrix[ 0 ][ 3 ] * T13;
 
  522        _matrix[ 0 ][ 2 ] = temp * T21 + _matrix[ 0 ][ 2 ] * T22 + _matrix[ 0 ][ 3 ] * T23;
 
  523        temp              = _matrix[ 1 ][ 1 ];
 
  524        _matrix[ 1 ][ 1 ] = temp * T11 + _matrix[ 1 ][ 2 ] * T12 + _matrix[ 1 ][ 3 ] * T13;
 
  525        _matrix[ 1 ][ 2 ] = temp * T21 + _matrix[ 1 ][ 2 ] * T22 + _matrix[ 1 ][ 3 ] * T23;
 
  526        temp              = _matrix[ 2 ][ 1 ];
 
  527        _matrix[ 2 ][ 1 ] = temp * T11 + _matrix[ 2 ][ 2 ] * T12 + _matrix[ 2 ][ 3 ] * T13;
 
  528        _matrix[ 2 ][ 2 ] = temp * T21 + _matrix[ 2 ][ 2 ] * T22 + _matrix[ 2 ][ 3 ] * T23;
 
  529        temp              = _matrix[ 3 ][ 1 ];
 
  530        _matrix[ 3 ][ 1 ] = temp * T11 + _matrix[ 3 ][ 2 ] * T12 + _matrix[ 3 ][ 3 ] * T13;
 
  531        _matrix[ 3 ][ 2 ] = temp * T21 + _matrix[ 3 ][ 2 ] * T22 + _matrix[ 3 ][ 3 ] * T23;
 
  547        const Type T00( cosa ), T02( sina ), T20( -sina ), T22( cosa ),
 
  548            T03( centerOfRotation.
x - ( sina * centerOfRotation.
z + cosa * centerOfRotation.
x ) ),
 
  550            T23( centerOfRotation.
z - ( cosa * centerOfRotation.
z - sina * centerOfRotation.
x ) );
 
  554        temp              = _matrix[ 0 ][ 0 ];
 
  555        _matrix[ 0 ][ 0 ] = temp * T00 + _matrix[ 0 ][ 2 ] * T02 + _matrix[ 0 ][ 3 ] * T03;
 
  556        _matrix[ 0 ][ 2 ] = temp * T20 + _matrix[ 0 ][ 2 ] * T22 + _matrix[ 0 ][ 3 ] * T23;
 
  557        temp              = _matrix[ 1 ][ 0 ];
 
  558        _matrix[ 1 ][ 0 ] = temp * T00 + _matrix[ 1 ][ 2 ] * T02 + _matrix[ 1 ][ 3 ] * T03;
 
  559        _matrix[ 1 ][ 2 ] = temp * T20 + _matrix[ 1 ][ 2 ] * T22 + _matrix[ 1 ][ 3 ] * T23;
 
  560        temp              = _matrix[ 2 ][ 0 ];
 
  561        _matrix[ 2 ][ 0 ] = temp * T00 + _matrix[ 2 ][ 2 ] * T02 + _matrix[ 2 ][ 3 ] * T03;
 
  562        _matrix[ 2 ][ 2 ] = temp * T20 + _matrix[ 2 ][ 2 ] * T22 + _matrix[ 2 ][ 3 ] * T23;
 
  563        temp              = _matrix[ 3 ][ 0 ];
 
  564        _matrix[ 3 ][ 0 ] = temp * T00 + _matrix[ 3 ][ 2 ] * T02 + _matrix[ 3 ][ 3 ] * T03;
 
  565        _matrix[ 3 ][ 2 ] = temp * T20 + _matrix[ 3 ][ 2 ] * T22 + _matrix[ 3 ][ 3 ] * T23;
 
  581        const Type T00( cosa ), T01( -sina ), T10( sina ), T11( cosa ),
 
  582            T03( centerOfRotation.
x - ( cosa * centerOfRotation.
x - sina * centerOfRotation.
y ) ),
 
  583            T13( centerOfRotation.
y - ( sina * centerOfRotation.
x + cosa * centerOfRotation.
y ) );
 
  588        temp              = _matrix[ 0 ][ 0 ];
 
  589        _matrix[ 0 ][ 0 ] = temp * T00 + _matrix[ 0 ][ 1 ] * T01 + _matrix[ 0 ][ 3 ] * T03;
 
  590        _matrix[ 0 ][ 1 ] = temp * T10 + _matrix[ 0 ][ 1 ] * T11 + _matrix[ 0 ][ 3 ] * T13;
 
  591        temp              = _matrix[ 1 ][ 0 ];
 
  592        _matrix[ 1 ][ 0 ] = temp * T00 + _matrix[ 1 ][ 1 ] * T01 + _matrix[ 1 ][ 3 ] * T03;
 
  593        _matrix[ 1 ][ 1 ] = temp * T10 + _matrix[ 1 ][ 1 ] * T11 + _matrix[ 1 ][ 3 ] * T13;
 
  594        temp              = _matrix[ 2 ][ 0 ];
 
  595        _matrix[ 2 ][ 0 ] = temp * T00 + _matrix[ 2 ][ 1 ] * T01 + _matrix[ 2 ][ 3 ] * T03;
 
  596        _matrix[ 2 ][ 1 ] = temp * T10 + _matrix[ 2 ][ 1 ] * T11 + _matrix[ 2 ][ 3 ] * T13;
 
  597        temp              = _matrix[ 3 ][ 0 ];
 
  598        _matrix[ 3 ][ 0 ] = temp * T00 + _matrix[ 3 ][ 1 ] * T01 + _matrix[ 3 ][ 3 ] * T03;
 
  599        _matrix[ 3 ][ 1 ] = temp * T10 + _matrix[ 3 ][ 1 ] * T11 + _matrix[ 3 ][ 3 ] * T13;
 
  608    const Vector&                        centerOfRotation,
 
  645        const Type xx( Type( u.
x * u.
x ) );
 
  646        const Type yy( Type( u.
y * u.
y ) );
 
  647        const Type zz( Type( u.
z * u.
z ) );
 
  648        const Type xy( Type( u.
x * u.
y ) );
 
  649        const Type xz( Type( u.
x * u.
z ) );
 
  650        const Type yz( Type( u.
y * u.
z ) );
 
  654        const double a( 
double( angle ) * 
DEG_TO_RAD );
 
  655        const Type   sina( (Type)sin( a ) );
 
  656        const Type   cosa( (Type)cos( a ) );
 
  666        R( 0, 0 ) = xx + ( 1 - xx ) * cosa;
 
  667        R( 1, 0 ) = xy - xy * cosa + u.
z * sina;
 
  668        R( 2, 0 ) = xz - xz * cosa - u.
y * sina;
 
  670        R( 0, 1 ) = xy - xy * cosa - u.
z * sina;
 
  671        R( 1, 1 ) = yy + ( 1 - yy ) * cosa;
 
  672        R( 2, 1 ) = yz - yz * cosa + u.
x * sina;
 
  674        R( 0, 2 ) = xz - xz * cosa + u.
y * sina;
 
  675        R( 1, 2 ) = yz - yz * cosa - u.
x * sina;
 
  676        R( 2, 2 ) = zz + ( 1 - zz ) * cosa;
 
  681        this->Translate( -centerOfRotation.
x, -centerOfRotation.
y, -centerOfRotation.
z );
 
  683        this->Translate( centerOfRotation.
x, centerOfRotation.
y, centerOfRotation.
z );
 
  698    _matrix[ 0 ][ 0 ] = _matrix[ 0 ][ 0 ] * x;
 
  699    _matrix[ 0 ][ 1 ] = _matrix[ 0 ][ 1 ] * y;
 
  700    _matrix[ 0 ][ 2 ] = _matrix[ 0 ][ 2 ] * z;
 
  703    _matrix[ 1 ][ 0 ] = _matrix[ 1 ][ 0 ] * x;
 
  704    _matrix[ 1 ][ 1 ] = _matrix[ 1 ][ 1 ] * y;
 
  705    _matrix[ 1 ][ 2 ] = _matrix[ 1 ][ 2 ] * z;
 
  708    _matrix[ 2 ][ 0 ] = _matrix[ 2 ][ 0 ] * x;
 
  709    _matrix[ 2 ][ 1 ] = _matrix[ 2 ][ 1 ] * y;
 
  710    _matrix[ 2 ][ 2 ] = _matrix[ 2 ][ 2 ] * z;
 
  713    _matrix[ 3 ][ 0 ] = _matrix[ 3 ][ 0 ] * x;
 
  714    _matrix[ 3 ][ 1 ] = _matrix[ 3 ][ 1 ] * y;
 
  715    _matrix[ 3 ][ 2 ] = _matrix[ 3 ][ 2 ] * z;
 
  735    const Type T03 = anchor.
x * ( 1 - x );
 
  736    const Type T13 = anchor.
y * ( 1 - y );
 
  737    const Type T23 = anchor.
z * ( 1 - z );
 
  742    _matrix[ 0 ][ 0 ] = _matrix[ 0 ][ 0 ] * T00 + _matrix[ 0 ][ 3 ] * T03;
 
  743    _matrix[ 0 ][ 1 ] = _matrix[ 0 ][ 1 ] * T11 + _matrix[ 0 ][ 3 ] * T13;
 
  744    _matrix[ 0 ][ 2 ] = _matrix[ 0 ][ 2 ] * T22 + _matrix[ 0 ][ 3 ] * T23;
 
  747    _matrix[ 1 ][ 0 ] = _matrix[ 1 ][ 0 ] * T00 + _matrix[ 1 ][ 3 ] * T03;
 
  748    _matrix[ 1 ][ 1 ] = _matrix[ 1 ][ 1 ] * T11 + _matrix[ 1 ][ 3 ] * T13;
 
  749    _matrix[ 1 ][ 2 ] = _matrix[ 1 ][ 2 ] * T22 + _matrix[ 1 ][ 3 ] * T23;
 
  752    _matrix[ 2 ][ 0 ] = _matrix[ 2 ][ 0 ] * T00 + _matrix[ 2 ][ 3 ] * T03;
 
  753    _matrix[ 2 ][ 1 ] = _matrix[ 2 ][ 1 ] * T11 + _matrix[ 2 ][ 3 ] * T13;
 
  754    _matrix[ 2 ][ 2 ] = _matrix[ 2 ][ 2 ] * T22 + _matrix[ 2 ][ 3 ] * T23;
 
  757    _matrix[ 3 ][ 0 ] = _matrix[ 3 ][ 0 ] * T00 + _matrix[ 3 ][ 3 ] * T03;
 
  758    _matrix[ 3 ][ 1 ] = _matrix[ 3 ][ 1 ] * T11 + _matrix[ 3 ][ 3 ] * T13;
 
  759    _matrix[ 3 ][ 2 ] = _matrix[ 3 ][ 2 ] * T22 + _matrix[ 3 ][ 3 ] * T23;
 
  764#ifdef MATRIX_TYPE_FLOAT 
  771#ifdef MATRIX_TYPE_FLOAT 
  778#ifdef MATRIX_TYPE_FLOAT 
  779#    define GLS_glLoadMatrix_TYPE glLoadMatrixf 
  781#    define GLS_glLoadMatrix_TYPE glLoadMatrixd 
  785#ifdef MATRIX_TYPE_FLOAT 
  786#    define GLS_glMultMatrix_TYPE glMultMatrixf 
  788#    define GLS_glMultMatrix_TYPE glMultMatrixd 
unsigned char G() const
Definition: gls_color.h:214
unsigned char R() const
Definition: gls_color.h:211
unsigned char B() const
Definition: gls_color.h:217
unsigned char A() const
Definition: gls_color.h:220
Definition: gls_matrix_affine.h:61
void Rotate(Type angle, RotationAxis axis)
Definition: gls_matrix_affine.h:392
void Scale(Type x, Type y, Type z)
Definition: gls_matrix_affine.h:688
void Rotate(Type angle, const Vector ¢erOfRotation, RotationAxis axis)
Definition: gls_matrix_affine.h:483
void Scale(Type x, Type y, Type z, const Vector &anchor)
Definition: gls_matrix_affine.h:722
GlsMatrixAffine()
Definition: gls_matrix_affine.h:363
void Rotate(Type angle, const Vector ¢erOfRotation, const Vector &axis)
Definition: gls_matrix_affine.h:607
void Translate(const Vector &v)
Definition: gls_matrix_affine.h:240
Vertex operator*(const Vertex &v) const
Definition: gls_matrix_affine.h:258
Vector operator*(const Vector &v) const
Definition: gls_matrix_affine.h:247
void Transform(Vector &v) const
Definition: gls_matrix_affine.h:273
~GlsMatrixAffine()
Definition: gls_matrix_affine.h:386
void Translate(Type x, Type y, Type z)
Definition: gls_matrix_affine.h:205
bool IsVeryClose(const GlsMatrix< Type, 4 > &b) const
Definition: gls_matrix_affine.h:117
Definition: gls_matrix.h:62
Type * Data()
Definition: gls_matrix.h:128
static const double PRECISION
Definition: gls_matrix.h:368
Type * _matrix[DIM]
Definition: gls_matrix.h:389
Type _data[DIM *DIM]
Definition: gls_matrix.h:377
Definition: gls_quaternion.h:57
float MagnitudeSquared() const
Definition: vertex.h:338
float y
The Y component.
Definition: vertex.h:88
float x
The X component.
Definition: vertex.h:87
float Magnitude() const
Definition: vertex.h:330
void Normalize()
Definition: vertex.h:311
float z
The Z component.
Definition: vertex.h:89
GlsColor color
The RGBA color component.
Definition: vertex.h:422
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
The disti::GlsQuaternion class.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
GlsMatrix< Type, 4 > DecomposeRotationMatrix(const GlsMatrix< Type, 4 > &matrix, const Vector &scale)
Definition: gls_matrix_affine.h:308
GlsMatrixAffine< double > GlsMatrixAffineD
Typedef for a matrix of doubles.
Definition: gls_matrix_affine.h:353
Vector DecomposeScale(const GlsMatrix< Type, 4 > &m)
Definition: gls_matrix_affine.h:293
RotationAxis
Definition: vertex.h:74
@ Z_AXIS
Definition: vertex.h:77
@ X_AXIS
Definition: vertex.h:75
@ Y_AXIS
Definition: vertex.h:76
const double DEG_TO_RAD
Definition: vertex.h:61
VertexNoColor Vector
Definition: gls_font_base.h:69
void DecomposeMatrix(const GlsMatrix< Type, 4 > &matrix, Vector &scale, Vector &location, GlsQuaternion< Type > &rotation)
Definition: gls_matrix_affine.h:342
GlsMatrixAffine< float > GlsMatrixAffineF
Typedef for a matrix of floats.
Definition: gls_matrix_affine.h:352
GlsMatrixAffineD GlsMatrixType
Typedef for a generic (float or double elements) matrix.
Definition: gls_matrix_affine.h:774
double GlsMatrixElementType
Typedef for a generic (float or double) matrix element.
Definition: gls_matrix_affine.h:767
The disti::Vertex class. A class for manipulating 3D vertices.