Qt 4.8
Classes | Functions
qmatrix4x4.h File Reference
#include <QtGui/qvector3d.h>
#include <QtGui/qvector4d.h>
#include <QtGui/qquaternion.h>
#include <QtGui/qgenericmatrix.h>
#include <QtCore/qrect.h>

Go to the source code of this file.

Classes

class  QMatrix4x4
 The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space. More...
 

Functions

QMatrix4x4 operator* (const QMatrix4x4 &m1, const QMatrix4x4 &m2)
 
QVector3D operator* (const QVector3D &vector, const QMatrix4x4 &matrix)
 
QVector3D operator* (const QMatrix4x4 &matrix, const QVector3D &vector)
 
QVector4D operator* (const QVector4D &vector, const QMatrix4x4 &matrix)
 
QVector4D operator* (const QMatrix4x4 &matrix, const QVector4D &vector)
 
QPoint operator* (const QPoint &point, const QMatrix4x4 &matrix)
 
QPointF operator* (const QPointF &point, const QMatrix4x4 &matrix)
 
QPoint operator* (const QMatrix4x4 &matrix, const QPoint &point)
 
QPointF operator* (const QMatrix4x4 &matrix, const QPointF &point)
 
QMatrix4x4 operator* (qreal factor, const QMatrix4x4 &matrix)
 
QMatrix4x4 operator* (const QMatrix4x4 &matrix, qreal factor)
 
QMatrix4x4 operator+ (const QMatrix4x4 &m1, const QMatrix4x4 &m2)
 
QMatrix4x4 operator- (const QMatrix4x4 &m1, const QMatrix4x4 &m2)
 
QMatrix4x4 operator- (const QMatrix4x4 &matrix)
 
Q_GUI_EXPORT QMatrix4x4 operator/ (const QMatrix4x4 &matrix, qreal divisor)
 
Q_GUI_EXPORT QDebug operator<< (QDebug dbg, const QMatrix4x4 &m)
 
Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QMatrix4x4 &)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QMatrix4x4 &)
 
 Q_DECLARE_TYPEINFO (QMatrix4x4, Q_MOVABLE_TYPE)
 
bool qFuzzyCompare (const QMatrix4x4 &m1, const QMatrix4x4 &m2)
 
template<int N, int M>
QT_DEPRECATED QGenericMatrix< N, M, qrealqGenericMatrixFromMatrix4x4 (const QMatrix4x4 &matrix)
 
template<int N, int M>
QT_DEPRECATED QMatrix4x4 qGenericMatrixToMatrix4x4 (const QGenericMatrix< N, M, qreal > &matrix)
 

Function Documentation

◆ operator*() [1/11]

QMatrix4x4 operator* ( const QMatrix4x4 m1,
const QMatrix4x4 m2 
)
inline

Definition at line 529 of file qmatrix4x4.h.

Referenced by QMatrix4x4::QMatrix4x4().

