blob: 7f7ff0b66d5bab7652a57f2ea45321181e7156a1 [file] [log] [blame]
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07001#
2# Copyright (C) 2015 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
17header:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070018summary: Matrix Functions
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -070019description:
20 These functions let you manipulate square matrices of rank 2x2, 3x3, and 4x4.
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070021 They are particularly useful for graphical transformations and are compatible
22 with OpenGL.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -070023
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070024 We use a zero-based index for rows and columns. E.g. the last element of a
25 @rs_matrix4x4 is found at (3, 3).
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -070026
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070027 RenderScript uses column-major matrices and column-based vectors. Transforming
28 a vector is done by postmultiplying the vector, e.g. <code>(matrix * vector)</code>,
29 as provided by @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -070030
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070031 To create a transformation matrix that performs two transformations at once,
32 multiply the two source matrices, with the first transformation as the right
33 argument. E.g. to create a transformation matrix that applies the
34 transformation s1 followed by s2, call <code>rsMatrixLoadMultiply(&amp;combined, &amp;s2, &amp;s1)</code>.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -070035 This derives from <code>s2 * (s1 * v)</code>, which is <code>(s2 * s1) * v</code>.
36
37 We have two style of functions to create transformation matrices:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070038 rsMatrixLoad<i>Transformation</i> and rsMatrix<i>Transformation</i>. The former
39 style simply stores the transformation matrix in the first argument. The latter
40 modifies a pre-existing transformation matrix so that the new transformation
41 happens first. E.g. if you call @rsMatrixTranslate() on a matrix that already
42 does a scaling, the resulting matrix when applied to a vector will first do the
43 translation then the scaling.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070044include:
45 #include "rs_vector_math.rsh"
46end:
47
48function: rsExtractFrustumPlanes
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070049ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070050arg: const rs_matrix4x4* viewProj, "Matrix to extract planes from."
51arg: float4* left, "Left plane."
52arg: float4* right, "Right plane."
53arg: float4* top, "Top plane."
54arg: float4* bottom, "Bottom plane."
55arg: float4* near, "Near plane."
56arg: float4* far, "Far plane."
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070057summary: Compute frustum planes
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070058description:
59 Computes 6 frustum planes from the view projection matrix
60inline:
61 // x y z w = a b c d in the plane equation
62 left->x = viewProj->m[3] + viewProj->m[0];
63 left->y = viewProj->m[7] + viewProj->m[4];
64 left->z = viewProj->m[11] + viewProj->m[8];
65 left->w = viewProj->m[15] + viewProj->m[12];
66
67 right->x = viewProj->m[3] - viewProj->m[0];
68 right->y = viewProj->m[7] - viewProj->m[4];
69 right->z = viewProj->m[11] - viewProj->m[8];
70 right->w = viewProj->m[15] - viewProj->m[12];
71
72 top->x = viewProj->m[3] - viewProj->m[1];
73 top->y = viewProj->m[7] - viewProj->m[5];
74 top->z = viewProj->m[11] - viewProj->m[9];
75 top->w = viewProj->m[15] - viewProj->m[13];
76
77 bottom->x = viewProj->m[3] + viewProj->m[1];
78 bottom->y = viewProj->m[7] + viewProj->m[5];
79 bottom->z = viewProj->m[11] + viewProj->m[9];
80 bottom->w = viewProj->m[15] + viewProj->m[13];
81
82 near->x = viewProj->m[3] + viewProj->m[2];
83 near->y = viewProj->m[7] + viewProj->m[6];
84 near->z = viewProj->m[11] + viewProj->m[10];
85 near->w = viewProj->m[15] + viewProj->m[14];
86
87 far->x = viewProj->m[3] - viewProj->m[2];
88 far->y = viewProj->m[7] - viewProj->m[6];
89 far->z = viewProj->m[11] - viewProj->m[10];
90 far->w = viewProj->m[15] - viewProj->m[14];
91
92 float len = length(left->xyz);
93 *left /= len;
94 len = length(right->xyz);
95 *right /= len;
96 len = length(top->xyz);
97 *top /= len;
98 len = length(bottom->xyz);
99 *bottom /= len;
100 len = length(near->xyz);
101 *near /= len;
102 len = length(far->xyz);
103 *far /= len;
104test: none
105end:
106
107function: rsIsSphereInFrustum
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700108ret: bool
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700109arg: float4* sphere, "float4 representing the sphere."
110arg: float4* left, "Left plane."
111arg: float4* right, "Right plane."
112arg: float4* top, "Top plane."
113arg: float4* bottom, "Bottom plane."
114arg: float4* near, "Near plane."
115arg: float4* far, "Far plane."
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700116summary: Checks if a sphere is within the frustum planes
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700117description:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700118 Returns true if the sphere is within the 6 frustum planes.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700119inline:
120 float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
121 if (distToCenter < -sphere->w) {
122 return false;
123 }
124 distToCenter = dot(right->xyz, sphere->xyz) + right->w;
125 if (distToCenter < -sphere->w) {
126 return false;
127 }
128 distToCenter = dot(top->xyz, sphere->xyz) + top->w;
129 if (distToCenter < -sphere->w) {
130 return false;
131 }
132 distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
133 if (distToCenter < -sphere->w) {
134 return false;
135 }
136 distToCenter = dot(near->xyz, sphere->xyz) + near->w;
137 if (distToCenter < -sphere->w) {
138 return false;
139 }
140 distToCenter = dot(far->xyz, sphere->xyz) + far->w;
141 if (distToCenter < -sphere->w) {
142 return false;
143 }
144 return true;
145test: none
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700146end:
147
148function: rsMatrixGet
149t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2
150ret: float
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700151arg: const #1* m, "Matrix to extract the element from."
152arg: uint32_t col, "Zero-based column of the element to be extracted."
153arg: uint32_t row, "Zero-based row of the element to extracted."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700154summary: Get one element
155description:
156 Returns one element of a matrix.
157
158 <b>Warning:</b> The order of the column and row parameters may be unexpected.
159test: none
160end:
161
162function: rsMatrixInverse
163ret: bool
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700164arg: rs_matrix4x4* m, "Matrix to invert."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700165summary: Inverts a matrix in place
166description:
167 Returns true if the matrix was successfully inverted.
168test: none
169end:
170
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700171function: rsMatrixInverseTranspose
172ret: bool
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700173arg: rs_matrix4x4* m, "Matrix to modify."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700174summary: Inverts and transpose a matrix in place
175description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700176 The matrix is first inverted then transposed. Returns true if the matrix was
177 successfully inverted.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700178test: none
179end:
180
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700181function: rsMatrixLoad
182t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2
183ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700184arg: #1* destination, "Matrix to set."
185arg: const float* array, "Array of values to set the matrix to. These arrays should be 4, 9, or 16 floats long, depending on the matrix size."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700186summary: Load or copy a matrix
187description:
188 Set the elements of a matrix from an array of floats or from another matrix.
189
190 If loading from an array, the floats should be in row-major order, i.e. the element a
191 <code>row 0, column 0</code> should be first, followed by the element at
192 <code>row 0, column 1</code>, etc.
193
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700194 If loading from a matrix and the source is smaller than the destination, the rest
195 of the destination is filled with elements of the identity matrix. E.g.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700196 loading a rs_matrix2x2 into a rs_matrix4x4 will give:
197 <table style="max-width:300px">
198 <tr><td>m00</td> <td>m01</td> <td>0.0</td> <td>0.0</td></tr>
199 <tr><td>m10</td> <td>m11</td> <td>0.0</td> <td>0.0</td></tr>
200 <tr><td>0.0</td> <td>0.0</td> <td>1.0</td> <td>0.0</td></tr>
201 <tr><td>0.0</td> <td>0.0</td> <td>0.0</td> <td>1.0</td></tr>
202 </table>
203test: none
204end:
205
206function: rsMatrixLoad
207t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2
208ret: void
209arg: #1* destination
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700210arg: const #1* source, "Source matrix."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700211test: none
212end:
213
214function: rsMatrixLoad
215t: rs_matrix3x3, rs_matrix2x2
216ret: void
217arg: rs_matrix4x4* destination
218arg: const #1* source
219test: none
220end:
221
222function: rsMatrixLoadFrustum
223ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700224arg: rs_matrix4x4* m, "Matrix to set."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700225arg: float left
226arg: float right
227arg: float bottom
228arg: float top
229arg: float near
230arg: float far
231summary: Load a frustum projection matrix
232description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700233 Constructs a frustum projection matrix, transforming the box identified by
234 the six clipping planes <code>left, right, bottom, top, near, far</code>.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700235
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700236 To apply this projection to a vector, multiply the vector by the created
237 matrix using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700238test: none
239end:
240
241function: rsMatrixLoadIdentity
242t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2
243ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700244arg: #1* m, "Matrix to set."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700245summary: Load identity matrix
246description:
247 Set the elements of a matrix to the identity matrix.
248test: none
249end:
250
251function: rsMatrixLoadMultiply
252t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2
253ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700254arg: #1* m, "Matrix to set."
255arg: const #1* lhs, "Left matrix of the product."
256arg: const #1* rhs, "Right matrix of the product."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700257summary: Multiply two matrices
258description:
259 Sets m to the matrix product of <code>lhs * rhs</code>.
260
261 To combine two 4x4 transformaton matrices, multiply the second transformation matrix
262 by the first transformation matrix. E.g. to create a transformation matrix that applies
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700263 the transformation s1 followed by s2, call <code>rsMatrixLoadMultiply(&amp;combined, &amp;s2, &amp;s1)</code>.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700264
265 <b>Warning:</b> Prior to version 21, storing the result back into right matrix is not supported and
266 will result in undefined behavior. Use rsMatrixMulitply instead. E.g. instead of doing
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700267 rsMatrixLoadMultiply (&amp;m2r, &amp;m2r, &amp;m2l), use rsMatrixMultiply (&amp;m2r, &amp;m2l).
268 rsMatrixLoadMultiply (&amp;m2l, &amp;m2r, &amp;m2l) works as expected.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700269test: none
270end:
271
272function: rsMatrixLoadOrtho
273ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700274arg: rs_matrix4x4* m, "Matrix to set."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700275arg: float left
276arg: float right
277arg: float bottom
278arg: float top
279arg: float near
280arg: float far
281summary: Load an orthographic projection matrix
282description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700283 Constructs an orthographic projection matrix, transforming the box identified by the
284 six clipping planes <code>left, right, bottom, top, near, far</code> into a unit cube
285 with a corner at <code>(-1, -1, -1)</code> and the opposite at <code>(1, 1, 1)</code>.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700286
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700287 To apply this projection to a vector, multiply the vector by the created matrix
288 using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700289
290 See https://en.wikipedia.org/wiki/Orthographic_projection .
291test: none
292end:
293
294function: rsMatrixLoadPerspective
295ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700296arg: rs_matrix4x4* m, "Matrix to set."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700297arg: float fovy, "Field of view, in degrees along the Y axis."
298arg: float aspect, "Ratio of x / y."
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700299arg: float near, "Near clipping plane."
300arg: float far, "Far clipping plane."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700301summary: Load a perspective projection matrix
302description:
303 Constructs a perspective projection matrix, assuming a symmetrical field of view.
304
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700305 To apply this projection to a vector, multiply the vector by the created matrix
306 using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700307test: none
308end:
309
310function: rsMatrixLoadRotate
311ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700312arg: rs_matrix4x4* m, "Matrix to set."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700313arg: float rot, "How much rotation to do, in degrees."
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700314arg: float x, "X component of the vector that is the axis of rotation."
315arg: float y, "Y component of the vector that is the axis of rotation."
316arg: float z, "Z component of the vector that is the axis of rotation."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700317summary: Load a rotation matrix
318description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700319 This function creates a rotation matrix. The axis of rotation is the <code>(x, y, z)</code> vector.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700320
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700321 To rotate a vector, multiply the vector by the created matrix using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700322
323 See http://en.wikipedia.org/wiki/Rotation_matrix .
324test: none
325end:
326
327function: rsMatrixLoadScale
328ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700329arg: rs_matrix4x4* m, "Matrix to set."
330arg: float x, "Multiple to scale the x components by."
331arg: float y, "Multiple to scale the y components by."
332arg: float z, "Multiple to scale the z components by."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700333summary: Load a scaling matrix
334description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700335 This function creates a scaling matrix, where each component of a vector is multiplied
336 by a number. This number can be negative.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700337
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700338 To scale a vector, multiply the vector by the created matrix using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700339test: none
340end:
341
342function: rsMatrixLoadTranslate
343ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700344arg: rs_matrix4x4* m, "Matrix to set."
345arg: float x, "Number to add to each x component."
346arg: float y, "Number to add to each y component."
347arg: float z, "Number to add to each z component."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700348summary: Load a translation matrix
349description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700350 This function creates a translation matrix, where a number is added to each element of
351 a vector.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700352
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700353 To translate a vector, multiply the vector by the created matrix using
354 @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700355test: none
356end:
357
358function: rsMatrixMultiply
359t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2
360ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700361arg: #1* m, "Left matrix of the product and the matrix to be set."
362arg: const #1* rhs, "Right matrix of the product."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700363summary: Multiply a matrix by a vector or another matrix
364description:
365 For the matrix by matrix variant, sets m to the matrix product <code>m * rhs</code>.
366
367 When combining two 4x4 transformation matrices using this function, the resulting
368 matrix will correspond to performing the rhs transformation first followed by
369 the original m transformation.
370
371 For the matrix by vector variant, returns the post-multiplication of the vector
372 by the matrix, ie. <code>m * in</code>.
373
374 When multiplying a float3 to a @rs_matrix4x4, the vector is expanded with (1).
375
376 When multiplying a float2 to a @rs_matrix4x4, the vector is expanded with (0, 1).
377
378 When multiplying a float2 to a @rs_matrix3x3, the vector is expanded with (0).
379
380 Starting with API 14, this function takes a const matrix as the first argument.
381test: none
382end:
383
384function: rsMatrixMultiply
385version: 9 13
386ret: float4
387arg: rs_matrix4x4* m
388arg: float4 in
389test: none
390end:
391
392function: rsMatrixMultiply
393version: 9 13
394ret: float4
395arg: rs_matrix4x4* m
396arg: float3 in
397test: none
398end:
399
400function: rsMatrixMultiply
401version: 9 13
402ret: float4
403arg: rs_matrix4x4* m
404arg: float2 in
405test: none
406end:
407
408function: rsMatrixMultiply
409version: 9 13
410ret: float3
411arg: rs_matrix3x3* m
412arg: float3 in
413test: none
414end:
415
416function: rsMatrixMultiply
417version: 9 13
418ret: float3
419arg: rs_matrix3x3* m
420arg: float2 in
421test: none
422end:
423
424function: rsMatrixMultiply
425version: 9 13
426ret: float2
427arg: rs_matrix2x2* m
428arg: float2 in
429test: none
430end:
431
432function: rsMatrixMultiply
433version: 14
434ret: float4
435arg: const rs_matrix4x4* m
436arg: float4 in
437test: none
438end:
439
440function: rsMatrixMultiply
441version: 14
442ret: float4
443arg: const rs_matrix4x4* m
444arg: float3 in
445test: none
446end:
447
448function: rsMatrixMultiply
449version: 14
450ret: float4
451arg: const rs_matrix4x4* m
452arg: float2 in
453test: none
454end:
455
456function: rsMatrixMultiply
457version: 14
458ret: float3
459arg: const rs_matrix3x3* m
460arg: float3 in
461test: none
462end:
463
464function: rsMatrixMultiply
465version: 14
466ret: float3
467arg: const rs_matrix3x3* m
468arg: float2 in
469test: none
470end:
471
472function: rsMatrixMultiply
473version: 14
474ret: float2
475arg: const rs_matrix2x2* m
476arg: float2 in
477test: none
478end:
479
480function: rsMatrixRotate
481ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700482arg: rs_matrix4x4* m, "Matrix to modify."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700483arg: float rot, "How much rotation to do, in degrees."
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700484arg: float x, "X component of the vector that is the axis of rotation."
485arg: float y, "Y component of the vector that is the axis of rotation."
486arg: float z, "Z component of the vector that is the axis of rotation."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700487summary: Apply a rotation to a transformation matrix
488description:
489 Multiply the matrix m with a rotation matrix.
490
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700491 This function modifies a transformation matrix to first do a rotation. The axis of
492 rotation is the <code>(x, y, z)</code> vector.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700493
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700494 To apply this combined transformation to a vector, multiply the vector by the created
495 matrix using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700496test: none
497end:
498
499function: rsMatrixScale
500ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700501arg: rs_matrix4x4* m, "Matrix to modify."
502arg: float x, "Multiple to scale the x components by."
503arg: float y, "Multiple to scale the y components by."
504arg: float z, "Multiple to scale the z components by."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700505summary: Apply a scaling to a transformation matrix
506description:
507 Multiply the matrix m with a scaling matrix.
508
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700509 This function modifies a transformation matrix to first do a scaling. When scaling,
510 each component of a vector is multiplied by a number. This number can be negative.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700511
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700512 To apply this combined transformation to a vector, multiply the vector by the created
513 matrix using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700514test: none
515end:
516
517function: rsMatrixSet
518t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2
519ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700520arg: #1* m, "Matrix that will be modified."
521arg: uint32_t col, "Zero-based column of the element to be set."
522arg: uint32_t row, "Zero-based row of the element to be set."
523arg: float v, "Value to set."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700524summary: Set one element
525description:
526 Set an element of a matrix.
527
528 <b>Warning:</b> The order of the column and row parameters may be unexpected.
529test: none
530end:
531
532function: rsMatrixTranslate
533ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700534arg: rs_matrix4x4* m, "Matrix to modify."
535arg: float x, "Number to add to each x component."
536arg: float y, "Number to add to each y component."
537arg: float z, "Number to add to each z component."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700538summary: Apply a translation to a transformation matrix
539description:
540 Multiply the matrix m with a translation matrix.
541
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700542 This function modifies a transformation matrix to first do a translation. When
543 translating, a number is added to each component of a vector.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700544
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700545 To apply this combined transformation to a vector, multiply the vector by the
546 created matrix using @rsMatrixMultiply().
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700547test: none
548end:
549
550function: rsMatrixTranspose
551t: rs_matrix4x4*, rs_matrix3x3*, rs_matrix2x2*
552ret: void
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700553arg: #1 m, "Matrix to transpose."
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -0700554summary: Transpose a matrix place
555description:
556 Transpose the matrix m in place.
557test: none
558end: