SH4ZAM! 0.1.0
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz_xmtrx.h
Go to the documentation of this file.
1/*! \file
2 * \brief Active Matrix API.
3 * \ingroup xmtrx
4 *
5 * This file provides an API built around manipulating and performing
6 * calculations using the SH4's "current" 4x4 matrix, which is held within
7 * a secondary back-bank of 16 single-precision floating-point registers.
8 *
9 * \todo
10 * - shz_xmtrx_xxx_fft()
11 * - shz_xmtrx_invert() (within XMTRX)
12 * - shz_xmtrx_position()
13 * - shz_xmtrx_size()
14 * - shz_xmtrx_angles()
15 * - shz_xmtrx_init_rotation_quat() (within XMTRX)
16 * - shz_xmtrx_apply_store_4x4()
17 *
18 * \author 2025, 2026 Falco Girgis
19 * \author 2025 Twada
20 * \author 2026 TapamN
21 *
22 * \copyright MIT License
23 */
24
25#ifndef SHZ_XMTRX_H
26#define SHZ_XMTRX_H
27
28#include "shz_vector.h"
29#include "shz_quat.h"
30
31/*! \defgroup xmtrx XMTRX
32 \brief API for managing the SH4's "active matrix."
33
34 `XMTRX` is the name given to identify the 16 FP registers contained
35 within the back-bank of the SH4's FPU. These 16 registers combine
36 to represent the SH4's 4x4 "active matrix," which can be subsequently
37 transformed against using the `FTRV` instruction (shz_xmtrx_trans_vec4()).
38
39 For maximum FP performance on the SH4, strategic usage of `XMTRX` to batch
40 transform operations together without having reload FP registers, is key.
41
42 Typically, for one-off operations, the in-memory API for \ref matrix is
43 what should be used; however, when operations can be batched, using `XMTRX`
44 to hold your matrix within registers is going to give the best performance.
45
46 Examples of such scenarios are:
47 - Applying multiple operations to a source matrix before storing the result.
48 - Transforming batches of vectors against a single matrix.
49
50 \sa matrix
51 */
52
53SHZ_DECLS_BEGIN
54
55/*! \cond Forward Declarations */
56SHZ_DECLARE_STRUCT_ALIGNED(shz_mat2x2, shz_mat2x2_t, 8);
58SHZ_DECLARE_STRUCT (shz_mat3x3, shz_mat3x3_t);
59SHZ_DECLARE_STRUCT (shz_mat4x3, shz_mat4x3_t);
60SHZ_DECLARE_STRUCT (shz_mat3x4, shz_mat3x4_t);
61/*! \endcond */
62
63//! Registers comprising XMTRX, in the FPU back-bank.
64typedef enum shz_xmtrx_reg {
65 SHZ_XMTRX_XF0, //!< FP register `xf0`.
66 SHZ_XMTRX_XF1, //!< FP register `xf1`.
67 SHZ_XMTRX_XF2, //!< FP register `xf2`.
68 SHZ_XMTRX_XF3, //!< FP register `xf3`.
69 SHZ_XMTRX_XF4, //!< FP register `xf4`.
70 SHZ_XMTRX_XF5, //!< FP register `xf5`.
71 SHZ_XMTRX_XF6, //!< FP register `xf6`.
72 SHZ_XMTRX_XF7, //!< FP register `xf7`.
73 SHZ_XMTRX_XF8, //!< FP register `xf8`.
74 SHZ_XMTRX_XF9, //!< FP register `xf9`.
75 SHZ_XMTRX_XF10, //!< FP register `xf10`.
76 SHZ_XMTRX_XF11, //!< FP register `xf11`.
77 SHZ_XMTRX_XF12, //!< FP register `xf12`.
78 SHZ_XMTRX_XF13, //!< FP register `xf13`.
79 SHZ_XMTRX_XF14, //!< FP register `xf14`.
80 SHZ_XMTRX_XF15 //!< FP register `xf15`.
81} shz_xmtrx_reg_t, shz_xmtrx_reg;
82
83/*! \name Accessors
84 \brief Setting and retrieving individual XMTRX register values.
85 @{
86*/
87
88//! Returns the floating-point value held within the given XMTRX register.
89SHZ_INLINE float shz_xmtrx_read(shz_xmtrx_reg_t xf) SHZ_NOEXCEPT;
90
91//! Sets the floating-point value held within the given XMTRX register to \p value.
92SHZ_INLINE void shz_xmtrx_write(shz_xmtrx_reg_t xf, float value) SHZ_NOEXCEPT;
93
94//! Returns the values at the the given row \p index, as a 4D vector.
95SHZ_INLINE shz_vec4_t shz_xmtrx_read_row(unsigned int index) SHZ_NOEXCEPT;
96
97//! Returns the values at the given column \p index, as a 4D vector.
98SHZ_INLINE shz_vec4_t shz_xmtrx_read_col(unsigned int index) SHZ_NOEXCEPT;
99
100//! Sets the values at the given row \p index to the given 4D vector.
101SHZ_INLINE void shz_xmtrx_write_row(unsigned int index, shz_vec4_t vector) SHZ_NOEXCEPT;
102
103//! Sets the values at the given column \p index to the given 4D vector.
104SHZ_INLINE void shz_xmtrx_write_col(unsigned int index, shz_vec4_t vector) SHZ_NOEXCEPT;
105
106//! Swaps the values of the rows with the given indices.
107SHZ_INLINE void shz_xmtrx_swap_rows(unsigned int index1, unsigned int index2) SHZ_NOEXCEPT;
108
109//! Swaps the values of the columns with the given indices.
110SHZ_INLINE void shz_xmtrx_swap_cols(unsigned int index1, unsigned int index2) SHZ_NOEXCEPT;
111
112//! @}
113
114/*! \name Loading
115 \brief Routines for loading XMTRX contents from memory.
116 @{
117*/
118
119//! Loads the given 4x4 matrix as XMTRX.
120SHZ_INLINE void shz_xmtrx_load_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
121
122//! Loads the given 4x4 matrix as XMTRX, with the 4th column for translation being loaded as the first column.
123SHZ_INLINE void shz_xmtrx_load_wxyz_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
124
125//! Loads the given array of unaligned 16 float values as the 4x4 XMTRX matrix.
126SHZ_INLINE void shz_xmtrx_load_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT;
127
128//! Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D column vectors.
129SHZ_INLINE void shz_xmtrx_load_cols_4x4(const shz_vec4_t* c1,
130 const shz_vec4_t* c2,
131 const shz_vec4_t* c3,
132 const shz_vec4_t* c4) SHZ_NOEXCEPT;
133
134//! Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D row vectors.
135SHZ_INLINE void shz_xmtrx_load_rows_4x4(const shz_vec4_t* r1,
136 const shz_vec4_t* r2,
137 const shz_vec4_t* r3,
138 const shz_vec4_t* r4) SHZ_NOEXCEPT;
139
140//! Loads XMTRX with the transpose of the given 4x4 matrix.
141SHZ_INLINE void shz_xmtrx_load_transpose_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
142
143//! Loads XMTRX with the transpose of the 4x4 matrix created from the given unaligned array of 16 floats.
144SHZ_FORCE_INLINE void shz_xmtrx_load_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT;
145
146//! Loads the given 3x4 matrix into XMTRX, initializing its remaining elements to identity.
147SHZ_INLINE void shz_xmtrx_load_3x4(const shz_mat3x4_t* matrix) SHZ_NOEXCEPT;
148
149/*! Loads the 3x4 matrix formed from the given 3 4D column vectors into XMTRX.
150
151 All remaining elements are initialized to identity matrix values.
152
153 \sa shz_xmtrx_load_rows_3x4()
154*/
155SHZ_INLINE void shz_xmtrx_load_cols_4x3(const shz_vec4_t* c1,
156 const shz_vec4_t* c2,
157 const shz_vec4_t* c3) SHZ_NOEXCEPT;
158
159/*! Loads the 3x4 matrix formed from the given 3 4D row vectors into XMTRX.
160
161 All remaining elements are initialized to identity matrix values.
162
163 \sa shz_xmtrx_load_cols_3x4()
164*/
165SHZ_INLINE void shz_xmtrx_load_rows_3x4(const shz_vec4_t* r1,
166 const shz_vec4_t* r2,
167 const shz_vec4_t* r3) SHZ_NOEXCEPT;
168
169//! Loads the given 3x3 matrix into XMTRX, initalizing its remaining elements to identity.
170SHZ_INLINE void shz_xmtrx_load_3x3(const shz_mat3x3_t* matrix) SHZ_NOEXCEPT;
171
172//! Loads the transpose of the given 3x3 matrix into XMTRX, initializing its remaining elements to identity.
173SHZ_INLINE void shz_xmtrx_load_transpose_3x3(const float* matrix) SHZ_NOEXCEPT;
174
175//! Loads the given 2x2 matrix into XMTRX, initializing its remaining elements to identity.
176SHZ_INLINE void shz_xmtrx_load_2x2(const shz_mat2x2_t* matrix) SHZ_NOEXCEPT;
177
178//! @}
179
180/*! \name Storing
181 \brief Routines for saving XMTRX contents to memory.
182 @{
183*/
184
185//! Stores the current values held within XMTRX into the given 4x4 matrix.
186SHZ_INLINE void shz_xmtrx_store_4x4(shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
187
188//! Stores the current values held within XMTRX into the given unaligned 16-float array.
189SHZ_INLINE void shz_xmtrx_store_unaligned_4x4(float matrix[16]) SHZ_NOEXCEPT;
190
191//! Stores the transpose of the current values held within XMTRX into the given 4x4 matrix.
192SHZ_INLINE void shz_xmtrx_store_transpose_4x4(shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
193
194//! Stores the transpose of the the current values held within XMTRX into the given 16-element float array.
195SHZ_FORCE_INLINE void shz_xmtrx_store_transpose_unaligned_4x4(float matrix[16]) SHZ_NOEXCEPT;
196
197//! Stores the top-left 3x4 values currently held within XMTRX into the given matrix.
198SHZ_INLINE void shz_xmtrx_store_3x4(shz_mat3x4_t* matrix) SHZ_NOEXCEPT;
199
200//! Stores the top-left 3x3 values currently held within XMTRX into the given matrix.
201SHZ_INLINE void shz_xmtrx_store_3x3(shz_mat3x3_t* matrix) SHZ_NOEXCEPT;
202
203//! Stores the transpose of the top-left 3x3 values currently held within XMTRX into the given matrix.
204SHZ_INLINE void shz_xmtrx_store_transpose_3x3(shz_mat3x3_t* matrix) SHZ_NOEXCEPT;
205
206//! Stores the top-left 2x2 values currently held within XMTRX into the given matrix.
207SHZ_INLINE void shz_xmtrx_store_2x2(shz_mat2x2_t* matrix) SHZ_NOEXCEPT;
208
209//! @}
210
211/*! \name Initialization
212 \brief Routines used to initialize the entirety of XMTRX.
213 @{
214*/
215
216/*! Quickly initializes XMTRX to be a 4D identity matrix.
217
218 \warning This routine will not properly zero-out NaN values!
219
220 \sa shz_xmtrx_init_identity_safe()
221*/
222SHZ_INLINE void shz_xmtrx_init_identity(void) SHZ_NOEXCEPT;
223
224/*! Safely initializes XMTRX to be a 4D identity matrix.
225
226 This routine is guaranteed to properly initialize XMTRX, regardless of NaN values.
227
228 \sa shz_xmtrx_init_identity()
229*/
230SHZ_INLINE void shz_xmtrx_init_identity_safe(void) SHZ_NOEXCEPT;
231
232//! Initializes XMTRX to contain the value of 0.0f for each element.
233SHZ_INLINE void shz_xmtrx_init_zero(void) SHZ_NOEXCEPT;
234
235//! Initializes XMTRX to contain the value of 1.0f for each element.
236SHZ_INLINE void shz_xmtrx_init_one(void) SHZ_NOEXCEPT;
237
238//! Initializes XMTRX to contain the given \p value for each element.
239SHZ_INLINE void shz_xmtrx_init_fill(float value) SHZ_NOEXCEPT;
240
241//! Initializes XMTRX to be a 3D translation matrix to the given coordinates.
242SHZ_INLINE void shz_xmtrx_init_translation(float x, float y, float z) SHZ_NOEXCEPT;
243
244//! Initializes XMTRX to be a 3D scale matrix with the given dimensions.
245SHZ_FORCE_INLINE void shz_xmtrx_init_scale(float x, float y, float z) SHZ_NOEXCEPT;
246
247//! Initializes XMTRX to be a 3D rotation matrix by \p x radians about the X axis.
248SHZ_INLINE void shz_xmtrx_init_rotation_x(float x) SHZ_NOEXCEPT;
249
250//! Initializes XMTRX to be a 3D rotation matrix by \p y radians about the Y axis.
251SHZ_INLINE void shz_xmtrx_init_rotation_y(float y) SHZ_NOEXCEPT;
252
253//! Initializes XMTRX to be a 3D rotation matrix by \p z radians about the Z axis.
254SHZ_INLINE void shz_xmtrx_init_rotation_z(float z) SHZ_NOEXCEPT;
255
256/*! Initializes XMTRX to be a 3D X-Y-Z rotation matrix, with the corresponding angles given in radians.
257
258 \note
259 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
260
261 \sa shz_xmtrx_init_rotation_zyx(), shz_xmtrx_init_rotation_yxz()
262*/
263SHZ_INLINE void shz_xmtrx_init_rotation_xyz(float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT;
264
265/*! Initializes XMTRX to be a 3D Z-Y-X rotation matrix, with the corresponding angles given in radians.
266
267 \note
268 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
269
270 \sa shz_xmtrx_init_rotation_xyz(), shz_xmtrx_init_rotation_yxz()
271*/
272SHZ_INLINE void shz_xmtrx_init_rotation_zyx(float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT;
273
274/*! Initializes XMTRX to be a 3D Z-X-Y rotation matrix, with the corresponding angles given in radians.
275
276 \note
277 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
278
279 \sa shz_xmtrx_init_rotation_zyx(), shz_xmtrx_init_rotation_yxz()
280*/
281SHZ_INLINE void shz_xmtrx_init_rotation_zxy(float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT;
282
283/*! Initializes XMTRX to be a 3D Y-X-Z rotation matrix, with the corresponding angles given in radians.
284
285 \note
286 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
287
288 \sa shz_xmtrx_init_rotation_yxz(), shz_xmtrx_init_rotation_xyz()
289*/
290SHZ_INLINE void shz_xmtrx_init_rotation_yxz(float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT;
291
292//! Initializes XMTRX to a 3D rotation matrix of \p angle radians about the given \p axis.
293SHZ_INLINE void shz_xmtrx_init_rotation(float angle, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT;
294
295//! Initializes XMTRX to be a diagonal matrix with the given diagonal values.
296SHZ_INLINE void shz_xmtrx_init_diagonal(float x, float y, float z, float w) SHZ_NOEXCEPT;
297
298//! Initializes XMTRX to be an upper triangular matrix with the given column values.
299SHZ_INLINE void shz_xmtrx_init_upper_triangular(float col1, shz_vec2_t col2, shz_vec3_t col3, shz_vec4_t col4) SHZ_NOEXCEPT;
300
301//! Initializes XMTRX to be a lower triangular matrix with the given column values.
302SHZ_INLINE void shz_xmtrx_init_lower_triangular(shz_vec4_t col1, shz_vec3_t col2, shz_vec2_t col3, float col4) SHZ_NOEXCEPT;
303
304//! Initializes XMTRX to be the 3D symmetric skew matrix formed from the given vector components.
305SHZ_INLINE void shz_xmtrx_init_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT;
306
307//! Initializes XMTRX to the 4D matrix resulting from taking the outer product of the two 4D vectors.
308SHZ_INLINE void shz_xmtrx_init_outer_product(shz_vec4_t x, shz_vec4_t y) SHZ_NOEXCEPT;
309
310//! Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order.
311SHZ_INLINE void shz_xmtrx_init_permutation_wxyz(void) SHZ_NOEXCEPT;
312
313//! Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in YZWX order.
314SHZ_INLINE void shz_xmtrx_init_permutation_yzwx(void) SHZ_NOEXCEPT;
315
316/*! Initializes XMTRX to the viewport matrix with the given dimensions.
317
318 fr[n + 0] | fr[n + 4] | fr[n + 8] | fr[n + 12]
319 -----------|-----------|-----------|-----------
320 w*0.5f | 0.0f | 0.0f | w*0.5f
321 0.0f | -h*0.5f | 0.0f | h*0.5f
322 0.0f | 0.0f | 1.0f | 0.0f
323 0.0f | 0.0f | 0.0f | 1.0f
324*/
325SHZ_INLINE void shz_xmtrx_init_screen(float width, float height) SHZ_NOEXCEPT;
326
327/*! Initializes XMTRX to a "lookAt" view matrix, equivalent to gluLookAt().
328
329 \warning This routine clobbers any previous XMTRX contents.
330*/
331SHZ_INLINE void shz_xmtrx_init_lookat(shz_vec3_t eye, shz_vec3_t center, shz_vec3_t up) SHZ_NOEXCEPT;
332
333/*! Initializes XMTRX to an orthographic projection matrix, equivalent to glOrtho().
334
335 \warning This routine clobbers any previous XMTRX contents.
336*/
337SHZ_INLINE void shz_xmtrx_init_ortho(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT;
338
339/*! Initializes XMTRX to a frustum projection matrix, equivalent to glFrustum().
340
341 \warning This routine clobbers any previous XMTRX contents.
342*/
343SHZ_INLINE void shz_xmtrx_init_frustum(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT;
344
345/*! Initializes XMTRX to a perspective projection matrix.
346
347 \warning This routine clobbers any previous XMTRX contents.
348*/
349SHZ_INLINE void shz_xmtrx_init_perspective(float fov, float aspect, float near_z) SHZ_NOEXCEPT;
350
351/*! Initializes XMTRX to a 3D rotation matrix with its orientation given by a quaternion.
352
353 \warning This routine clobbers any previous XMTRX contents.
354 \warning This routine is out-of-line.
355*/
356void shz_xmtrx_init_rotation_quat(shz_quat_t q) SHZ_NOEXCEPT;
357
358//! @}
359
360/*! \name Apply Operation
361 \brief Updates only relevant values of XMTRX based on the given transform.
362 @{
363*/
364
365//! Multiplies and accumulates the given 4x4 matrix onto XMTRX.
366SHZ_INLINE void shz_xmtrx_apply_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
367
368//! Multiplies and accumulates the given 16-entry float array as a 4x4 matrix onto XMTRX.
369SHZ_INLINE void shz_xmtrx_apply_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT;
370
371//! Multiplies and accumulates the transpose of the given 4x4 matrix onto XMTRX.
372SHZ_INLINE void shz_xmtrx_apply_transpose_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
373
374//! Multiplies and accumulates the transpose of the given 16-entry float array as a 4x4 matrix onto XMTRX.
375SHZ_FORCE_INLINE void shz_xmtrx_apply_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT;
376
377//! Multiplies and accumulates XMTRX onto \p matrix, storing the result as XMTRX.
378SHZ_INLINE void shz_xmtrx_apply_reverse_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
379
380//! Multiplies and accumulates XMTRX onto the given float array as a 4x4 matrix, storing the result as XMTRX.
381SHZ_INLINE void shz_xmtrx_apply_reverse_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT;
382
383//! Multiplies and accumulates XMTRX onto the transpose of \p matrix, storing the result as XMTRX.
384SHZ_INLINE void shz_xmtrx_apply_reverse_transpose_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT;
385
386//! Multiplies and accumulates XMTRX onto the transpose of the given float array as a 4x4 matrix, storing the result as XMTRX.
387SHZ_INLINE void shz_xmtrx_apply_reverse_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT;
388
389//! Multiplies and accumulates the given 3x4 matrix onto XMTRX, not modifying other elements.
390SHZ_INLINE void shz_xmtrx_apply_3x4(const shz_mat3x4_t* matrix) SHZ_NOEXCEPT;
391
392//! Multiplies and accumulates the given 3x3 matrix onto XMTRX, not modifying other elements.
393SHZ_INLINE void shz_xmtrx_apply_3x3(const shz_mat3x3_t* matrix) SHZ_NOEXCEPT;
394
395//! Multiplies and accumulateas the transpose of the given 3x3 matrix onto XMTRX, not modifying other elements.
396SHZ_INLINE void shz_xmtrx_apply_transpose_3x3(const shz_mat3x3_t* matrix) SHZ_NOEXCEPT;
397
398//! Multiplies and accumulates the given 2x2 matrix onto XMTRX, not modifying other elements.
399SHZ_INLINE void shz_xmtrx_apply_2x2(const shz_mat2x2_t* matrix) SHZ_NOEXCEPT;
400
401//! Adds the values of the given 3 components to the 3D translation components of XMTRX.
402SHZ_INLINE void shz_xmtrx_apply_translation(float x, float y, float z) SHZ_NOEXCEPT;
403
404//! Multiplies the values of the inner 3x3 matrix by the given 3D scaling terms.
405SHZ_INLINE void shz_xmtrx_apply_scale(float x, float y, float z) SHZ_NOEXCEPT;
406
407//! Transforms the values of the inner 3x3 matrix by a rotation matrix of \p x radians about the X axis.
408SHZ_INLINE void shz_xmtrx_apply_rotation_x(float x) SHZ_NOEXCEPT;
409
410//! Transforms the values of the inner 3x3 matrix by a rotation matrix of \p y radians about the Y axis.
411SHZ_INLINE void shz_xmtrx_apply_rotation_y(float y) SHZ_NOEXCEPT;
412
413//! Transforms the values of the inner 3x3 matrix by a rotation matrix of \p z radians about the Z axis.
414SHZ_INLINE void shz_xmtrx_apply_rotation_z(float z) SHZ_NOEXCEPT;
415
416/*! Multiplies and accumulates XMTRX by a 3D X-Y-Z rotation matrix, with the corresponding angles given in radians.
417
418 The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components.
419
420 \note
421 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
422
423 \sa shz_xmtrx_apply_rotation_zyx(), shz_xmtrx_apply_rotation_yxz()
424*/
425SHZ_INLINE void shz_xmtrx_apply_rotation_xyz(float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT;
426
427/*! Multiplies and accumulates XMTRX by a 3D Z-Y-X rotation matrix, with the corresponding angles given in radians.
428
429 The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components.
430
431 \note
432 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
433
434 \sa shz_xmtrx_apply_rotation_xyz(), shz_xmtrx_apply_rotation_yxz()
435*/
436SHZ_INLINE void shz_xmtrx_apply_rotation_zyx(float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT;
437
438/*! Multiplies and accumulates XMTRX by a 3D Z-X-Y rotation matrix, with the corresponding angles given in radians.
439
440 The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components.
441
442 \note
443 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
444
445 \sa shz_xmtrx_apply_rotation_zyx(), shz_xmtrx_apply_rotation_yxz()
446*/
447SHZ_INLINE void shz_xmtrx_apply_rotation_zxy(float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT;
448
449/*! Multiplies and accumulates XMTRX by a 3D Y-X-Z rotation matrix, with the corresponding angles given in radians.
450
451 The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components.
452
453 \note
454 The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation.
455
456 \sa shz_xmtrx_apply_rotation_xyz(), shz_xmtrx_apply_rotation_zyx()
457*/
458SHZ_INLINE void shz_xmtrx_apply_rotation_yxz(float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT;
459
460//! Transforms the values of the inner 3x3 matrix by a rotation matrix of \p angle radians about the axis with the given components.
461SHZ_INLINE void shz_xmtrx_apply_rotation(float angle, float x, float y, float z) SHZ_NOEXCEPT;
462
463//! Transforms the values of the inner 3x3 matrix by the rotation matrix represented by the given quaternion.
464SHZ_INLINE void shz_xmtrx_apply_rotation_quat(shz_quat_t quat) SHZ_NOEXCEPT;
465
466//! Applies the 3D "lookAt" matrix constructed with the given vector components onto XMTRX. Equivalent to gluLookAt().
467SHZ_INLINE void shz_xmtrx_apply_lookat(shz_vec3_t eye, shz_vec3_t center, shz_vec3_t up) SHZ_NOEXCEPT;
468
469//! Applies a 2D orthographic projection matrix onto XMTRX, equivalent to glOrtho().
470SHZ_INLINE void shz_xmtrx_apply_ortho(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT;
471
472//! Applies a frustum projection matrix onto XMTRX, equivalent to glFrustum().
473SHZ_INLINE void shz_xmtrx_apply_frustum(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT;
474
475/*! Multiplies and accumulates the perspective matrix constructed from the given values onto XMTRX.
476
477 fr[n + 0] | fr[n + 4] | fr[n + 8] | fr[n + 12]
478 -----------|-----------|-----------|-----------
479 cot(f)/a | 0.0f | 0.0f | 0.0f
480 0.0f | cot(f) | 0.0f | 0.0f
481 0.0f | 0.0f | 0.0f | nz
482 0.0f | 0.0f | -1.0f | 0.0f
483*/
484SHZ_INLINE void shz_xmtrx_apply_perspective(float fov, float aspect, float near_z) SHZ_NOEXCEPT;
485
486/*! Multiplies and accumulates the viewport matrix created with the given components.
487
488 fr[n + 0] | fr[n + 4] | fr[n + 8] | fr[n + 12]
489 -----------|-----------|-----------|-----------
490 w*0.5f | 0.0f | 0.0f | w*0.5f
491 0.0f | -h*0.5f | 0.0f | h*0.5f
492 0.0f | 0.0f | 1.0f | 0.0f
493 0.0f | 0.0f | 0.0f | 1.0f
494*/
495SHZ_INLINE void shz_xmtrx_apply_screen(float width, float height) SHZ_NOEXCEPT;
496
497//! Multiplies and accumulates the 3D symmetric skew matrix with the given components onto XMTRX.
498SHZ_INLINE void shz_xmtrx_apply_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT;
499
500//! Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order.
501SHZ_INLINE void shz_xmtrx_apply_permutation_wxyz(void) SHZ_NOEXCEPT;
502
503//! Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in YZWX order.
504SHZ_INLINE void shz_xmtrx_apply_permutation_yzwx(void) SHZ_NOEXCEPT;
505
506//! Multiplies and accumulatse the XMTRX matrix by itself, squaring it.
507SHZ_INLINE void shz_xmtrx_apply_self(void) SHZ_NOEXCEPT;
508
509//! @}
510
511/*! \name GL Transformations
512 \brief OpenGL-style 4x4 matrix transforms.
513 @{
514*/
515
516//! Multiplies and accumulates XMTRX by a 3D translation matrix with the given components (glTranslatef() equivalent).
517SHZ_INLINE void shz_xmtrx_translate(float x, float y, float z) SHZ_NOEXCEPT;
518
519//! Multiplies and accumulates XMTRX by a 3D scaling matrix with the given components (glScalef() equivalent).
520SHZ_INLINE void shz_xmtrx_scale(float x, float y, float z) SHZ_NOEXCEPT;
521
522//! Multiplies and accumulates XMTRX by a 3D rotation matrix about the X axis.
523SHZ_INLINE void shz_xmtrx_rotate_x(float radians) SHZ_NOEXCEPT;
524
525//! Multiplies and accumulates XMTRX by a 3D rotation matrix about the Y axis.
526SHZ_INLINE void shz_xmtrx_rotate_y(float radians) SHZ_NOEXCEPT;
527
528//! Multiplies and accumulates XMTRX by a 3D rotation matrix about the Z axis.
529SHZ_INLINE void shz_xmtrx_rotate_z(float radians) SHZ_NOEXCEPT;
530
531//! Multiplies and accumulates XMTRX by 3D rotation matrices about the X then Y then Z axes.
532SHZ_FORCE_INLINE void shz_xmtrx_rotate_xyz(float xRadians, float yRadians, float zRadians) SHZ_NOEXCEPT;
533
534//! Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then Y then X axes.
535SHZ_FORCE_INLINE void shz_xmtrx_rotate_zyx(float zRadians, float yRadians, float xRadians) SHZ_NOEXCEPT;
536
537//! Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then X then Y axes.
538SHZ_FORCE_INLINE void shz_xmtrx_rotate_zxy(float zRadians, float xRadians, float yRadians) SHZ_NOEXCEPT;
539
540//! Multiplies and accumulates XMTRX by 3D rotation matrices about the Y then X then Z axes.
541SHZ_FORCE_INLINE void shz_xmtrx_rotate_yxz(float yRadians, float xRadians, float zRadians) SHZ_NOEXCEPT;
542
543//! Multiplies and accumulates XMTRX by the 3D rotation matrix formed by the given axis and angle (glRotatef equivalent).
544SHZ_INLINE void shz_xmtrx_rotate(float radians, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT;
545
546//!@}
547
548/*! \name Compound Operations
549 \brief Multiple operations combined into one pipelined transaction.
550 @{
551*/
552
553/*! Loads XMTRX with the result of applying \p matrix2 onto \p matrix1.
554
555 This operation is equivalent to:
556 shz_xmtrx_load_4x4(matrix1);
557 shz_xmtrx_apply_4x4(matrix2);
558
559 However, it has been optimized and pipelined for performing the load
560 and multiply in parallel.
561
562 \sa shz_xmtrx_load_4x4(), shz_xmtrx_apply_4x4(), shz_xmtrx_load_apply_store_4x4()
563*/
564SHZ_INLINE void shz_xmtrx_load_apply_4x4(const shz_mat4x4_t* matrix1,
565 const shz_mat4x4_t* matrix2) SHZ_NOEXCEPT;
566
567/*! Loads XMTRX with the result of applying unaligned \p matrix2 onto \p matrix1.
568
569 This routine is equivalent to shz_xmtrx_load_apply_4x4(), except that the two
570 operand matrices do not require 8-byte alignment and can simply be 16-element
571 single-precision float arrays.
572
573 \sa shz_xmtrx_load_apply_4x4()
574*/
575SHZ_INLINE void shz_xmtrx_load_apply_unaligned_4x4(const float matrix1[16],
576 const float matrix2[16]) SHZ_NOEXCEPT;
577
578/*! Loads XMTRX with the 4x4 result of applying \p matrix2 onto \p matrix1, storing the result.
579
580 This operation is equivalent to:
581 shz_xmtrx_load_4x4(matrix1);
582 shz_xmtrx_apply_4x4(matrix2);
583 shz_xmtrx_store_4x4(out);
584
585 However, it has been optimized and pipelined for performing the loads, multiplies, and
586 stores in parallel.
587
588 \sa shz_xmtrx_load_apply(), shz_xmtrx_load_apply_store_unaligned_4x4()
589*/
590SHZ_INLINE void shz_xmtrx_load_apply_store_4x4(shz_mat4x4_t* out,
591 const shz_mat4x4_t* matrix1,
592 const shz_mat4x4_t* matrix2) SHZ_NOEXCEPT;
593
594/*! Loads XMTRX with the result of applying unaligned \p matrix2 onto unaligned \p matrix1, storing the result.
595
596 This routine is equivalent to shz_xmtrx_load_apply_store_4x4(), except that the three
597 operand matrices do not require 8-byte alignment and can simply be 16-element
598 single-precision float arrays.
599
600 \sa shz_xmtrx_load_apply_store_4x4()
601*/
602SHZ_INLINE void shz_xmtrx_load_apply_store_unaligned_4x4(float out[16],
603 const float matrix1[16],
604 const float matrix2[16]) SHZ_NOEXCEPT;
605
606/*! Loads XMTRX with the 3x4 result of applying \p matrix2 onto \p matrix1, storing the result.
607
608 This operation is equivalent to:
609 shz_xmtrx_load_3x4(matrix1);
610 shz_xmtrx_apply_3x4(matrix2);
611 shz_xmtrx_store_3x4(out);
612
613 However, it has been optimized and pipelined for performing the loads, multiplies,
614 and stores in parallel.
615
616 \note
617 The resulting matrix does not get stored within XMTRX, despite it getting clobbered.
618
619 \sa shz_xmtrx_load_3x4(), shz_xmtrx_apply_3x4(), shz_xmtrx_store_3x4()
620*/
621SHZ_INLINE void shz_xmtrx_load_apply_store_3x4(shz_mat3x4_t* out,
622 const shz_mat3x4_t* matrix1,
623 const shz_mat3x4_t* matrix2) SHZ_NOEXCEPT;
624
625/*! Loads XMTRX with the 3x3 result of applying \p matrix2 onto \p matrix1, storing the result.
626
627 This operation is equivalent to:
628 shz_xmtrx_load_3x3(matrix1);
629 shz_xmtrx_apply_3x3(matrix2);
630 shz_xmtrx_store_3x3(out);
631
632 However, it has been optimized and pipelined for performing the loads, multiplies,
633 and stores in parallel.
634
635 \note
636 The resulting matrix does not get stored within XMTRX, despite it getting clobbered.
637
638 \sa shz_xmtrx_load_3x3(), shz_xmtrx_apply_3x3(), shz_xmtrx_store_3x3()
639*/
640SHZ_INLINE void shz_xmtrx_load_apply_store_3x3(shz_mat3x3_t* out,
641 const shz_mat3x3_t* matrix1,
642 const shz_mat3x3_t* matrix2) SHZ_NOEXCEPT;
643
644//! @}
645
646/*! \name Transformations
647 \brief Transforming vectors and points against XMTRX.
648 @{
649*/
650
651//! Returns the 4D vector that is the result of transforming \p vec by XMTRX.
652SHZ_FORCE_INLINE shz_vec4_t shz_xmtrx_transform_vec4(shz_vec4_t vec) SHZ_NOEXCEPT;
653
654//! Returns the 3D vector that is the result of transforming \p vec by XMTRX.
655SHZ_FORCE_INLINE shz_vec3_t shz_xmtrx_transform_vec3(shz_vec3_t vec) SHZ_NOEXCEPT;
656
657//! Returns the 2D vector that is the result of transforming \p vec by XMTRX.
658SHZ_FORCE_INLINE shz_vec2_t shz_xmtrx_transform_vec2(shz_vec2_t vec) SHZ_NOEXCEPT;
659
660//! Returns the 2D point that is the result of transforming \p pt by XMTRX.
661SHZ_FORCE_INLINE shz_vec2_t shz_xmtrx_transform_point2(shz_vec2_t pt) SHZ_NOEXCEPT;
662
663//! Returns the 3D point that is the result of transforming \p pt by XMTRX.
664SHZ_FORCE_INLINE shz_vec3_t shz_xmtrx_transform_point3(shz_vec3_t pt) SHZ_NOEXCEPT;
665
666//! @}
667
668/*! \name Setters
669 \brief Sets the values of related XMTRX components.
670 @{
671*/
672
673//! Sets only the translational components of XMTRX to the given values.
674SHZ_FORCE_INLINE void shz_xmtrx_set_translation(float x, float y, float z) SHZ_NOEXCEPT;
675
676//! @}
677
678/*! \name Miscellaneous
679 \brief Random operations and conversions on XMTRX.
680 @{
681*/
682
683//! Adds each element within \p mat to each element within XMTRX, storing the result in XMTRX.
684SHZ_INLINE void shz_xmtrx_add_4x4(const shz_mat4x4_t* mat) SHZ_NOEXCEPT;
685
686//! Subtracts each element within \p mat from each element within XMTRX, storing the result in XMTRX.
687SHZ_INLINE void shz_xmtrx_sub_4x4(const shz_mat4x4_t* mat) SHZ_NOEXCEPT;
688
689//! Adds the values of a 3D symmetric skew matrix constructed from the given components to XMTRX.
690SHZ_INLINE void shz_xmtrx_add_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT;
691
692//! Adds the values of a 4D diagonal matrix constructed from the given components to XMTRX.
693SHZ_INLINE void shz_xmtrx_add_diagonal(float x, float y, float z, float w) SHZ_NOEXCEPT;
694
695//! Transposes the elements within XMTRX, in-place.
696SHZ_INLINE void shz_xmtrx_transpose(void) SHZ_NOEXCEPT;
697
698//! Negates each element held within XMTRX.
699SHZ_INLINE void shz_xmtrx_negate(void) SHZ_NOEXCEPT;
700
701//! Takes the absolute value of each element held within XMTRX.
702SHZ_INLINE void shz_xmtrx_abs(void) SHZ_NOEXCEPT;
703
704//! Initializes XMTRX to the sin/cos weights used to multiply two samples within an FFT.
705SHZ_INLINE void shz_xmtrx_init_fft_weights(float radians) SHZ_NOEXCEPT;
706
707//! Constructs a quaternion from the 3D rotation matrix within XMTRX.
708shz_quat_t shz_xmtrx_to_quat(void) SHZ_NOEXCEPT;
709
710//! Returns the determinant of XMTRX.
711float shz_xmtrx_determinant(void) SHZ_NOEXCEPT;
712
713/*! Inverts XMTRX in-place.
714
715 Stores XMTRX to memory, computes the inverse via shz_mat4x4_inverse(),
716 and reloads the result.
717
718 \warning This routine is out-of-line.
719*/
720void shz_xmtrx_invert(void) SHZ_NOEXCEPT;
721
722//! @}
723
724#include "inline/shz_xmtrx.inl.h"
725
726SHZ_DECLS_END
727
728#endif // SHZ_XMTRX_H
#define SHZ_DECLARE_STRUCT(n, t)
Macro which forward declares a struct and its typedef.
Definition shz_cdefs.h:54
#define SHZ_DECLARE_STRUCT_ALIGNED(n, t, a)
Macro which forward declares a manually aligned struct and its typedef.
Definition shz_cdefs.h:56
void shz_xmtrx_rotate_z(float radians) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D rotation matrix about the Z axis.
float shz_xmtrx_determinant(void) SHZ_NOEXCEPT
Returns the determinant of XMTRX.
void shz_xmtrx_load_transpose_3x3(const float *matrix) SHZ_NOEXCEPT
Loads the transpose of the given 3x3 matrix into XMTRX, initializing its remaining elements to identi...
void shz_xmtrx_write_row(unsigned int index, shz_vec4_t vector) SHZ_NOEXCEPT
Sets the values at the given row index to the given 4D vector.
void shz_xmtrx_load_transpose_4x4(const shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Loads XMTRX with the transpose of the given 4x4 matrix.
void shz_xmtrx_load_apply_store_4x4(shz_mat4x4_t *out, const shz_mat4x4_t *matrix1, const shz_mat4x4_t *matrix2) SHZ_NOEXCEPT
Loads XMTRX with the 4x4 result of applying matrix2 onto matrix1, storing the result.
void shz_xmtrx_init_identity(void) SHZ_NOEXCEPT
Quickly initializes XMTRX to be a 4D identity matrix.
shz_quat_t shz_xmtrx_to_quat(void) SHZ_NOEXCEPT
Constructs a quaternion from the 3D rotation matrix within XMTRX.
void shz_xmtrx_apply_rotation_zxy(float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D Z-X-Y rotation matrix, with the corresponding angles given i...
void shz_xmtrx_rotate_xyz(float xRadians, float yRadians, float zRadians) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by 3D rotation matrices about the X then Y then Z axes.
void shz_xmtrx_init_perspective(float fov, float aspect, float near_z) SHZ_NOEXCEPT
Initializes XMTRX to a perspective projection matrix.
void shz_xmtrx_load_apply_store_3x4(shz_mat3x4_t *out, const shz_mat3x4_t *matrix1, const shz_mat3x4_t *matrix2) SHZ_NOEXCEPT
Loads XMTRX with the 3x4 result of applying matrix2 onto matrix1, storing the result.
void shz_xmtrx_load_rows_4x4(const shz_vec4_t *r1, const shz_vec4_t *r2, const shz_vec4_t *r3, const shz_vec4_t *r4) SHZ_NOEXCEPT
Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D row vectors.
void shz_xmtrx_init_fill(float value) SHZ_NOEXCEPT
Initializes XMTRX to contain the given value for each element.
void shz_xmtrx_apply_rotation_zyx(float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D Z-Y-X rotation matrix, with the corresponding angles given i...
void shz_xmtrx_load_2x2(const shz_mat2x2_t *matrix) SHZ_NOEXCEPT
Loads the given 2x2 matrix into XMTRX, initializing its remaining elements to identity.
void shz_xmtrx_load_rows_3x4(const shz_vec4_t *r1, const shz_vec4_t *r2, const shz_vec4_t *r3) SHZ_NOEXCEPT
Loads the 3x4 matrix formed from the given 3 4D row vectors into XMTRX.
void shz_xmtrx_rotate_y(float radians) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D rotation matrix about the Y axis.
void shz_xmtrx_load_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT
Loads XMTRX with the transpose of the 4x4 matrix created from the given unaligned array of 16 floats.
shz_vec3_t shz_xmtrx_transform_point3(shz_vec3_t pt) SHZ_NOEXCEPT
Returns the 3D point that is the result of transforming pt by XMTRX.
void shz_xmtrx_apply_rotation_y(float y) SHZ_NOEXCEPT
Transforms the values of the inner 3x3 matrix by a rotation matrix of y radians about the Y axis.
void shz_xmtrx_init_translation(float x, float y, float z) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D translation matrix to the given coordinates.
void shz_xmtrx_rotate_zxy(float zRadians, float xRadians, float yRadians) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then X then Y axes.
shz_vec2_t shz_xmtrx_transform_point2(shz_vec2_t pt) SHZ_NOEXCEPT
Returns the 2D point that is the result of transforming pt by XMTRX.
void shz_xmtrx_init_ortho(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT
Initializes XMTRX to an orthographic projection matrix, equivalent to glOrtho().
void shz_xmtrx_rotate_x(float radians) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D rotation matrix about the X axis.
shz_vec2_t shz_xmtrx_transform_vec2(shz_vec2_t vec) SHZ_NOEXCEPT
Returns the 2D vector that is the result of transforming vec by XMTRX.
void shz_xmtrx_init_rotation(float angle, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT
Initializes XMTRX to a 3D rotation matrix of angle radians about the given axis.
void shz_xmtrx_apply_reverse_4x4(const shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX onto matrix, storing the result as XMTRX.
float shz_xmtrx_read(shz_xmtrx_reg_t xf) SHZ_NOEXCEPT
Returns the floating-point value held within the given XMTRX register.
void shz_xmtrx_load_wxyz_4x4(const shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Loads the given 4x4 matrix as XMTRX, with the 4th column for translation being loaded as the first co...
void shz_xmtrx_apply_3x3(const shz_mat3x3_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulates the given 3x3 matrix onto XMTRX, not modifying other elements.
void shz_xmtrx_apply_screen(float width, float height) SHZ_NOEXCEPT
Multiplies and accumulates the viewport matrix created with the given components.
void shz_xmtrx_store_4x4(shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Stores the current values held within XMTRX into the given 4x4 matrix.
void shz_xmtrx_load_4x4(const shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Loads the given 4x4 matrix as XMTRX.
void shz_xmtrx_apply_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT
Multiplies and accumulates the transpose of the given 16-entry float array as a 4x4 matrix onto XMTRX...
void shz_xmtrx_set_translation(float x, float y, float z) SHZ_NOEXCEPT
Sets only the translational components of XMTRX to the given values.
shz_xmtrx_reg
Registers comprising XMTRX, in the FPU back-bank.
Definition shz_xmtrx.h:64
@ SHZ_XMTRX_XF8
FP register xf8.
Definition shz_xmtrx.h:73
@ SHZ_XMTRX_XF9
FP register xf9.
Definition shz_xmtrx.h:74
@ SHZ_XMTRX_XF12
FP register xf12.
Definition shz_xmtrx.h:77
@ SHZ_XMTRX_XF11
FP register xf11.
Definition shz_xmtrx.h:76
@ SHZ_XMTRX_XF14
FP register xf14.
Definition shz_xmtrx.h:79
@ SHZ_XMTRX_XF3
FP register xf3.
Definition shz_xmtrx.h:68
@ SHZ_XMTRX_XF6
FP register xf6.
Definition shz_xmtrx.h:71
@ SHZ_XMTRX_XF4
FP register xf4.
Definition shz_xmtrx.h:69
@ SHZ_XMTRX_XF13
FP register xf13.
Definition shz_xmtrx.h:78
@ SHZ_XMTRX_XF10
FP register xf10.
Definition shz_xmtrx.h:75
@ SHZ_XMTRX_XF2
FP register xf2.
Definition shz_xmtrx.h:67
@ SHZ_XMTRX_XF0
FP register xf0.
Definition shz_xmtrx.h:65
@ SHZ_XMTRX_XF5
FP register xf5.
Definition shz_xmtrx.h:70
@ SHZ_XMTRX_XF7
FP register xf7.
Definition shz_xmtrx.h:72
@ SHZ_XMTRX_XF15
FP register xf15.
Definition shz_xmtrx.h:80
@ SHZ_XMTRX_XF1
FP register xf1.
Definition shz_xmtrx.h:66
void shz_xmtrx_add_4x4(const shz_mat4x4_t *mat) SHZ_NOEXCEPT
Adds each element within mat to each element within XMTRX, storing the result in XMTRX.
void shz_xmtrx_init_permutation_wxyz(void) SHZ_NOEXCEPT
Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be...
void shz_xmtrx_invert(void) SHZ_NOEXCEPT
Inverts XMTRX in-place.
void shz_xmtrx_load_apply_4x4(const shz_mat4x4_t *matrix1, const shz_mat4x4_t *matrix2) SHZ_NOEXCEPT
Loads XMTRX with the result of applying matrix2 onto matrix1.
void shz_xmtrx_translate(float x, float y, float z) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D translation matrix with the given components (glTranslatef()...
shz_vec4_t shz_xmtrx_read_row(unsigned int index) SHZ_NOEXCEPT
Returns the values at the the given row index, as a 4D vector.
void shz_xmtrx_rotate_zyx(float zRadians, float yRadians, float xRadians) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then Y then X axes.
void shz_xmtrx_apply_permutation_yzwx(void) SHZ_NOEXCEPT
Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors...
void shz_xmtrx_init_rotation_z(float z) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D rotation matrix by z radians about the Z axis.
void shz_xmtrx_rotate_yxz(float yRadians, float xRadians, float zRadians) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by 3D rotation matrices about the Y then X then Z axes.
void shz_xmtrx_apply_3x4(const shz_mat3x4_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulates the given 3x4 matrix onto XMTRX, not modifying other elements.
void shz_xmtrx_apply_translation(float x, float y, float z) SHZ_NOEXCEPT
Adds the values of the given 3 components to the 3D translation components of XMTRX.
void shz_xmtrx_apply_rotation(float angle, float x, float y, float z) SHZ_NOEXCEPT
Transforms the values of the inner 3x3 matrix by a rotation matrix of angle radians about the axis wi...
void shz_xmtrx_abs(void) SHZ_NOEXCEPT
Takes the absolute value of each element held within XMTRX.
void shz_xmtrx_apply_permutation_wxyz(void) SHZ_NOEXCEPT
Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors...
void shz_xmtrx_store_3x3(shz_mat3x3_t *matrix) SHZ_NOEXCEPT
Stores the top-left 3x3 values currently held within XMTRX into the given matrix.
void shz_xmtrx_apply_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT
Multiplies and accumulates the given 16-entry float array as a 4x4 matrix onto XMTRX.
void shz_xmtrx_load_cols_4x4(const shz_vec4_t *c1, const shz_vec4_t *c2, const shz_vec4_t *c3, const shz_vec4_t *c4) SHZ_NOEXCEPT
Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D column vectors.
void shz_xmtrx_store_transpose_4x4(shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Stores the transpose of the current values held within XMTRX into the given 4x4 matrix.
void shz_xmtrx_apply_self(void) SHZ_NOEXCEPT
Multiplies and accumulatse the XMTRX matrix by itself, squaring it.
void shz_xmtrx_load_apply_unaligned_4x4(const float matrix1[16], const float matrix2[16]) SHZ_NOEXCEPT
Loads XMTRX with the result of applying unaligned matrix2 onto matrix1.
void shz_xmtrx_transpose(void) SHZ_NOEXCEPT
Transposes the elements within XMTRX, in-place.
void shz_xmtrx_apply_rotation_z(float z) SHZ_NOEXCEPT
Transforms the values of the inner 3x3 matrix by a rotation matrix of z radians about the Z axis.
void shz_xmtrx_load_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT
Loads the given array of unaligned 16 float values as the 4x4 XMTRX matrix.
void shz_xmtrx_scale(float x, float y, float z) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D scaling matrix with the given components (glScalef() equival...
void shz_xmtrx_init_upper_triangular(float col1, shz_vec2_t col2, shz_vec3_t col3, shz_vec4_t col4) SHZ_NOEXCEPT
Initializes XMTRX to be an upper triangular matrix with the given column values.
void shz_xmtrx_init_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT
Initializes XMTRX to be the 3D symmetric skew matrix formed from the given vector components.
void shz_xmtrx_load_3x4(const shz_mat3x4_t *matrix) SHZ_NOEXCEPT
Loads the given 3x4 matrix into XMTRX, initializing its remaining elements to identity.
void shz_xmtrx_apply_rotation_quat(shz_quat_t quat) SHZ_NOEXCEPT
Transforms the values of the inner 3x3 matrix by the rotation matrix represented by the given quatern...
void shz_xmtrx_write_col(unsigned int index, shz_vec4_t vector) SHZ_NOEXCEPT
Sets the values at the given column index to the given 4D vector.
void shz_xmtrx_apply_ortho(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT
Applies a 2D orthographic projection matrix onto XMTRX, equivalent to glOrtho().
void shz_xmtrx_store_unaligned_4x4(float matrix[16]) SHZ_NOEXCEPT
Stores the current values held within XMTRX into the given unaligned 16-float array.
void shz_xmtrx_init_lower_triangular(shz_vec4_t col1, shz_vec3_t col2, shz_vec2_t col3, float col4) SHZ_NOEXCEPT
Initializes XMTRX to be a lower triangular matrix with the given column values.
void shz_xmtrx_init_rotation_quat(shz_quat_t q) SHZ_NOEXCEPT
Initializes XMTRX to a 3D rotation matrix with its orientation given by a quaternion.
void shz_xmtrx_apply_4x4(const shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulates the given 4x4 matrix onto XMTRX.
void shz_xmtrx_apply_rotation_yxz(float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D Y-X-Z rotation matrix, with the corresponding angles given i...
void shz_xmtrx_apply_frustum(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT
Applies a frustum projection matrix onto XMTRX, equivalent to glFrustum().
void shz_xmtrx_init_rotation_x(float x) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D rotation matrix by x radians about the X axis.
void shz_xmtrx_store_transpose_3x3(shz_mat3x3_t *matrix) SHZ_NOEXCEPT
Stores the transpose of the top-left 3x3 values currently held within XMTRX into the given matrix.
void shz_xmtrx_init_scale(float x, float y, float z) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D scale matrix with the given dimensions.
void shz_xmtrx_load_3x3(const shz_mat3x3_t *matrix) SHZ_NOEXCEPT
Loads the given 3x3 matrix into XMTRX, initalizing its remaining elements to identity.
void shz_xmtrx_store_3x4(shz_mat3x4_t *matrix) SHZ_NOEXCEPT
Stores the top-left 3x4 values currently held within XMTRX into the given matrix.
void shz_xmtrx_init_diagonal(float x, float y, float z, float w) SHZ_NOEXCEPT
Initializes XMTRX to be a diagonal matrix with the given diagonal values.
void shz_xmtrx_write(shz_xmtrx_reg_t xf, float value) SHZ_NOEXCEPT
Sets the floating-point value held within the given XMTRX register to value.
void shz_xmtrx_apply_2x2(const shz_mat2x2_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulates the given 2x2 matrix onto XMTRX, not modifying other elements.
void shz_xmtrx_init_identity_safe(void) SHZ_NOEXCEPT
Safely initializes XMTRX to be a 4D identity matrix.
void shz_xmtrx_load_apply_store_3x3(shz_mat3x3_t *out, const shz_mat3x3_t *matrix1, const shz_mat3x3_t *matrix2) SHZ_NOEXCEPT
Loads XMTRX with the 3x3 result of applying matrix2 onto matrix1, storing the result.
shz_vec4_t shz_xmtrx_transform_vec4(shz_vec4_t vec) SHZ_NOEXCEPT
Returns the 4D vector that is the result of transforming vec by XMTRX.
void shz_xmtrx_init_lookat(shz_vec3_t eye, shz_vec3_t center, shz_vec3_t up) SHZ_NOEXCEPT
Initializes XMTRX to a "lookAt" view matrix, equivalent to gluLookAt().
void shz_xmtrx_init_screen(float width, float height) SHZ_NOEXCEPT
Initializes XMTRX to the viewport matrix with the given dimensions.
void shz_xmtrx_init_outer_product(shz_vec4_t x, shz_vec4_t y) SHZ_NOEXCEPT
Initializes XMTRX to the 4D matrix resulting from taking the outer product of the two 4D vectors.
void shz_xmtrx_load_cols_4x3(const shz_vec4_t *c1, const shz_vec4_t *c2, const shz_vec4_t *c3) SHZ_NOEXCEPT
Loads the 3x4 matrix formed from the given 3 4D column vectors into XMTRX.
void shz_xmtrx_sub_4x4(const shz_mat4x4_t *mat) SHZ_NOEXCEPT
Subtracts each element within mat from each element within XMTRX, storing the result in XMTRX.
void shz_xmtrx_swap_rows(unsigned int index1, unsigned int index2) SHZ_NOEXCEPT
Swaps the values of the rows with the given indices.
void shz_xmtrx_apply_lookat(shz_vec3_t eye, shz_vec3_t center, shz_vec3_t up) SHZ_NOEXCEPT
Applies the 3D "lookAt" matrix constructed with the given vector components onto XMTRX....
void shz_xmtrx_add_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT
Adds the values of a 3D symmetric skew matrix constructed from the given components to XMTRX.
void shz_xmtrx_store_transpose_unaligned_4x4(float matrix[16]) SHZ_NOEXCEPT
Stores the transpose of the the current values held within XMTRX into the given 16-element float arra...
void shz_xmtrx_apply_reverse_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX onto the transpose of the given float array as a 4x4 matrix,...
void shz_xmtrx_apply_rotation_x(float x) SHZ_NOEXCEPT
Transforms the values of the inner 3x3 matrix by a rotation matrix of x radians about the X axis.
void shz_xmtrx_apply_scale(float x, float y, float z) SHZ_NOEXCEPT
Multiplies the values of the inner 3x3 matrix by the given 3D scaling terms.
void shz_xmtrx_load_apply_store_unaligned_4x4(float out[16], const float matrix1[16], const float matrix2[16]) SHZ_NOEXCEPT
Loads XMTRX with the result of applying unaligned matrix2 onto unaligned matrix1, storing the result.
void shz_xmtrx_init_rotation_xyz(float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D X-Y-Z rotation matrix, with the corresponding angles given in radians.
void shz_xmtrx_add_diagonal(float x, float y, float z, float w) SHZ_NOEXCEPT
Adds the values of a 4D diagonal matrix constructed from the given components to XMTRX.
void shz_xmtrx_init_rotation_zyx(float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D Z-Y-X rotation matrix, with the corresponding angles given in radians.
shz_vec4_t shz_xmtrx_read_col(unsigned int index) SHZ_NOEXCEPT
Returns the values at the given column index, as a 4D vector.
void shz_xmtrx_apply_rotation_xyz(float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by a 3D X-Y-Z rotation matrix, with the corresponding angles given i...
void shz_xmtrx_init_rotation_yxz(float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D Y-X-Z rotation matrix, with the corresponding angles given in radians.
void shz_xmtrx_apply_transpose_3x3(const shz_mat3x3_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulateas the transpose of the given 3x3 matrix onto XMTRX, not modifying other ele...
void shz_xmtrx_init_zero(void) SHZ_NOEXCEPT
Initializes XMTRX to contain the value of 0.0f for each element.
void shz_xmtrx_apply_transpose_4x4(const shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulates the transpose of the given 4x4 matrix onto XMTRX.
void shz_xmtrx_negate(void) SHZ_NOEXCEPT
Negates each element held within XMTRX.
void shz_xmtrx_init_fft_weights(float radians) SHZ_NOEXCEPT
Initializes XMTRX to the sin/cos weights used to multiply two samples within an FFT.
void shz_xmtrx_init_rotation_zxy(float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D Z-X-Y rotation matrix, with the corresponding angles given in radians.
void shz_xmtrx_init_permutation_yzwx(void) SHZ_NOEXCEPT
Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be...
void shz_xmtrx_apply_reverse_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX onto the given float array as a 4x4 matrix, storing the result as XM...
void shz_xmtrx_swap_cols(unsigned int index1, unsigned int index2) SHZ_NOEXCEPT
Swaps the values of the columns with the given indices.
void shz_xmtrx_apply_reverse_transpose_4x4(const shz_mat4x4_t *matrix) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX onto the transpose of matrix, storing the result as XMTRX.
void shz_xmtrx_apply_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT
Multiplies and accumulates the 3D symmetric skew matrix with the given components onto XMTRX.
void shz_xmtrx_init_one(void) SHZ_NOEXCEPT
Initializes XMTRX to contain the value of 1.0f for each element.
void shz_xmtrx_apply_perspective(float fov, float aspect, float near_z) SHZ_NOEXCEPT
Multiplies and accumulates the perspective matrix constructed from the given values onto XMTRX.
void shz_xmtrx_store_2x2(shz_mat2x2_t *matrix) SHZ_NOEXCEPT
Stores the top-left 2x2 values currently held within XMTRX into the given matrix.
void shz_xmtrx_init_frustum(float left, float right, float bottom, float top, float near, float far) SHZ_NOEXCEPT
Initializes XMTRX to a frustum projection matrix, equivalent to glFrustum().
shz_vec3_t shz_xmtrx_transform_vec3(shz_vec3_t vec) SHZ_NOEXCEPT
Returns the 3D vector that is the result of transforming vec by XMTRX.
void shz_xmtrx_init_rotation_y(float y) SHZ_NOEXCEPT
Initializes XMTRX to be a 3D rotation matrix by y radians about the Y axis.
void shz_xmtrx_rotate(float radians, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT
Multiplies and accumulates XMTRX by the 3D rotation matrix formed by the given axis and angle (glRota...
Structure representing a 4x4 column-major matrix.
Definition shz_matrix.h:73