530 {
531  if (m1.flagBits == QMatrix4x4::Identity)
532  return m2;
533  else if (m2.flagBits == QMatrix4x4::Identity)
534  return m1;
535 
536  QMatrix4x4 m(1);
537  m.m[0][0] = m1.m[0][0] * m2.m[0][0] +
538  m1.m[1][0] * m2.m[0][1] +
539  m1.m[2][0] * m2.m[0][2] +
540  m1.m[3][0] * m2.m[0][3];
541  m.m[0][1] = m1.m[0][1] * m2.m[0][0] +
542  m1.m[1][1] * m2.m[0][1] +
543  m1.m[2][1] * m2.m[0][2] +
544  m1.m[3][1] * m2.m[0][3];
545  m.m[0][2] = m1.m[0][2] * m2.m[0][0] +
546  m1.m[1][2] * m2.m[0][1] +
547  m1.m[2][2] * m2.m[0][2] +
548  m1.m[3][2] * m2.m[0][3];
549  m.m[0][3] = m1.m[0][3] * m2.m[0][0] +
550  m1.m[1][3] * m2.m[0][1] +
551  m1.m[2][3] * m2.m[0][2] +
552  m1.m[3][3] * m2.m[0][3];
553  m.m[1][0] = m1.m[0][0] * m2.m[1][0] +
554  m1.m[1][0] * m2.m[1][1] +
555  m1.m[2][0] * m2.m[1][2] +
556  m1.m[3][0] * m2.m[1][3];
557  m.m[1][1] = m1.m[0][1] * m2.m[1][0] +
558  m1.m[1][1] * m2.m[1][1] +
559  m1.m[2][1] * m2.m[1][2] +
560  m1.m[3][1] * m2.m[1][3];
561  m.m[1][2] = m1.m[0][2] * m2.m[1][0] +
562  m1.m[1][2] * m2.m[1][1] +
563  m1.m[2][2] * m2.m[1][2] +
564  m1.m[3][2] * m2.m[1][3];
565  m.m[1][3] = m1.m[0][3] * m2.m[1][0] +
566  m1.m[1][3] * m2.m[1][1] +
567  m1.m[2][3] * m2.m[1][2] +
568  m1.m[3][3] * m2.m[1][3];
569  m.m[2][0] = m1.m[0][0] * m2.m[2][0] +
570  m1.m[1][0] * m2.m[2][1] +
571  m1.m[2][0] * m2.m[2][2] +
572  m1.m[3][0] * m2.m[2][3];
573  m.m[2][1] = m1.m[0][1] * m2.m[2][0] +
574  m1.m[1][1] * m2.m[2][1] +
575  m1.m[2][1] * m2.m[2][2] +
576  m1.m[3][1] * m2.m[2][3];
577  m.m[2][2] = m1.m[0][2] * m2.m[2][0] +
578  m1.m[1][2] * m2.m[2][1] +
579  m1.m[2][2] * m2.m[2][2] +
580  m1.m[3][2] * m2.m[2][3];
581  m.m[2][3] = m1.m[0][3] * m2.m[2][0] +
582  m1.m[1][3] * m2.m[2][1] +
583  m1.m[2][3] * m2.m[2][2] +
584  m1.m[3][3] * m2.m[2][3];
585  m.m[3][0] = m1.m[0][0] * m2.m[3][0] +
586  m1.m[1][0] * m2.m[3][1] +
587  m1.m[2][0] * m2.m[3][2] +
588  m1.m[3][0] * m2.m[3][3];
589  m.m[3][1] = m1.m[0][1] * m2.m[3][0] +
590  m1.m[1][1] * m2.m[3][1] +
591  m1.m[2][1] * m2.m[3][2] +
592  m1.m[3][1] * m2.m[3][3];
593  m.m[3][2] = m1.m[0][2] * m2.m[3][0] +
594  m1.m[1][2] * m2.m[3][1] +
595  m1.m[2][2] * m2.m[3][2] +
596  m1.m[3][2] * m2.m[3][3];
597  m.m[3][3] = m1.m[0][3] * m2.m[3][0] +
598  m1.m[1][3] * m2.m[3][1] +
599  m1.m[2][3] * m2.m[3][2] +
600  m1.m[3][3] * m2.m[3][3];
601  return m;
602 }
int flagBits
Definition: qmatrix4x4.h:189
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
qreal m[4][4]
Definition: qmatrix4x4.h:188

◆ operator*() [2/11]

QVector3D operator* ( const QVector3D vector,
const QMatrix4x4 matrix 
)
inline

Definition at line 606 of file qmatrix4x4.h.

607 {
608  qreal x, y, z, w;
609  x = vector.x() * matrix.m[0][0] +
610  vector.y() * matrix.m[0][1] +
611  vector.z() * matrix.m[0][2] +
612  matrix.m[0][3];
613  y = vector.x() * matrix.m[1][0] +
614  vector.y() * matrix.m[1][1] +
615  vector.z() * matrix.m[1][2] +
616  matrix.m[1][3];
617  z = vector.x() * matrix.m[2][0] +
618  vector.y() * matrix.m[2][1] +
619  vector.z() * matrix.m[2][2] +
620  matrix.m[2][3];
621  w = vector.x() * matrix.m[3][0] +
622  vector.y() * matrix.m[3][1] +
623  vector.z() * matrix.m[3][2] +
624  matrix.m[3][3];
625  if (w == 1.0f)
626  return QVector3D(x, y, z);
627  else
628  return QVector3D(x / w, y / w, z / w);
629 }
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
double qreal
Definition: qglobal.h:1193
qreal x() const
Returns the x coordinate of this point.
Definition: qvector3d.h:161
qreal z() const
Returns the z coordinate of this point.
Definition: qvector3d.h:163
qreal m[4][4]
Definition: qmatrix4x4.h:188
qreal y() const
Returns the y coordinate of this point.
Definition: qvector3d.h:162

