Merge "Merge branch 'newdocs'" into refs/staging/master
[profile/ivi/qtbase.git] / src / gui / math3d / qgenericmatrix.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qgenericmatrix.h"
43
44 QT_BEGIN_NAMESPACE
45
46 /*!
47     \class QGenericMatrix
48     \brief The QGenericMatrix class is a template class that represents a NxM transformation matrix with N columns and M rows.
49     \since 4.6
50     \ingroup painting
51     \ingroup painting-3D
52     \inmodule QtGui
53
54     The QGenericMatrix template has three parameters:
55
56     \table
57     \row \li N \li Number of columns.
58     \row \li M \li Number of rows.
59     \row \li T \li Element type that is visible to users of the class.
60     \endtable
61
62     \sa QMatrix4x4
63 */
64
65 /*!
66     \fn QGenericMatrix::QGenericMatrix()
67
68     Constructs a NxM identity matrix.
69 */
70
71 /*!
72     \fn QGenericMatrix::QGenericMatrix(const QGenericMatrix<N, M, T>& other)
73
74     Constructs a copy of \a other.
75 */
76
77 /*!
78     \fn QGenericMatrix::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 const T& QGenericMatrix::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 T& QGenericMatrix::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 bool QGenericMatrix::isIdentity() const
103
104     Returns true if this matrix is the identity; false otherwise.
105
106     \sa setToIdentity()
107 */
108
109 /*!
110     \fn void QGenericMatrix::setToIdentity()
111
112     Sets this matrix to the identity.
113
114     \sa isIdentity()
115 */
116
117 /*!
118     \fn void QGenericMatrix::fill(T value)
119
120     Fills all elements of this matrix with \a value.
121 */
122
123 /*!
124     \fn QGenericMatrix<M, N> QGenericMatrix::transposed() const
125
126     Returns this matrix, transposed about its diagonal.
127 */
128
129 /*!
130     \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator+=(const QGenericMatrix<N, M, T>& other)
131
132     Adds the contents of \a other to this matrix.
133 */
134
135 /*!
136     \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator-=(const QGenericMatrix<N, M, T>& other)
137
138     Subtracts the contents of \a other from this matrix.
139 */
140
141 /*!
142     \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator*=(T factor)
143
144     Multiplies all elements of this matrix by \a factor.
145 */
146
147 /*!
148     \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator/=(T divisor)
149
150     Divides all elements of this matrix by \a divisor.
151 */
152
153 /*!
154     \fn bool QGenericMatrix::operator==(const QGenericMatrix<N, M, T>& other) const
155
156     Returns true if this matrix is identical to \a other; false otherwise.
157 */
158
159 /*!
160     \fn bool QGenericMatrix::operator!=(const QGenericMatrix<N, M, T>& other) const
161
162     Returns true if this matrix is not identical to \a other; false otherwise.
163 */
164
165 /*!
166     \fn 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 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 QGenericMatrix<M1, M2, T> operator*(const QGenericMatrix<N, M2, T>& m1, const QGenericMatrix<M1, N, T>& m2)
181     \relates QGenericMatrix
182
183     Returns the product of the NxM2 matrix \a m1 and the M1xN matrix \a m2
184     to produce a M1xM2 matrix result.
185 */
186
187 /*!
188     \fn 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 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 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 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 void QGenericMatrix::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 T *QGenericMatrix::data()
225
226     Returns a pointer to the raw data of this matrix.
227
228     \sa constData()
229 */
230
231 /*!
232     \fn const T *QGenericMatrix::data() const
233
234     Returns a constant pointer to the raw data of this matrix.
235
236     \sa constData()
237 */
238
239 /*!
240     \fn const T *QGenericMatrix::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 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 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
343 QT_END_NAMESPACE