1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - FX -
3 File: fx_mtx33.h
4
5 Copyright 2003-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2008-09-18#$
14 $Rev: 8573 $
15 $Author: okubata_ryoma $
16 *---------------------------------------------------------------------------*/
17
18 #ifndef NITRO_FX_MTX33_H_
19 #define NITRO_FX_MTX33_H_
20
21 #include <nitro/fx/fx.h>
22 #include <nitro/fx/fx_vec.h>
23 #include <nitro/mi/memory.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 //----------------------------------------------------------------------------
30 // Type definition
31 //----------------------------------------------------------------------------
32
33 //----------------------------------------------------------------------------
34 // Declaration of function
35 //----------------------------------------------------------------------------
36
37 SDK_DECL_INLINE void MTX_Identity33(MtxFx33 *pDst);
38 SDK_DECL_INLINE void MTX_Copy33(const MtxFx33 *pSrc, MtxFx33 *pDst);
39 SDK_DECL_INLINE void MTX_Copy33To43(const MtxFx33 *pSrc, MtxFx43 *pDst);
40 SDK_DECL_INLINE void MTX_Copy33To44(const MtxFx33 *pSrc, MtxFx44 *pDst);
41 SDK_DECL_INLINE void MTX_Transpose33(const MtxFx33 *pSrc, MtxFx33 *pDst);
42 SDK_DECL_INLINE void MTX_Scale33(MtxFx33 *pDst, fx32 x, fx32 y, fx32 z);
43 void MTX_ScaleApply33(const MtxFx33 *pSrc, MtxFx33 *pDst, fx32 x, fx32 y, fx32 z);
44 SDK_DECL_INLINE void MTX_RotX33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal);
45 SDK_DECL_INLINE void MTX_RotY33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal);
46 SDK_DECL_INLINE void MTX_RotZ33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal);
47 void MTX_RotAxis33(MtxFx33 *pDst, const VecFx32 *vec, fx32 sinVal, fx32 cosVal);
48 int MTX_Inverse33(const MtxFx33 *pSrc, MtxFx33 *pDst);
49 void MTX_Concat33(const MtxFx33 *a, const MtxFx33 *b, MtxFx33 *ab);
50 void MTX_MultVec33(const VecFx32 *vec, const MtxFx33 *m, VecFx32 *dst);
51
52 void MTX_Identity33_(register MtxFx33 *pDst);
53 void MTX_Copy33To43_(const register MtxFx33 *pSrc, register MtxFx43 *pDst);
54 void MTX_Copy33To44_(const register MtxFx33 *pSrc, register MtxFx44 *pDst);
55 void MTX_Transpose33_(const register MtxFx33 *pSrc, register MtxFx33 *pDst);
56 void MTX_Scale33_(register MtxFx33 *pDst, register fx32 x, register fx32 y, register fx32 z);
57 void MTX_RotX33_(register MtxFx33 *pDst, register fx32 sinVal, register fx32 cosVal);
58 void MTX_RotY33_(register MtxFx33 *pDst, register fx32 sinVal, register fx32 cosVal);
59 void MTX_RotZ33_(register MtxFx33 *pDst, register fx32 sinVal, register fx32 cosVal);
60
61 //----------------------------------------------------------------------------
62 // Implementation of inline function
63 //----------------------------------------------------------------------------
64
65 /*---------------------------------------------------------------------------*
66 Name: MTX_Identity33
67
68 Description: Sets a matrix to identity.
69
70 Arguments: pDst a pointer to a 3x3 matrix
71
72 Returns: none
73 *---------------------------------------------------------------------------*/
MTX_Identity33(MtxFx33 * pDst)74 SDK_INLINE void MTX_Identity33(MtxFx33 *pDst)
75 {
76 SDK_NULL_ASSERT(pDst);
77 MTX_Identity33_(pDst);
78 }
79
80 /*---------------------------------------------------------------------------*
81 Name: MTX_Copy33
82
83 Description: Copies a 3x3 matrix to a 3x3 matrix.
84
85 Arguments: pSrc a pointer to a 3x3 matrix
86 pDst a pointer to a 3x3 matrix
87
88 Returns: none
89 *---------------------------------------------------------------------------*/
MTX_Copy33(const MtxFx33 * pSrc,MtxFx33 * pDst)90 SDK_INLINE void MTX_Copy33(const MtxFx33 *pSrc, MtxFx33 *pDst)
91 {
92 SDK_NULL_ASSERT(pSrc);
93 SDK_NULL_ASSERT(pDst);
94 MI_Copy36B(pSrc, pDst);
95 }
96
97 /*---------------------------------------------------------------------------*
98 Name: MTX_Copy33To43
99
100 Description: Copies a 3x3 matrix to a 4x3 matrix.
101
102 Arguments: pSrc a pointer to a 3x3 matrix
103 pDst a pointer to a 4x3 matrix
104
105 Returns: none
106 *---------------------------------------------------------------------------*/
MTX_Copy33To43(const MtxFx33 * pSrc,MtxFx43 * pDst)107 SDK_INLINE void MTX_Copy33To43(const MtxFx33 *pSrc, MtxFx43 *pDst)
108 {
109 SDK_NULL_ASSERT(pSrc);
110 SDK_NULL_ASSERT(pDst);
111 MTX_Copy33To43_(pSrc, pDst);
112 }
113
114
115 /*---------------------------------------------------------------------------*
116 Name: MTX_Copy33To44
117
118 Description: Copies a 3x3 matrix to a 4x4 matrix.
119
120 Arguments: pSrc a pointer to a 3x3 matrix
121 pDst a pointer to a 4x4 matrix
122
123 Returns: none
124 *---------------------------------------------------------------------------*/
MTX_Copy33To44(const MtxFx33 * pSrc,MtxFx44 * pDst)125 SDK_INLINE void MTX_Copy33To44(const MtxFx33 *pSrc, MtxFx44 *pDst)
126 {
127 SDK_NULL_ASSERT(pSrc);
128 SDK_NULL_ASSERT(pDst);
129 MTX_Copy33To44_(pSrc, pDst);
130 }
131
132
133 /*---------------------------------------------------------------------------*
134 Name: MTX_Transpose33
135
136 Description: Computes the transpose of a 3x3 matrix.
137
138 Arguments: pSrc a pointer to a 3x3 matrix
139 pDst a pointer to a 3x3 matrix
140
141 Returns: none
142 *---------------------------------------------------------------------------*/
MTX_Transpose33(const MtxFx33 * pSrc,MtxFx33 * pDst)143 SDK_INLINE void MTX_Transpose33(const MtxFx33 *pSrc, MtxFx33 *pDst)
144 {
145 SDK_NULL_ASSERT(pSrc);
146 SDK_NULL_ASSERT(pDst);
147 MTX_Transpose33_(pSrc, pDst);
148 }
149
150 /*---------------------------------------------------------------------------*
151 Name: MTX_Scale33
152
153 Description: Sets a scaling matrix.
154
155 Arguments: pDst a pointer to a 3x3 matrix
156 x x scale factor
157 y y scale factor
158 z z scale factor
159
160 Returns: none
161 *---------------------------------------------------------------------------*/
MTX_Scale33(MtxFx33 * pDst,fx32 x,fx32 y,fx32 z)162 SDK_INLINE void MTX_Scale33(MtxFx33 *pDst, fx32 x, fx32 y, fx32 z)
163 {
164 SDK_NULL_ASSERT(pDst);
165 MTX_Scale33_(pDst, x, y, z);
166 }
167
168 /*---------------------------------------------------------------------------*
169 Name: MTX_RotX33
170
171 Description: Sets a rotation matrix about the X axis.
172
173 Arguments: pDst a pointer to a 3x3 matrix
174 sinVal sine of an angle of rotation
175 cosVal cosine of an angle of rotation
176
177 Returns: none
178 *---------------------------------------------------------------------------*/
MTX_RotX33(MtxFx33 * pDst,fx32 sinVal,fx32 cosVal)179 SDK_INLINE void MTX_RotX33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal)
180 {
181 SDK_NULL_ASSERT(pDst);
182 MTX_RotX33_(pDst, sinVal, cosVal);
183 }
184
185 /*---------------------------------------------------------------------------*
186 Name: MTX_RotY33
187
188 Description: Sets a rotation matrix about the Y axis.
189
190 Arguments: pDst a pointer to a 3x3 matrix
191 sinVal sine of an angle of rotation
192 cosVal cosine of an angle of rotation
193
194 Returns: none
195 *---------------------------------------------------------------------------*/
MTX_RotY33(MtxFx33 * pDst,fx32 sinVal,fx32 cosVal)196 SDK_INLINE void MTX_RotY33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal)
197 {
198 SDK_NULL_ASSERT(pDst);
199 MTX_RotY33_(pDst, sinVal, cosVal);
200 }
201
202 /*---------------------------------------------------------------------------*
203 Name: MTX_RotZ33
204
205 Description: Sets a rotation matrix about the Z axis.
206
207 Arguments: pDst a pointer to a 3x3 matrix
208 sinVal sine of an angle of rotation
209 cosVal cosine of an angle of rotation
210
211 Returns: none
212 *---------------------------------------------------------------------------*/
MTX_RotZ33(MtxFx33 * pDst,fx32 sinVal,fx32 cosVal)213 SDK_INLINE void MTX_RotZ33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal)
214 {
215 SDK_NULL_ASSERT(pDst);
216 MTX_RotZ33_(pDst, sinVal, cosVal);
217 }
218
219
220
221 #ifdef __cplusplus
222 }/* extern "C" */
223 #endif
224
225 #endif
226