◆ operator*() [3/11]

QVector3D operator* ( const QMatrix4x4 matrix,
const QVector3D vector 
)
inline

Definition at line 631 of file qmatrix4x4.h.

632 {
633  qreal x, y, z, w;
634  if (matrix.flagBits == QMatrix4x4::Identity) {
635  return vector;
636  } else if (matrix.flagBits == QMatrix4x4::Translation) {
637  return QVector3D(vector.x() + matrix.m[3][0],
638  vector.y() + matrix.m[3][1],
639  vector.z() + matrix.m[3][2]);
640  } else if (matrix.flagBits ==
642  return QVector3D(vector.x() * matrix.m[0][0] + matrix.m[3][0],
643  vector.y() * matrix.m[1][1] + matrix.m[3][1],
644  vector.z() * matrix.m[2][2] + matrix.m[3][2]);
645  } else if (matrix.flagBits == QMatrix4x4::Scale) {
646  return QVector3D(vector.x() * matrix.m[0][0],
647  vector.y() * matrix.m[1][1],
648  vector.z() * matrix.m[2][2]);
649  } else {
650  x = vector.x() * matrix.m[0][0] +
651  vector.y() * matrix.m[1][0] +
652  vector.z() * matrix.m[2][0] +
653  matrix.m[3][0];
654  y = vector.x() * matrix.m[0][1] +
655  vector.y() * matrix.m[1][1] +
656  vector.z() * matrix.m[2][1] +
657  matrix.m[3][1];
658  z = vector.x() * matrix.m[0][2] +
659  vector.y() * matrix.m[1][2] +
660  vector.z() * matrix.m[2][2] +
661  matrix.m[3][2];
662  w = vector.x() * matrix.m[0][3] +
663  vector.y() * matrix.m[1][3] +
664  vector.z() * matrix.m[2][3] +
665  matrix.m[3][3];
666  if (w == 1.0f)
667  return QVector3D(x, y, z);
668  else
669  return QVector3D(x / w, y / w, z / w);
670  }
671 }
int flagBits
Definition: qmatrix4x4.h:189
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
double qreal
Definition: qglobal.h:1193
qreal x() const
Returns the x coordinate of this point.
Definition: qvector3d.h:161
qreal z() const
Returns the z coordinate of this point.
Definition: qvector3d.h:163
qreal m[4][4]
Definition: qmatrix4x4.h:188
qreal y() const
Returns the y coordinate of this point.
Definition: qvector3d.h:162

◆ operator*() [4/11]

QVector4D operator* ( const QVector4D vector,
const QMatrix4x4 matrix 
)
inline

Definition at line 677 of file qmatrix4x4.h.

678 {
679  qreal x, y, z, w;
680  x = vector.x() * matrix.m[0][0] +
681  vector.y() * matrix.m[0][1] +
682  vector.z() * matrix.m[0][2] +
683  vector.w() * matrix.m[0][3];
684  y = vector.x() * matrix.m[1][0] +
685  vector.y() * matrix.m[1][1] +
686  vector.z() * matrix.m[1][2] +
687  vector.w() * matrix.m[1][3];
688  z = vector.x() * matrix.m[2][0] +
689  vector.y() * matrix.m[2][1] +
690  vector.z() * matrix.m[2][2] +
691  vector.w() * matrix.m[2][3];
692  w = vector.x() * matrix.m[3][0] +
693  vector.y() * matrix.m[3][1] +
694  vector.z() * matrix.m[3][2] +
695  vector.w() * matrix.m[3][3];
696  return QVector4D(x, y, z, w);
697 }
double qreal
Definition: qglobal.h:1193
qreal w() const
Returns the w coordinate of this point.
Definition: qvector4d.h:161
The QVector4D class represents a vector or vertex in 4D space.
Definition: qvector4d.h:60
qreal x() const
Returns the x coordinate of this point.
Definition: qvector4d.h:158
qreal m[4][4]
Definition: qmatrix4x4.h:188
qreal z() const
Returns the z coordinate of this point.
Definition: qvector4d.h:160
qreal y() const
Returns the y coordinate of this point.
Definition: qvector4d.h:159

