Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / vectormathlibrary / tests / test3_aos_c.c
1 /*
2   Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
3   All rights reserved.
4
5   Redistribution and use in source and binary forms,
6   with or without modification, are permitted provided that the
7   following conditions are met:
8    * Redistributions of source code must retain the above copyright
9      notice, this list of conditions and the following disclaimer.
10    * Redistributions in binary form must reproduce the above copyright
11      notice, this list of conditions and the following disclaimer in the
12      documentation and/or other materials provided with the distribution.
13    * Neither the name of the Sony Computer Entertainment Inc nor the names
14      of its contributors may be used to endorse or promote products derived
15      from this software without specific prior written permission.
16
17   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27   POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #define _VECTORMATH_AOS_TEST
31
32 #include "vectormath_aos.h"
33 #include "test.h"
34
35 int iteration = 0;
36
37 void
38 Matrix3_methods_test()
39 {
40     VmathMatrix3 a_Matrix3, b_Matrix3;
41     VmathMatrix4 a_Matrix4, b_Matrix4;
42     VmathTransform3 a_Transform3, b_Transform3;
43     VmathMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5;
44     VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
45     VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
46     VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
47     VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
48     VmathVector4 tmpV4;
49     VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8;
50     float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
51     // set a pad value to detect invalid use of padding.
52     // this will be nan for scalar/ppu implementations, max. float for spu
53     union { float f; unsigned int u; } tmp;
54     tmp.u = 0x7fffffff;
55     pad = tmp.f;
56     rndflt1 = randfloat();
57     rndflt2 = randfloat();
58     rndflt3 = randfloat();
59     vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
60     rndflt4 = randfloat();
61     rndflt5 = randfloat();
62     rndflt6 = randfloat();
63     vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
64     rndflt1 = randfloat();
65     rndflt2 = randfloat();
66     rndflt3 = randfloat();
67     vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
68     rndflt1 = randfloat();
69     rndflt2 = randfloat();
70     rndflt3 = randfloat();
71     vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
72     vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
73     vmathV4GetXYZ( &a_Vector3, &tmpV4 );
74     vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
75     vmathV4GetXYZ( &b_Vector3, &tmpV4 );
76     vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
77     vmathV4GetXYZ( &c_Vector3, &tmpV4 );
78     vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
79     vmathV4GetXYZ( &d_Vector3, &tmpV4 );
80     vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
81     vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
82     vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
83     vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
84     rndflt1 = randfloat();
85     rndflt2 = randfloat();
86     rndflt3 = randfloat();
87     rndflt4 = randfloat();
88     vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
89     rndflt3 = randfloat();
90     rndflt4 = randfloat();
91     rndflt5 = randfloat();
92     rndflt6 = randfloat();
93     vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
94     rndflt1 = randfloat();
95     rndflt2 = randfloat();
96     rndflt3 = randfloat();
97     rndflt4 = randfloat();
98     vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
99     rndflt1 = randfloat();
100     rndflt2 = randfloat();
101     rndflt3 = randfloat();
102     rndflt4 = randfloat();
103     vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
104     vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
105     vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
106     vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
107     vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
108     rndflt1 = randfloat();
109     rndflt2 = randfloat();
110     rndflt3 = randfloat();
111     vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
112     rndflt4 = randfloat();
113     rndflt5 = randfloat();
114     rndflt6 = randfloat();
115     vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
116     rndflt1 = randfloat();
117     rndflt2 = randfloat();
118     rndflt3 = randfloat();
119     vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
120     rndflt1 = randfloat();
121     rndflt2 = randfloat();
122     rndflt3 = randfloat();
123     vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
124     vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
125     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
126     vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
127     vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
128     vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
129     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
130     vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
131     vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
132     vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
133     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
134     vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
135     vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
136     vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
137     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
138     vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
139     vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
140     vmathP3Prints( &a_Point3, "set Point3 with floats" );
141     vmathP3Prints( &b_Point3, "set Point3 with floats" );
142     vmathP3Prints( &c_Point3, "set Point3 with floats" );
143     vmathP3Prints( &d_Point3, "set Point3 with floats" );
144     rndflt1 = randfloat();
145     rndflt2 = randfloat();
146     rndflt3 = randfloat();
147     rndflt4 = randfloat();
148     vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
149     rndflt3 = randfloat();
150     rndflt4 = randfloat();
151     rndflt5 = randfloat();
152     rndflt6 = randfloat();
153     vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
154     rndflt1 = randfloat();
155     rndflt2 = randfloat();
156     rndflt3 = randfloat();
157     rndflt4 = randfloat();
158     vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
159     rndflt1 = randfloat();
160     rndflt2 = randfloat();
161     rndflt3 = randfloat();
162     rndflt4 = randfloat();
163     vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
164     vmathQPrints( &a_Quat, "set Quat with floats" );
165     vmathQPrints( &b_Quat, "set Quat with floats" );
166     vmathQPrints( &c_Quat, "set Quat with floats" );
167     vmathQPrints( &d_Quat, "set Quat with floats" );
168     vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
169     vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
170     vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
171     vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
172     vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
173     vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
174     vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
175     vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
176     vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
177     vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
178     vmathT3Prints( &a_Transform3, "set Transform3 columns" );
179     vmathT3Prints( &b_Transform3, "set Transform3 columns" );
180     vmathM3Add( &tmpM3_0, &a_Matrix3, &b_Matrix3 );
181     vmathM3Prints( &tmpM3_0, "Matrix3 + Matrix3" );
182     vmathM3Sub( &tmpM3_1, &a_Matrix3, &b_Matrix3 );
183     vmathM3Prints( &tmpM3_1, "Matrix3 - Matrix3" );
184     vmathM3Neg( &tmpM3_2, &a_Matrix3 );
185     vmathM3Prints( &tmpM3_2, "-Matrix3" );
186     vmathM3ScalarMul( &tmpM3_3, &a_Matrix3, randfloat() );
187     vmathM3Prints( &tmpM3_3, "Matrix3 * float" );
188     vmathM3ScalarMul( &tmpM3_4, &a_Matrix3, randfloat() );
189     vmathM3Prints( &tmpM3_4, "float * Matrix3" );
190     vmathM3MulV3( &tmpV3_8, &a_Matrix3, &a_Vector3 );
191     vmathV3Prints( &tmpV3_8, "Matrix3 * Vector3" );
192     vmathM3Mul( &tmpM3_5, &a_Matrix3, &b_Matrix3 );
193     vmathM3Prints( &tmpM3_5, "Matrix3 * Matrix3" );
194 }
195
196 void
197 Matrix4_methods_test()
198 {
199     VmathMatrix3 a_Matrix3, b_Matrix3;
200     VmathMatrix4 a_Matrix4, b_Matrix4;
201     VmathTransform3 a_Transform3, b_Transform3;
202     VmathMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6;
203     VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
204     VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
205     VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
206     VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
207     VmathVector4 tmpV4;
208     VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7;
209     VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2;
210     float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
211     // set a pad value to detect invalid use of padding.
212     // this will be nan for scalar/ppu implementations, max. float for spu
213     union { float f; unsigned int u; } tmp;
214     tmp.u = 0x7fffffff;
215     pad = tmp.f;
216     rndflt1 = randfloat();
217     rndflt2 = randfloat();
218     rndflt3 = randfloat();
219     vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
220     rndflt4 = randfloat();
221     rndflt5 = randfloat();
222     rndflt6 = randfloat();
223     vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
224     rndflt1 = randfloat();
225     rndflt2 = randfloat();
226     rndflt3 = randfloat();
227     vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
228     rndflt1 = randfloat();
229     rndflt2 = randfloat();
230     rndflt3 = randfloat();
231     vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
232     vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
233     vmathV4GetXYZ( &a_Vector3, &tmpV4 );
234     vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
235     vmathV4GetXYZ( &b_Vector3, &tmpV4 );
236     vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
237     vmathV4GetXYZ( &c_Vector3, &tmpV4 );
238     vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
239     vmathV4GetXYZ( &d_Vector3, &tmpV4 );
240     vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
241     vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
242     vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
243     vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
244     rndflt1 = randfloat();
245     rndflt2 = randfloat();
246     rndflt3 = randfloat();
247     rndflt4 = randfloat();
248     vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
249     rndflt3 = randfloat();
250     rndflt4 = randfloat();
251     rndflt5 = randfloat();
252     rndflt6 = randfloat();
253     vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
254     rndflt1 = randfloat();
255     rndflt2 = randfloat();
256     rndflt3 = randfloat();
257     rndflt4 = randfloat();
258     vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
259     rndflt1 = randfloat();
260     rndflt2 = randfloat();
261     rndflt3 = randfloat();
262     rndflt4 = randfloat();
263     vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
264     vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
265     vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
266     vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
267     vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
268     rndflt1 = randfloat();
269     rndflt2 = randfloat();
270     rndflt3 = randfloat();
271     vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
272     rndflt4 = randfloat();
273     rndflt5 = randfloat();
274     rndflt6 = randfloat();
275     vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
276     rndflt1 = randfloat();
277     rndflt2 = randfloat();
278     rndflt3 = randfloat();
279     vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
280     rndflt1 = randfloat();
281     rndflt2 = randfloat();
282     rndflt3 = randfloat();
283     vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
284     vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
285     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
286     vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
287     vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
288     vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
289     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
290     vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
291     vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
292     vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
293     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
294     vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
295     vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
296     vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
297     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
298     vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
299     vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
300     vmathP3Prints( &a_Point3, "set Point3 with floats" );
301     vmathP3Prints( &b_Point3, "set Point3 with floats" );
302     vmathP3Prints( &c_Point3, "set Point3 with floats" );
303     vmathP3Prints( &d_Point3, "set Point3 with floats" );
304     rndflt1 = randfloat();
305     rndflt2 = randfloat();
306     rndflt3 = randfloat();
307     rndflt4 = randfloat();
308     vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
309     rndflt3 = randfloat();
310     rndflt4 = randfloat();
311     rndflt5 = randfloat();
312     rndflt6 = randfloat();
313     vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
314     rndflt1 = randfloat();
315     rndflt2 = randfloat();
316     rndflt3 = randfloat();
317     rndflt4 = randfloat();
318     vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
319     rndflt1 = randfloat();
320     rndflt2 = randfloat();
321     rndflt3 = randfloat();
322     rndflt4 = randfloat();
323     vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
324     vmathQPrints( &a_Quat, "set Quat with floats" );
325     vmathQPrints( &b_Quat, "set Quat with floats" );
326     vmathQPrints( &c_Quat, "set Quat with floats" );
327     vmathQPrints( &d_Quat, "set Quat with floats" );
328     vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
329     vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
330     vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
331     vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
332     vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
333     vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
334     vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
335     vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
336     vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
337     vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
338     vmathT3Prints( &a_Transform3, "set Transform3 columns" );
339     vmathT3Prints( &b_Transform3, "set Transform3 columns" );
340     vmathM4Add( &tmpM4_0, &a_Matrix4, &b_Matrix4 );
341     vmathM4Prints( &tmpM4_0, "Matrix4 + Matrix4" );
342     vmathM4Sub( &tmpM4_1, &a_Matrix4, &b_Matrix4 );
343     vmathM4Prints( &tmpM4_1, "Matrix4 - Matrix4" );
344     vmathM4Neg( &tmpM4_2, &a_Matrix4 );
345     vmathM4Prints( &tmpM4_2, "-Matrix4" );
346     vmathM4ScalarMul( &tmpM4_3, &a_Matrix4, randfloat() );
347     vmathM4Prints( &tmpM4_3, "Matrix4 * float" );
348     vmathM4ScalarMul( &tmpM4_4, &a_Matrix4, randfloat() );
349     vmathM4Prints( &tmpM4_4, "float * Matrix4" );
350     vmathM4MulV4( &tmpV4_0, &a_Matrix4, &a_Vector4 );
351     vmathV4Prints( &tmpV4_0, "Matrix4 * Vector4" );
352     vmathM4MulV3( &tmpV4_1, &a_Matrix4, &a_Vector3 );
353     vmathV4Prints( &tmpV4_1, "Matrix4 * Vector3" );
354     vmathM4MulP3( &tmpV4_2, &a_Matrix4, &a_Point3 );
355     vmathV4Prints( &tmpV4_2, "Matrix4 * Point3" );
356     vmathM4Mul( &tmpM4_5, &a_Matrix4, &b_Matrix4 );
357     vmathM4Prints( &tmpM4_5, "Matrix4 * Matrix4" );
358     vmathM4MulT3( &tmpM4_6, &a_Matrix4, &b_Transform3 );
359     vmathM4Prints( &tmpM4_6, "Matrix4 * Transform3" );
360 }
361
362 void
363 Transform3_methods_test()
364 {
365     VmathMatrix3 a_Matrix3, b_Matrix3;
366     VmathMatrix4 a_Matrix4, b_Matrix4;
367     VmathTransform3 a_Transform3, b_Transform3, tmpT3_0;
368     VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
369     VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
370     VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
371     VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
372     VmathVector4 tmpV4;
373     VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8;
374     VmathPoint3 tmpP3_0;
375     float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
376     // set a pad value to detect invalid use of padding.
377     // this will be nan for scalar/ppu implementations, max. float for spu
378     union { float f; unsigned int u; } tmp;
379     tmp.u = 0x7fffffff;
380     pad = tmp.f;
381     rndflt1 = randfloat();
382     rndflt2 = randfloat();
383     rndflt3 = randfloat();
384     vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
385     rndflt4 = randfloat();
386     rndflt5 = randfloat();
387     rndflt6 = randfloat();
388     vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
389     rndflt1 = randfloat();
390     rndflt2 = randfloat();
391     rndflt3 = randfloat();
392     vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
393     rndflt1 = randfloat();
394     rndflt2 = randfloat();
395     rndflt3 = randfloat();
396     vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
397     vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
398     vmathV4GetXYZ( &a_Vector3, &tmpV4 );
399     vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
400     vmathV4GetXYZ( &b_Vector3, &tmpV4 );
401     vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
402     vmathV4GetXYZ( &c_Vector3, &tmpV4 );
403     vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
404     vmathV4GetXYZ( &d_Vector3, &tmpV4 );
405     vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
406     vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
407     vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
408     vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
409     rndflt1 = randfloat();
410     rndflt2 = randfloat();
411     rndflt3 = randfloat();
412     rndflt4 = randfloat();
413     vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
414     rndflt3 = randfloat();
415     rndflt4 = randfloat();
416     rndflt5 = randfloat();
417     rndflt6 = randfloat();
418     vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
419     rndflt1 = randfloat();
420     rndflt2 = randfloat();
421     rndflt3 = randfloat();
422     rndflt4 = randfloat();
423     vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
424     rndflt1 = randfloat();
425     rndflt2 = randfloat();
426     rndflt3 = randfloat();
427     rndflt4 = randfloat();
428     vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
429     vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
430     vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
431     vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
432     vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
433     rndflt1 = randfloat();
434     rndflt2 = randfloat();
435     rndflt3 = randfloat();
436     vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
437     rndflt4 = randfloat();
438     rndflt5 = randfloat();
439     rndflt6 = randfloat();
440     vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
441     rndflt1 = randfloat();
442     rndflt2 = randfloat();
443     rndflt3 = randfloat();
444     vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
445     rndflt1 = randfloat();
446     rndflt2 = randfloat();
447     rndflt3 = randfloat();
448     vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
449     vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
450     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
451     vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
452     vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
453     vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
454     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
455     vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
456     vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
457     vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
458     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
459     vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
460     vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
461     vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
462     vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
463     vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
464     vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
465     vmathP3Prints( &a_Point3, "set Point3 with floats" );
466     vmathP3Prints( &b_Point3, "set Point3 with floats" );
467     vmathP3Prints( &c_Point3, "set Point3 with floats" );
468     vmathP3Prints( &d_Point3, "set Point3 with floats" );
469     rndflt1 = randfloat();
470     rndflt2 = randfloat();
471     rndflt3 = randfloat();
472     rndflt4 = randfloat();
473     vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
474     rndflt3 = randfloat();
475     rndflt4 = randfloat();
476     rndflt5 = randfloat();
477     rndflt6 = randfloat();
478     vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
479     rndflt1 = randfloat();
480     rndflt2 = randfloat();
481     rndflt3 = randfloat();
482     rndflt4 = randfloat();
483     vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
484     rndflt1 = randfloat();
485     rndflt2 = randfloat();
486     rndflt3 = randfloat();
487     rndflt4 = randfloat();
488     vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
489     vmathQPrints( &a_Quat, "set Quat with floats" );
490     vmathQPrints( &b_Quat, "set Quat with floats" );
491     vmathQPrints( &c_Quat, "set Quat with floats" );
492     vmathQPrints( &d_Quat, "set Quat with floats" );
493     vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
494     vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
495     vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
496     vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
497     vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
498     vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
499     vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
500     vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
501     vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
502     vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
503     vmathT3Prints( &a_Transform3, "set Transform3 columns" );
504     vmathT3Prints( &b_Transform3, "set Transform3 columns" );
505     vmathT3MulV3( &tmpV3_8, &a_Transform3, &a_Vector3 );
506     vmathV3Prints( &tmpV3_8, "Transform3 * Vector3" );
507     vmathT3MulP3( &tmpP3_0, &a_Transform3, &a_Point3 );
508     vmathP3Prints( &tmpP3_0, "Transform3 * Point3" );
509     vmathT3Mul( &tmpT3_0, &a_Transform3, &b_Transform3 );
510     vmathT3Prints( &tmpT3_0, "Transform3 * Transform3" );
511 }
512
513 int main()
514 {
515     int i;
516     printf("\n __begin__ \n");
517     for ( i = 0; i < 2; i++ ) {
518         Matrix3_methods_test();
519         Matrix4_methods_test();
520         Transform3_methods_test();
521     }
522     printf("\n __end__ \n");
523     return 0;
524 }