push 93d38255e04d8d2fa525a0100c5e1cee4a9f11a8
[wine/hacks.git] / dlls / d3dx9_36 / tests / math.c
blobff5e1102af783fb1fea521200e1afbab37f8bd47
1 /*
2 * Copyright 2008 Philip Nilsson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wine/test.h"
20 #include "d3dx9math.h"
22 #define ARRAY_SIZE 5
24 #define admitted_error 0.0001f
26 #define relative_error(exp, out) ((exp == out) ? 0.0f : (fabs(out - exp) / fabs(exp)))
28 #define compare_rotation(exp, got) \
29 ok(fabs(exp.w - got.w) < admitted_error && \
30 fabs(exp.x - got.x) < admitted_error && \
31 fabs(exp.y - got.y) < admitted_error && \
32 fabs(exp.z - got.z) < admitted_error, \
33 "Expected rotation = (%f, %f, %f, %f), \
34 got rotation = (%f, %f, %f, %f)\n", \
35 exp.w, exp.x, exp.y, exp.z, got.w, got.x, got.y, got.z)
37 #define compare_scale(exp, got) \
38 ok(fabs(exp.x - got.x) < admitted_error && \
39 fabs(exp.y - got.y) < admitted_error && \
40 fabs(exp.z - got.z) < admitted_error, \
41 "Expected scale = (%f, %f, %f), \
42 got scale = (%f, %f, %f)\n", \
43 exp.x, exp.y, exp.z, got.x, got.y, got.z)
45 #define compare_translation(exp, got) \
46 ok(fabs(exp.x - got.x) < admitted_error && \
47 fabs(exp.y - got.y) < admitted_error && \
48 fabs(exp.z - got.z) < admitted_error, \
49 "Expected translation = (%f, %f, %f), \
50 got translation = (%f, %f, %f)\n", \
51 exp.x, exp.y, exp.z, got.x, got.y, got.z)
53 #define compare_vectors(exp, out) \
54 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
55 ok(relative_error(exp[i].x, out[i].x) < admitted_error && \
56 relative_error(exp[i].y, out[i].y) < admitted_error && \
57 relative_error(exp[i].z, out[i].z) < admitted_error && \
58 relative_error(exp[i].w, out[i].w) < admitted_error, \
59 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
60 out[i].x, out[i].y, out[i].z, out[i].w, \
61 exp[i].x, exp[i].y, exp[i].z, exp[i].w, \
62 i); \
65 #define compare_planes(exp, out) \
66 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
67 ok(relative_error(exp[i].a, out[i].a) < admitted_error && \
68 relative_error(exp[i].b, out[i].b) < admitted_error && \
69 relative_error(exp[i].c, out[i].c) < admitted_error && \
70 relative_error(exp[i].d, out[i].d) < admitted_error, \
71 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
72 out[i].a, out[i].b, out[i].c, out[i].d, \
73 exp[i].a, exp[i].b, exp[i].c, exp[i].d, \
74 i); \
77 /* The mathematical properties are checked in the d3dx8 testsuite.
79 * These tests check:
80 * That the functions work.
81 * That the stride functionality works.
82 * That nothing is written where it should not be.
84 * These tests should check:
85 * That inp_vec is not modified.
86 * That the input and output arrays can be the same (MSDN
87 * says they can, and some testing with a native DLL
88 * says so too).
91 static void test_Matrix_Decompose(void)
93 D3DXMATRIX pm;
94 D3DXQUATERNION exp_rotation, got_rotation;
95 D3DXVECTOR3 exp_scale, got_scale, exp_translation, got_translation;
96 HRESULT hr;
98 /*___________*/
100 U(pm).m[0][0] = -0.9238790f;
101 U(pm).m[1][0] = -0.2705984f;
102 U(pm).m[2][0] = 0.2705984f;
103 U(pm).m[3][0] = -5.0f;
104 U(pm).m[0][1] = 0.2705984f;
105 U(pm).m[1][1] = 0.03806049f;
106 U(pm).m[2][1] = 0.9619395f;
107 U(pm).m[3][1] = 0.0f;
108 U(pm).m[0][2] = -0.2705984f;
109 U(pm).m[1][2] = 0.9619395f;
110 U(pm).m[2][2] = 0.03806049f;
111 U(pm).m[3][2] = 10.0f;
112 U(pm).m[0][3] = 0.0f;
113 U(pm).m[1][3] = 0.0f;
114 U(pm).m[2][3] = 0.0f;
115 U(pm).m[3][3] = 1.0f;
117 exp_scale.x = 1.0f;
118 exp_scale.y = 1.0f;
119 exp_scale.z = 1.0f;
121 exp_rotation.w = 0.195091f;
122 exp_rotation.x = 0.0f;
123 exp_rotation.y = 0.693520f;
124 exp_rotation.z = 0.693520f;
126 exp_translation.x = -5.0f;
127 exp_translation.y = 0.0f;
128 exp_translation.z = 10.0f;
130 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
132 compare_scale(exp_scale, got_scale);
133 compare_rotation(exp_rotation, got_rotation);
134 compare_translation(exp_translation, got_translation);
136 /*_________*/
138 U(pm).m[0][0] = -2.255813f;
139 U(pm).m[1][0] = 1.302324f;
140 U(pm).m[2][0] = 1.488373f;
141 U(pm).m[3][0] = 1.0f;
142 U(pm).m[0][1] = 1.302327f;
143 U(pm).m[1][1] = -0.7209296f;
144 U(pm).m[2][1] = 2.60465f;
145 U(pm).m[3][1] = 2.0f;
146 U(pm).m[0][2] = 1.488371f;
147 U(pm).m[1][2] = 2.604651f;
148 U(pm).m[2][2] = -0.02325551f;
149 U(pm).m[3][2] = 3.0f;
150 U(pm).m[0][3] = 0.0f;
151 U(pm).m[1][3] = 0.0f;
152 U(pm).m[2][3] = 0.0f;
153 U(pm).m[3][3] = 1.0f;
155 exp_scale.x = 3.0f;
156 exp_scale.y = 3.0f;
157 exp_scale.z = 3.0f;
159 exp_rotation.w = 0.0;
160 exp_rotation.x = 0.352180f;
161 exp_rotation.y = 0.616316f;
162 exp_rotation.z = 0.704361f;
164 exp_translation.x = 1.0f;
165 exp_translation.y = 2.0f;
166 exp_translation.z = 3.0f;
168 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
170 compare_scale(exp_scale, got_scale);
171 compare_rotation(exp_rotation, got_rotation);
172 compare_translation(exp_translation, got_translation);
174 /*_____________*/
176 U(pm).m[0][0] = 2.427051f;
177 U(pm).m[1][0] = 0.0f;
178 U(pm).m[2][0] = 1.763355f;
179 U(pm).m[3][0] = 5.0f;
180 U(pm).m[0][1] = 0.0f;
181 U(pm).m[1][1] = 3.0f;
182 U(pm).m[2][1] = 0.0f;
183 U(pm).m[3][1] = 5.0f;
184 U(pm).m[0][2] = -1.763355f;
185 U(pm).m[1][2] = 0.0f;
186 U(pm).m[2][2] = 2.427051f;
187 U(pm).m[3][2] = 5.0f;
188 U(pm).m[0][3] = 0.0f;
189 U(pm).m[1][3] = 0.0f;
190 U(pm).m[2][3] = 0.0f;
191 U(pm).m[3][3] = 1.0f;
193 exp_scale.x = 3.0f;
194 exp_scale.y = 3.0f;
195 exp_scale.z = 3.0f;
197 exp_rotation.w = 0.951057f;
198 exp_rotation.x = 0.0f;
199 exp_rotation.y = 0.309017f;
200 exp_rotation.z = 0.0f;
202 exp_translation.x = 5.0f;
203 exp_translation.y = 5.0f;
204 exp_translation.z = 5.0f;
206 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
208 compare_scale(exp_scale, got_scale);
209 compare_rotation(exp_rotation, got_rotation);
210 compare_translation(exp_translation, got_translation);
212 /*_____________*/
214 U(pm).m[0][0] = -0.9238790f;
215 U(pm).m[1][0] = -0.2705984f;
216 U(pm).m[2][0] = 0.2705984f;
217 U(pm).m[3][0] = -5.0f;
218 U(pm).m[0][1] = 0.2705984f;
219 U(pm).m[1][1] = 0.03806049f;
220 U(pm).m[2][1] = 0.9619395f;
221 U(pm).m[3][1] = 0.0f;
222 U(pm).m[0][2] = -0.2705984f;
223 U(pm).m[1][2] = 0.9619395f;
224 U(pm).m[2][2] = 0.03806049f;
225 U(pm).m[3][2] = 10.0f;
226 U(pm).m[0][3] = 0.0f;
227 U(pm).m[1][3] = 0.0f;
228 U(pm).m[2][3] = 0.0f;
229 U(pm).m[3][3] = 1.0f;
231 exp_scale.x = 1.0f;
232 exp_scale.y = 1.0f;
233 exp_scale.z = 1.0f;
235 exp_rotation.w = 0.195091f;
236 exp_rotation.x = 0.0f;
237 exp_rotation.y = 0.693520f;
238 exp_rotation.z = 0.693520f;
240 exp_translation.x = -5.0f;
241 exp_translation.y = 0.0f;
242 exp_translation.z = 10.0f;
244 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
246 compare_scale(exp_scale, got_scale);
247 compare_rotation(exp_rotation, got_rotation);
248 compare_translation(exp_translation, got_translation);
250 /*__________*/
252 U(pm).m[0][0] = -0.9238790f;
253 U(pm).m[1][0] = -0.5411968f;
254 U(pm).m[2][0] = 0.8117952f;
255 U(pm).m[3][0] = -5.0f;
256 U(pm).m[0][1] = 0.2705984f;
257 U(pm).m[1][1] = 0.07612098f;
258 U(pm).m[2][1] = 2.8858185f;
259 U(pm).m[3][1] = 0.0f;
260 U(pm).m[0][2] = -0.2705984f;
261 U(pm).m[1][2] = 1.9238790f;
262 U(pm).m[2][2] = 0.11418147f;
263 U(pm).m[3][2] = 10.0f;
264 U(pm).m[0][3] = 0.0f;
265 U(pm).m[1][3] = 0.0f;
266 U(pm).m[2][3] = 0.0f;
267 U(pm).m[3][3] = 1.0f;
269 exp_scale.x = 1.0f;
270 exp_scale.y = 2.0f;
271 exp_scale.z = 3.0f;
273 exp_rotation.w = 0.195091f;
274 exp_rotation.x = 0.0f;
275 exp_rotation.y = 0.693520f;
276 exp_rotation.z = 0.693520f;
278 exp_translation.x = -5.0f;
279 exp_translation.y = 0.0f;
280 exp_translation.z = 10.0f;
282 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
284 compare_scale(exp_scale, got_scale);
285 compare_rotation(exp_rotation, got_rotation);
286 compare_translation(exp_translation, got_translation);
288 /*__________*/
290 U(pm).m[0][0] = 0.7156004f;
291 U(pm).m[1][0] = -0.5098283f;
292 U(pm).m[2][0] = -0.4774843f;
293 U(pm).m[3][0] = -5.0f;
294 U(pm).m[0][1] = -0.6612288f;
295 U(pm).m[1][1] = -0.7147621f;
296 U(pm).m[2][1] = -0.2277977f;
297 U(pm).m[3][1] = 0.0f;
298 U(pm).m[0][2] = -0.2251499f;
299 U(pm).m[1][2] = 0.4787385f;
300 U(pm).m[2][2] = -0.8485972f;
301 U(pm).m[3][2] = 10.0f;
302 U(pm).m[0][3] = 0.0f;
303 U(pm).m[1][3] = 0.0f;
304 U(pm).m[2][3] = 0.0f;
305 U(pm).m[3][3] = 1.0f;
307 exp_scale.x = 1.0f;
308 exp_scale.y = 1.0f;
309 exp_scale.z = 1.0f;
311 exp_rotation.w = 0.195091f;
312 exp_rotation.x = 0.905395f;
313 exp_rotation.y = -0.323355f;
314 exp_rotation.z = -0.194013f;
316 exp_translation.x = -5.0f;
317 exp_translation.y = 0.0f;
318 exp_translation.z = 10.0f;
320 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
322 compare_scale(exp_scale, got_scale);
323 compare_rotation(exp_rotation, got_rotation);
324 compare_translation(exp_translation, got_translation);
326 /*_____________*/
328 U(pm).m[0][0] = 0.06554436f;
329 U(pm).m[1][0] = -0.6873012f;
330 U(pm).m[2][0] = 0.7234092f;
331 U(pm).m[3][0] = -5.0f;
332 U(pm).m[0][1] = -0.9617381f;
333 U(pm).m[1][1] = -0.2367795f;
334 U(pm).m[2][1] = -0.1378230f;
335 U(pm).m[3][1] = 0.0f;
336 U(pm).m[0][2] = 0.2660144f;
337 U(pm).m[1][2] = -0.6866967f;
338 U(pm).m[2][2] = -0.6765233f;
339 U(pm).m[3][2] = 10.0f;
340 U(pm).m[0][3] = 0.0f;
341 U(pm).m[1][3] = 0.0f;
342 U(pm).m[2][3] = 0.0f;
343 U(pm).m[3][3] = 1.0f;
345 exp_scale.x = 1.0f;
346 exp_scale.y = 1.0f;
347 exp_scale.z = 1.0f;
349 exp_rotation.w = -0.195091f;
350 exp_rotation.x = 0.703358f;
351 exp_rotation.y = -0.586131f;
352 exp_rotation.z = 0.351679f;
354 exp_translation.x = -5.0f;
355 exp_translation.y = 0.0f;
356 exp_translation.z = 10.0f;
358 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
360 compare_scale(exp_scale, got_scale);
361 compare_rotation(exp_rotation, got_rotation);
362 compare_translation(exp_translation, got_translation);
364 /*_________*/
366 U(pm).m[0][0] = 7.121047f;
367 U(pm).m[1][0] = -5.883487f;
368 U(pm).m[2][0] = 11.81843f;
369 U(pm).m[3][0] = -5.0f;
370 U(pm).m[0][1] = 5.883487f;
371 U(pm).m[1][1] = -10.60660f;
372 U(pm).m[2][1] = -8.825232f;
373 U(pm).m[3][1] = 0.0f;
374 U(pm).m[0][2] = 11.81843f;
375 U(pm).m[1][2] = 8.8252320f;
376 U(pm).m[2][2] = -2.727645f;
377 U(pm).m[3][2] = 2.0f;
378 U(pm).m[0][3] = 0.0f;
379 U(pm).m[1][3] = 0.0f;
380 U(pm).m[2][3] = 0.0f;
381 U(pm).m[3][3] = 1.0f;
383 exp_scale.x = 15.0f;
384 exp_scale.y = 15.0f;
385 exp_scale.z = 15.0f;
387 exp_rotation.w = 0.382684f;
388 exp_rotation.x = 0.768714f;
389 exp_rotation.y = 0.0f;
390 exp_rotation.z = 0.512476f;
392 exp_translation.x = -5.0f;
393 exp_translation.y = 0.0f;
394 exp_translation.z = 2.0f;
396 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
398 compare_scale(exp_scale, got_scale);
399 compare_rotation(exp_rotation, got_rotation);
400 compare_translation(exp_translation, got_translation);
402 /*__________*/
404 U(pm).m[0][0] = 0.0f;
405 U(pm).m[1][0] = 4.0f;
406 U(pm).m[2][0] = 5.0f;
407 U(pm).m[3][0] = -5.0f;
408 U(pm).m[0][1] = 0.0f;
409 U(pm).m[1][1] = -10.60660f;
410 U(pm).m[2][1] = -8.825232f;
411 U(pm).m[3][1] = 6.0f;
412 U(pm).m[0][2] = 0.0f;
413 U(pm).m[1][2] = 8.8252320f;
414 U(pm).m[2][2] = 2.727645;
415 U(pm).m[3][2] = 3.0f;
416 U(pm).m[0][3] = 0.0f;
417 U(pm).m[1][3] = 0.0f;
418 U(pm).m[2][3] = 0.0f;
419 U(pm).m[3][3] = 1.0f;
421 hr = D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
422 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);
424 /*___________*/
426 hr = D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, NULL);
427 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);
430 static void test_D3DXVec_Array(void)
432 unsigned int i;
433 D3DVIEWPORT9 viewport;
434 D3DXMATRIX mat, projection, view, world;
435 D3DXVECTOR4 inp_vec[ARRAY_SIZE];
436 D3DXVECTOR4 out_vec[ARRAY_SIZE + 2];
437 D3DXVECTOR4 exp_vec[ARRAY_SIZE + 2];
438 D3DXPLANE inp_plane[ARRAY_SIZE];
439 D3DXPLANE out_plane[ARRAY_SIZE + 2];
440 D3DXPLANE exp_plane[ARRAY_SIZE + 2];
442 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
443 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
445 for (i = 0; i < ARRAY_SIZE + 2; ++i) {
446 out_vec[i].x = out_vec[i].y = out_vec[i].z = out_vec[i].w = 0.0f;
447 exp_vec[i].x = exp_vec[i].y = exp_vec[i].z = exp_vec[i].w = 0.0f;
448 out_plane[i].a = out_plane[i].b = out_plane[i].c = out_plane[i].d = 0.0f;
449 exp_plane[i].a = exp_plane[i].b = exp_plane[i].c = exp_plane[i].d = 0.0f;
452 for (i = 0; i < ARRAY_SIZE; ++i) {
453 inp_plane[i].a = inp_plane[i].c = inp_vec[i].x = inp_vec[i].z = i;
454 inp_plane[i].b = inp_plane[i].d = inp_vec[i].y = inp_vec[i].w = ARRAY_SIZE - i;
457 U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
458 U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
459 U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
460 U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
462 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
464 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
465 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
466 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
467 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
468 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
469 U(view).m[3][3] = -40.0f;
471 U(world).m[0][0] = 21.0f; U(world).m[0][1] = 2.0f; U(world).m[0][2] = 3.0f; U(world).m[0][3] = 4.0;
472 U(world).m[1][0] = 5.0f; U(world).m[1][1] = 23.0f; U(world).m[1][2] = 7.0f; U(world).m[1][3] = 8.0f;
473 U(world).m[2][0] = -8.0f; U(world).m[2][1] = -7.0f; U(world).m[2][2] = 25.0f; U(world).m[2][3] = -5.0f;
474 U(world).m[3][0] = -4.0f; U(world).m[3][1] = -3.0f; U(world).m[3][2] = -2.0f; U(world).m[3][3] = 27.0f;
476 /* D3DXVec2TransformCoordArray */
477 exp_vec[1].x = 0.678571f; exp_vec[1].y = 0.785714f;
478 exp_vec[2].x = 0.653846f; exp_vec[2].y = 0.769231f;
479 exp_vec[3].x = 0.625f; exp_vec[3].y = 0.75f;
480 exp_vec[4].x = 0.590909f; exp_vec[4].y = 8.0f/11.0f;
481 exp_vec[5].x = 0.55f; exp_vec[5].y = 0.7f;
482 D3DXVec2TransformCoordArray((D3DXVECTOR2*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
483 compare_vectors(exp_vec, out_vec);
485 /* D3DXVec2TransformNormalArray */
486 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f;
487 exp_vec[2].x = 21.0f; exp_vec[2].y = 26.0f;
488 exp_vec[3].x = 17.0f; exp_vec[3].y = 22.0f;
489 exp_vec[4].x = 13.0f; exp_vec[4].y = 18.0f;
490 exp_vec[5].x = 9.0f; exp_vec[5].y = 14.0f;
491 D3DXVec2TransformNormalArray((D3DXVECTOR2*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
492 compare_vectors(exp_vec, out_vec);
494 /* D3DXVec3TransformCoordArray */
495 exp_vec[1].x = 0.678571f; exp_vec[1].y = 0.785714f; exp_vec[1].z = 0.892857f;
496 exp_vec[2].x = 0.671875f; exp_vec[2].y = 0.78125f; exp_vec[2].z = 0.890625f;
497 exp_vec[3].x = 6.0f/9.0f; exp_vec[3].y = 7.0f/9.0f; exp_vec[3].z = 8.0f/9.0f;
498 exp_vec[4].x = 0.6625f; exp_vec[4].y = 0.775f; exp_vec[4].z = 0.8875f;
499 exp_vec[5].x = 0.659091f; exp_vec[5].y = 0.772727f; exp_vec[5].z = 0.886364f;
500 D3DXVec3TransformCoordArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
501 compare_vectors(exp_vec, out_vec);
503 /* D3DXVec3TransformNormalArray */
504 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f; exp_vec[1].z = 35.0f;
505 exp_vec[2].x = 30.0f; exp_vec[2].y = 36.0f; exp_vec[2].z = 42.0f;
506 exp_vec[3].x = 35.0f; exp_vec[3].y = 42.0f; exp_vec[3].z = 49.0f;
507 exp_vec[4].x = 40.0f; exp_vec[4].y = 48.0f; exp_vec[4].z = 56.0f;
508 exp_vec[5].x = 45.0f; exp_vec[5].y = 54.0f; exp_vec[5].z = 63.0f;
509 D3DXVec3TransformNormalArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
510 compare_vectors(exp_vec, out_vec);
512 /* D3DXVec3ProjectArray */
513 exp_vec[1].x = 1089.554199f; exp_vec[1].y = -226.590622f; exp_vec[1].z = 0.215273f;
514 exp_vec[2].x = 1068.903320f; exp_vec[2].y = 103.085129f; exp_vec[2].z = 0.183050f;
515 exp_vec[3].x = 1051.778931f; exp_vec[3].y = 376.462250f; exp_vec[3].z = 0.156329f;
516 exp_vec[4].x = 1037.348877f; exp_vec[4].y = 606.827393f; exp_vec[4].z = 0.133813f;
517 exp_vec[5].x = 1025.023560f; exp_vec[5].y = 803.591248f; exp_vec[5].z = 0.114581f;
518 D3DXVec3ProjectArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (CONST D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &viewport, &projection, &view, &world, ARRAY_SIZE);
519 compare_vectors(exp_vec, out_vec);
521 /* D3DXVec3UnprojectArray */
522 exp_vec[1].x = -6.124031f; exp_vec[1].y = 3.225360f; exp_vec[1].z = 0.620571f;
523 exp_vec[2].x = -3.807109f; exp_vec[2].y = 2.046579f; exp_vec[2].z = 0.446894f;
524 exp_vec[3].x = -2.922839f; exp_vec[3].y = 1.596689f; exp_vec[3].z = 0.380609f;
525 exp_vec[4].x = -2.456225f; exp_vec[4].y = 1.359290f; exp_vec[4].z = 0.345632f;
526 exp_vec[5].x = -2.167897f; exp_vec[5].y = 1.212597f; exp_vec[5].z = 0.324019f;
527 D3DXVec3UnprojectArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (CONST D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &viewport, &projection, &view, &world, ARRAY_SIZE);
528 compare_vectors(exp_vec, out_vec);
530 /* D3DXVec2TransformArray */
531 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
532 exp_vec[2].x = 34.0f; exp_vec[2].y = 40.0f; exp_vec[2].z = 46.0f; exp_vec[2].w = 52.0f;
533 exp_vec[3].x = 30.0f; exp_vec[3].y = 36.0f; exp_vec[3].z = 42.0f; exp_vec[3].w = 48.0f;
534 exp_vec[4].x = 26.0f; exp_vec[4].y = 32.0f; exp_vec[4].z = 38.0f; exp_vec[4].w = 44.0f;
535 exp_vec[5].x = 22.0f; exp_vec[5].y = 28.0f; exp_vec[5].z = 34.0f; exp_vec[5].w = 40.0f;
536 D3DXVec2TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
537 compare_vectors(exp_vec, out_vec);
539 /* D3DXVec3TransformArray */
540 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
541 exp_vec[2].x = 43.0f; exp_vec[2].y = 50.0f; exp_vec[2].z = 57.0f; exp_vec[2].w = 64.0f;
542 exp_vec[3].x = 48.0f; exp_vec[3].y = 56.0f; exp_vec[3].z = 64.0f; exp_vec[3].w = 72.0f;
543 exp_vec[4].x = 53.0f; exp_vec[4].y = 62.0f; exp_vec[4].z = 71.0f; exp_vec[4].w = 80.0f;
544 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
545 D3DXVec3TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
546 compare_vectors(exp_vec, out_vec);
548 /* D3DXVec4TransformArray */
549 exp_vec[1].x = 90.0f; exp_vec[1].y = 100.0f; exp_vec[1].z = 110.0f; exp_vec[1].w = 120.0f;
550 exp_vec[2].x = 82.0f; exp_vec[2].y = 92.0f; exp_vec[2].z = 102.0f; exp_vec[2].w = 112.0f;
551 exp_vec[3].x = 74.0f; exp_vec[3].y = 84.0f; exp_vec[3].z = 94.0f; exp_vec[3].w = 104.0f;
552 exp_vec[4].x = 66.0f; exp_vec[4].y = 76.0f; exp_vec[4].z = 86.0f; exp_vec[4].w = 96.0f;
553 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
554 D3DXVec4TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
555 compare_vectors(exp_vec, out_vec);
557 /* D3DXPlaneTransformArray */
558 exp_plane[1].a = 90.0f; exp_plane[1].b = 100.0f; exp_plane[1].c = 110.0f; exp_plane[1].d = 120.0f;
559 exp_plane[2].a = 82.0f; exp_plane[2].b = 92.0f; exp_plane[2].c = 102.0f; exp_plane[2].d = 112.0f;
560 exp_plane[3].a = 74.0f; exp_plane[3].b = 84.0f; exp_plane[3].c = 94.0f; exp_plane[3].d = 104.0f;
561 exp_plane[4].a = 66.0f; exp_plane[4].b = 76.0f; exp_plane[4].c = 86.0f; exp_plane[4].d = 96.0f;
562 exp_plane[5].a = 58.0f; exp_plane[5].b = 68.0f; exp_plane[5].c = 78.0f; exp_plane[5].d = 88.0f;
563 D3DXPlaneTransformArray(out_plane + 1, sizeof(D3DXPLANE), inp_plane, sizeof(D3DXPLANE), &mat, ARRAY_SIZE);
564 compare_planes(exp_plane, out_plane);
567 START_TEST(math)
569 test_Matrix_Decompose();
570 test_D3DXVec_Array();