◆ operator*() [5/11]

QVector4D operator* ( const QMatrix4x4 matrix,
const QVector4D vector 
)
inline

Definition at line 699 of file qmatrix4x4.h.

700 {
701  qreal x, y, z, w;
702  x = vector.x() * matrix.m[0][0] +
703  vector.y() * matrix.m[1][0] +
704  vector.z() * matrix.m[2][0] +
705  vector.w() * matrix.m[3][0];
706  y = vector.x() * matrix.m[0][1] +
707  vector.y() * matrix.m[1][1] +
708  vector.z() * matrix.m[2][1] +
709  vector.w() * matrix.m[3][1];
710  z = vector.x() * matrix.m[0][2] +
711  vector.y() * matrix.m[1][2] +
712  vector.z() * matrix.m[2][2] +
713  vector.w() * matrix.m[3][2];
714  w = vector.x() * matrix.m[0][3] +
715  vector.y() * matrix.m[1][3] +
716  vector.z() * matrix.m[2][3] +
717  vector.w() * matrix.m[3][3];
718  return QVector4D(x, y, z, w);
719 }
double qreal
Definition: qglobal.h:1193
qreal w() const
Returns the w coordinate of this point.
Definition: qvector4d.h:161
The QVector4D class represents a vector or vertex in 4D space.
Definition: qvector4d.h:60
qreal x() const
Returns the x coordinate of this point.
Definition: qvector4d.h:158
qreal m[4][4]
Definition: qmatrix4x4.h:188
qreal z() const
Returns the z coordinate of this point.
Definition: qvector4d.h:160
qreal y() const
Returns the y coordinate of this point.
Definition: qvector4d.h:159

◆ operator*() [6/11]

QPoint operator* ( const QPoint point,
const QMatrix4x4 matrix 
)
inline

Definition at line 723 of file qmatrix4x4.h.

724 {
725  qreal xin, yin;
726  qreal x, y, w;
727  xin = point.x();
728  yin = point.y();
729  x = xin * matrix.m[0][0] +
730  yin * matrix.m[0][1] +
731  matrix.m[0][3];
732  y = xin * matrix.m[1][0] +
733  yin * matrix.m[1][1] +
734  matrix.m[1][3];
735  w = xin * matrix.m[3][0] +
736  yin * matrix.m[3][1] +
737  matrix.m[3][3];
738  if (w == 1.0f)
739  return QPoint(qRound(x), qRound(y));
740  else
741  return QPoint(qRound(x / w), qRound(y / w));
742 }
double qreal
Definition: qglobal.h:1193
qreal m[4][4]
Definition: qmatrix4x4.h:188
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ operator*() [7/11]

QPointF operator* ( const QPointF point,
const QMatrix4x4 matrix 
)
inline

Definition at line 744 of file qmatrix4x4.h.

745 {
746  qreal xin, yin;
747  qreal x, y, w;
748  xin = point.x();
749  yin = point.y();
750  x = xin * matrix.m[0][0] +
751  yin * matrix.m[0][1] +
752  matrix.m[0][3];
753  y = xin * matrix.m[1][0] +
754  yin * matrix.m[1][1] +
755  matrix.m[1][3];
756  w = xin * matrix.m[3][0] +
757  yin * matrix.m[3][1] +
758  matrix.m[3][3];
759  if (w == 1.0f) {
760  return QPointF(qreal(x), qreal(y));
761  } else {
762  return QPointF(qreal(x / w), qreal(y / w));
763  }
764 }
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal m[4][4]
Definition: qmatrix4x4.h:188
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ operator*() [8/11]

QPoint operator* ( const QMatrix4x4 matrix,
const QPoint point 
)
inline

Definition at line 766 of file qmatrix4x4.h.

