Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgenericmatrix.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6QT_BEGIN_NAMESPACE
7
8QT_IMPL_METATYPE_EXTERN(QMatrix2x2)
9QT_IMPL_METATYPE_EXTERN(QMatrix2x3)
10QT_IMPL_METATYPE_EXTERN(QMatrix2x4)
11QT_IMPL_METATYPE_EXTERN(QMatrix3x2)
12QT_IMPL_METATYPE_EXTERN(QMatrix3x3)
13QT_IMPL_METATYPE_EXTERN(QMatrix3x4)
14QT_IMPL_METATYPE_EXTERN(QMatrix4x2)
15QT_IMPL_METATYPE_EXTERN(QMatrix4x3)
16
17/*!
18 \class QGenericMatrix
19 \brief The QGenericMatrix class is a template class that represents an N x M transformation matrix with N columns and M rows.
20 \since 4.6
21 \ingroup painting
22 \ingroup painting-3D
23 \inmodule QtGui
24
25 QGenericMatrix<N, M, T> is a template class where \a N is the number of
26 columns, \a M is the number of rows, and \a T is the element type that is
27 visible to users of the class.
28
29 \sa QMatrix4x4
30*/
31
32/*!
33 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>::QGenericMatrix()
34
35 Constructs an \a N x \a M identity matrix.
36*/
37
38/*!
39 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>::QGenericMatrix(Qt::Initialization)
40 \since 5.5
41 \internal
42
43 Constructs an \a N x \a M matrix without initializing the contents.
44*/
45
46/*!
47 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>::QGenericMatrix(const T *values)
48
49 Constructs a matrix from the given \a N * \a M floating-point \a values.
50 The contents of the array \a values is assumed to be in
51 row-major order.
52
53 \sa copyDataTo()
54*/
55
56/*!
57 \fn template <int N, int M, typename T> const T& QGenericMatrix<N, M, T>::operator()(int row, int column) const
58
59 Returns a constant reference to the element at position
60 (\a row, \a column) in this matrix.
61*/
62
63/*!
64 \fn template <int N, int M, typename T> T& QGenericMatrix<N, M, T>::operator()(int row, int column)
65
66 Returns a reference to the element at position (\a row, \a column)
67 in this matrix so that the element can be assigned to.
68*/
69
70/*!
71 \fn template <int N, int M, typename T> bool QGenericMatrix<N, M, T>::isIdentity() const
72
73 Returns \c true if this matrix is the identity; false otherwise.
74
75 \sa setToIdentity()
76*/
77
78/*!
79 \fn template <int N, int M, typename T> void QGenericMatrix<N, M, T>::setToIdentity()
80
81 Sets this matrix to the identity.
82
83 \sa isIdentity()
84*/
85
86/*!
87 \fn template <int N, int M, typename T> void QGenericMatrix<N, M, T>::fill(T value)
88
89 Fills all elements of this matrix with \a value.
90*/
91
92/*!
93 \fn template <int N, int M, typename T> QGenericMatrix<M, N> QGenericMatrix<N, M, T>::transposed() const
94
95 Returns this matrix, transposed about its diagonal.
96*/
97
98/*!
99 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator+=(const QGenericMatrix<N, M, T>& other)
100
101 Adds the contents of \a other to this matrix.
102*/
103
104/*!
105 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator-=(const QGenericMatrix<N, M, T>& other)
106
107 Subtracts the contents of \a other from this matrix.
108*/
109
110/*!
111 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator*=(T factor)
112
113 Multiplies all elements of this matrix by \a factor.
114*/
115
116/*!
117 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator/=(T divisor)
118
119 Divides all elements of this matrix by \a divisor.
120*/
121
122/*!
123 \fn template <int N, int M, typename T> bool QGenericMatrix<N, M, T>::operator==(const QGenericMatrix<N, M, T>& other) const
124
125 Returns \c true if this matrix is identical to \a other; false otherwise.
126*/
127
128/*!
129 \fn template <int N, int M, typename T> bool QGenericMatrix<N, M, T>::operator!=(const QGenericMatrix<N, M, T>& other) const
130
131 Returns \c true if this matrix is not identical to \a other; false otherwise.
132*/
133
134/*!
135 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator+(const QGenericMatrix<N, M, T>& m1, const QGenericMatrix<N, M, T>& m2)
136 \relates QGenericMatrix
137
138 Returns the sum of the \a N x \a M matrices \a m1 and \a m2.
139*/
140
141/*!
142 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T>& m1, const QGenericMatrix<N, M, T>& m2)
143 \relates QGenericMatrix
144
145 Returns the difference of the \a N x \a M matrices \a m1 and \a m2.
146*/
147
148/*!
149 \fn template <int N, int M, typename T> template<int NN, int M1, int M2, typename TT> QGenericMatrix<M1, M2, TT> QGenericMatrix<N, M, T>::operator*(const QGenericMatrix<NN, M2, TT>& m1, const QGenericMatrix<M1, NN, TT>& m2)
150
151 Returns the product of the \a NN x \a M2 matrix \a m1 and the \a M1 x \a NN
152 matrix \a m2 to produce an \a M1 x \a M2 matrix result.
153*/
154
155/*!
156 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T>& matrix)
157 \overload
158 \relates QGenericMatrix
159
160 Returns the negation of \a matrix.
161*/
162
163/*!
164 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator*(T factor, const QGenericMatrix<N, M, T>& matrix)
165 \relates QGenericMatrix
166
167 Returns the result of multiplying all elements of the \a N x \a M
168 \a matrix by \a factor.
169*/
170
171/*!
172 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator*(const QGenericMatrix<N, M, T>& matrix, T factor)
173 \relates QGenericMatrix
174
175 Returns the result of multiplying all elements of \a matrix by \a factor.
176*/
177
178/*!
179 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator/(const QGenericMatrix<N, M, T>& matrix, T divisor)
180 \relates QGenericMatrix
181
182 Returns the result of dividing all elements of the \a N x \a M
183 \a matrix by \a divisor.
184*/
185
186/*!
187 \fn template <int N, int M, typename T> void QGenericMatrix<N, M, T>::copyDataTo(T *values) const
188
189 Retrieves the \a N * \a M items in this matrix and copies them to \a values
190 in row-major order.
191*/
192
193/*!
194 \fn template <int N, int M, typename T> T *QGenericMatrix<N, M, T>::data()
195
196 Returns a pointer to the raw data of this matrix.
197
198 \sa constData()
199*/
200
201/*!
202 \fn template <int N, int M, typename T> const T *QGenericMatrix<N, M, T>::data() const
203
204 Returns a constant pointer to the raw data of this matrix.
205
206 \sa constData()
207*/
208
209/*!
210 \fn template <int N, int M, typename T> const T *QGenericMatrix<N, M, T>::constData() const
211
212 Returns a constant pointer to the raw data of this matrix.
213
214 \sa data()
215*/
216
217#ifndef QT_NO_DATASTREAM
218
219/*!
220 \fn template <int N, int M, typename T> QDataStream &operator<<(QDataStream &stream, const QGenericMatrix<N, M, T> &matrix)
221 \relates QGenericMatrix
222
223 Writes the given \a N x \a M \a matrix to the given \a stream and returns a
224 reference to the stream.
225
226 \sa {Serializing Qt Data Types}
227*/
228
229/*!
230 \fn template <int N, int M, typename T> QDataStream &operator>>(QDataStream &stream, QGenericMatrix<N, M, T> &matrix)
231 \relates QGenericMatrix
232
233 Reads an \a N x \a M matrix from the given \a stream into the given \a matrix
234 and returns a reference to the stream.
235
236 \sa {Serializing Qt Data Types}
237*/
238
239#endif
240
241/*!
242 \typedef QMatrix2x2
243 \relates QGenericMatrix
244
245 The QMatrix2x2 type defines a convenient instantiation of the
246 QGenericMatrix template for 2 columns, 2 rows, and float as
247 the element type.
248*/
249
250/*!
251 \typedef QMatrix2x3
252 \relates QGenericMatrix
253
254 The QMatrix2x3 type defines a convenient instantiation of the
255 QGenericMatrix template for 2 columns, 3 rows, and float as
256 the element type.
257*/
258
259/*!
260 \typedef QMatrix2x4
261 \relates QGenericMatrix
262
263 The QMatrix2x4 type defines a convenient instantiation of the
264 QGenericMatrix template for 2 columns, 4 rows, and float as
265 the element type.
266*/
267
268/*!
269 \typedef QMatrix3x2
270 \relates QGenericMatrix
271
272 The QMatrix3x2 type defines a convenient instantiation of the
273 QGenericMatrix template for 3 columns, 2 rows, and float as
274 the element type.
275*/
276
277/*!
278 \typedef QMatrix3x3
279 \relates QGenericMatrix
280
281 The QMatrix3x3 type defines a convenient instantiation of the
282 QGenericMatrix template for 3 columns, 3 rows, and float as
283 the element type.
284*/
285
286/*!
287 \typedef QMatrix3x4
288 \relates QGenericMatrix
289
290 The QMatrix3x4 type defines a convenient instantiation of the
291 QGenericMatrix template for 3 columns, 4 rows, and float as
292 the element type.
293*/
294
295/*!
296 \typedef QMatrix4x2
297 \relates QGenericMatrix
298
299 The QMatrix4x2 type defines a convenient instantiation of the
300 QGenericMatrix template for 4 columns, 2 rows, and float as
301 the element type.
302*/
303
304/*!
305 \typedef QMatrix4x3
306 \relates QGenericMatrix
307
308 The QMatrix4x3 type defines a convenient instantiation of the
309 QGenericMatrix template for 4 columns, 3 rows, and float as
310 the element type.
311*/
312
313QT_END_NAMESPACE