39#ifndef GLS_MATRIXAFFINE_H
40#define GLS_MATRIXAFFINE_H
63 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
111# pragma warning( push )
112# pragma warning( disable : 4458 )
118 static const unsigned int SIZE = 4 * 4;
121 for(
unsigned int i = 0; i < SIZE; ++i )
129# pragma warning( pop )
179 void Scale( Type x, Type y, Type z );
242 using BaseClass::operator*;
250 float( ( M( 0, 0 ) * v.
x ) + ( M( 0, 1 ) * v.
y ) + ( M( 0, 2 ) * v.
z ) + M( 0, 3 ) ),
251 float( ( M( 1, 0 ) * v.
x ) + ( M( 1, 1 ) * v.
y ) + ( M( 1, 2 ) * v.
z ) + M( 1, 3 ) ),
252 float( ( M( 2, 0 ) * v.
x ) + ( M( 2, 1 ) * v.
y ) + ( M( 2, 2 ) * v.
z ) + M( 2, 3 ) ) );
261 float( ( M( 0, 0 ) * v.
x ) + ( M( 0, 1 ) * v.
y ) + ( M( 0, 2 ) * v.
z ) + M( 0, 3 ) ),
262 float( ( M( 1, 0 ) * v.
x ) + ( M( 1, 1 ) * v.
y ) + ( M( 1, 2 ) * v.
z ) + M( 1, 3 ) ),
263 float( ( M( 2, 0 ) * v.
x ) + ( M( 2, 1 ) * v.
y ) + ( M( 2, 2 ) * v.
z ) + M( 2, 3 ) ),
294 const Vector xAxis =
Vector(
float( m( 0, 0 ) ),
float( m( 1, 0 ) ),
float( m( 2, 0 ) ) );
295 const Vector yAxis =
Vector(
float( m( 0, 1 ) ),
float( m( 1, 1 ) ),
float( m( 2, 1 ) ) );
296 const Vector zAxis =
Vector(
float( m( 0, 2 ) ),
float( m( 1, 2 ) ),
float( m( 2, 2 ) ) );
317 if( 0 != scale.
x && 0 != scale.
y && 0 != scale.
z )
319 m( 0, 0 ) /= scale.
x;
320 m( 1, 0 ) /= scale.
x;
321 m( 2, 0 ) /= scale.
x;
322 m( 0, 1 ) /= scale.
y;
323 m( 1, 1 ) /= scale.
y;
324 m( 2, 1 ) /= scale.
y;
325 m( 0, 2 ) /= scale.
z;
326 m( 1, 2 ) /= scale.
z;
327 m( 2, 2 ) /= scale.
z;
346 location =
Vector(
float( matrix( 0, 3 ) ),
float( matrix( 1, 3 ) ),
float( matrix( 2, 3 ) ) );
395 const double a(
double( angle ) *
DEG_TO_RAD );
396 const Type sina( (Type)sin( a ) );
397 const Type cosa( (Type)cos( a ) );
413 temp = _matrix[ 0 ][ 1 ];
414 _matrix[ 0 ][ 1 ] = temp * cosa - _matrix[ 0 ][ 2 ] * sina;
415 _matrix[ 0 ][ 2 ] = temp * sina + _matrix[ 0 ][ 2 ] * cosa;
416 temp = _matrix[ 1 ][ 1 ];
417 _matrix[ 1 ][ 1 ] = temp * cosa - _matrix[ 1 ][ 2 ] * sina;
418 _matrix[ 1 ][ 2 ] = temp * sina + _matrix[ 1 ][ 2 ] * cosa;
419 temp = _matrix[ 2 ][ 1 ];
420 _matrix[ 2 ][ 1 ] = temp * cosa - _matrix[ 2 ][ 2 ] * sina;
421 _matrix[ 2 ][ 2 ] = temp * sina + _matrix[ 2 ][ 2 ] * cosa;
422 temp = _matrix[ 3 ][ 1 ];
423 _matrix[ 3 ][ 1 ] = temp * cosa - _matrix[ 3 ][ 2 ] * sina;
424 _matrix[ 3 ][ 2 ] = temp * sina + _matrix[ 3 ][ 2 ] * cosa;
438 temp = _matrix[ 0 ][ 0 ];
439 _matrix[ 0 ][ 0 ] = temp * cosa + _matrix[ 0 ][ 2 ] * sina;
440 _matrix[ 0 ][ 2 ] = _matrix[ 0 ][ 2 ] * cosa - temp * sina;
441 temp = _matrix[ 1 ][ 0 ];
442 _matrix[ 1 ][ 0 ] = temp * cosa + _matrix[ 1 ][ 2 ] * sina;
443 _matrix[ 1 ][ 2 ] = _matrix[ 1 ][ 2 ] * cosa - temp * sina;
444 temp = _matrix[ 2 ][ 0 ];
445 _matrix[ 2 ][ 0 ] = temp * cosa + _matrix[ 2 ][ 2 ] * sina;
446 _matrix[ 2 ][ 2 ] = _matrix[ 2 ][ 2 ] * cosa - temp * sina;
447 temp = _matrix[ 3 ][ 0 ];
448 _matrix[ 3 ][ 0 ] = temp * cosa + _matrix[ 3 ][ 2 ] * sina;
449 _matrix[ 3 ][ 2 ] = _matrix[ 3 ][ 2 ] * cosa - temp * sina;
463 temp = _matrix[ 0 ][ 0 ];
464 _matrix[ 0 ][ 0 ] = temp * cosa - _matrix[ 0 ][ 1 ] * sina;
465 _matrix[ 0 ][ 1 ] = temp * sina + _matrix[ 0 ][ 1 ] * cosa;
466 temp = _matrix[ 1 ][ 0 ];
467 _matrix[ 1 ][ 0 ] = temp * cosa - _matrix[ 1 ][ 1 ] * sina;
468 _matrix[ 1 ][ 1 ] = temp * sina + _matrix[ 1 ][ 1 ] * cosa;
469 temp = _matrix[ 2 ][ 0 ];
470 _matrix[ 2 ][ 0 ] = temp * cosa - _matrix[ 2 ][ 1 ] * sina;
471 _matrix[ 2 ][ 1 ] = temp * sina + _matrix[ 2 ][ 1 ] * cosa;
472 temp = _matrix[ 3 ][ 0 ];
473 _matrix[ 3 ][ 0 ] = temp * cosa - _matrix[ 3 ][ 1 ] * sina;
474 _matrix[ 3 ][ 1 ] = temp * sina + _matrix[ 3 ][ 1 ] * cosa;
483 const Vector& centerOfRotation,
492 const double a(
double( angle ) *
DEG_TO_RAD );
493 const Type sina( (Type)sin( a ) );
494 const Type cosa( (Type)cos( a ) );
512 const Type T11( cosa ), T12( -sina ), T21( sina ), T22( cosa ),
514 T13( centerOfRotation.
y - ( cosa * centerOfRotation.
y - sina * centerOfRotation.
z ) ),
515 T23( centerOfRotation.
z - ( sina * centerOfRotation.
y + cosa * centerOfRotation.
z ) );
519 temp = _matrix[ 0 ][ 1 ];
520 _matrix[ 0 ][ 1 ] = temp * T11 + _matrix[ 0 ][ 2 ] * T12 + _matrix[ 0 ][ 3 ] * T13;
521 _matrix[ 0 ][ 2 ] = temp * T21 + _matrix[ 0 ][ 2 ] * T22 + _matrix[ 0 ][ 3 ] * T23;
522 temp = _matrix[ 1 ][ 1 ];
523 _matrix[ 1 ][ 1 ] = temp * T11 + _matrix[ 1 ][ 2 ] * T12 + _matrix[ 1 ][ 3 ] * T13;
524 _matrix[ 1 ][ 2 ] = temp * T21 + _matrix[ 1 ][ 2 ] * T22 + _matrix[ 1 ][ 3 ] * T23;
525 temp = _matrix[ 2 ][ 1 ];
526 _matrix[ 2 ][ 1 ] = temp * T11 + _matrix[ 2 ][ 2 ] * T12 + _matrix[ 2 ][ 3 ] * T13;
527 _matrix[ 2 ][ 2 ] = temp * T21 + _matrix[ 2 ][ 2 ] * T22 + _matrix[ 2 ][ 3 ] * T23;
528 temp = _matrix[ 3 ][ 1 ];
529 _matrix[ 3 ][ 1 ] = temp * T11 + _matrix[ 3 ][ 2 ] * T12 + _matrix[ 3 ][ 3 ] * T13;
530 _matrix[ 3 ][ 2 ] = temp * T21 + _matrix[ 3 ][ 2 ] * T22 + _matrix[ 3 ][ 3 ] * T23;
546 const Type T00( cosa ), T02( sina ), T20( -sina ), T22( cosa ),
547 T03( centerOfRotation.
x - ( sina * centerOfRotation.
z + cosa * centerOfRotation.
x ) ),
549 T23( centerOfRotation.
z - ( cosa * centerOfRotation.
z - sina * centerOfRotation.
x ) );
553 temp = _matrix[ 0 ][ 0 ];
554 _matrix[ 0 ][ 0 ] = temp * T00 + _matrix[ 0 ][ 2 ] * T02 + _matrix[ 0 ][ 3 ] * T03;
555 _matrix[ 0 ][ 2 ] = temp * T20 + _matrix[ 0 ][ 2 ] * T22 + _matrix[ 0 ][ 3 ] * T23;
556 temp = _matrix[ 1 ][ 0 ];
557 _matrix[ 1 ][ 0 ] = temp * T00 + _matrix[ 1 ][ 2 ] * T02 + _matrix[ 1 ][ 3 ] * T03;
558 _matrix[ 1 ][ 2 ] = temp * T20 + _matrix[ 1 ][ 2 ] * T22 + _matrix[ 1 ][ 3 ] * T23;
559 temp = _matrix[ 2 ][ 0 ];
560 _matrix[ 2 ][ 0 ] = temp * T00 + _matrix[ 2 ][ 2 ] * T02 + _matrix[ 2 ][ 3 ] * T03;
561 _matrix[ 2 ][ 2 ] = temp * T20 + _matrix[ 2 ][ 2 ] * T22 + _matrix[ 2 ][ 3 ] * T23;
562 temp = _matrix[ 3 ][ 0 ];
563 _matrix[ 3 ][ 0 ] = temp * T00 + _matrix[ 3 ][ 2 ] * T02 + _matrix[ 3 ][ 3 ] * T03;
564 _matrix[ 3 ][ 2 ] = temp * T20 + _matrix[ 3 ][ 2 ] * T22 + _matrix[ 3 ][ 3 ] * T23;
580 const Type T00( cosa ), T01( -sina ), T10( sina ), T11( cosa ),
581 T03( centerOfRotation.
x - ( cosa * centerOfRotation.
x - sina * centerOfRotation.
y ) ),
582 T13( centerOfRotation.
y - ( sina * centerOfRotation.
x + cosa * centerOfRotation.
y ) );
587 temp = _matrix[ 0 ][ 0 ];
588 _matrix[ 0 ][ 0 ] = temp * T00 + _matrix[ 0 ][ 1 ] * T01 + _matrix[ 0 ][ 3 ] * T03;
589 _matrix[ 0 ][ 1 ] = temp * T10 + _matrix[ 0 ][ 1 ] * T11 + _matrix[ 0 ][ 3 ] * T13;
590 temp = _matrix[ 1 ][ 0 ];
591 _matrix[ 1 ][ 0 ] = temp * T00 + _matrix[ 1 ][ 1 ] * T01 + _matrix[ 1 ][ 3 ] * T03;
592 _matrix[ 1 ][ 1 ] = temp * T10 + _matrix[ 1 ][ 1 ] * T11 + _matrix[ 1 ][ 3 ] * T13;
593 temp = _matrix[ 2 ][ 0 ];
594 _matrix[ 2 ][ 0 ] = temp * T00 + _matrix[ 2 ][ 1 ] * T01 + _matrix[ 2 ][ 3 ] * T03;
595 _matrix[ 2 ][ 1 ] = temp * T10 + _matrix[ 2 ][ 1 ] * T11 + _matrix[ 2 ][ 3 ] * T13;
596 temp = _matrix[ 3 ][ 0 ];
597 _matrix[ 3 ][ 0 ] = temp * T00 + _matrix[ 3 ][ 1 ] * T01 + _matrix[ 3 ][ 3 ] * T03;
598 _matrix[ 3 ][ 1 ] = temp * T10 + _matrix[ 3 ][ 1 ] * T11 + _matrix[ 3 ][ 3 ] * T13;
607 const Vector& centerOfRotation,
644 const Type xx( Type( u.
x * u.
x ) );
645 const Type yy( Type( u.
y * u.
y ) );
646 const Type zz( Type( u.
z * u.
z ) );
647 const Type xy( Type( u.
x * u.
y ) );
648 const Type xz( Type( u.
x * u.
z ) );
649 const Type yz( Type( u.
y * u.
z ) );
653 const double a(
double( angle ) *
DEG_TO_RAD );
654 const Type sina( (Type)sin( a ) );
655 const Type cosa( (Type)cos( a ) );
665 R( 0, 0 ) = xx + ( 1 - xx ) * cosa;
666 R( 1, 0 ) = xy - xy * cosa + u.
z * sina;
667 R( 2, 0 ) = xz - xz * cosa - u.
y * sina;
669 R( 0, 1 ) = xy - xy * cosa - u.
z * sina;
670 R( 1, 1 ) = yy + ( 1 - yy ) * cosa;
671 R( 2, 1 ) = yz - yz * cosa + u.
x * sina;
673 R( 0, 2 ) = xz - xz * cosa + u.
y * sina;
674 R( 1, 2 ) = yz - yz * cosa - u.
x * sina;
675 R( 2, 2 ) = zz + ( 1 - zz ) * cosa;
680 this->Translate( -centerOfRotation.
x, -centerOfRotation.
y, -centerOfRotation.
z );
682 this->Translate( centerOfRotation.
x, centerOfRotation.
y, centerOfRotation.
z );
697 _matrix[ 0 ][ 0 ] = _matrix[ 0 ][ 0 ] * x;
698 _matrix[ 0 ][ 1 ] = _matrix[ 0 ][ 1 ] * y;
699 _matrix[ 0 ][ 2 ] = _matrix[ 0 ][ 2 ] * z;
702 _matrix[ 1 ][ 0 ] = _matrix[ 1 ][ 0 ] * x;
703 _matrix[ 1 ][ 1 ] = _matrix[ 1 ][ 1 ] * y;
704 _matrix[ 1 ][ 2 ] = _matrix[ 1 ][ 2 ] * z;
707 _matrix[ 2 ][ 0 ] = _matrix[ 2 ][ 0 ] * x;
708 _matrix[ 2 ][ 1 ] = _matrix[ 2 ][ 1 ] * y;
709 _matrix[ 2 ][ 2 ] = _matrix[ 2 ][ 2 ] * z;
712 _matrix[ 3 ][ 0 ] = _matrix[ 3 ][ 0 ] * x;
713 _matrix[ 3 ][ 1 ] = _matrix[ 3 ][ 1 ] * y;
714 _matrix[ 3 ][ 2 ] = _matrix[ 3 ][ 2 ] * z;
734 const Type T03 = anchor.
x * ( 1 - x );
735 const Type T13 = anchor.
y * ( 1 - y );
736 const Type T23 = anchor.
z * ( 1 - z );
741 _matrix[ 0 ][ 0 ] = _matrix[ 0 ][ 0 ] * T00 + _matrix[ 0 ][ 3 ] * T03;
742 _matrix[ 0 ][ 1 ] = _matrix[ 0 ][ 1 ] * T11 + _matrix[ 0 ][ 3 ] * T13;
743 _matrix[ 0 ][ 2 ] = _matrix[ 0 ][ 2 ] * T22 + _matrix[ 0 ][ 3 ] * T23;
746 _matrix[ 1 ][ 0 ] = _matrix[ 1 ][ 0 ] * T00 + _matrix[ 1 ][ 3 ] * T03;
747 _matrix[ 1 ][ 1 ] = _matrix[ 1 ][ 1 ] * T11 + _matrix[ 1 ][ 3 ] * T13;
748 _matrix[ 1 ][ 2 ] = _matrix[ 1 ][ 2 ] * T22 + _matrix[ 1 ][ 3 ] * T23;
751 _matrix[ 2 ][ 0 ] = _matrix[ 2 ][ 0 ] * T00 + _matrix[ 2 ][ 3 ] * T03;
752 _matrix[ 2 ][ 1 ] = _matrix[ 2 ][ 1 ] * T11 + _matrix[ 2 ][ 3 ] * T13;
753 _matrix[ 2 ][ 2 ] = _matrix[ 2 ][ 2 ] * T22 + _matrix[ 2 ][ 3 ] * T23;
756 _matrix[ 3 ][ 0 ] = _matrix[ 3 ][ 0 ] * T00 + _matrix[ 3 ][ 3 ] * T03;
757 _matrix[ 3 ][ 1 ] = _matrix[ 3 ][ 1 ] * T11 + _matrix[ 3 ][ 3 ] * T13;
758 _matrix[ 3 ][ 2 ] = _matrix[ 3 ][ 2 ] * T22 + _matrix[ 3 ][ 3 ] * T23;
763#ifdef MATRIX_TYPE_FLOAT
770#ifdef MATRIX_TYPE_FLOAT
777#ifdef MATRIX_TYPE_FLOAT
778# define GLS_glLoadMatrix_TYPE glLoadMatrixf
780# define GLS_glLoadMatrix_TYPE glLoadMatrixd
784#ifdef MATRIX_TYPE_FLOAT
785# define GLS_glMultMatrix_TYPE glMultMatrixf
787# define GLS_glMultMatrix_TYPE glMultMatrixd
unsigned char G() const
Definition: gls_color.h:217
unsigned char R() const
Definition: gls_color.h:214
unsigned char B() const
Definition: gls_color.h:220
unsigned char A() const
Definition: gls_color.h:223
Definition: gls_matrix_affine.h:60
void Rotate(Type angle, RotationAxis axis)
Definition: gls_matrix_affine.h:391
void Scale(Type x, Type y, Type z)
Definition: gls_matrix_affine.h:687
void Rotate(Type angle, const Vector ¢erOfRotation, RotationAxis axis)
Definition: gls_matrix_affine.h:482
void Scale(Type x, Type y, Type z, const Vector &anchor)
Definition: gls_matrix_affine.h:721
GlsMatrixAffine()
Definition: gls_matrix_affine.h:362
void Rotate(Type angle, const Vector ¢erOfRotation, const Vector &axis)
Definition: gls_matrix_affine.h:606
void Translate(const Vector &v)
Definition: gls_matrix_affine.h:239
Vertex operator*(const Vertex &v) const
Definition: gls_matrix_affine.h:257
Vector operator*(const Vector &v) const
Definition: gls_matrix_affine.h:246
void Transform(Vector &v) const
Definition: gls_matrix_affine.h:272
~GlsMatrixAffine()
Definition: gls_matrix_affine.h:385
void Translate(Type x, Type y, Type z)
Definition: gls_matrix_affine.h:204
bool IsVeryClose(const GlsMatrix< Type, 4 > &b) const
Definition: gls_matrix_affine.h:116
Definition: gls_matrix.h:61
Type * Data()
Definition: gls_matrix.h:127
static const double PRECISION
Definition: gls_matrix.h:367
Type * _matrix[DIM]
Definition: gls_matrix.h:388
Type _data[DIM *DIM]
Definition: gls_matrix.h:376
Definition: gls_quaternion.h:55
float MagnitudeSquared() const
Definition: vertex.h:337
float y
The Y component.
Definition: vertex.h:87
float x
The X component.
Definition: vertex.h:86
float Magnitude() const
Definition: vertex.h:329
void Normalize()
Definition: vertex.h:310
float z
The Z component.
Definition: vertex.h:88
GlsColor color
The RGBA color component.
Definition: vertex.h:421
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
The disti::GlsQuaternion class.
Definition: bmpimage.h:46
GlsMatrix< Type, 4 > DecomposeRotationMatrix(const GlsMatrix< Type, 4 > &matrix, const Vector &scale)
Definition: gls_matrix_affine.h:307
GlsMatrixAffine< double > GlsMatrixAffineD
Typedef for a matrix of doubles.
Definition: gls_matrix_affine.h:352
Vector DecomposeScale(const GlsMatrix< Type, 4 > &m)
Definition: gls_matrix_affine.h:292
RotationAxis
Definition: vertex.h:73
@ Z_AXIS
Definition: vertex.h:76
@ X_AXIS
Definition: vertex.h:74
@ Y_AXIS
Definition: vertex.h:75
const double DEG_TO_RAD
Definition: vertex.h:60
VertexNoColor Vector
Definition: gls_font_base.h:68
void DecomposeMatrix(const GlsMatrix< Type, 4 > &matrix, Vector &scale, Vector &location, GlsQuaternion< Type > &rotation)
Definition: gls_matrix_affine.h:341
GlsMatrixAffine< float > GlsMatrixAffineF
Typedef for a matrix of floats.
Definition: gls_matrix_affine.h:351
GlsMatrixAffineD GlsMatrixType
Typedef for a generic (float or double elements) matrix.
Definition: gls_matrix_affine.h:773
double GlsMatrixElementType
Typedef for a generic (float or double) matrix element.
Definition: gls_matrix_affine.h:766
The disti::Vertex class. A class for manipulating 3D vertices.