767 {
768  qreal xin, yin;
769  qreal x, y, w;
770  xin = point.x();
771  yin = point.y();
772  if (matrix.flagBits == QMatrix4x4::Identity) {
773  return point;
774  } else if (matrix.flagBits == QMatrix4x4::Translation) {
775  return QPoint(qRound(xin + matrix.m[3][0]),
776  qRound(yin + matrix.m[3][1]));
777  } else if (matrix.flagBits ==
779  return QPoint(qRound(xin * matrix.m[0][0] + matrix.m[3][0]),
780  qRound(yin * matrix.m[1][1] + matrix.m[3][1]));
781  } else if (matrix.flagBits == QMatrix4x4::Scale) {
782  return QPoint(qRound(xin * matrix.m[0][0]),
783  qRound(yin * matrix.m[1][1]));
784  } else {
785  x = xin * matrix.m[0][0] +
786  yin * matrix.m[1][0] +
787  matrix.m[3][0];
788  y = xin * matrix.m[0][1] +
789  yin * matrix.m[1][1] +
790  matrix.m[3][1];
791  w = xin * matrix.m[0][3] +
792  yin * matrix.m[1][3] +
793  matrix.m[3][3];
794  if (w == 1.0f)
795  return QPoint(qRound(x), qRound(y));
796  else
797  return QPoint(qRound(x / w), qRound(y / w));
798  }
799 }
int flagBits
Definition: qmatrix4x4.h:189
double qreal
Definition: qglobal.h:1193
qreal m[4][4]
Definition: qmatrix4x4.h:188
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ operator*() [9/11]

QPointF operator* ( const QMatrix4x4 matrix,
const QPointF point 
)
inline

Definition at line 801 of file qmatrix4x4.h.

802 {
803  qreal xin, yin;
804  qreal x, y, w;
805  xin = point.x();
806  yin = point.y();
807  if (matrix.flagBits == QMatrix4x4::Identity) {
808  return point;
809  } else if (matrix.flagBits == QMatrix4x4::Translation) {
810  return QPointF(xin + matrix.m[3][0],
811  yin + matrix.m[3][1]);
812  } else if (matrix.flagBits ==
814  return QPointF(xin * matrix.m[0][0] + matrix.m[3][0],
815  yin * matrix.m[1][1] + matrix.m[3][1]);
816  } else if (matrix.flagBits == QMatrix4x4::Scale) {
817  return QPointF(xin * matrix.m[0][0],
818  yin * matrix.m[1][1]);
819  } else {
820  x = xin * matrix.m[0][0] +
821  yin * matrix.m[1][0] +
822  matrix.m[3][0];
823  y = xin * matrix.m[0][1] +
824  yin * matrix.m[1][1] +
825  matrix.m[3][1];
826  w = xin * matrix.m[0][3] +
827  yin * matrix.m[1][3] +
828  matrix.m[3][3];
829  if (w == 1.0f) {
830  return QPointF(qreal(x), qreal(y));
831  } else {
832  return QPointF(qreal(x / w), qreal(y / w));
833  }
834  }
835 }
int flagBits
Definition: qmatrix4x4.h:189
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal m[4][4]
Definition: qmatrix4x4.h:188
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ operator*() [10/11]

QMatrix4x4 operator* ( qreal  factor,
const QMatrix4x4 matrix 
)
inline

Definition at line 859 of file qmatrix4x4.h.

860 {
861  QMatrix4x4 m(1);
862  m.m[0][0] = matrix.m[0][0] * factor;
863  m.m[0][1] = matrix.m[0][1] * factor;
864  m.m[0][2] = matrix.m[0][2] * factor;
865  m.m[0][3] = matrix.m[0][3] * factor;
866  m.m[1][0] = matrix.m[1][0] * factor;
867  m.m[1][1] = matrix.m[1][1] * factor;
868  m.m[1][2] = matrix.m[1][2] * factor;
869  m.m[1][3] = matrix.m[1][3] * factor;
870  m.m[2][0] = matrix.m[2][0] * factor;
871  m.m[2][1] = matrix.m[2][1] * factor;
872  m.m[2][2] = matrix.m[2][2] * factor;
873  m.m[2][3] = matrix.m[2][3] * factor;
874  m.m[3][0] = matrix.m[3][0] * factor;
875  m.m[3][1] = matrix.m[3][1] * factor;
876  m.m[3][2] = matrix.m[3][2] * factor;
877  m.m[3][3] = matrix.m[3][3] * factor;
878  return m;
879 }
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
qreal m[4][4]
Definition: qmatrix4x4.h:188

