1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qgenericmatrix.h"
41
42QT_BEGIN_NAMESPACE
43
44/*!
45 \class QGenericMatrix
46 \brief The QGenericMatrix class is a template class that represents a NxM transformation matrix with N columns and M rows.
47 \since 4.6
48 \ingroup painting
49 \ingroup painting-3D
50 \inmodule QtGui
51
52 The QGenericMatrix template has three parameters:
53
54 \table
55 \row \li N \li Number of columns.
56 \row \li M \li Number of rows.
57 \row \li T \li Element type that is visible to users of the class.
58 \endtable
59
60 \sa QMatrix4x4
61*/
62
63/*!
64 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>::QGenericMatrix()
65
66 Constructs a NxM identity matrix.
67*/
68
69/*!
70 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>::QGenericMatrix(Qt::Initialization)
71 \since 5.5
72 \internal
73
74 Constructs a NxM matrix without initializing the contents.
75*/
76
77/*!
78 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>::QGenericMatrix(const T *values)
79
80 Constructs a matrix from the given N * M floating-point \a values.
81 The contents of the array \a values is assumed to be in
82 row-major order.
83
84 \sa copyDataTo()
85*/
86
87/*!
88 \fn template <int N, int M, typename T> const T& QGenericMatrix<N, M, T>::operator()(int row, int column) const
89
90 Returns a constant reference to the element at position
91 (\a row, \a column) in this matrix.
92*/
93
94/*!
95 \fn template <int N, int M, typename T> T& QGenericMatrix<N, M, T>::operator()(int row, int column)
96
97 Returns a reference to the element at position (\a row, \a column)
98 in this matrix so that the element can be assigned to.
99*/
100
101/*!
102 \fn template <int N, int M, typename T> bool QGenericMatrix<N, M, T>::isIdentity() const
103
104 Returns \c true if this matrix is the identity; false otherwise.
105
106 \sa setToIdentity()
107*/
108
109/*!
110 \fn template <int N, int M, typename T> void QGenericMatrix<N, M, T>::setToIdentity()
111
112 Sets this matrix to the identity.
113
114 \sa isIdentity()
115*/
116
117/*!
118 \fn template <int N, int M, typename T> void QGenericMatrix<N, M, T>::fill(T value)
119
120 Fills all elements of this matrix with \a value.
121*/
122
123/*!
124 \fn template <int N, int M, typename T> QGenericMatrix<M, N> QGenericMatrix<N, M, T>::transposed() const
125
126 Returns this matrix, transposed about its diagonal.
127*/
128
129/*!
130 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator+=(const QGenericMatrix<N, M, T>& other)
131
132 Adds the contents of \a other to this matrix.
133*/
134
135/*!
136 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator-=(const QGenericMatrix<N, M, T>& other)
137
138 Subtracts the contents of \a other from this matrix.
139*/
140
141/*!
142 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator*=(T factor)
143
144 Multiplies all elements of this matrix by \a factor.
145*/
146
147/*!
148 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator/=(T divisor)
149
150 Divides all elements of this matrix by \a divisor.
151*/
152
153/*!
154 \fn template <int N, int M, typename T> bool QGenericMatrix<N, M, T>::operator==(const QGenericMatrix<N, M, T>& other) const
155
156 Returns \c true if this matrix is identical to \a other; false otherwise.
157*/
158
159/*!
160 \fn template <int N, int M, typename T> bool QGenericMatrix<N, M, T>::operator!=(const QGenericMatrix<N, M, T>& other) const
161
162 Returns \c true if this matrix is not identical to \a other; false otherwise.
163*/
164
165/*!
166 \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)
167 \relates QGenericMatrix
168
169 Returns the sum of \a m1 and \a m2.
170*/
171
172/*!
173 \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)
174 \relates QGenericMatrix
175
176 Returns the difference of \a m1 and \a m2.
177*/
178
179/*!
180 \fn template<int NN, int M1, int M2, typename TT> QGenericMatrix<M1, M2, TT> operator*(const QGenericMatrix<NN, M2, TT>& m1, const QGenericMatrix<M1, NN, TT>& m2)
181 \relates QGenericMatrix
182
183 Returns the product of the NNxM2 matrix \a m1 and the M1xNN matrix \a m2
184 to produce a M1xM2 matrix result.
185*/
186
187/*!
188 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T>& matrix)
189 \overload
190 \relates QGenericMatrix
191
192 Returns the negation of \a matrix.
193*/
194
195/*!
196 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator*(T factor, const QGenericMatrix<N, M, T>& matrix)
197 \relates QGenericMatrix
198
199 Returns the result of multiplying all elements of \a matrix by \a factor.
200*/
201
202/*!
203 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator*(const QGenericMatrix<N, M, T>& matrix, T factor)
204 \relates QGenericMatrix
205
206 Returns the result of multiplying all elements of \a matrix by \a factor.
207*/
208
209/*!
210 \fn template <int N, int M, typename T> QGenericMatrix<N, M, T> operator/(const QGenericMatrix<N, M, T>& matrix, T divisor)
211 \relates QGenericMatrix
212
213 Returns the result of dividing all elements of \a matrix by \a divisor.
214*/
215
216/*!
217 \fn template <int N, int M, typename T> void QGenericMatrix<N, M, T>::copyDataTo(T *values) const
218
219 Retrieves the N * M items in this matrix and copies them to \a values
220 in row-major order.
221*/
222
223/*!
224 \fn template <int N, int M, typename T> T *QGenericMatrix<N, M, T>::data()
225
226 Returns a pointer to the raw data of this matrix.
227
228 \sa constData()
229*/
230
231/*!
232 \fn template <int N, int M, typename T> const T *QGenericMatrix<N, M, T>::data() const
233
234 Returns a constant pointer to the raw data of this matrix.
235
236 \sa constData()
237*/
238
239/*!
240 \fn template <int N, int M, typename T> const T *QGenericMatrix<N, M, T>::constData() const
241
242 Returns a constant pointer to the raw data of this matrix.
243
244 \sa data()
245*/
246
247#ifndef QT_NO_DATASTREAM
248
249/*!
250 \fn template <int N, int M, typename T> QDataStream &operator<<(QDataStream &stream, const QGenericMatrix<N, M, T> &matrix)
251 \relates QGenericMatrix
252
253 Writes the given \a matrix to the given \a stream and returns a
254 reference to the stream.
255
256 \sa {Serializing Qt Data Types}
257*/
258
259/*!
260 \fn template <int N, int M, typename T> QDataStream &operator>>(QDataStream &stream, QGenericMatrix<N, M, T> &matrix)
261 \relates QGenericMatrix
262
263 Reads a NxM matrix from the given \a stream into the given \a matrix
264 and returns a reference to the stream.
265
266 \sa {Serializing Qt Data Types}
267*/
268
269#endif
270
271/*!
272 \typedef QMatrix2x2
273 \relates QGenericMatrix
274
275 The QMatrix2x2 type defines a convenient instantiation of the
276 QGenericMatrix template for 2 columns, 2 rows, and float as
277 the element type.
278*/
279
280/*!
281 \typedef QMatrix2x3
282 \relates QGenericMatrix
283
284 The QMatrix2x3 type defines a convenient instantiation of the
285 QGenericMatrix template for 2 columns, 3 rows, and float as
286 the element type.
287*/
288
289/*!
290 \typedef QMatrix2x4
291 \relates QGenericMatrix
292
293 The QMatrix2x4 type defines a convenient instantiation of the
294 QGenericMatrix template for 2 columns, 4 rows, and float as
295 the element type.
296*/
297
298/*!
299 \typedef QMatrix3x2
300 \relates QGenericMatrix
301
302 The QMatrix3x2 type defines a convenient instantiation of the
303 QGenericMatrix template for 3 columns, 2 rows, and float as
304 the element type.
305*/
306
307/*!
308 \typedef QMatrix3x3
309 \relates QGenericMatrix
310
311 The QMatrix3x3 type defines a convenient instantiation of the
312 QGenericMatrix template for 3 columns, 3 rows, and float as
313 the element type.
314*/
315
316/*!
317 \typedef QMatrix3x4
318 \relates QGenericMatrix
319
320 The QMatrix3x4 type defines a convenient instantiation of the
321 QGenericMatrix template for 3 columns, 4 rows, and float as
322 the element type.
323*/
324
325/*!
326 \typedef QMatrix4x2
327 \relates QGenericMatrix
328
329 The QMatrix4x2 type defines a convenient instantiation of the
330 QGenericMatrix template for 4 columns, 2 rows, and float as
331 the element type.
332*/
333
334/*!
335 \typedef QMatrix4x3
336 \relates QGenericMatrix
337
338 The QMatrix4x3 type defines a convenient instantiation of the
339 QGenericMatrix template for 4 columns, 3 rows, and float as
340 the element type.
341*/
342
343QT_END_NAMESPACE
344