2 Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
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.
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.
30 #define _VECTORMATH_SOA_TEST
32 #include "vectormath_soa.h"
37 using namespace Vectormath;
38 using namespace Vectormath::Soa;
41 Matrix3_methods_test()
43 Matrix3 a_Matrix3, b_Matrix3;
44 Matrix4 a_Matrix4, b_Matrix4;
45 Transform3 a_Transform3, b_Transform3;
46 Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
47 Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
48 Point3 a_Point3, b_Point3, c_Point3, d_Point3;
49 Quat a_Quat, b_Quat, c_Quat, d_Quat;
50 vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
51 rndflt1 = randfloat();
52 rndflt2 = randfloat();
53 rndflt3 = randfloat();
54 a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
55 rndflt4 = randfloat();
56 rndflt5 = randfloat();
57 rndflt6 = randfloat();
58 b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
59 rndflt1 = randfloat();
60 rndflt2 = randfloat();
61 rndflt3 = randfloat();
62 c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
63 rndflt1 = randfloat();
64 rndflt2 = randfloat();
65 rndflt3 = randfloat();
66 d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
67 print( a_Vector3, "set Vector3 with floats" );
68 print( b_Vector3, "set Vector3 with floats" );
69 print( c_Vector3, "set Vector3 with floats" );
70 print( d_Vector3, "set Vector3 with floats" );
71 rndflt1 = randfloat();
72 rndflt2 = randfloat();
73 rndflt3 = randfloat();
74 rndflt4 = randfloat();
75 a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
76 rndflt3 = randfloat();
77 rndflt4 = randfloat();
78 rndflt5 = randfloat();
79 rndflt6 = randfloat();
80 b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
81 rndflt1 = randfloat();
82 rndflt2 = randfloat();
83 rndflt3 = randfloat();
84 rndflt4 = randfloat();
85 c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
86 rndflt1 = randfloat();
87 rndflt2 = randfloat();
88 rndflt3 = randfloat();
89 rndflt4 = randfloat();
90 d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
91 print( a_Vector4, "set Vector4 with floats" );
92 print( b_Vector4, "set Vector4 with floats" );
93 print( c_Vector4, "set Vector4 with floats" );
94 print( d_Vector4, "set Vector4 with floats" );
95 rndflt1 = randfloat();
96 rndflt2 = randfloat();
97 rndflt3 = randfloat();
98 a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
99 rndflt4 = randfloat();
100 rndflt5 = randfloat();
101 rndflt6 = randfloat();
102 b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
103 rndflt1 = randfloat();
104 rndflt2 = randfloat();
105 rndflt3 = randfloat();
106 c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
107 rndflt1 = randfloat();
108 rndflt2 = randfloat();
109 rndflt3 = randfloat();
110 d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
111 print( a_Point3, "set Point3 with floats" );
112 print( b_Point3, "set Point3 with floats" );
113 print( c_Point3, "set Point3 with floats" );
114 print( d_Point3, "set Point3 with floats" );
115 rndflt1 = randfloat();
116 rndflt2 = randfloat();
117 rndflt3 = randfloat();
118 rndflt4 = randfloat();
119 a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
120 rndflt3 = randfloat();
121 rndflt4 = randfloat();
122 rndflt5 = randfloat();
123 rndflt6 = randfloat();
124 b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
125 rndflt1 = randfloat();
126 rndflt2 = randfloat();
127 rndflt3 = randfloat();
128 rndflt4 = randfloat();
129 c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
130 rndflt1 = randfloat();
131 rndflt2 = randfloat();
132 rndflt3 = randfloat();
133 rndflt4 = randfloat();
134 d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
135 print( a_Quat, "set Quat with floats" );
136 print( b_Quat, "set Quat with floats" );
137 print( c_Quat, "set Quat with floats" );
138 print( d_Quat, "set Quat with floats" );
139 a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
140 b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
141 print( a_Matrix3, "set Matrix3 columns" );
142 print( b_Matrix3, "set Matrix3 columns" );
143 a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
144 b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
145 print( a_Matrix4, "set Matrix4 columns" );
146 print( b_Matrix4, "set Matrix4 columns" );
147 a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
148 b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
149 print( a_Transform3, "set Transform3 columns" );
150 print( b_Transform3, "set Transform3 columns" );
151 print( ( a_Matrix3 + b_Matrix3 ), "Matrix3 + Matrix3" );
152 print( ( a_Matrix3 - b_Matrix3 ), "Matrix3 - Matrix3" );
153 print( ( -a_Matrix3 ), "-Matrix3" );
154 print( ( a_Matrix3 * randfloat() ), "Matrix3 * float" );
155 print( ( randfloat() * a_Matrix3 ), "float * Matrix3" );
156 print( ( a_Matrix3 * a_Vector3 ), "Matrix3 * Vector3" );
157 print( ( a_Matrix3 * b_Matrix3 ), "Matrix3 * Matrix3" );
161 Matrix4_methods_test()
163 Matrix3 a_Matrix3, b_Matrix3;
164 Matrix4 a_Matrix4, b_Matrix4;
165 Transform3 a_Transform3, b_Transform3;
166 Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
167 Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
168 Point3 a_Point3, b_Point3, c_Point3, d_Point3;
169 Quat a_Quat, b_Quat, c_Quat, d_Quat;
170 vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
171 rndflt1 = randfloat();
172 rndflt2 = randfloat();
173 rndflt3 = randfloat();
174 a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
175 rndflt4 = randfloat();
176 rndflt5 = randfloat();
177 rndflt6 = randfloat();
178 b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
179 rndflt1 = randfloat();
180 rndflt2 = randfloat();
181 rndflt3 = randfloat();
182 c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
183 rndflt1 = randfloat();
184 rndflt2 = randfloat();
185 rndflt3 = randfloat();
186 d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
187 print( a_Vector3, "set Vector3 with floats" );
188 print( b_Vector3, "set Vector3 with floats" );
189 print( c_Vector3, "set Vector3 with floats" );
190 print( d_Vector3, "set Vector3 with floats" );
191 rndflt1 = randfloat();
192 rndflt2 = randfloat();
193 rndflt3 = randfloat();
194 rndflt4 = randfloat();
195 a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
196 rndflt3 = randfloat();
197 rndflt4 = randfloat();
198 rndflt5 = randfloat();
199 rndflt6 = randfloat();
200 b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
201 rndflt1 = randfloat();
202 rndflt2 = randfloat();
203 rndflt3 = randfloat();
204 rndflt4 = randfloat();
205 c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
206 rndflt1 = randfloat();
207 rndflt2 = randfloat();
208 rndflt3 = randfloat();
209 rndflt4 = randfloat();
210 d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
211 print( a_Vector4, "set Vector4 with floats" );
212 print( b_Vector4, "set Vector4 with floats" );
213 print( c_Vector4, "set Vector4 with floats" );
214 print( d_Vector4, "set Vector4 with floats" );
215 rndflt1 = randfloat();
216 rndflt2 = randfloat();
217 rndflt3 = randfloat();
218 a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
219 rndflt4 = randfloat();
220 rndflt5 = randfloat();
221 rndflt6 = randfloat();
222 b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
223 rndflt1 = randfloat();
224 rndflt2 = randfloat();
225 rndflt3 = randfloat();
226 c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
227 rndflt1 = randfloat();
228 rndflt2 = randfloat();
229 rndflt3 = randfloat();
230 d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
231 print( a_Point3, "set Point3 with floats" );
232 print( b_Point3, "set Point3 with floats" );
233 print( c_Point3, "set Point3 with floats" );
234 print( d_Point3, "set Point3 with floats" );
235 rndflt1 = randfloat();
236 rndflt2 = randfloat();
237 rndflt3 = randfloat();
238 rndflt4 = randfloat();
239 a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
240 rndflt3 = randfloat();
241 rndflt4 = randfloat();
242 rndflt5 = randfloat();
243 rndflt6 = randfloat();
244 b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
245 rndflt1 = randfloat();
246 rndflt2 = randfloat();
247 rndflt3 = randfloat();
248 rndflt4 = randfloat();
249 c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
250 rndflt1 = randfloat();
251 rndflt2 = randfloat();
252 rndflt3 = randfloat();
253 rndflt4 = randfloat();
254 d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
255 print( a_Quat, "set Quat with floats" );
256 print( b_Quat, "set Quat with floats" );
257 print( c_Quat, "set Quat with floats" );
258 print( d_Quat, "set Quat with floats" );
259 a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
260 b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
261 print( a_Matrix3, "set Matrix3 columns" );
262 print( b_Matrix3, "set Matrix3 columns" );
263 a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
264 b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
265 print( a_Matrix4, "set Matrix4 columns" );
266 print( b_Matrix4, "set Matrix4 columns" );
267 a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
268 b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
269 print( a_Transform3, "set Transform3 columns" );
270 print( b_Transform3, "set Transform3 columns" );
271 print( ( a_Matrix4 + b_Matrix4 ), "Matrix4 + Matrix4" );
272 print( ( a_Matrix4 - b_Matrix4 ), "Matrix4 - Matrix4" );
273 print( ( -a_Matrix4 ), "-Matrix4" );
274 print( ( a_Matrix4 * randfloat() ), "Matrix4 * float" );
275 print( ( randfloat() * a_Matrix4 ), "float * Matrix4" );
276 print( ( a_Matrix4 * a_Vector4 ), "Matrix4 * Vector4" );
277 print( ( a_Matrix4 * a_Vector3 ), "Matrix4 * Vector3" );
278 print( ( a_Matrix4 * a_Point3 ), "Matrix4 * Point3" );
279 print( ( a_Matrix4 * b_Matrix4 ), "Matrix4 * Matrix4" );
280 print( ( a_Matrix4 * b_Transform3 ), "Matrix4 * Transform3" );
284 Transform3_methods_test()
286 Matrix3 a_Matrix3, b_Matrix3;
287 Matrix4 a_Matrix4, b_Matrix4;
288 Transform3 a_Transform3, b_Transform3;
289 Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
290 Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
291 Point3 a_Point3, b_Point3, c_Point3, d_Point3;
292 Quat a_Quat, b_Quat, c_Quat, d_Quat;
293 vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
294 rndflt1 = randfloat();
295 rndflt2 = randfloat();
296 rndflt3 = randfloat();
297 a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
298 rndflt4 = randfloat();
299 rndflt5 = randfloat();
300 rndflt6 = randfloat();
301 b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
302 rndflt1 = randfloat();
303 rndflt2 = randfloat();
304 rndflt3 = randfloat();
305 c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
306 rndflt1 = randfloat();
307 rndflt2 = randfloat();
308 rndflt3 = randfloat();
309 d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
310 print( a_Vector3, "set Vector3 with floats" );
311 print( b_Vector3, "set Vector3 with floats" );
312 print( c_Vector3, "set Vector3 with floats" );
313 print( d_Vector3, "set Vector3 with floats" );
314 rndflt1 = randfloat();
315 rndflt2 = randfloat();
316 rndflt3 = randfloat();
317 rndflt4 = randfloat();
318 a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
319 rndflt3 = randfloat();
320 rndflt4 = randfloat();
321 rndflt5 = randfloat();
322 rndflt6 = randfloat();
323 b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
324 rndflt1 = randfloat();
325 rndflt2 = randfloat();
326 rndflt3 = randfloat();
327 rndflt4 = randfloat();
328 c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
329 rndflt1 = randfloat();
330 rndflt2 = randfloat();
331 rndflt3 = randfloat();
332 rndflt4 = randfloat();
333 d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
334 print( a_Vector4, "set Vector4 with floats" );
335 print( b_Vector4, "set Vector4 with floats" );
336 print( c_Vector4, "set Vector4 with floats" );
337 print( d_Vector4, "set Vector4 with floats" );
338 rndflt1 = randfloat();
339 rndflt2 = randfloat();
340 rndflt3 = randfloat();
341 a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
342 rndflt4 = randfloat();
343 rndflt5 = randfloat();
344 rndflt6 = randfloat();
345 b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
346 rndflt1 = randfloat();
347 rndflt2 = randfloat();
348 rndflt3 = randfloat();
349 c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
350 rndflt1 = randfloat();
351 rndflt2 = randfloat();
352 rndflt3 = randfloat();
353 d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
354 print( a_Point3, "set Point3 with floats" );
355 print( b_Point3, "set Point3 with floats" );
356 print( c_Point3, "set Point3 with floats" );
357 print( d_Point3, "set Point3 with floats" );
358 rndflt1 = randfloat();
359 rndflt2 = randfloat();
360 rndflt3 = randfloat();
361 rndflt4 = randfloat();
362 a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
363 rndflt3 = randfloat();
364 rndflt4 = randfloat();
365 rndflt5 = randfloat();
366 rndflt6 = randfloat();
367 b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
368 rndflt1 = randfloat();
369 rndflt2 = randfloat();
370 rndflt3 = randfloat();
371 rndflt4 = randfloat();
372 c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
373 rndflt1 = randfloat();
374 rndflt2 = randfloat();
375 rndflt3 = randfloat();
376 rndflt4 = randfloat();
377 d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
378 print( a_Quat, "set Quat with floats" );
379 print( b_Quat, "set Quat with floats" );
380 print( c_Quat, "set Quat with floats" );
381 print( d_Quat, "set Quat with floats" );
382 a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
383 b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
384 print( a_Matrix3, "set Matrix3 columns" );
385 print( b_Matrix3, "set Matrix3 columns" );
386 a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
387 b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
388 print( a_Matrix4, "set Matrix4 columns" );
389 print( b_Matrix4, "set Matrix4 columns" );
390 a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
391 b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
392 print( a_Transform3, "set Transform3 columns" );
393 print( b_Transform3, "set Transform3 columns" );
394 print( ( a_Transform3 * a_Vector3 ), "Transform3 * Vector3" );
395 print( ( a_Transform3 * a_Point3 ), "Transform3 * Point3" );
396 print( ( a_Transform3 * b_Transform3 ), "Transform3 * Transform3" );
402 printf("\n __begin__ \n");
403 for ( i = 0; i < 2; i++ ) {
404 Matrix3_methods_test();
405 Matrix4_methods_test();
406 Transform3_methods_test();
408 printf("\n __end__ \n");