◆ operator*() [11/11]

QMatrix4x4 operator* ( const QMatrix4x4 matrix,
qreal  factor 
)
inline

Definition at line 881 of file qmatrix4x4.h.

882 {
883  QMatrix4x4 m(1);
884  m.m[0][0] = matrix.m[0][0] * factor;
885  m.m[0][1] = matrix.m[0][1] * factor;
886  m.m[0][2] = matrix.m[0][2] * factor;
887  m.m[0][3] = matrix.m[0][3] * factor;
888  m.m[1][0] = matrix.m[1][0] * factor;
889  m.m[1][1] = matrix.m[1][1] * factor;
890  m.m[1][2] = matrix.m[1][2] * factor;
891  m.m[1][3] = matrix.m[1][3] * factor;
892  m.m[2][0] = matrix.m[2][0] * factor;
893  m.m[2][1] = matrix.m[2][1] * factor;
894  m.m[2][2] = matrix.m[2][2] * factor;
895  m.m[2][3] = matrix.m[2][3] * factor;
896  m.m[3][0] = matrix.m[3][0] * factor;
897  m.m[3][1] = matrix.m[3][1] * factor;
898  m.m[3][2] = matrix.m[3][2] * factor;
899  m.m[3][3] = matrix.m[3][3] * factor;
900  return m;
901 }
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
qreal m[4][4]
Definition: qmatrix4x4.h:188

◆ operator+()

QMatrix4x4 operator+ ( const QMatrix4x4 m1,
const QMatrix4x4 m2 
)
inline

Definition at line 485 of file qmatrix4x4.h.

Referenced by QMatrix4x4::QMatrix4x4().

486 {
487  QMatrix4x4 m(1);
488  m.m[0][0] = m1.m[0][0] + m2.m[0][0];
489  m.m[0][1] = m1.m[0][1] + m2.m[0][1];
490  m.m[0][2] = m1.m[0][2] + m2.m[0][2];
491  m.m[0][3] = m1.m[0][3] + m2.m[0][3];
492  m.m[1][0] = m1.m[1][0] + m2.m[1][0];
493  m.m[1][1] = m1.m[1][1] + m2.m[1][1];
494  m.m[1][2] = m1.m[1][2] + m2.m[1][2];
495  m.m[1][3] = m1.m[1][3] + m2.m[1][3];
496  m.m[2][0] = m1.m[2][0] + m2.m[2][0];
497  m.m[2][1] = m1.m[2][1] + m2.m[2][1];
498  m.m[2][2] = m1.m[2][2] + m2.m[2][2];
499  m.m[2][3] = m1.m[2][3] + m2.m[2][3];
500  m.m[3][0] = m1.m[3][0] + m2.m[3][0];
501  m.m[3][1] = m1.m[3][1] + m2.m[3][1];
502  m.m[3][2] = m1.m[3][2] + m2.m[3][2];
503  m.m[3][3] = m1.m[3][3] + m2.m[3][3];
504  return m;
505 }
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
qreal m[4][4]
Definition: qmatrix4x4.h:188

◆ operator-() [1/2]

QMatrix4x4 operator- ( const QMatrix4x4 m1,
const QMatrix4x4 m2 
)
inline

Definition at line 507 of file qmatrix4x4.h.

Referenced by QMatrix4x4::QMatrix4x4().

