Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 1 | # |
| 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 | |
| 17 | header: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame^] | 18 | summary: Matrix Functions |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 19 | description: |
| 20 | 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 | We use a zero-based index for rows and columns. E.g. the last element of |
| 25 | a @rs_matrix4x4 is found at (3, 3). |
| 26 | |
| 27 | RenderScript uses column-major matrices and column-based vectors. |
| 28 | Transforming a vector is done by postmultiplying the vector, |
| 29 | e.g. <code>(matrix * vector)</code>, as provided by @rsMatrixMultiply(). |
| 30 | |
| 31 | To create a transformation matrix that performs two transformations at |
| 32 | once, multiply the two source matrices, with the first transformation as the |
| 33 | right argument. E.g. to create a transformation matrix that applies the |
| 34 | transformation s1 followed by s2, call <code>rsMatrixLoadMultiply(&combined, &s2, &s1)</code>. |
| 35 | 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: |
| 38 | rsMatrixLoad<i>Transformation</i> and rsMatrix<i>Transformation</i>. The |
| 39 | former style simply stores the transformation matrix in the first argument. |
| 40 | The latter modifies a pre-existing transformation matrix so that the new |
| 41 | transformation happens first. E.g. if you call @rsMatrixTranslate() |
| 42 | on a matrix that already does a scaling, the resulting matrix when applied |
| 43 | to a vector will first do the translation then the scaling. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 44 | include: |
| 45 | #include "rs_vector_math.rsh" |
| 46 | end: |
| 47 | |
| 48 | function: rsExtractFrustumPlanes |
| 49 | # TODO Why always_inline? |
| 50 | attrib: always_inline |
| 51 | ret: void |
| 52 | arg: const rs_matrix4x4* viewProj, "matrix to extract planes from" |
| 53 | arg: float4* left, "left plane" |
| 54 | arg: float4* right, "right plane" |
| 55 | arg: float4* top, "top plane" |
| 56 | arg: float4* bottom, "bottom plane" |
| 57 | arg: float4* near, "near plane" |
| 58 | arg: float4* far, "far plane" |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame^] | 59 | summary: Compute frustum planes |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 60 | description: |
| 61 | Computes 6 frustum planes from the view projection matrix |
| 62 | inline: |
| 63 | // x y z w = a b c d in the plane equation |
| 64 | left->x = viewProj->m[3] + viewProj->m[0]; |
| 65 | left->y = viewProj->m[7] + viewProj->m[4]; |
| 66 | left->z = viewProj->m[11] + viewProj->m[8]; |
| 67 | left->w = viewProj->m[15] + viewProj->m[12]; |
| 68 | |
| 69 | right->x = viewProj->m[3] - viewProj->m[0]; |
| 70 | right->y = viewProj->m[7] - viewProj->m[4]; |
| 71 | right->z = viewProj->m[11] - viewProj->m[8]; |
| 72 | right->w = viewProj->m[15] - viewProj->m[12]; |
| 73 | |
| 74 | top->x = viewProj->m[3] - viewProj->m[1]; |
| 75 | top->y = viewProj->m[7] - viewProj->m[5]; |
| 76 | top->z = viewProj->m[11] - viewProj->m[9]; |
| 77 | top->w = viewProj->m[15] - viewProj->m[13]; |
| 78 | |
| 79 | bottom->x = viewProj->m[3] + viewProj->m[1]; |
| 80 | bottom->y = viewProj->m[7] + viewProj->m[5]; |
| 81 | bottom->z = viewProj->m[11] + viewProj->m[9]; |
| 82 | bottom->w = viewProj->m[15] + viewProj->m[13]; |
| 83 | |
| 84 | near->x = viewProj->m[3] + viewProj->m[2]; |
| 85 | near->y = viewProj->m[7] + viewProj->m[6]; |
| 86 | near->z = viewProj->m[11] + viewProj->m[10]; |
| 87 | near->w = viewProj->m[15] + viewProj->m[14]; |
| 88 | |
| 89 | far->x = viewProj->m[3] - viewProj->m[2]; |
| 90 | far->y = viewProj->m[7] - viewProj->m[6]; |
| 91 | far->z = viewProj->m[11] - viewProj->m[10]; |
| 92 | far->w = viewProj->m[15] - viewProj->m[14]; |
| 93 | |
| 94 | float len = length(left->xyz); |
| 95 | *left /= len; |
| 96 | len = length(right->xyz); |
| 97 | *right /= len; |
| 98 | len = length(top->xyz); |
| 99 | *top /= len; |
| 100 | len = length(bottom->xyz); |
| 101 | *bottom /= len; |
| 102 | len = length(near->xyz); |
| 103 | *near /= len; |
| 104 | len = length(far->xyz); |
| 105 | *far /= len; |
| 106 | test: none |
| 107 | end: |
| 108 | |
| 109 | function: rsIsSphereInFrustum |
| 110 | attrib: always_inline |
| 111 | ret: bool |
| 112 | arg: float4* sphere, "float4 representing the sphere" |
| 113 | arg: float4* left, "left plane" |
| 114 | arg: float4* right, "right plane" |
| 115 | arg: float4* top, "top plane" |
| 116 | arg: float4* bottom, "bottom plane" |
| 117 | arg: float4* near, "near plane" |
| 118 | arg: float4* far, "far plane" |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame^] | 119 | summary: Checks if a sphere is within the frustum planes |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 120 | description: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame^] | 121 | Returns true if the sphere is within the 6 frustum planes. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 122 | inline: |
| 123 | float distToCenter = dot(left->xyz, sphere->xyz) + left->w; |
| 124 | if (distToCenter < -sphere->w) { |
| 125 | return false; |
| 126 | } |
| 127 | distToCenter = dot(right->xyz, sphere->xyz) + right->w; |
| 128 | if (distToCenter < -sphere->w) { |
| 129 | return false; |
| 130 | } |
| 131 | distToCenter = dot(top->xyz, sphere->xyz) + top->w; |
| 132 | if (distToCenter < -sphere->w) { |
| 133 | return false; |
| 134 | } |
| 135 | distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w; |
| 136 | if (distToCenter < -sphere->w) { |
| 137 | return false; |
| 138 | } |
| 139 | distToCenter = dot(near->xyz, sphere->xyz) + near->w; |
| 140 | if (distToCenter < -sphere->w) { |
| 141 | return false; |
| 142 | } |
| 143 | distToCenter = dot(far->xyz, sphere->xyz) + far->w; |
| 144 | if (distToCenter < -sphere->w) { |
| 145 | return false; |
| 146 | } |
| 147 | return true; |
| 148 | test: none |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 149 | end: |
| 150 | |
| 151 | function: rsMatrixGet |
| 152 | t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2 |
| 153 | ret: float |
| 154 | arg: const #1* m, "The matrix to extract the element from." |
| 155 | arg: uint32_t col, "The zero-based column of the element to be extracted." |
| 156 | arg: uint32_t row, "The zero-based row of the element to extracted." |
| 157 | summary: Get one element |
| 158 | description: |
| 159 | Returns one element of a matrix. |
| 160 | |
| 161 | <b>Warning:</b> The order of the column and row parameters may be unexpected. |
| 162 | test: none |
| 163 | end: |
| 164 | |
| 165 | function: rsMatrixInverse |
| 166 | ret: bool |
| 167 | arg: rs_matrix4x4* m, "The matrix to invert." |
| 168 | summary: Inverts a matrix in place |
| 169 | description: |
| 170 | Returns true if the matrix was successfully inverted. |
| 171 | test: none |
| 172 | end: |
| 173 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 174 | function: rsMatrixInverseTranspose |
| 175 | ret: bool |
| 176 | arg: rs_matrix4x4* m, "The matrix to modify." |
| 177 | summary: Inverts and transpose a matrix in place |
| 178 | description: |
| 179 | The matrix is first inverted then transposed. |
| 180 | Returns true if the matrix was successfully inverted. |
| 181 | test: none |
| 182 | end: |
| 183 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 184 | function: rsMatrixLoad |
| 185 | t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2 |
| 186 | ret: void |
| 187 | arg: #1* destination, "The matrix to set." |
| 188 | arg: const float* array, "The array of values to set the matrix to. These arrays should be 4, 9, or 16 floats long, depending on the matrix size." |
| 189 | summary: Load or copy a matrix |
| 190 | description: |
| 191 | Set the elements of a matrix from an array of floats or from another matrix. |
| 192 | |
| 193 | If loading from an array, the floats should be in row-major order, i.e. the element a |
| 194 | <code>row 0, column 0</code> should be first, followed by the element at |
| 195 | <code>row 0, column 1</code>, etc. |
| 196 | |
| 197 | If loading from a matrix and the source is smaller than the destination, the rest of the |
| 198 | destination is filled with elements of the identity matrix. E.g. |
| 199 | loading a rs_matrix2x2 into a rs_matrix4x4 will give: |
| 200 | <table style="max-width:300px"> |
| 201 | <tr><td>m00</td> <td>m01</td> <td>0.0</td> <td>0.0</td></tr> |
| 202 | <tr><td>m10</td> <td>m11</td> <td>0.0</td> <td>0.0</td></tr> |
| 203 | <tr><td>0.0</td> <td>0.0</td> <td>1.0</td> <td>0.0</td></tr> |
| 204 | <tr><td>0.0</td> <td>0.0</td> <td>0.0</td> <td>1.0</td></tr> |
| 205 | </table> |
| 206 | test: none |
| 207 | end: |
| 208 | |
| 209 | function: rsMatrixLoad |
| 210 | t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2 |
| 211 | ret: void |
| 212 | arg: #1* destination |
| 213 | arg: const #1* source, "The source matrix." |
| 214 | test: none |
| 215 | end: |
| 216 | |
| 217 | function: rsMatrixLoad |
| 218 | t: rs_matrix3x3, rs_matrix2x2 |
| 219 | ret: void |
| 220 | arg: rs_matrix4x4* destination |
| 221 | arg: const #1* source |
| 222 | test: none |
| 223 | end: |
| 224 | |
| 225 | function: rsMatrixLoadFrustum |
| 226 | ret: void |
| 227 | arg: rs_matrix4x4* m, "The matrix to set." |
| 228 | arg: float left |
| 229 | arg: float right |
| 230 | arg: float bottom |
| 231 | arg: float top |
| 232 | arg: float near |
| 233 | arg: float far |
| 234 | summary: Load a frustum projection matrix |
| 235 | description: |
| 236 | Constructs a frustum projection matrix, transforming the box |
| 237 | identified by the six clipping planes <code>left, right, bottom, top, |
| 238 | near, far</code>. |
| 239 | |
| 240 | To apply this projection to a vector, multiply the vector by the |
| 241 | created matrix using @rsMatrixMultiply(). |
| 242 | test: none |
| 243 | end: |
| 244 | |
| 245 | function: rsMatrixLoadIdentity |
| 246 | t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2 |
| 247 | ret: void |
| 248 | arg: #1* m, "The matrix to set." |
| 249 | summary: Load identity matrix |
| 250 | description: |
| 251 | Set the elements of a matrix to the identity matrix. |
| 252 | test: none |
| 253 | end: |
| 254 | |
| 255 | function: rsMatrixLoadMultiply |
| 256 | t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2 |
| 257 | ret: void |
| 258 | arg: #1* m, "The matrix to set." |
| 259 | arg: const #1* lhs, "The left matrix of the product." |
| 260 | arg: const #1* rhs, "The right matrix of the product." |
| 261 | summary: Multiply two matrices |
| 262 | description: |
| 263 | Sets m to the matrix product of <code>lhs * rhs</code>. |
| 264 | |
| 265 | To combine two 4x4 transformaton matrices, multiply the second transformation matrix |
| 266 | by the first transformation matrix. E.g. to create a transformation matrix that applies |
| 267 | the transformation s1 followed by s2, call |
| 268 | <code>rsMatrixLoadMultiply(&combined, &s2, &s1)</code>. |
| 269 | |
| 270 | <b>Warning:</b> Prior to version 21, storing the result back into right matrix is not supported and |
| 271 | will result in undefined behavior. Use rsMatrixMulitply instead. E.g. instead of doing |
| 272 | rsMatrixLoadMultiply (&m2r, &m2r, &m2l), use rsMatrixMultiply (&m2r, &m2l). |
| 273 | rsMatrixLoadMultiply (&m2l, &m2r, &m2l) works as expected. |
| 274 | test: none |
| 275 | end: |
| 276 | |
| 277 | function: rsMatrixLoadOrtho |
| 278 | ret: void |
| 279 | arg: rs_matrix4x4* m, "The matrix to set." |
| 280 | arg: float left |
| 281 | arg: float right |
| 282 | arg: float bottom |
| 283 | arg: float top |
| 284 | arg: float near |
| 285 | arg: float far |
| 286 | summary: Load an orthographic projection matrix |
| 287 | description: |
| 288 | Constructs an orthographic projection matrix, transforming the box |
| 289 | identified by the six clipping planes <code>left, right, bottom, top, |
| 290 | near, far</code> into a unit cube with a corner at |
| 291 | <code>(-1, -1, -1)</code> and the opposite at <code>(1, 1, 1)</code>. |
| 292 | |
| 293 | To apply this projection to a vector, multiply the vector by the |
| 294 | created matrix using @rsMatrixMultiply(). |
| 295 | |
| 296 | See https://en.wikipedia.org/wiki/Orthographic_projection . |
| 297 | test: none |
| 298 | end: |
| 299 | |
| 300 | function: rsMatrixLoadPerspective |
| 301 | ret: void |
| 302 | arg: rs_matrix4x4* m, "The matrix to set." |
| 303 | arg: float fovy, "Field of view, in degrees along the Y axis." |
| 304 | arg: float aspect, "Ratio of x / y." |
| 305 | arg: float near, "The near clipping plane." |
| 306 | arg: float far, "The far clipping plane." |
| 307 | summary: Load a perspective projection matrix |
| 308 | description: |
| 309 | Constructs a perspective projection matrix, assuming a symmetrical field of view. |
| 310 | |
| 311 | To apply this projection to a vector, multiply the vector by the |
| 312 | created matrix using @rsMatrixMultiply(). |
| 313 | test: none |
| 314 | end: |
| 315 | |
| 316 | function: rsMatrixLoadRotate |
| 317 | ret: void |
| 318 | arg: rs_matrix4x4* m, "The matrix to set." |
| 319 | arg: float rot, "How much rotation to do, in degrees." |
| 320 | arg: float x, "The x component of the vector that is the axis of rotation." |
| 321 | arg: float y, "The y component of the vector that is the axis of rotation." |
| 322 | arg: float z, "The z component of the vector that is the axis of rotation." |
| 323 | summary: Load a rotation matrix |
| 324 | description: |
| 325 | This function creates a rotation matrix. The axis of rotation is the |
| 326 | <code>(x, y, z)</code> vector. |
| 327 | |
| 328 | To rotate a vector, multiply the vector by the created matrix |
| 329 | using @rsMatrixMultiply(). |
| 330 | |
| 331 | See http://en.wikipedia.org/wiki/Rotation_matrix . |
| 332 | test: none |
| 333 | end: |
| 334 | |
| 335 | function: rsMatrixLoadScale |
| 336 | ret: void |
| 337 | arg: rs_matrix4x4* m, "The matrix to set." |
| 338 | arg: float x, "The multiple to scale the x components by." |
| 339 | arg: float y, "The multiple to scale the y components by." |
| 340 | arg: float z, "The multiple to scale the z components by." |
| 341 | summary: Load a scaling matrix |
| 342 | description: |
| 343 | This function creates a scaling matrix, where each component of a |
| 344 | vector is multiplied by a number. This number can be negative. |
| 345 | |
| 346 | To scale a vector, multiply the vector by the created matrix |
| 347 | using @rsMatrixMultiply(). |
| 348 | test: none |
| 349 | end: |
| 350 | |
| 351 | function: rsMatrixLoadTranslate |
| 352 | ret: void |
| 353 | arg: rs_matrix4x4* m, "The matrix to set." |
| 354 | arg: float x, "The number to add to each x component." |
| 355 | arg: float y, "The number to add to each y component." |
| 356 | arg: float z, "The number to add to each z component." |
| 357 | summary: Load a translation matrix |
| 358 | description: |
| 359 | This function creates a translation matrix, where a |
| 360 | number is added to each element of a vector. |
| 361 | |
| 362 | To translate a vector, multiply the vector by the created matrix |
| 363 | using @rsMatrixMultiply(). |
| 364 | test: none |
| 365 | end: |
| 366 | |
| 367 | function: rsMatrixMultiply |
| 368 | t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2 |
| 369 | ret: void |
| 370 | arg: #1* m, "The left matrix of the product and the matrix to be set." |
| 371 | arg: const #1* rhs, "The right matrix of the product." |
| 372 | summary: Multiply a matrix by a vector or another matrix |
| 373 | description: |
| 374 | For the matrix by matrix variant, sets m to the matrix product <code>m * rhs</code>. |
| 375 | |
| 376 | When combining two 4x4 transformation matrices using this function, the resulting |
| 377 | matrix will correspond to performing the rhs transformation first followed by |
| 378 | the original m transformation. |
| 379 | |
| 380 | For the matrix by vector variant, returns the post-multiplication of the vector |
| 381 | by the matrix, ie. <code>m * in</code>. |
| 382 | |
| 383 | When multiplying a float3 to a @rs_matrix4x4, the vector is expanded with (1). |
| 384 | |
| 385 | When multiplying a float2 to a @rs_matrix4x4, the vector is expanded with (0, 1). |
| 386 | |
| 387 | When multiplying a float2 to a @rs_matrix3x3, the vector is expanded with (0). |
| 388 | |
| 389 | Starting with API 14, this function takes a const matrix as the first argument. |
| 390 | test: none |
| 391 | end: |
| 392 | |
| 393 | function: rsMatrixMultiply |
| 394 | version: 9 13 |
| 395 | ret: float4 |
| 396 | arg: rs_matrix4x4* m |
| 397 | arg: float4 in |
| 398 | test: none |
| 399 | end: |
| 400 | |
| 401 | function: rsMatrixMultiply |
| 402 | version: 9 13 |
| 403 | ret: float4 |
| 404 | arg: rs_matrix4x4* m |
| 405 | arg: float3 in |
| 406 | test: none |
| 407 | end: |
| 408 | |
| 409 | function: rsMatrixMultiply |
| 410 | version: 9 13 |
| 411 | ret: float4 |
| 412 | arg: rs_matrix4x4* m |
| 413 | arg: float2 in |
| 414 | test: none |
| 415 | end: |
| 416 | |
| 417 | function: rsMatrixMultiply |
| 418 | version: 9 13 |
| 419 | ret: float3 |
| 420 | arg: rs_matrix3x3* m |
| 421 | arg: float3 in |
| 422 | test: none |
| 423 | end: |
| 424 | |
| 425 | function: rsMatrixMultiply |
| 426 | version: 9 13 |
| 427 | ret: float3 |
| 428 | arg: rs_matrix3x3* m |
| 429 | arg: float2 in |
| 430 | test: none |
| 431 | end: |
| 432 | |
| 433 | function: rsMatrixMultiply |
| 434 | version: 9 13 |
| 435 | ret: float2 |
| 436 | arg: rs_matrix2x2* m |
| 437 | arg: float2 in |
| 438 | test: none |
| 439 | end: |
| 440 | |
| 441 | function: rsMatrixMultiply |
| 442 | version: 14 |
| 443 | ret: float4 |
| 444 | arg: const rs_matrix4x4* m |
| 445 | arg: float4 in |
| 446 | test: none |
| 447 | end: |
| 448 | |
| 449 | function: rsMatrixMultiply |
| 450 | version: 14 |
| 451 | ret: float4 |
| 452 | arg: const rs_matrix4x4* m |
| 453 | arg: float3 in |
| 454 | test: none |
| 455 | end: |
| 456 | |
| 457 | function: rsMatrixMultiply |
| 458 | version: 14 |
| 459 | ret: float4 |
| 460 | arg: const rs_matrix4x4* m |
| 461 | arg: float2 in |
| 462 | test: none |
| 463 | end: |
| 464 | |
| 465 | function: rsMatrixMultiply |
| 466 | version: 14 |
| 467 | ret: float3 |
| 468 | arg: const rs_matrix3x3* m |
| 469 | arg: float3 in |
| 470 | test: none |
| 471 | end: |
| 472 | |
| 473 | function: rsMatrixMultiply |
| 474 | version: 14 |
| 475 | ret: float3 |
| 476 | arg: const rs_matrix3x3* m |
| 477 | arg: float2 in |
| 478 | test: none |
| 479 | end: |
| 480 | |
| 481 | function: rsMatrixMultiply |
| 482 | version: 14 |
| 483 | ret: float2 |
| 484 | arg: const rs_matrix2x2* m |
| 485 | arg: float2 in |
| 486 | test: none |
| 487 | end: |
| 488 | |
| 489 | function: rsMatrixRotate |
| 490 | ret: void |
| 491 | arg: rs_matrix4x4* m, "The matrix to modify." |
| 492 | arg: float rot, "How much rotation to do, in degrees." |
| 493 | arg: float x, "The x component of the vector that is the axis of rotation." |
| 494 | arg: float y, "The y component of the vector that is the axis of rotation." |
| 495 | arg: float z, "The z component of the vector that is the axis of rotation." |
| 496 | summary: Apply a rotation to a transformation matrix |
| 497 | description: |
| 498 | Multiply the matrix m with a rotation matrix. |
| 499 | |
| 500 | This function modifies a transformation matrix to first do a rotation. |
| 501 | The axis of rotation is the <code>(x, y, z)</code> vector. |
| 502 | |
| 503 | To apply this combined transformation to a vector, multiply |
| 504 | the vector by the created matrix using @rsMatrixMultiply(). |
| 505 | test: none |
| 506 | end: |
| 507 | |
| 508 | function: rsMatrixScale |
| 509 | ret: void |
| 510 | arg: rs_matrix4x4* m, "The matrix to modify." |
| 511 | arg: float x, "The multiple to scale the x components by." |
| 512 | arg: float y, "The multiple to scale the y components by." |
| 513 | arg: float z, "The multiple to scale the z components by." |
| 514 | summary: Apply a scaling to a transformation matrix |
| 515 | description: |
| 516 | Multiply the matrix m with a scaling matrix. |
| 517 | |
| 518 | This function modifies a transformation matrix to first do a scaling. |
| 519 | When scaling, each component of a vector is multiplied by a number. |
| 520 | This number can be negative. |
| 521 | |
| 522 | To apply this combined transformation to a vector, multiply |
| 523 | the vector by the created matrix using @rsMatrixMultiply(). |
| 524 | test: none |
| 525 | end: |
| 526 | |
| 527 | function: rsMatrixSet |
| 528 | t: rs_matrix4x4, rs_matrix3x3, rs_matrix2x2 |
| 529 | ret: void |
| 530 | arg: #1* m, "The matrix that will be modified." |
| 531 | arg: uint32_t col, "The zero-based column of the element to be set." |
| 532 | arg: uint32_t row, "The zero-based row of the element to be set." |
| 533 | arg: float v, "The value to set." |
| 534 | summary: Set one element |
| 535 | description: |
| 536 | Set an element of a matrix. |
| 537 | |
| 538 | <b>Warning:</b> The order of the column and row parameters may be unexpected. |
| 539 | test: none |
| 540 | end: |
| 541 | |
| 542 | function: rsMatrixTranslate |
| 543 | ret: void |
| 544 | arg: rs_matrix4x4* m, "The matrix to modify." |
| 545 | arg: float x, "The number to add to each x component." |
| 546 | arg: float y, "The number to add to each y component." |
| 547 | arg: float z, "The number to add to each z component." |
| 548 | summary: Apply a translation to a transformation matrix |
| 549 | description: |
| 550 | Multiply the matrix m with a translation matrix. |
| 551 | |
| 552 | This function modifies a transformation matrix to first |
| 553 | do a translation. When translating, a number is added |
| 554 | to each component of a vector. |
| 555 | |
| 556 | To apply this combined transformation to a vector, multiply |
| 557 | the vector by the created matrix using @rsMatrixMultiply(). |
| 558 | test: none |
| 559 | end: |
| 560 | |
| 561 | function: rsMatrixTranspose |
| 562 | t: rs_matrix4x4*, rs_matrix3x3*, rs_matrix2x2* |
| 563 | ret: void |
| 564 | arg: #1 m, "The matrix to transpose." |
| 565 | summary: Transpose a matrix place |
| 566 | description: |
| 567 | Transpose the matrix m in place. |
| 568 | test: none |
| 569 | end: |