Qt 4.8
Functions | Variables
qmatrix4x4.cpp File Reference
#include "qmatrix4x4.h"
#include <QtCore/qmath.h>
#include <QtCore/qvariant.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qtransform.h>

Go to the source code of this file.

Functions

static qreal matrixDet3 (const qreal m[4][4], int col0, int col1, int col2, int row0, int row1, int row2)
 
static qreal matrixDet4 (const qreal m[4][4])
 
QDebug operator<< (QDebug dbg, const QMatrix4x4 &m)
 
QDataStreamoperator<< (QDataStream &stream, const QMatrix4x4 &matrix)
 
QDataStreamoperator>> (QDataStream &stream, QMatrix4x4 &matrix)
 

Variables

static const qreal inv_dist_to_plane = 1. / 1024.
 

Function Documentation

◆ matrixDet3()

static qreal matrixDet3 ( const qreal  m[4][4],
int  col0,
int  col1,
int  col2,
int  row0,
int  row1,
int  row2 
)
inlinestatic

Definition at line 363 of file qmatrix4x4.cpp.

Referenced by QMatrix4x4::inverted(), matrixDet4(), QMatrix4x4::normalMatrix(), and QMatrix4x4::QMatrix4x4().

365 {
366  return m[col0][row0] *
367  (m[col1][row1] * m[col2][row2] -
368  m[col1][row2] * m[col2][row1]) -
369  m[col1][row0] *
370  (m[col0][row1] * m[col2][row2] -
371  m[col0][row2] * m[col2][row1]) +
372  m[col2][row0] *
373  (m[col0][row1] * m[col1][row2] -
374  m[col0][row2] * m[col1][row1]);
375 }

◆ matrixDet4()

static qreal matrixDet4 ( const qreal  m[4][4])
inlinestatic

Definition at line 378 of file qmatrix4x4.cpp.

Referenced by QMatrix4x4::determinant(), and QMatrix4x4::inverted().

379 {
380  qreal det;
381  det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
382  det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
383  det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
384  det -= m[3][0] * matrixDet3(m, 0, 1, 2, 1, 2, 3);
385  return det;
386 }
double qreal
Definition: qglobal.h:1193
static qreal matrixDet3(const qreal m[4][4], int col0, int col1, int col2, int row0, int row1, int row2)
Definition: qmatrix4x4.cpp:363

◆ operator<<() [1/2]

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]

QDataStream& operator<< ( QDataStream stream,
const QMatrix4x4 matrix 
)
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>>()

QDataStream& operator>> ( QDataStream stream,
QMatrix4x4 matrix 
)
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
void optimize()
Optimize the usage of this matrix from its current elements.
static FILE * stream

Variable Documentation

◆ inv_dist_to_plane

const qreal inv_dist_to_plane = 1. / 1024.
static

Definition at line 64 of file qmatrix4x4.cpp.

Referenced by QMatrix4x4::projectedRotate(), and QMatrix4x4::toTransform().