508 {
509  QMatrix4x4 m(1);
510  m.m[0][0] = m1.m[0][0] - m2.m[0][0];
511  m.m[0][1] = m1.m[0][1] - m2.m[0][1];
512  m.m[0][2] = m1.m[0][2] - m2.m[0][2];
513  m.m[0][3] = m1.m[0][3] - m2.m[0][3];
514  m.m[1][0] = m1.m[1][0] - m2.m[1][0];
515  m.m[1][1] = m1.m[1][1] - m2.m[1][1];
516  m.m[1][2] = m1.m[1][2] - m2.m[1][2];
517  m.m[1][3] = m1.m[1][3] - m2.m[1][3];
518  m.m[2][0] = m1.m[2][0] - m2.m[2][0];
519  m.m[2][1] = m1.m[2][1] - m2.m[2][1];
520  m.m[2][2] = m1.m[2][2] - m2.m[2][2];
521  m.m[2][3] = m1.m[2][3] - m2.m[2][3];
522  m.m[3][0] = m1.m[3][0] - m2.m[3][0];
523  m.m[3][1] = m1.m[3][1] - m2.m[3][1];
524  m.m[3][2] = m1.m[3][2] - m2.m[3][2];
525  m.m[3][3] = m1.m[3][3] - m2.m[3][3];
526  return m;
527 }
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
qreal m[4][4]
Definition: qmatrix4x4.h:188

◆ operator-() [2/2]

QMatrix4x4 operator- ( const QMatrix4x4 matrix)
inline

Definition at line 837 of file qmatrix4x4.h.

838 {
839  QMatrix4x4 m(1);
840  m.m[0][0] = -matrix.m[0][0];
841  m.m[0][1] = -matrix.m[0][1];
842  m.m[0][2] = -matrix.m[0][2];
843  m.m[0][3] = -matrix.m[0][3];
844  m.m[1][0] = -matrix.m[1][0];
845  m.m[1][1] = -matrix.m[1][1];
846  m.m[1][2] = -matrix.m[1][2];
847  m.m[1][3] = -matrix.m[1][3];
848  m.m[2][0] = -matrix.m[2][0];
849  m.m[2][1] = -matrix.m[2][1];
850  m.m[2][2] = -matrix.m[2][2];
851  m.m[2][3] = -matrix.m[2][3];
852  m.m[3][0] = -matrix.m[3][0];
853  m.m[3][1] = -matrix.m[3][1];
854  m.m[3][2] = -matrix.m[3][2];
855  m.m[3][3] = -matrix.m[3][3];
856  return m;
857 }
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
qreal m[4][4]
Definition: qmatrix4x4.h:188

◆ operator/()

Q_GUI_EXPORT QMatrix4x4 operator/ ( const QMatrix4x4 matrix,
qreal  divisor 
)

◆ operator<<() [1/2]

Q_GUI_EXPORT QDebug operator<< ( QDebug  dbg,
const QMatrix4x4 m 
)

Definition at line 1955 of file qmatrix4x4.cpp.

Referenced by QMatrix4x4::constData(), and QMatrix4x4::data().

1956 {
1957  // Create a string that represents the matrix type.
1958  QByteArray bits;
1959  if ((m.flagBits & QMatrix4x4::Identity) != 0)
1960  bits += "Identity,";
1961  if ((m.flagBits & QMatrix4x4::General) != 0)
1962  bits += "General,";
1963  if ((m.flagBits & QMatrix4x4::Translation) != 0)
1964  bits += "Translation,";
1965  if ((m.flagBits & QMatrix4x4::Scale) != 0)
1966  bits += "Scale,";
1967  if ((m.flagBits & QMatrix4x4::Rotation) != 0)
1968  bits += "Rotation,";
1969  if (bits.size() > 0)
1970  bits = bits.left(bits.size() - 1);
1971 
1972  // Output in row-major order because it is more human-readable.
1973  dbg.nospace() << "QMatrix4x4(type:" << bits.constData() << endl
1974  << qSetFieldWidth(10)
1975  << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << endl
1976  << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << endl
1977  << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << endl
1978  << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << endl
1979  << qSetFieldWidth(0) << ')';
1980  return dbg.space();
1981 }
int flagBits
Definition: qmatrix4x4.h:189
QTextStream & endl(QTextStream &stream)
Writes &#39; &#39; to the stream and flushes the stream.
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QTextStreamManipulator qSetFieldWidth(int width)
Equivalent to QTextStream::setFieldWidth(width).
Definition: qtextstream.h:329
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91

◆ operator<<() [2/2]

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream ,
const QMatrix4x4  
)
related

Definition at line 2000 of file qmatrix4x4.cpp.

