blob: 6faeca1e7cc0787d3582e7bf4f28f18f2ec4dd5e [file] [log] [blame]
Jason Sams044e2ee2011-08-08 16:52:30 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/** @file rs_matrix.rsh
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070018 * \brief Matrix functions.
Jason Sams044e2ee2011-08-08 16:52:30 -070019 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070020 * These functions let you manipulate square matrices of rank 2x2, 3x3, and 4x4.
21 * They are particularly useful for graphical transformations and are
22 * compatible with OpenGL.
23 *
24 * A few general notes:
25 *
26 * \li We use a zero-based index for rows and columns. E.g. the last element of
27 * a \ref rs_matrix4x4 is found at (3, 3).
28 *
29 * \li RenderScript uses column-based vectors. Transforming a vector is done by
30 * postmultiplying the vector, e.g. <em>(matrix * vector)</em>, as provided by
31 * \ref rsMatrixMultiply.
32 *
33 * \li To create a transformation matrix that performs two transformations at
34 * once, multiply the two source matrices, with the first transformation as the
35 * right argument. E.g. to create a transformation matrix that applies the
36 * transformation \e s1 followed by \e s2, call
Jean-Luc Brouillet462e62c2014-12-12 13:42:24 -080037 * <c>rsMatrixLoadMultiply(&combined, &s2, &s1)</c>.
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070038 * This derives from <em>s2 * (s1 * v)</em>, which is <em>(s2 * s1) * v</em>.
39 *
40 * \li We have two style of functions to create transformation matrices:
41 * rsMatrixLoad<em>Transformation</em> and rsMatrix<em>Transformation</em>. The
42 * former style simply stores the transformation matrix in the first argument.
43 * The latter modifies a pre-existing transformation matrix so that the new
44 * transformation happens first. E.g. if you call \ref rsMatrixTranslate
45 * on a matrix that already does a scaling, the resulting matrix when applied
46 * to a vector will first do the translation then the scaling.
Jason Sams044e2ee2011-08-08 16:52:30 -070047 *
48 */
49
50#ifndef __RS_MATRIX_RSH__
51#define __RS_MATRIX_RSH__
52
53/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070054 * Set an element of a matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -070055 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070056 * @param m The matrix that will be modified.
57 * @param col The zero-based column of the element to be set.
58 * @param row The zero-based row of the element to be set.
59 * @param v The value to set.
60 *
61 * \warning The order of the column and row parameters may be
62 * unexpected.
Jason Sams044e2ee2011-08-08 16:52:30 -070063 */
64_RS_RUNTIME void __attribute__((overloadable))
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070065rsMatrixSet(rs_matrix4x4 *m, uint32_t col, uint32_t row, float v);
Jason Sams044e2ee2011-08-08 16:52:30 -070066/**
67 * \overload
68 */
69_RS_RUNTIME void __attribute__((overloadable))
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070070rsMatrixSet(rs_matrix3x3 *m, uint32_t col, uint32_t row, float v);
Jason Sams044e2ee2011-08-08 16:52:30 -070071/**
72 * \overload
73 */
74_RS_RUNTIME void __attribute__((overloadable))
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070075rsMatrixSet(rs_matrix2x2 *m, uint32_t col, uint32_t row, float v);
Jason Sams044e2ee2011-08-08 16:52:30 -070076
77/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070078 * Returns one element of a matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -070079 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070080 * @param m The matrix to extract the element from.
81 * @param col The zero-based column of the element to be extracted.
82 * @param row The zero-based row of the element to extracted.
83 *
84 * \warning The order of the column and row parameters may be
85 * unexpected.
Jason Sams044e2ee2011-08-08 16:52:30 -070086 *
87 * @return float
88 */
89_RS_RUNTIME float __attribute__((overloadable))
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070090rsMatrixGet(const rs_matrix4x4 *m, uint32_t col, uint32_t row);
Jason Sams044e2ee2011-08-08 16:52:30 -070091/**
92 * \overload
93 */
94_RS_RUNTIME float __attribute__((overloadable))
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -070095rsMatrixGet(const rs_matrix3x3 *m, uint32_t col, uint32_t row);
Jason Sams044e2ee2011-08-08 16:52:30 -070096/**
97 * \overload
98 */
99_RS_RUNTIME float __attribute__((overloadable))
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700100rsMatrixGet(const rs_matrix2x2 *m, uint32_t col, uint32_t row);
Jason Sams044e2ee2011-08-08 16:52:30 -0700101
102/**
103 * Set the elements of a matrix to the identity matrix.
104 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700105 * @param m The matrix to set.
Jason Sams044e2ee2011-08-08 16:52:30 -0700106 */
107extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
108/**
109 * \overload
110 */
111extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
112/**
113 * \overload
114 */
115extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
116
117/**
118 * Set the elements of a matrix from an array of floats.
119 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700120 * The array of floats should be in row-major order, i.e. the element a
121 * <em>row 0, column 0</em> should be first, followed by the element at
122 * <em>row 0, column 1</em>, etc.
123 *
124 * @param m The matrix to set.
125 * @param v The array of values to set the matrix to. These arrays should be
126 * 4, 9, or 16 floats long, depending on the matrix size.
Jason Sams044e2ee2011-08-08 16:52:30 -0700127 */
128extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
129/**
130 * \overload
131 */
132extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
133/**
134 * \overload
135 */
136extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
137/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700138 * Set the elements of a matrix from another matrix.
139 *
140 * If the source matrix is smaller than the destination, the rest of the
141 * destination is filled with elements of the identity matrix. E.g.
142 * loading a rs_matrix2x2 into a rs_matrix4x4 will give:
143 *
144 * \htmlonly<table>
145 * <tr><td>m00</td><td>m01</td><td>0.0</td><td>0.0</td></tr>
146 * <tr><td>m10</td><td>m11</td><td>0.0</td><td>0.0</td></tr>
147 * <tr><td>0.0</td><td>0.0</td><td>1.0</td><td>0.0</td></tr>
148 * <tr><td>0.0</td><td>0.0</td><td>0.0</td><td>1.0</td></tr>
149 * </table>\endhtmlonly
150 *
151 * @param m The matrix to set.
152 * @param v The source matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -0700153 */
154extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
155/**
156 * \overload
157 */
158extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
Jason Sams044e2ee2011-08-08 16:52:30 -0700159/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700160 * \overload
Jason Sams044e2ee2011-08-08 16:52:30 -0700161 */
162extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
163/**
164 * \overload
165 */
166extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
167/**
168 * \overload
169 */
170extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
171
172/**
173 * Load a rotation matrix.
174 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700175 * This function creates a rotation matrix. The axis of rotation is the
176 * <em>(x, y, z)</em> vector.
177 *
178 * To rotate a vector, multiply the vector by the created matrix
179 * using \ref rsMatrixMultiply.
180 *
181 * See http://en.wikipedia.org/wiki/Rotation_matrix .
182 *
183 * @param m The matrix to set.
184 * @param rot How much rotation to do, in degrees.
185 * @param x The x component of the vector that is the axis of rotation.
186 * @param y The y component of the vector that is the axis of rotation.
187 * @param z The z component of the vector that is the axis of rotation.
Jason Sams044e2ee2011-08-08 16:52:30 -0700188 */
189extern void __attribute__((overloadable))
190rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
191
192/**
193 * Load a scale matrix.
194 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700195 * This function creates a scaling matrix, where each component of a
196 * vector is multiplied by a number. This number can be negative.
197 *
198 * To scale a vector, multiply the vector by the created matrix
199 * using \ref rsMatrixMultiply.
200 *
201 * @param m The matrix to set.
202 * @param x The multiple to scale the x components by.
203 * @param y The multiple to scale the y components by.
204 * @param z The multiple to scale the z components by.
Jason Sams044e2ee2011-08-08 16:52:30 -0700205 */
206extern void __attribute__((overloadable))
207rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
208
209/**
210 * Load a translation matrix.
211 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700212 * This function creates a translation matrix, where a
213 * number is added to each element of a vector.
214 *
215 * To translate a vector, multiply the vector by the created matrix
216 * using \ref rsMatrixMultiply.
217 *
218 * @param m The matrix to set.
219 * @param x The number to add to each x component.
220 * @param y The number to add to each y component.
221 * @param z The number to add to each z component.
Jason Sams044e2ee2011-08-08 16:52:30 -0700222 */
223extern void __attribute__((overloadable))
224rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
225
226/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700227 * Multiply two matrices.
Jason Sams044e2ee2011-08-08 16:52:30 -0700228 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700229 * Sets \e m to the matrix product of <em>lhs * rhs</em>.
230 *
231 * To combine two 4x4 transformaton matrices, multiply the second transformation matrix
232 * by the first transformation matrix. E.g. to create a transformation matrix that applies
233 * the transformation \e s1 followed by \e s2, call
Jean-Luc Brouillet462e62c2014-12-12 13:42:24 -0800234 * <c>rsMatrixLoadMultiply(&combined, &s2, &s1)</c>.
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700235 *
236 * \warning Prior to version 21, storing the result back into right matrix is not supported and
237 * will result in undefined behavior. Use rsMatrixMulitply instead. E.g. instead of doing
238 * rsMatrixLoadMultiply (&m2r, &m2r, &m2l), use rsMatrixMultiply (&m2r, &m2l).
239 * rsMatrixLoadMultiply (&m2l, &m2r, &m2l) works as expected.
240 *
241 * @param m The matrix to set.
242 * @param lhs The left matrix of the product.
243 * @param rhs The right matrix of the product.
Jason Sams044e2ee2011-08-08 16:52:30 -0700244 */
245extern void __attribute__((overloadable))
246rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
247/**
248 * \overload
249 */
250extern void __attribute__((overloadable))
251rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
252/**
253 * \overload
254 */
255extern void __attribute__((overloadable))
256rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
257
258/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700259 * Multiply a matrix into another one.
Jason Sams044e2ee2011-08-08 16:52:30 -0700260 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700261 * Sets \e m to the matrix product <em>m * rhs</em>.
262 *
263 * When combining two 4x4 transformation matrices using this function, the resulting
264 * matrix will correspond to performing the \e rhs transformation first followed by
265 * the original \e m transformation.
266 *
267 * @param m The left matrix of the product and the matrix to be set.
268 * @param rhs The right matrix of the product.
Jason Sams044e2ee2011-08-08 16:52:30 -0700269 */
270extern void __attribute__((overloadable))
271rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
272/**
273 * \overload
274 */
275extern void __attribute__((overloadable))
276rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
277/**
278 * \overload
279 */
280extern void __attribute__((overloadable))
281rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
282
283/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700284 * Multiply the matrix \e m with a rotation matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -0700285 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700286 * This function modifies a transformation matrix to first do a rotation.
287 * The axis of rotation is the <em>(x, y, z)</em> vector.
288 *
289 * To apply this combined transformation to a vector, multiply
290 * the vector by the created matrix using \ref rsMatrixMultiply.
291 *
292 * @param m The matrix to modify.
293 * @param rot How much rotation to do, in degrees.
294 * @param x The x component of the vector that is the axis of rotation.
295 * @param y The y component of the vector that is the axis of rotation.
296 * @param z The z component of the vector that is the axis of rotation.
Jason Sams044e2ee2011-08-08 16:52:30 -0700297 */
298extern void __attribute__((overloadable))
299rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
300
301/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700302 * Multiply the matrix \e m with a scaling matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -0700303 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700304 * This function modifies a transformation matrix to first do a scaling.
305 * When scaling, each component of a vector is multiplied by a number.
306 * This number can be negative.
307 *
308 * To apply this combined transformation to a vector, multiply
309 * the vector by the created matrix using \ref rsMatrixMultiply.
310 *
311 * @param m The matrix to modify.
312 * @param x The multiple to scale the x components by.
313 * @param y The multiple to scale the y components by.
314 * @param z The multiple to scale the z components by.
Jason Sams044e2ee2011-08-08 16:52:30 -0700315 */
316extern void __attribute__((overloadable))
317rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
318
319/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700320 * Multiply the matrix \e m with a translation matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -0700321 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700322 * This function modifies a transformation matrix to first
323 * do a translation. When translating, a number is added
324 * to each component of a vector.
325 *
326 * To apply this combined transformation to a vector, multiply
327 * the vector by the created matrix using \ref rsMatrixMultiply.
328 *
329 * @param m The matrix to modify.
330 * @param x The number to add to each x component.
331 * @param y The number to add to each y component.
332 * @param z The number to add to each z component.
Jason Sams044e2ee2011-08-08 16:52:30 -0700333 */
334extern void __attribute__((overloadable))
335rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
336
337/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700338 * Load an orthographic projection matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -0700339 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700340 * Constructs an orthographic projection matrix, transforming the box
341 * identified by the six clipping planes <em>left, right, bottom, top,
342 * near, far</em> into a unit cube with a corner at
343 * <em>(-1, -1, -1)</em> and the opposite at <em>(1, 1, 1)</em>.
344 *
345 * To apply this projection to a vector, multiply the vector by the
346 * created matrix using \ref rsMatrixMultiply.
347 *
348 * See https://en.wikipedia.org/wiki/Orthographic_projection .
349 *
350 * @param m The matrix to set.
Jason Sams044e2ee2011-08-08 16:52:30 -0700351 * @param left
352 * @param right
353 * @param bottom
354 * @param top
355 * @param near
356 * @param far
357 */
358extern void __attribute__((overloadable))
359rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
360
361/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700362 * Load a frustum projection matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -0700363 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700364 * Constructs a frustum projection matrix, transforming the box
365 * identified by the six clipping planes <em>left, right, bottom, top,
366 * near, far</em>.
367 *
368 * To apply this projection to a vector, multiply the vector by the
369 * created matrix using \ref rsMatrixMultiply.
370 *
371 * @param m The matrix to set.
Jason Sams044e2ee2011-08-08 16:52:30 -0700372 * @param left
373 * @param right
374 * @param bottom
375 * @param top
376 * @param near
377 * @param far
378 */
379extern void __attribute__((overloadable))
380rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
381
382/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700383 * Load a perspective projection matrix.
Jason Sams044e2ee2011-08-08 16:52:30 -0700384 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700385 * Constructs a perspective projection matrix, assuming a symmetrical field of view.
386 *
387 * To apply this projection to a vector, multiply the vector by the
388 * created matrix using \ref rsMatrixMultiply.
389 *
390 * @param m The matrix to set.
Jason Sams044e2ee2011-08-08 16:52:30 -0700391 * @param fovy Field of view, in degrees along the Y axis.
392 * @param aspect Ratio of x / y.
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700393 * @param near The near clipping plane.
394 * @param far The far clipping plane.
Jason Sams044e2ee2011-08-08 16:52:30 -0700395 */
396extern void __attribute__((overloadable))
397rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
398
399#if !defined(RS_VERSION) || (RS_VERSION < 14)
400/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700401 * Multiply a vector by a matrix.
402 *
403 * Returns the post-multiplication of the vector by the matrix, ie. <em>m * in</em>.
404 *
405 * When multiplying a \e float3 to a \e rs_matrix4x4, the vector is expanded with (1).
406 *
407 * When multiplying a \e float2 to a \e rs_matrix4x4, the vector is expanded with (0, 1).
408 *
409 * When multiplying a \e float2 to a \e rs_matrix3x3, the vector is expanded with (0).
410 *
411 * This function is available in API version 10-13. Starting with API 14,
412 * the function takes a const matrix as the first argument.
Jason Sams044e2ee2011-08-08 16:52:30 -0700413 */
414_RS_RUNTIME float4 __attribute__((overloadable))
415rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
416
417/**
418 * \overload
419 */
420_RS_RUNTIME float4 __attribute__((overloadable))
421rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
422
423/**
424 * \overload
425 */
426_RS_RUNTIME float4 __attribute__((overloadable))
427rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
428
429/**
430 * \overload
431 */
432_RS_RUNTIME float3 __attribute__((overloadable))
433rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
434
435/**
436 * \overload
437 */
438_RS_RUNTIME float3 __attribute__((overloadable))
439rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
440
441/**
442 * \overload
443 */
444_RS_RUNTIME float2 __attribute__((overloadable))
445rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
446#else
447/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700448 * Multiply a vector by a matrix.
449 *
450 * Returns the post-multiplication of the vector of the matrix, i.e. <em>m * in</em>.
451 *
452 * When multiplying a \e float3 to a \e rs_matrix4x4, the vector is expanded with (1).
453 *
454 * When multiplying a \e float2 to a \e rs_matrix4x4, the vector is expanded with (0, 1).
455 *
456 * When multiplying a \e float2 to a \e rs_matrix3x3, the vector is expanded with (0).
457 *
458 * This function is available starting with API version 14.
Jason Sams044e2ee2011-08-08 16:52:30 -0700459 */
460_RS_RUNTIME float4 __attribute__((overloadable))
461rsMatrixMultiply(const rs_matrix4x4 *m, float4 in);
462
463/**
464 * \overload
465 */
466_RS_RUNTIME float4 __attribute__((overloadable))
467rsMatrixMultiply(const rs_matrix4x4 *m, float3 in);
468
469/**
470 * \overload
471 */
472_RS_RUNTIME float4 __attribute__((overloadable))
473rsMatrixMultiply(const rs_matrix4x4 *m, float2 in);
474
475/**
476 * \overload
477 */
478_RS_RUNTIME float3 __attribute__((overloadable))
479rsMatrixMultiply(const rs_matrix3x3 *m, float3 in);
480
481/**
482 * \overload
483 */
484_RS_RUNTIME float3 __attribute__((overloadable))
485rsMatrixMultiply(const rs_matrix3x3 *m, float2 in);
486
487/**
488 * \overload
489 */
490_RS_RUNTIME float2 __attribute__((overloadable))
491rsMatrixMultiply(const rs_matrix2x2 *m, float2 in);
492#endif
493
494
495/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700496 * Inverts a matrix in place.
Jason Sams044e2ee2011-08-08 16:52:30 -0700497 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700498 * Returns true if the matrix was successfully inverted.
499 *
500 * @param m The matrix to invert.
Jason Sams044e2ee2011-08-08 16:52:30 -0700501 */
502extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
503
504/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700505 * Inverts and transpose a matrix in place.
Jason Sams044e2ee2011-08-08 16:52:30 -0700506 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700507 * The matrix is first inverted then transposed.
508 * Returns true if the matrix was successfully inverted.
509 *
510 * @param m The matrix to modify.
Jason Sams044e2ee2011-08-08 16:52:30 -0700511 */
512extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
513
514/**
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700515 * Transpose the matrix m in place.
Jason Sams044e2ee2011-08-08 16:52:30 -0700516 *
Jean-Luc Brouillet1bb2eed2014-09-05 17:44:48 -0700517 * @param m The matrix to transpose.
Jason Sams044e2ee2011-08-08 16:52:30 -0700518 */
519extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
520/**
521 * \overload
522 */
523extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
524/**
525 * \overload
526 */
527extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
528
529
530#endif