1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - FX -
3   File:     fx_mtx43.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_MTX43_H_
19 #define NITRO_FX_MTX43_H_
20 
21 #include <nitro/fx/fx.h>
22 #include <nitro/mi/memory.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 //----------------------------------------------------------------------------
29 // Type definition
30 //----------------------------------------------------------------------------
31 
32 //----------------------------------------------------------------------------
33 // Declaration of function
34 //----------------------------------------------------------------------------
35 
36 SDK_DECL_INLINE void MTX_Identity43(MtxFx43 *pDst);
37 SDK_DECL_INLINE void MTX_Copy43(const MtxFx43 *pSrc, MtxFx43 *pDst);
38 SDK_DECL_INLINE void MTX_Copy43To33(const MtxFx43 *pSrc, MtxFx33 *pDst);
39 SDK_DECL_INLINE void MTX_Copy43To44(const MtxFx43 *pSrc, MtxFx44 *pDst);
40 SDK_DECL_INLINE void MTX_Transpose43(const MtxFx43 *pSrc, MtxFx43 *pDst);
41 void    MTX_TransApply43(const MtxFx43 *pSrc, MtxFx43 *pDst, fx32 x, fx32 y, fx32 z);
42 SDK_DECL_INLINE void MTX_Scale43(MtxFx43 *pDst, fx32 x, fx32 y, fx32 z);
43 void    MTX_ScaleApply43(const MtxFx43 *pSrc, MtxFx43 *pDst, fx32 x, fx32 y, fx32 z);
44 SDK_DECL_INLINE void MTX_RotX43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal);
45 SDK_DECL_INLINE void MTX_RotY43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal);
46 SDK_DECL_INLINE void MTX_RotZ43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal);
47 void    MTX_RotAxis43(MtxFx43 *pDst, const VecFx32 *vec, fx32 sinVal, fx32 cosVal);
48 int     MTX_Inverse43(const MtxFx43 *pSrc, MtxFx43 *pDst);
49 void    MTX_Concat43(const MtxFx43 *a, const MtxFx43 *b, MtxFx43 *ab);
50 void    MTX_MultVec43(const VecFx32 *vec, const MtxFx43 *m, VecFx32 *dst);
51 void    MTX_LookAt(const VecFx32 *camPos, const VecFx32 *camUp, const VecFx32 *target, MtxFx43 *mtx);
52 
53 void    MTX_Identity43_(register MtxFx43 *pDst);
54 void    MTX_Copy43To44_(register const MtxFx43 *pSrc, register MtxFx44 *pDst);
55 void    MTX_Transpose43_(register const MtxFx43 *pSrc, register MtxFx43 *pDst);
56 void    MTX_Scale43_(register MtxFx43 *pDst, register fx32 x, register fx32 y, register fx32 z);
57 void    MTX_RotX43_(register MtxFx43 *pDst, register fx32 sinVal, register fx32 cosVal);
58 void    MTX_RotY43_(register MtxFx43 *pDst, register fx32 sinVal, register fx32 cosVal);
59 void    MTX_RotZ43_(register MtxFx43 *pDst, register fx32 sinVal, register fx32 cosVal);
60 
61 //----------------------------------------------------------------------------
62 // Implementation of inline function
63 //----------------------------------------------------------------------------
64 
65 /*---------------------------------------------------------------------------*
66   Name:         MTX_Identity43
67 
68   Description:  Sets a matrix to identity.
69 
70   Arguments:    pDst         a pointer to a 4x3 matrix
71 
72   Returns:      none
73  *---------------------------------------------------------------------------*/
MTX_Identity43(MtxFx43 * pDst)74 SDK_INLINE void MTX_Identity43(MtxFx43 *pDst)
75 {
76     SDK_NULL_ASSERT(pDst);
77     MTX_Identity43_(pDst);
78 }
79 
80 /*---------------------------------------------------------------------------*
81   Name:         MTX_Copy43
82 
83   Description:  Copies a 4x3 matrix to a 4x3 matrix.
84 
85   Arguments:    pSrc         a pointer to a 4x3 matrix
86                 pDst         a pointer to a 4x3 matrix
87 
88   Returns:      none
89  *---------------------------------------------------------------------------*/
MTX_Copy43(const MtxFx43 * pSrc,MtxFx43 * pDst)90 SDK_INLINE void MTX_Copy43(const MtxFx43 *pSrc, MtxFx43 *pDst)
91 {
92     SDK_NULL_ASSERT(pSrc);
93     SDK_NULL_ASSERT(pDst);
94     MI_Copy48B(pSrc, pDst);
95 }
96 
97 /*---------------------------------------------------------------------------*
98   Name:         MTX_Copy43To33
99 
100   Description:  Copies a 4x3 matrix to a 3x3 matrix.
101 
102   Arguments:    pSrc         a pointer to a 4x3 matrix
103                 pDst         a pointer to a 3x3 matrix
104 
105   Returns:      none
106  *---------------------------------------------------------------------------*/
MTX_Copy43To33(const MtxFx43 * pSrc,MtxFx33 * pDst)107 SDK_INLINE void MTX_Copy43To33(const MtxFx43 *pSrc, MtxFx33 *pDst)
108 {
109     SDK_NULL_ASSERT(pSrc);
110     SDK_NULL_ASSERT(pDst);
111     MI_Copy36B(pSrc, pDst);
112 }
113 
114 /*---------------------------------------------------------------------------*
115   Name:         MTX_Copy43To44
116 
117   Description:  Copies a 4x3 matrix to a 4x4 matrix.
118 
119   Arguments:    pSrc         a pointer to a 4x3 matrix
120                 pDst         a pointer to a 4x4 matrix
121 
122   Returns:      none
123  *---------------------------------------------------------------------------*/
MTX_Copy43To44(const MtxFx43 * pSrc,MtxFx44 * pDst)124 SDK_INLINE void MTX_Copy43To44(const MtxFx43 *pSrc, MtxFx44 *pDst)
125 {
126     SDK_NULL_ASSERT(pSrc);
127     SDK_NULL_ASSERT(pDst);
128     MTX_Copy43To44_(pSrc, pDst);
129 }
130 
131 
132 /*---------------------------------------------------------------------------*
133   Name:         MTX_Transpose43
134 
135   Description:  Computes the transpose of a 4x3 matrix.
136                 Since matrices are 3x4, fourth row is lost and becomes (0,0,0).
137 
138   Arguments:    pSrc         a pointer to a 4x3 matrix
139                 pDst         a pointer to a 4x3 matrix
140 
141   Returns:      none
142  *---------------------------------------------------------------------------*/
MTX_Transpose43(const MtxFx43 * pSrc,MtxFx43 * pDst)143 SDK_INLINE void MTX_Transpose43(const MtxFx43 *pSrc, MtxFx43 *pDst)
144 {
145     SDK_NULL_ASSERT(pSrc);
146     SDK_NULL_ASSERT(pDst);
147 
148     MTX_Transpose43_(pSrc, pDst);
149 }
150 
151 /*---------------------------------------------------------------------------*
152   Name:         MTX_Scale43
153 
154   Description:  Sets a scaling matrix.
155 
156   Arguments:    pDst         a pointer to a 4x3 matrix
157                 x            x scale factor
158                 y            y scale factor
159                 z            z scale factor
160 
161   Returns:      none
162  *---------------------------------------------------------------------------*/
MTX_Scale43(MtxFx43 * pDst,fx32 x,fx32 y,fx32 z)163 SDK_INLINE void MTX_Scale43(MtxFx43 *pDst, fx32 x, fx32 y, fx32 z)
164 {
165     SDK_NULL_ASSERT(pDst);
166     MTX_Scale43_(pDst, x, y, z);
167 }
168 
169 /*---------------------------------------------------------------------------*
170   Name:         MTX_RotX43
171 
172   Description:  Sets a rotation matrix about the X axis.
173 
174   Arguments:    pDst         a pointer to a 4x3 matrix
175                 sinVal       sine of an angle of rotation
176                 cosVal       cosine of an angle of rotation
177 
178   Returns:      none
179  *---------------------------------------------------------------------------*/
MTX_RotX43(MtxFx43 * pDst,fx32 sinVal,fx32 cosVal)180 SDK_INLINE void MTX_RotX43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal)
181 {
182     SDK_NULL_ASSERT(pDst);
183     MTX_RotX43_(pDst, sinVal, cosVal);
184 }
185 
186 /*---------------------------------------------------------------------------*
187   Name:         MTX_RotY43
188 
189   Description:  Sets a rotation matrix about the Y axis.
190 
191   Arguments:    pDst         a pointer to a 4x3 matrix
192                 sinVal       sine of an angle of rotation
193                 cosVal       cosine of an angle of rotation
194 
195   Returns:      none
196  *---------------------------------------------------------------------------*/
MTX_RotY43(MtxFx43 * pDst,fx32 sinVal,fx32 cosVal)197 SDK_INLINE void MTX_RotY43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal)
198 {
199     SDK_NULL_ASSERT(pDst);
200     MTX_RotY43_(pDst, sinVal, cosVal);
201 }
202 
203 /*---------------------------------------------------------------------------*
204   Name:         MTX_RotZ43
205 
206   Description:  Sets a rotation matrix about the Z axis.
207 
208   Arguments:    pDst         a pointer to a 4x3 matrix
209                 sinVal       sine of an angle of rotation
210                 cosVal       cosine of an angle of rotation
211 
212   Returns:      none
213  *---------------------------------------------------------------------------*/
MTX_RotZ43(MtxFx43 * pDst,fx32 sinVal,fx32 cosVal)214 SDK_INLINE void MTX_RotZ43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal)
215 {
216     SDK_NULL_ASSERT(pDst);
217     MTX_RotZ43_(pDst, sinVal, cosVal);
218 }
219 
220 
221 #ifdef __cplusplus
222 }/* extern "C" */
223 #endif
224 
225 #endif
226