2001 {
2002  for (int row = 0; row < 4; ++row)
2003  for (int col = 0; col < 4; ++col)
2004  stream << double(matrix(row, col));
2005  return stream;
2006 }
static FILE * stream

◆ operator>>()

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream ,
QMatrix4x4  
)
related

Definition at line 2021 of file qmatrix4x4.cpp.

Referenced by QMatrix4x4::data().

2022 {
2023  double x;
2024  for (int row = 0; row < 4; ++row) {
2025  for (int col = 0; col < 4; ++col) {
2026  stream >> x;
2027  matrix(row, col) = qreal(x);
2028  }
2029  }
2030  matrix.optimize();
2031  return stream;
2032 }
double qreal
Definition: qglobal.h:1193
static FILE * stream

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( QMatrix4x4  ,
Q_MOVABLE_TYPE   
)

◆ qFuzzyCompare()

bool qFuzzyCompare ( const QMatrix4x4 m1,
const QMatrix4x4 m2 
)
inline

Definition at line 903 of file qmatrix4x4.h.

Referenced by QMatrix4x4::QMatrix4x4().

904 {
905  return qFuzzyCompare(m1.m[0][0], m2.m[0][0]) &&
906  qFuzzyCompare(m1.m[0][1], m2.m[0][1]) &&
907  qFuzzyCompare(m1.m[0][2], m2.m[0][2]) &&
908  qFuzzyCompare(m1.m[0][3], m2.m[0][3]) &&
909  qFuzzyCompare(m1.m[1][0], m2.m[1][0]) &&
910  qFuzzyCompare(m1.m[1][1], m2.m[1][1]) &&
911  qFuzzyCompare(m1.m[1][2], m2.m[1][2]) &&
912  qFuzzyCompare(m1.m[1][3], m2.m[1][3]) &&
913  qFuzzyCompare(m1.m[2][0], m2.m[2][0]) &&
914  qFuzzyCompare(m1.m[2][1], m2.m[2][1]) &&
915  qFuzzyCompare(m1.m[2][2], m2.m[2][2]) &&
916  qFuzzyCompare(m1.m[2][3], m2.m[2][3]) &&
917  qFuzzyCompare(m1.m[3][0], m2.m[3][0]) &&
918  qFuzzyCompare(m1.m[3][1], m2.m[3][1]) &&
919  qFuzzyCompare(m1.m[3][2], m2.m[3][2]) &&
920  qFuzzyCompare(m1.m[3][3], m2.m[3][3]);
921 }
qreal m[4][4]
Definition: qmatrix4x4.h:188
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
The qFuzzyCompare function is for comparing two matrices using a fuzziness factor.
Definition: qmatrix.h:172

◆ qGenericMatrixFromMatrix4x4()

template<int N, int M>
QT_DEPRECATED QGenericMatrix<N, M, qreal> qGenericMatrixFromMatrix4x4 ( const QMatrix4x4 matrix)
related

Definition at line 997 of file qmatrix4x4.h.

998 {
1000  const qreal *m = matrix.constData();
1001  qreal *values = result.data();
1002  for (int col = 0; col < N; ++col) {
1003  for (int row = 0; row < M; ++row) {
1004  if (col < 4 && row < 4)
1005  values[col * M + row] = m[col * 4 + row];
1006  else if (col == row)
1007  values[col * M + row] = 1.0f;
1008  else
1009  values[col * M + row] = 0.0f;
1010  }
1011  }
1012  return result;
1013 }
T * data()
Returns a pointer to the raw data of this matrix.
double qreal
Definition: qglobal.h:1193
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
#define M(row, col)
quint16 values[128]
const qreal * constData() const
Returns a constant pointer to the raw data of this matrix.
Definition: qmatrix4x4.h:177

◆ qGenericMatrixToMatrix4x4()

template<int N, int M>
QT_DEPRECATED QMatrix4x4 qGenericMatrixToMatrix4x4 ( const QGenericMatrix< N, M, qreal > &  matrix)
related

Definition at line 991 of file qmatrix4x4.h.

992 {
993  return QMatrix4x4(matrix.constData(), N, M);
994 }
const T * constData() const
Returns a constant pointer to the raw data of this matrix.
#define M(row, col)
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63