mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / d3dx9_36 / tests / math.c
blob6f64e25d200ca64ee724e5436d481ba4ccf3f707
1 /*
2 * Copyright 2008 David Adam
3 * Copyright 2008 Luis Busquets
4 * Copyright 2008 Philip Nilsson
5 * Copyright 2008 Henri Verbeet
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
23 #include "d3dx9.h"
24 #include <math.h>
26 static BOOL compare_float(float f, float g, unsigned int ulps)
28 int x = *(int *)&f;
29 int y = *(int *)&g;
31 if (x < 0)
32 x = INT_MIN - x;
33 if (y < 0)
34 y = INT_MIN - y;
36 if (abs(x - y) > ulps)
37 return FALSE;
39 return TRUE;
42 static BOOL compare_vec2(const D3DXVECTOR2 *v1, const D3DXVECTOR2 *v2, unsigned int ulps)
44 return compare_float(v1->x, v2->x, ulps) && compare_float(v1->y, v2->y, ulps);
47 static BOOL compare_vec3(const D3DXVECTOR3 *v1, const D3DXVECTOR3 *v2, unsigned int ulps)
49 return compare_float(v1->x, v2->x, ulps)
50 && compare_float(v1->y, v2->y, ulps)
51 && compare_float(v1->z, v2->z, ulps);
54 static BOOL compare_vec4(const D3DXVECTOR4 *v1, const D3DXVECTOR4 *v2, unsigned int ulps)
56 return compare_float(v1->x, v2->x, ulps)
57 && compare_float(v1->y, v2->y, ulps)
58 && compare_float(v1->z, v2->z, ulps)
59 && compare_float(v1->w, v2->w, ulps);
62 static BOOL compare_color(const D3DXCOLOR *c1, const D3DXCOLOR *c2, unsigned int ulps)
64 return compare_float(c1->r, c2->r, ulps)
65 && compare_float(c1->g, c2->g, ulps)
66 && compare_float(c1->b, c2->b, ulps)
67 && compare_float(c1->a, c2->a, ulps);
70 static BOOL compare_plane(const D3DXPLANE *p1, const D3DXPLANE *p2, unsigned int ulps)
72 return compare_float(p1->a, p2->a, ulps)
73 && compare_float(p1->b, p2->b, ulps)
74 && compare_float(p1->c, p2->c, ulps)
75 && compare_float(p1->d, p2->d, ulps);
78 static BOOL compare_quaternion(const D3DXQUATERNION *q1, const D3DXQUATERNION *q2, unsigned int ulps)
80 return compare_float(q1->x, q2->x, ulps)
81 && compare_float(q1->y, q2->y, ulps)
82 && compare_float(q1->z, q2->z, ulps)
83 && compare_float(q1->w, q2->w, ulps);
86 static BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2, unsigned int ulps)
88 unsigned int i, j;
90 for (i = 0; i < 4; ++i)
92 for (j = 0; j < 4; ++j)
94 if (!compare_float(U(*m1).m[i][j], U(*m2).m[i][j], ulps))
95 return FALSE;
99 return TRUE;
102 #define expect_vec2(expected, vector, ulps) expect_vec2_(__LINE__, expected, vector, ulps)
103 static void expect_vec2_(unsigned int line, const D3DXVECTOR2 *expected, const D3DXVECTOR2 *vector, unsigned int ulps)
105 BOOL equal = compare_vec2(expected, vector, ulps);
106 ok_(__FILE__, line)(equal,
107 "Got unexpected vector {%.8e, %.8e}, expected {%.8e, %.8e}.\n",
108 vector->x, vector->y, expected->x, expected->y);
111 #define expect_vec3(expected, vector, ulps) expect_vec3_(__LINE__, expected, vector, ulps)
112 static void expect_vec3_(unsigned int line, const D3DXVECTOR3 *expected, const D3DXVECTOR3 *vector, unsigned int ulps)
114 BOOL equal = compare_vec3(expected, vector, ulps);
115 ok_(__FILE__, line)(equal,
116 "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
117 vector->x, vector->y, vector->z, expected->x, expected->y, expected->z);
120 #define expect_vec4(expected, vector, ulps) expect_vec4_(__LINE__, expected, vector, ulps)
121 static void expect_vec4_(unsigned int line, const D3DXVECTOR4 *expected, const D3DXVECTOR4 *vector, unsigned int ulps)
123 BOOL equal = compare_vec4(expected, vector, ulps);
124 ok_(__FILE__, line)(equal,
125 "Got unexpected vector {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
126 vector->x, vector->y, vector->z, vector->w, expected->x, expected->y, expected->z, expected->w);
129 #define expect_color(expected, color, ulps) expect_color_(__LINE__, expected, color, ulps)
130 static void expect_color_(unsigned int line, const D3DXCOLOR *expected, const D3DXCOLOR *color, unsigned int ulps)
132 BOOL equal = compare_color(expected, color, ulps);
133 ok_(__FILE__, line)(equal,
134 "Got unexpected color {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
135 color->r, color->g, color->b, color->a, expected->r, expected->g, expected->b, expected->a);
138 #define expect_plane(expected, plane, ulps) expect_plane_(__LINE__, expected, plane, ulps)
139 static void expect_plane_(unsigned int line, const D3DXPLANE *expected, const D3DXPLANE *plane, unsigned int ulps)
141 BOOL equal = compare_plane(expected, plane, ulps);
142 ok_(__FILE__, line)(equal,
143 "Got unexpected plane {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
144 plane->a, plane->b, plane->c, plane->d, expected->a, expected->b, expected->c, expected->d);
147 #define expect_quaternion(expected, quaternion, ulps) expect_quaternion_(__LINE__, expected, quaternion, ulps)
148 static void expect_quaternion_(unsigned int line, const D3DXQUATERNION *expected,
149 const D3DXQUATERNION *quaternion, unsigned int ulps)
151 BOOL equal = compare_quaternion(expected, quaternion, ulps);
152 ok_(__FILE__, line)(equal,
153 "Got unexpected quaternion {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
154 quaternion->x, quaternion->y, quaternion->z, quaternion->w,
155 expected->x, expected->y, expected->z, expected->w);
158 #define expect_matrix(expected, matrix, ulps) expect_matrix_(__LINE__, expected, matrix, ulps)
159 static void expect_matrix_(unsigned int line, const D3DXMATRIX *expected, const D3DXMATRIX *matrix, unsigned int ulps)
161 BOOL equal = compare_matrix(expected, matrix, ulps);
162 ok_(__FILE__, line)(equal,
163 "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
164 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, "
165 "expected {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
166 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
167 U(*matrix).m[0][0], U(*matrix).m[0][1], U(*matrix).m[0][2], U(*matrix).m[0][3],
168 U(*matrix).m[1][0], U(*matrix).m[1][1], U(*matrix).m[1][2], U(*matrix).m[1][3],
169 U(*matrix).m[2][0], U(*matrix).m[2][1], U(*matrix).m[2][2], U(*matrix).m[2][3],
170 U(*matrix).m[3][0], U(*matrix).m[3][1], U(*matrix).m[3][2], U(*matrix).m[3][3],
171 U(*expected).m[0][0], U(*expected).m[0][1], U(*expected).m[0][2], U(*expected).m[0][3],
172 U(*expected).m[1][0], U(*expected).m[1][1], U(*expected).m[1][2], U(*expected).m[1][3],
173 U(*expected).m[2][0], U(*expected).m[2][1], U(*expected).m[2][2], U(*expected).m[2][3],
174 U(*expected).m[3][0], U(*expected).m[3][1], U(*expected).m[3][2], U(*expected).m[3][3]);
177 #define expect_vec4_array(count, expected, vector, ulps) expect_vec4_array_(__LINE__, count, expected, vector, ulps)
178 static void expect_vec4_array_(unsigned int line, unsigned int count, const D3DXVECTOR4 *expected,
179 const D3DXVECTOR4 *vector, unsigned int ulps)
181 BOOL equal;
182 unsigned int i;
184 for (i = 0; i < count; ++i)
186 equal = compare_vec4(&expected[i], &vector[i], ulps);
187 ok_(__FILE__, line)(equal,
188 "Got unexpected vector {%.8e, %.8e, %.8e, %.8e} at index %u, expected {%.8e, %.8e, %.8e, %.8e}.\n",
189 vector[i].x, vector[i].y, vector[i].z, vector[i].w, i,
190 expected[i].x, expected[i].y, expected[i].z, expected[i].w);
191 if (!equal)
192 break;
196 static void set_matrix(D3DXMATRIX* mat,
197 float m00, float m01, float m02, float m03,
198 float m10, float m11, float m12, float m13,
199 float m20, float m21, float m22, float m23,
200 float m30, float m31, float m32, float m33)
202 U(mat)->m[0][0] = m00; U(mat)->m[0][1] = m01; U(mat)->m[0][2] = m02; U(mat)->m[0][3] = m03;
203 U(mat)->m[1][0] = m10; U(mat)->m[1][1] = m11; U(mat)->m[1][2] = m12; U(mat)->m[1][3] = m13;
204 U(mat)->m[2][0] = m20; U(mat)->m[2][1] = m21; U(mat)->m[2][2] = m22; U(mat)->m[2][3] = m23;
205 U(mat)->m[3][0] = m30; U(mat)->m[3][1] = m31; U(mat)->m[3][2] = m32; U(mat)->m[3][3] = m33;
208 static void D3DXColorTest(void)
210 D3DXCOLOR color, color1, color2, expected, got;
211 LPD3DXCOLOR funcpointer;
212 FLOAT scale;
214 color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
215 color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
216 color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
218 scale = 0.3f;
220 /*_______________D3DXColorAdd________________*/
221 expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f; expected.a = 0.93f;
222 D3DXColorAdd(&got,&color1,&color2);
223 expect_color(&expected, &got, 1);
224 /* Test the NULL case */
225 funcpointer = D3DXColorAdd(&got,NULL,&color2);
226 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
227 funcpointer = D3DXColorAdd(NULL,NULL,&color2);
228 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
229 funcpointer = D3DXColorAdd(NULL,NULL,NULL);
230 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
232 /*_______________D3DXColorAdjustContrast______*/
233 expected.r = 0.41f; expected.g = 0.575f; expected.b = 0.473f; expected.a = 0.93f;
234 D3DXColorAdjustContrast(&got,&color,scale);
235 expect_color(&expected, &got, 0);
237 /*_______________D3DXColorAdjustSaturation______*/
238 expected.r = 0.486028f; expected.g = 0.651028f; expected.b = 0.549028f; expected.a = 0.93f;
239 D3DXColorAdjustSaturation(&got,&color,scale);
240 expect_color(&expected, &got, 16);
242 /*_______________D3DXColorLerp________________*/
243 expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
244 D3DXColorLerp(&got,&color,&color1,scale);
245 expect_color(&expected, &got, 0);
246 /* Test the NULL case */
247 funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
248 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
249 funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
250 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
251 funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
252 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
254 /*_______________D3DXColorModulate________________*/
255 expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
256 D3DXColorModulate(&got,&color1,&color2);
257 expect_color(&expected, &got, 0);
258 /* Test the NULL case */
259 funcpointer = D3DXColorModulate(&got,NULL,&color2);
260 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
261 funcpointer = D3DXColorModulate(NULL,NULL,&color2);
262 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
263 funcpointer = D3DXColorModulate(NULL,NULL,NULL);
264 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
266 /*_______________D3DXColorNegative________________*/
267 expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
268 D3DXColorNegative(&got,&color);
269 expect_color(&expected, &got, 1);
270 /* Test the greater than 1 case */
271 color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
272 expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
273 D3DXColorNegative(&got,&color1);
274 expect_color(&expected, &got, 1);
275 /* Test the negative case */
276 color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
277 expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
278 D3DXColorNegative(&got,&color1);
279 expect_color(&expected, &got, 1);
280 /* Test the NULL case */
281 funcpointer = D3DXColorNegative(&got,NULL);
282 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
283 funcpointer = D3DXColorNegative(NULL,NULL);
284 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
286 /*_______________D3DXColorScale________________*/
287 expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
288 D3DXColorScale(&got,&color,scale);
289 expect_color(&expected, &got, 1);
290 /* Test the NULL case */
291 funcpointer = D3DXColorScale(&got,NULL,scale);
292 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
293 funcpointer = D3DXColorScale(NULL,NULL,scale);
294 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
296 /*_______________D3DXColorSubtract_______________*/
297 expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f; expected.a = 0.82f;
298 D3DXColorSubtract(&got,&color,&color2);
299 expect_color(&expected, &got, 1);
300 /* Test the NULL case */
301 funcpointer = D3DXColorSubtract(&got,NULL,&color2);
302 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
303 funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
304 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
305 funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
306 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
309 static void D3DXFresnelTest(void)
311 float fresnel;
312 BOOL equal;
314 fresnel = D3DXFresnelTerm(0.5f, 1.5f);
315 equal = compare_float(fresnel, 8.91867128e-02f, 1);
316 ok(equal, "Got unexpected Fresnel term %.8e.\n", fresnel);
319 static void D3DXMatrixTest(void)
321 D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
322 BOOL expected, got, equal;
323 float angle, determinant;
324 D3DXPLANE plane;
325 D3DXQUATERNION q, r;
326 D3DXVECTOR3 at, axis, eye, last;
327 D3DXVECTOR4 light;
328 D3DXMATRIX *ret;
330 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
331 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
332 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
333 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
334 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
335 U(mat).m[3][3] = -40.0f;
337 U(mat2).m[0][0] = 1.0f; U(mat2).m[1][0] = 2.0f; U(mat2).m[2][0] = 3.0f;
338 U(mat2).m[3][0] = 4.0f; U(mat2).m[0][1] = 5.0f; U(mat2).m[1][1] = 6.0f;
339 U(mat2).m[2][1] = 7.0f; U(mat2).m[3][1] = 8.0f; U(mat2).m[0][2] = -8.0f;
340 U(mat2).m[1][2] = -7.0f; U(mat2).m[2][2] = -6.0f; U(mat2).m[3][2] = -5.0f;
341 U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f;
342 U(mat2).m[3][3] = -1.0f;
344 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
346 q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
347 r.x = 0.87f; r.y = 0.65f; r.z =0.43f; r.w= 0.21f;
349 at.x = -2.0f; at.y = 13.0f; at.z = -9.0f;
350 axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f;
351 eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
352 last.x = 9.7f; last.y = -8.6; last.z = 1.3f;
354 light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3;
356 angle = D3DX_PI/3.0f;
358 /*____________D3DXMatrixAffineTransformation______*/
359 set_matrix(&expectedmat,
360 -459.239990f, -576.719971f, -263.440002f, 0.0f,
361 519.760010f, -352.440002f, -277.679993f, 0.0f,
362 363.119995f, -121.040001f, -117.479996f, 0.0f,
363 -1239.0f, 667.0f, 567.0f, 1.0f);
364 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, &q, &axis);
365 expect_matrix(&expectedmat, &gotmat, 0);
367 /* Test the NULL case */
368 U(expectedmat).m[3][0] = 1.0f; U(expectedmat).m[3][1] = -3.0f; U(expectedmat).m[3][2] = 7.0f; U(expectedmat).m[3][3] = 1.0f;
369 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, &q, &axis);
370 expect_matrix(&expectedmat, &gotmat, 0);
372 U(expectedmat).m[3][0] = -1240.0f; U(expectedmat).m[3][1] = 670.0f; U(expectedmat).m[3][2] = 560.0f; U(expectedmat).m[3][3] = 1.0f;
373 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, &q, NULL);
374 expect_matrix(&expectedmat, &gotmat, 0);
376 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
377 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, &q, NULL);
378 expect_matrix(&expectedmat, &gotmat, 0);
380 set_matrix(&expectedmat,
381 3.56f, 0.0f, 0.0f, 0.0f,
382 0.0f, 3.56f, 0.0f, 0.0f,
383 0.0f, 0.0f, 3.56f, 0.0f,
384 1.0f, -3.0f, 7.0f, 1.0f);
385 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, NULL, &axis);
386 expect_matrix(&expectedmat, &gotmat, 0);
388 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, NULL, &axis);
389 expect_matrix(&expectedmat, &gotmat, 0);
391 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
392 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, NULL, NULL);
393 expect_matrix(&expectedmat, &gotmat, 0);
395 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, NULL, NULL);
396 expect_matrix(&expectedmat, &gotmat, 0);
398 /*____________D3DXMatrixfDeterminant_____________*/
399 determinant = D3DXMatrixDeterminant(&mat);
400 equal = compare_float(determinant, -147888.0f, 0);
401 ok(equal, "Got unexpected determinant %.8e.\n", determinant);
403 /*____________D3DXMatrixInverse______________*/
404 set_matrix(&expectedmat,
405 16067.0f/73944.0f, -10165.0f/147888.0f, -2729.0f/147888.0f, -1631.0f/49296.0f,
406 -565.0f/36972.0f, 2723.0f/73944.0f, -1073.0f/73944.0f, 289.0f/24648.0f,
407 -389.0f/2054.0f, 337.0f/4108.0f, 181.0f/4108.0f, 317.0f/4108.0f,
408 163.0f/5688.0f, -101.0f/11376.0f, -73.0f/11376.0f, -127.0f/3792.0f);
409 D3DXMatrixInverse(&gotmat, &determinant, &mat);
410 expect_matrix(&expectedmat, &gotmat, 1);
411 equal = compare_float(determinant, -147888.0f, 0);
412 ok(equal, "Got unexpected determinant %.8e.\n", determinant);
413 determinant = 5.0f;
414 ret = D3DXMatrixInverse(&gotmat, &determinant, &mat2);
415 ok(!ret, "Unexpected return value %p.\n", ret);
416 expect_matrix(&expectedmat, &gotmat, 1);
417 ok(compare_float(determinant, 5.0f, 0) || broken(!determinant), /* Vista 64 bit testbot */
418 "Unexpected determinant %.8e.\n", determinant);
420 /*____________D3DXMatrixIsIdentity______________*/
421 expected = FALSE;
422 memset(&mat3, 0, sizeof(mat3));
423 got = D3DXMatrixIsIdentity(&mat3);
424 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
425 D3DXMatrixIdentity(&mat3);
426 expected = TRUE;
427 got = D3DXMatrixIsIdentity(&mat3);
428 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
429 U(mat3).m[0][0] = 0.000009f;
430 expected = FALSE;
431 got = D3DXMatrixIsIdentity(&mat3);
432 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
433 /* Test the NULL case */
434 expected = FALSE;
435 got = D3DXMatrixIsIdentity(NULL);
436 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
438 /*____________D3DXMatrixLookAtLH_______________*/
439 set_matrix(&expectedmat,
440 -0.82246518f, -0.40948939f, -0.39480308f, 0.0f,
441 -0.55585691f, 0.43128574f, 0.71064550f, 0.0f,
442 -0.12072885f, 0.80393475f, -0.58233452f, 0.0f,
443 4.4946337f, 0.80971903f, 10.060076f, 1.0f);
444 D3DXMatrixLookAtLH(&gotmat, &eye, &at, &axis);
445 expect_matrix(&expectedmat, &gotmat, 32);
447 /*____________D3DXMatrixLookAtRH_______________*/
448 set_matrix(&expectedmat,
449 0.82246518f, -0.40948939f, 0.39480308f, 0.0f,
450 0.55585691f, 0.43128574f, -0.71064550f, 0.0f,
451 0.12072885f, 0.80393475f, 0.58233452f, 0.0f,
452 -4.4946337f, 0.80971903f, -10.060076f, 1.0f);
453 D3DXMatrixLookAtRH(&gotmat, &eye, &at, &axis);
454 expect_matrix(&expectedmat, &gotmat, 32);
456 /*____________D3DXMatrixMultiply______________*/
457 set_matrix(&expectedmat,
458 73.0f, 193.0f, -197.0f, -77.0f,
459 231.0f, 551.0f, -489.0f, -169.0f,
460 239.0f, 523.0f, -400.0f, -116.0f,
461 -164.0f, -320.0f, 187.0f, 31.0f);
462 D3DXMatrixMultiply(&gotmat, &mat, &mat2);
463 expect_matrix(&expectedmat, &gotmat, 0);
465 /*____________D3DXMatrixMultiplyTranspose____*/
466 set_matrix(&expectedmat,
467 73.0f, 231.0f, 239.0f, -164.0f,
468 193.0f, 551.0f, 523.0f, -320.0f,
469 -197.0f, -489.0f, -400.0f, 187.0f,
470 -77.0f, -169.0f, -116.0f, 31.0f);
471 D3DXMatrixMultiplyTranspose(&gotmat, &mat, &mat2);
472 expect_matrix(&expectedmat, &gotmat, 0);
474 /*____________D3DXMatrixOrthoLH_______________*/
475 set_matrix(&expectedmat,
476 0.8f, 0.0f, 0.0f, 0.0f,
477 0.0f, 0.27027027f, 0.0f, 0.0f,
478 0.0f, 0.0f, -0.15151515f, 0.0f,
479 0.0f, 0.0f, -0.48484848f, 1.0f);
480 D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
481 expect_matrix(&expectedmat, &gotmat, 16);
483 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
484 set_matrix(&expectedmat,
485 3.6363636f, 0.0f, 0.0f, 0.0f,
486 0.0f, 0.18018018f, 0.0f, 0.0f,
487 0.0f, 0.0f, -0.045662100f, 0.0f,
488 -1.7272727f, -0.56756757f, 0.42465753f, 1.0f);
489 D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
490 expect_matrix(&expectedmat, &gotmat, 32);
492 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
493 set_matrix(&expectedmat,
494 3.6363636f, 0.0f, 0.0f, 0.0f,
495 0.0f, 0.18018018f, 0.0f, 0.0f,
496 0.0f, 0.0f, 0.045662100f, 0.0f,
497 -1.7272727f, -0.56756757f, 0.42465753f, 1.0f);
498 D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
499 expect_matrix(&expectedmat, &gotmat, 32);
501 /*____________D3DXMatrixOrthoRH_______________*/
502 set_matrix(&expectedmat,
503 0.8f, 0.0f, 0.0f, 0.0f,
504 0.0f, 0.27027027f, 0.0f, 0.0f,
505 0.0f, 0.0f, 0.15151515f, 0.0f,
506 0.0f, 0.0f, -0.48484848f, 1.0f);
507 D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
508 expect_matrix(&expectedmat, &gotmat, 16);
510 /*____________D3DXMatrixPerspectiveFovLH_______________*/
511 set_matrix(&expectedmat,
512 13.288858f, 0.0f, 0.0f, 0.0f,
513 0.0f, 9.9666444f, 0.0f, 0.0f,
514 0.0f, 0.0f, 0.78378378f, 1.0f,
515 0.0f, 0.0f, 1.8810811f, 0.0f);
516 D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
517 expect_matrix(&expectedmat, &gotmat, 4);
519 /*____________D3DXMatrixPerspectiveFovRH_______________*/
520 set_matrix(&expectedmat,
521 13.288858f, 0.0f, 0.0f, 0.0f,
522 0.0f, 9.9666444f, 0.0f, 0.0f,
523 0.0f, 0.0f, -0.78378378f, -1.0f,
524 0.0f, 0.0f, 1.8810811f, 0.0f);
525 D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
526 expect_matrix(&expectedmat, &gotmat, 4);
528 /*____________D3DXMatrixPerspectiveLH_______________*/
529 set_matrix(&expectedmat,
530 -24.0f, 0.0f, 0.0f, 0.0f,
531 0.0f, -6.4f, 0.0f, 0.0f,
532 0.0f, 0.0f, 0.78378378f, 1.0f,
533 0.0f, 0.0f, 1.8810811f, 0.0f);
534 D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
535 expect_matrix(&expectedmat, &gotmat, 4);
537 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
538 set_matrix(&expectedmat,
539 11.636364f, 0.0f, 0.0f, 0.0f,
540 0.0f, 0.57657658f, 0.0f, 0.0f,
541 -1.7272727f, -0.56756757f, 0.84079602f, 1.0f,
542 0.0f, 0.0f, -2.6905473f, 0.0f);
543 D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
544 expect_matrix(&expectedmat, &gotmat, 8);
546 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
547 set_matrix(&expectedmat,
548 11.636364f, 0.0f, 0.0f, 0.0f,
549 0.0f, 0.57657658f, 0.0f, 0.0f,
550 1.7272727f, 0.56756757f, -0.84079602f, -1.0f,
551 0.0f, 0.0f, -2.6905473f, 0.0f);
552 D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
553 expect_matrix(&expectedmat, &gotmat, 8);
555 /*____________D3DXMatrixPerspectiveRH_______________*/
556 set_matrix(&expectedmat,
557 -24.0f, -0.0f, 0.0f, 0.0f,
558 0.0f, -6.4f, 0.0f, 0.0f,
559 0.0f, 0.0f, -0.78378378f, -1.0f,
560 0.0f, 0.0f, 1.8810811f, 0.0f);
561 D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
562 expect_matrix(&expectedmat, &gotmat, 4);
564 /*____________D3DXMatrixReflect______________*/
565 set_matrix(&expectedmat,
566 0.30769235f, -0.23076922f, 0.92307687f, 0.0f,
567 -0.23076922, 0.92307693f, 0.30769232f, 0.0f,
568 0.92307687f, 0.30769232f, -0.23076922f, 0.0f,
569 1.6153846f, 0.53846157f, -2.1538463f, 1.0f);
570 D3DXMatrixReflect(&gotmat, &plane);
571 expect_matrix(&expectedmat, &gotmat, 32);
573 /*____________D3DXMatrixRotationAxis_____*/
574 set_matrix(&expectedmat,
575 0.50847453f, 0.76380461f, 0.39756277f, 0.0f,
576 -0.81465209f, 0.57627118f, -0.065219201f, 0.0f,
577 -0.27891868f, -0.29071301f, 0.91525424f, 0.0f,
578 0.0f, 0.0f, 0.0f, 1.0f);
579 D3DXMatrixRotationAxis(&gotmat, &axis, angle);
580 expect_matrix(&expectedmat, &gotmat, 32);
582 /*____________D3DXMatrixRotationQuaternion______________*/
583 set_matrix(&expectedmat,
584 -129.0f, -162.0f, -74.0f, 0.0f,
585 146.0f, -99.0f, -78.0f, 0.0f,
586 102.0f, -34.0f, -33.0f, 0.0f,
587 0.0f, 0.0f, 0.0f, 1.0f);
588 D3DXMatrixRotationQuaternion(&gotmat, &q);
589 expect_matrix(&expectedmat, &gotmat, 0);
591 /*____________D3DXMatrixRotationX______________*/
592 set_matrix(&expectedmat,
593 1.0f, 0.0f, 0.0f, 0.0f,
594 0.0f, 0.5f, sqrt(3.0f)/2.0f, 0.0f,
595 0.0f, -sqrt(3.0f)/2.0f, 0.5f, 0.0f,
596 0.0f, 0.0f, 0.0f, 1.0f);
597 D3DXMatrixRotationX(&gotmat, angle);
598 expect_matrix(&expectedmat, &gotmat, 1);
600 /*____________D3DXMatrixRotationY______________*/
601 set_matrix(&expectedmat,
602 0.5f, 0.0f, -sqrt(3.0f)/2.0f, 0.0f,
603 0.0f, 1.0f, 0.0f, 0.0f,
604 sqrt(3.0f)/2.0f, 0.0f, 0.5f, 0.0f,
605 0.0f, 0.0f, 0.0f, 1.0f);
606 D3DXMatrixRotationY(&gotmat, angle);
607 expect_matrix(&expectedmat, &gotmat, 1);
609 /*____________D3DXMatrixRotationYawPitchRoll____*/
610 set_matrix(&expectedmat,
611 0.88877726f, 0.091874748f, -0.44903678f, 0.0f,
612 0.35171318f, 0.49148652f, 0.79670501f, 0.0f,
613 0.29389259f, -0.86602545f, 0.40450847f, 0.0f,
614 0.0f, 0.0f, 0.0f, 1.0f);
615 D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f * angle / 5.0f, angle, 3.0f * angle / 17.0f);
616 expect_matrix(&expectedmat, &gotmat, 64);
618 /*____________D3DXMatrixRotationZ______________*/
619 set_matrix(&expectedmat,
620 0.5f, sqrt(3.0f)/2.0f, 0.0f, 0.0f,
621 -sqrt(3.0f)/2.0f, 0.5f, 0.0f, 0.0f,
622 0.0f, 0.0f, 1.0f, 0.0f,
623 0.0f, 0.0f, 0.0f, 1.0f);
624 D3DXMatrixRotationZ(&gotmat, angle);
625 expect_matrix(&expectedmat, &gotmat, 1);
627 /*____________D3DXMatrixScaling______________*/
628 set_matrix(&expectedmat,
629 0.69f, 0.0f, 0.0f, 0.0f,
630 0.0f, 0.53f, 0.0f, 0.0f,
631 0.0f, 0.0f, 4.11f, 0.0f,
632 0.0f, 0.0f, 0.0f, 1.0f);
633 D3DXMatrixScaling(&gotmat, 0.69f, 0.53f, 4.11f);
634 expect_matrix(&expectedmat, &gotmat, 0);
636 /*____________D3DXMatrixShadow______________*/
637 set_matrix(&expectedmat,
638 12.786773f, 5.0009613f, 4.3537784f, 3.7065949f,
639 1.8827150f, 8.8056154f, 1.4512594f, 1.2355317f,
640 -7.5308599f, -6.6679487f, 1.3335901f, -4.9421268f,
641 -13.179006f, -11.668910f, -10.158816f, -1.5100943f);
642 D3DXMatrixShadow(&gotmat, &light, &plane);
643 expect_matrix(&expectedmat, &gotmat, 8);
645 /*____________D3DXMatrixTransformation______________*/
646 set_matrix(&expectedmat,
647 1.0f, 0.0f, 0.0f, 0.0f,
648 0.0f, 1.0f, 0.0f, 0.0f,
649 0.0f, 0.0f, 1.0f, 0.0f,
650 0.0f, 0.0f, 0.0f, 1.0f);
651 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, NULL, NULL, NULL);
652 expect_matrix(&expectedmat, &gotmat, 0);
654 set_matrix(&expectedmat,
655 1.0f, 0.0f, 0.0f, 0.0f,
656 0.0f, 1.0f, 0.0f, 0.0f,
657 0.0f, 0.0f, 1.0f, 0.0f,
658 9.7f, -8.6f, 1.3f, 1.0f);
659 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, NULL, NULL, &last);
660 expect_matrix(&expectedmat, &gotmat, 0);
662 set_matrix(&expectedmat,
663 -0.2148f, 1.3116f, 0.4752f, 0.0f,
664 0.9504f, -0.8836f, 0.9244f, 0.0f,
665 1.0212f, 0.1936f, -1.3588f, 0.0f,
666 0.0f, 0.0f, 0.0f, 1.0f);
667 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, NULL, &r, NULL);
668 expect_matrix(&expectedmat, &gotmat, 8);
670 set_matrix(&expectedmat,
671 1.0f, 0.0f, 0.0f, 0.0f,
672 0.0f, 1.0f, 0.0f, 0.0f,
673 0.0f, 0.0f, 1.0f, 0.0f,
674 0.0f, 0.0f, 0.0f, 1.0f);
675 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, NULL, NULL);
676 expect_matrix(&expectedmat, &gotmat, 0);
678 set_matrix(&expectedmat,
679 1.0f, 0.0f, 0.0f, 0.0f,
680 0.0f, -3.0f, 0.0f, 0.0f,
681 0.0f, 0.0f, 7.0f, 0.0f,
682 0.0f, 0.0f, 0.0f, 1.0f);
683 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, NULL, NULL);
684 expect_matrix(&expectedmat, &gotmat, 0);
686 set_matrix(&expectedmat,
687 1.0f, 0.0f, 0.0f, 0.0f,
688 0.0f, 1.0f, 0.0f, 0.0f,
689 0.0f, 0.0f, 1.0f, 0.0f,
690 0.0f, 0.0f, 0.0f, 1.0f);
691 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, NULL, NULL);
692 expect_matrix(&expectedmat, &gotmat, 0);
694 set_matrix(&expectedmat,
695 1.0f, 0.0f, 0.0f, 0.0f,
696 0.0f, 1.0f, 0.0f, 0.0f,
697 0.0f, 0.0f, 1.0f, 0.0f,
698 0.0f, 0.0f, 0.0f, 1.0f);
699 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, NULL, NULL);
700 expect_matrix(&expectedmat, &gotmat, 0);
702 set_matrix(&expectedmat,
703 -0.2148f, 1.3116f, 0.4752f, 0.0f,
704 0.9504f, -0.8836f, 0.9244f, 0.0f,
705 1.0212f, 0.1936f, -1.3588f, 0.0f,
706 9.7f, -8.6f, 1.3f, 1.0f);
707 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, NULL, &r, &last);
708 expect_matrix(&expectedmat, &gotmat, 8);
710 set_matrix(&expectedmat,
711 1.0f, 0.0f, 0.0f, 0.0f,
712 0.0f, 1.0f, 0.0f, 0.0f,
713 0.0f, 0.0f, 1.0f, 0.0f,
714 9.7f, -8.6f, 1.3f, 1.0f);
715 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, NULL, &last);
716 expect_matrix(&expectedmat, &gotmat, 0);
718 set_matrix(&expectedmat,
719 1.0f, 0.0f, 0.0f, 0.0f,
720 0.0f, -3.0f, 0.0f, 0.0f,
721 0.0f, 0.0f, 7.0f, 0.0f,
722 9.7f, -8.6f, 1.3f, 1.0f);
723 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, NULL, &last);
724 expect_matrix(&expectedmat, &gotmat, 0);
726 set_matrix(&expectedmat,
727 1.0f, 0.0f, 0.0f, 0.0f,
728 0.0f, 1.0f, 0.0f, 0.0f,
729 0.0f, 0.0f, 1.0f, 0.0f,
730 9.7f, -8.6f, 1.3f, 1.0f);
731 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, NULL, &last);
732 expect_matrix(&expectedmat, &gotmat, 0);
734 set_matrix(&expectedmat,
735 1.0f, 0.0f, 0.0f, 0.0f,
736 0.0f, 1.0f, 0.0f, 0.0f,
737 0.0f, 0.0f, 1.0f, 0.0f,
738 9.7f, -8.6f, 1.3f, 1.0f);
739 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, NULL, &last);
740 expect_matrix(&expectedmat, &gotmat, 0);
742 set_matrix(&expectedmat,
743 -0.2148f, 1.3116f, 0.4752f, 0.0f,
744 0.9504f, -0.8836f, 0.9244f, 0.0f,
745 1.0212f, 0.1936f, -1.3588f, 0.0f,
746 8.5985f, -21.024f, 14.383499, 1.0f);
747 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, &r, NULL);
748 expect_matrix(&expectedmat, &gotmat, 8);
750 set_matrix(&expectedmat,
751 -0.2148f, 1.3116f, 0.4752f, 0.0f,
752 -2.8512f, 2.6508f, -2.7732f, 0.0f,
753 7.148399f, 1.3552f, -9.5116f, 0.0f,
754 0.0f, 0.0f, 0.0f, 1.0f);
755 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, &r, NULL);
756 expect_matrix(&expectedmat, &gotmat, 8);
758 set_matrix(&expectedmat,
759 -0.2148f, 1.3116f, 0.4752f, 0.0f,
760 0.9504f, -0.8836f, 0.9244f, 0.0f,
761 1.0212f, 0.1936f, -1.3588f, 0.0f,
762 0.0f, 0.0f, 0.0f, 1.0f);
763 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, &r, NULL);
764 expect_matrix(&expectedmat, &gotmat, 8);
766 set_matrix(&expectedmat,
767 -0.2148f, 1.3116f, 0.4752f, 0.0f,
768 0.9504f, -0.8836f, 0.9244f, 0.0f,
769 1.0212f, 0.1936f, -1.3588f, 0.0f,
770 0.0f, 0.0f, 0.0f, 1.0f);
771 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, &r, NULL);
772 expect_matrix(&expectedmat, &gotmat, 8);
774 set_matrix(&expectedmat,
775 1.0f, 0.0f, 0.0f, 0.0f,
776 0.0f, -3.0f, 0.0f, 0.0f,
777 0.0f, 0.0f, 7.0f, 0.0f,
778 0.0f, 0.0f, 0.0f, 1.0f);
779 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, NULL, NULL);
780 expect_matrix(&expectedmat, &gotmat, 0);
782 set_matrix(&expectedmat,
783 1.0f, 0.0f, 0.0f, 0.0f,
784 0.0f, 1.0f, 0.0f, 0.0f,
785 0.0f, 0.0f, 1.0f, 0.0f,
786 0.0f, 0.0f, 0.0f, 1.0f);
787 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, NULL, NULL);
788 expect_matrix(&expectedmat, &gotmat, 0);
790 set_matrix(&expectedmat,
791 1.0f, 0.0f, 0.0f, 0.0f,
792 0.0f, 1.0f, 0.0f, 0.0f,
793 0.0f, 0.0f, 1.0f, 0.0f,
794 0.0f, 0.0f, 0.0f, 1.0f);
795 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, NULL, NULL);
796 expect_matrix(&expectedmat, &gotmat, 0);
798 set_matrix(&expectedmat,
799 25521.0f, 39984.0f, 20148.0f, 0.0f,
800 39984.0f, 4933.0f, -3324.0f, 0.0f,
801 20148.0f, -3324.0f, -5153.0f, 0.0f,
802 0.0f, 0.0f, 0.0f, 1.0f);
803 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
804 expect_matrix(&expectedmat, &gotmat, 0);
806 set_matrix(&expectedmat,
807 1.0f, 0.0f, 0.0f, 0.0f,
808 0.0f, -3.0f, 0.0f, 0.0f,
809 0.0f, 0.0f, 7.0f, 0.0f,
810 0.0f, 52.0f, 54.0f, 1.0f);
811 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, NULL, NULL);
812 expect_matrix(&expectedmat, &gotmat, 0);
814 set_matrix(&expectedmat,
815 1.0f, 0.0f, 0.0f, 0.0f,
816 0.0f, 1.0f, 0.0f, 0.0f,
817 0.0f, 0.0f, 1.0f, 0.0f,
818 0.0f, 0.0f, 0.0f, 1.0f);
819 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, NULL, NULL);
820 expect_matrix(&expectedmat, &gotmat, 0);
822 set_matrix(&expectedmat,
823 -0.2148f, 1.3116f, 0.4752f, 0.0f,
824 0.9504f, -0.8836f, 0.9244f, 0.0f,
825 1.0212f, 0.1936f, -1.3588f, 0.0f,
826 18.2985f, -29.624001f, 15.683499f, 1.0f);
827 D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, &r, &last);
828 expect_matrix(&expectedmat, &gotmat, 8);
830 set_matrix(&expectedmat,
831 -0.2148f, 1.3116f, 0.4752f, 0.0f,
832 -2.8512f, 2.6508f, -2.7732f, 0.0f,
833 7.148399f, 1.3552f, -9.5116f, 0.0f,
834 9.7f, -8.6f, 1.3f, 1.0f);
835 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, &r, &last);
836 expect_matrix(&expectedmat, &gotmat, 8);
838 set_matrix(&expectedmat,
839 -0.2148f, 1.3116f, 0.4752f, 0.0f,
840 0.9504f, -0.8836f, 0.9244f, 0.0f,
841 1.0212f, 0.1936f, -1.3588f, 0.0f,
842 9.7f, -8.6f, 1.3f, 1.0f);
843 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, &r, &last);
844 expect_matrix(&expectedmat, &gotmat, 8);
846 set_matrix(&expectedmat,
847 -0.2148f, 1.3116f, 0.4752f, 0.0f,
848 0.9504f, -0.8836f, 0.9244f, 0.0f,
849 1.0212f, 0.1936f, -1.3588f, 0.0f,
850 9.7f, -8.6f, 1.3f, 1.0f);
851 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, &r, &last);
852 expect_matrix(&expectedmat, &gotmat, 8);
854 set_matrix(&expectedmat,
855 1.0f, 0.0f, 0.0f, 0.0f,
856 0.0f, -3.0f, 0.0f, 0.0f,
857 0.0f, 0.0f, 7.0f, 0.0f,
858 9.7f, -8.6f, 1.3f, 1.0f);
859 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, NULL, &last);
860 expect_matrix(&expectedmat, &gotmat, 0);
862 set_matrix(&expectedmat,
863 1.0f, 0.0f, 0.0f, 0.0f,
864 0.0f, 1.0f, 0.0f, 0.0f,
865 0.0f, 0.0f, 1.0f, 0.0f,
866 9.7f, -8.6f, 1.3f, 1.0f);
867 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, NULL, &last);
868 expect_matrix(&expectedmat, &gotmat, 0);
870 set_matrix(&expectedmat,
871 1.0f, 0.0f, 0.0f, 0.0f,
872 0.0f, 1.0f, 0.0f, 0.0f,
873 0.0f, 0.0f, 1.0f, 0.0f,
874 9.7f, -8.6f, 1.3f, 1.0f);
875 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, NULL, &last);
876 expect_matrix(&expectedmat, &gotmat, 0);
878 set_matrix(&expectedmat,
879 25521.0f, 39984.0f, 20148.0f, 0.0f,
880 39984.0f, 4933.0f, -3324.0f, 0.0f,
881 20148.0f, -3324.0f, -5153.0f, 0.0f,
882 9.7f, -8.6f, 1.3f, 1.0f);
883 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, &last);
884 expect_matrix(&expectedmat, &gotmat, 0);
886 set_matrix(&expectedmat,
887 1.0f, 0.0f, 0.0f, 0.0f,
888 0.0f, -3.0f, 0.0f, 0.0f,
889 0.0f, 0.0f, 7.0f, 0.0f,
890 9.7f, 43.400002f, 55.299999f, 1.0f);
891 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, NULL, &last);
892 expect_matrix(&expectedmat, &gotmat, 0);
894 set_matrix(&expectedmat,
895 1.0f, 0.0f, 0.0f, 0.0f,
896 0.0f, 1.0f, 0.0f, 0.0f,
897 0.0f, 0.0f, 1.0f, 0.0f,
898 9.7f, -8.6f, 1.3f, 1.0f);
899 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, NULL, &last);
900 expect_matrix(&expectedmat, &gotmat, 0);
902 set_matrix(&expectedmat,
903 -0.2148f, 1.3116f, 0.4752f, 0.0f,
904 -2.8512f, 2.6508f, -2.7732f, 0.0f,
905 7.148399f, 1.3552f, -9.5116f, 0.0f,
906 8.5985f, -21.024f, 14.383499, 1.0f);
907 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, &r, NULL);
908 expect_matrix(&expectedmat, &gotmat, 8);
910 set_matrix(&expectedmat,
911 -0.2148f, 1.3116f, 0.4752f, 0.0f,
912 0.9504f, -0.8836f, 0.9244f, 0.0f,
913 1.0212f, 0.1936f, -1.3588f, 0.0f,
914 8.5985f, -21.024f, 14.383499, 1.0f);
915 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, &r, NULL);
916 expect_matrix(&expectedmat, &gotmat, 8);
918 set_matrix(&expectedmat,
919 -0.2148f, 1.3116f, 0.4752f, 0.0f,
920 0.9504f, -0.8836f, 0.9244f, 0.0f,
921 1.0212f, 0.1936f, -1.3588f, 0.0f,
922 8.5985f, -21.024f, 14.383499, 1.0f);
923 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, &r, NULL);
924 expect_matrix(&expectedmat, &gotmat, 8);
926 set_matrix(&expectedmat,
927 53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
928 -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
929 -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
930 0.0f, 0.0f, 0.0f, 1.0f);
931 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, &r, NULL);
932 expect_matrix(&expectedmat, &gotmat, 32);
934 set_matrix(&expectedmat,
935 -0.2148f, 1.3116f, 0.4752f, 0.0f,
936 -2.8512f, 2.6508f, -2.7732f, 0.0f,
937 7.148399f, 1.3552f, -9.5116f, 0.0f,
938 104.565598f, -35.492798f, -25.306400f, 1.0f);
939 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, &r, NULL);
940 expect_matrix(&expectedmat, &gotmat, 8);
942 set_matrix(&expectedmat,
943 -0.2148f, 1.3116f, 0.4752f, 0.0f,
944 0.9504f, -0.8836f, 0.9244f, 0.0f,
945 1.0212f, 0.1936f, -1.3588f, 0.0f,
946 0.0f, 0.0f, 0.0f, 1.0f);
947 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, &r, NULL);
948 expect_matrix(&expectedmat, &gotmat, 8);
950 set_matrix(&expectedmat,
951 25521.0f, 39984.0f, 20148.0f, 0.0f,
952 39984.0f, 4933.0f, -3324.0f, 0.0f,
953 20148.0f, -3324.0f, -5153.0f, 0.0f,
954 0.0f, 0.0f, 0.0f, 1.0f);
955 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, NULL, NULL);
956 expect_matrix(&expectedmat, &gotmat, 0);
958 set_matrix(&expectedmat,
959 1.0f, 0.0f, 0.0f, 0.0f,
960 0.0f, -3.0f, 0.0f, 0.0f,
961 0.0f, 0.0f, 7.0f, 0.0f,
962 0.0f, 52.0f, 54.0f, 1.0f);
963 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, NULL, NULL);
964 expect_matrix(&expectedmat, &gotmat, 0);
966 set_matrix(&expectedmat,
967 1.0f, 0.0f, 0.0f, 0.0f,
968 0.0f, 1.0f, 0.0f, 0.0f,
969 0.0f, 0.0f, 1.0f, 0.0f,
970 0.0f, 0.0f, 0.0f, 1.0f);
971 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, NULL, NULL);
972 expect_matrix(&expectedmat, &gotmat, 0);
974 set_matrix(&expectedmat,
975 25521.0f, 39984.0f, 20148.0f, 0.0f,
976 39984.0f, 4933.0f, -3324.0f, 0.0f,
977 20148.0f, -3324.0f, -5153.0f, 0.0f,
978 -287420.0f, -14064.0f, 37122.0f, 1.0f);
979 D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, NULL, NULL);
980 expect_matrix(&expectedmat, &gotmat, 0);
982 set_matrix(&expectedmat,
983 -0.2148f, 1.3116f, 0.4752f, 0.0f,
984 -2.8512f, 2.6508f, -2.7732f, 0.0f,
985 7.148399f, 1.3552f, -9.5116f, 0.0f,
986 18.2985f, -29.624001f, 15.683499f, 1.0f);
987 D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, &r, &last);
988 expect_matrix(&expectedmat, &gotmat, 8);
990 set_matrix(&expectedmat,
991 -0.2148f, 1.3116f, 0.4752f, 0.0f,
992 0.9504f, -0.8836f, 0.9244f, 0.0f,
993 1.0212f, 0.1936f, -1.3588f, 0.0f,
994 18.2985f, -29.624001f, 15.683499f, 1.0f);
995 D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, &r, &last);
996 expect_matrix(&expectedmat, &gotmat, 8);
998 set_matrix(&expectedmat,
999 -0.2148f, 1.3116f, 0.4752f, 0.0f,
1000 0.9504f, -0.8836f, 0.9244f, 0.0f,
1001 1.0212f, 0.1936f, -1.3588f, 0.0f,
1002 18.2985f, -29.624001f, 15.683499f, 1.0f);
1003 D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, &r, &last);
1004 expect_matrix(&expectedmat, &gotmat, 8);
1006 set_matrix(&expectedmat,
1007 53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1008 -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1009 -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1010 9.7f, -8.6f, 1.3f, 1.0f);
1011 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, &r, &last);
1012 expect_matrix(&expectedmat, &gotmat, 32);
1014 set_matrix(&expectedmat,
1015 -0.2148f, 1.3116f, 0.4752f, 0.0f,
1016 -2.8512f, 2.6508f, -2.7732f, 0.0f,
1017 7.148399f, 1.3552f, -9.5116f, 0.0f,
1018 114.265594f, -44.092796f, -24.006401f, 1.0f);
1019 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, &r, &last);
1020 expect_matrix(&expectedmat, &gotmat, 8);
1022 set_matrix(&expectedmat,
1023 -0.2148f, 1.3116f, 0.4752f, 0.0f,
1024 0.9504f, -0.8836f, 0.9244f, 0.0f,
1025 1.0212f, 0.1936f, -1.3588f, 0.0f,
1026 9.7f, -8.6f, 1.3f, 1.0f);
1027 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, &r, &last);
1028 expect_matrix(&expectedmat, &gotmat, 8);
1030 set_matrix(&expectedmat,
1031 25521.0f, 39984.0f, 20148.0f, 0.0f,
1032 39984.0f, 4933.0f, -3324.0f, 0.0f,
1033 20148.0f, -3324.0f, -5153.0f, 0.0f,
1034 9.7f, -8.6f, 1.3f, 1.0f);
1035 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, NULL, &last);
1036 expect_matrix(&expectedmat, &gotmat, 0);
1038 set_matrix(&expectedmat,
1039 1.0f, 0.0f, 0.0f, 0.0f,
1040 0.0f, -3.0f, 0.0f, 0.0f,
1041 0.0f, 0.0f, 7.0f, 0.0f,
1042 9.7f, 43.400002f, 55.299999f, 1.0f);
1043 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, NULL, &last);
1044 expect_matrix(&expectedmat, &gotmat, 0);
1046 set_matrix(&expectedmat,
1047 1.0f, 0.0f, 0.0f, 0.0f,
1048 0.0f, 1.0f, 0.0f, 0.0f,
1049 0.0f, 0.0f, 1.0f, 0.0f,
1050 9.7f, -8.6f, 1.3f, 1.0f);
1051 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, NULL, &last);
1052 expect_matrix(&expectedmat, &gotmat, 0);
1054 set_matrix(&expectedmat,
1055 25521.0f, 39984.0f, 20148.0f, 0.0f,
1056 39984.0f, 4933.0f, -3324.0f, 0.0f,
1057 20148.0f, -3324.0f, -5153.0f, 0.0f,
1058 -287410.3125f, -14072.599609f, 37123.300781f, 1.0f);
1059 D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, NULL, &last);
1060 expect_matrix(&expectedmat, &gotmat, 0);
1062 set_matrix(&expectedmat,
1063 53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1064 -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1065 -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1066 8.598499f, -21.024f, 14.383499f, 1.0f);
1067 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, &r, NULL);
1068 expect_matrix(&expectedmat, &gotmat, 32);
1070 set_matrix(&expectedmat,
1071 -0.2148f, 1.3116f, 0.4752f, 0.0f,
1072 -2.8512f, 2.6508f, -2.7732f, 0.0f,
1073 7.148399f, 1.3552f, -9.5116f, 0.0f,
1074 113.164093f, -56.5168f, -10.922897f, 1.0f);
1075 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, &r, NULL);
1076 expect_matrix(&expectedmat, &gotmat, 8);
1078 set_matrix(&expectedmat,
1079 -0.2148f, 1.3116f, 0.4752f, 0.0f,
1080 0.9504f, -0.8836f, 0.9244f, 0.0f,
1081 1.0212f, 0.1936f, -1.3588f, 0.0f,
1082 8.5985f, -21.024f, 14.383499, 1.0f);
1083 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, &r, NULL);
1084 expect_matrix(&expectedmat, &gotmat, 8);
1086 set_matrix(&expectedmat,
1087 53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1088 -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1089 -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1090 86280.34375f, -357366.3125f, -200024.125f, 1.0f);
1091 D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, &r, NULL);
1092 expect_matrix(&expectedmat, &gotmat, 32);
1094 set_matrix(&expectedmat,
1095 25521.0f, 39984.0f, 20148.0f, 0.0f,
1096 39984.0f, 4933.0f, -3324.0f, 0.0f,
1097 20148.0f, -3324.0f, -5153.0f, 0.0f,
1098 -287410.3125f, -14064.0f, 37122.0f, 1.0f);
1099 D3DXMatrixTransformation(&gotmat, &at, &q, &axis, &eye, NULL, NULL);
1100 expect_matrix(&expectedmat, &gotmat, 512);
1102 set_matrix(&expectedmat,
1103 53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1104 -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1105 -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1106 86280.34375f, -357366.3125f, -200009.75f, 1.0f);
1107 D3DXMatrixTransformation(&gotmat, &at, &q, &axis, &eye, &r, NULL);
1108 expect_matrix(&expectedmat, &gotmat, 2048);
1110 set_matrix(&expectedmat,
1111 25521.0f, 39984.0f, 20148.0f, 0.0f,
1112 39984.0f, 4933.0f, -3324.0f, 0.0f,
1113 20148.0f, -3324.0f, -5153.0f, 0.0f,
1114 -287410.3125f, -14072.599609f, 37123.300781f, 1.0f);
1115 D3DXMatrixTransformation(&gotmat, &at, &q, &axis, &eye, NULL, &last);
1116 expect_matrix(&expectedmat, &gotmat, 0);
1118 set_matrix(&expectedmat,
1119 53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1120 -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1121 -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1122 86290.046875f, -357374.90625f, -200022.828125f, 1.0f);
1123 D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, &r, &last);
1124 expect_matrix(&expectedmat, &gotmat, 32);
1126 set_matrix(&expectedmat,
1127 -0.21480007f, 1.3116000f, 0.47520003f, 0.0f,
1128 0.95040143f, -0.88360137f, 0.92439979f, 0.0f,
1129 1.0212044f, 0.19359307f, -1.3588026f, 0.0f,
1130 18.298532f, -29.624001f, 15.683499f, 1.0f);
1131 D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, &r, &last);
1132 expect_matrix(&expectedmat, &gotmat, 512);
1134 set_matrix(&expectedmat,
1135 -0.2148f, 1.3116f, 0.4752f, 0.0f,
1136 -2.8512f, 2.6508f, -2.7732f, 0.0f,
1137 7.148399f, 1.3552f, -9.5116f, 0.0f,
1138 122.86409f, -65.116798f, -9.622897f, 1.0f);
1139 D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, &r, &last);
1140 expect_matrix(&expectedmat, &gotmat, 8);
1142 set_matrix(&expectedmat,
1143 53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1144 -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1145 -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1146 18.2985f, -29.624001f, 15.683499f, 1.0f);
1147 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, &r, &last);
1148 expect_matrix(&expectedmat, &gotmat, 32);
1150 q.x = 1.0f; q.y = 1.0f; q.z = 1.0f; q.w = 1.0f;
1151 axis.x = 1.0f; axis.y = 1.0f; axis.z = 2.0f;
1153 set_matrix(&expectedmat,
1154 41.0f, -12.0f, -24.0f, 0.0f,
1155 -12.0f, 25.0f, -12.0f, 0.0f,
1156 -24.0f, -12.0f, 34.0f, 0.0f,
1157 0.0f, 0.0f, 0.0f, 1.0f);
1158 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1159 expect_matrix(&expectedmat, &gotmat, 0);
1161 q.x = 1.0f; q.y = 1.0f; q.z = 1.0f; q.w = 1.0f;
1162 axis.x = 1.0f; axis.y = 1.0f; axis.z = 3.0f;
1164 set_matrix(&expectedmat,
1165 57.0f, -12.0f, -36.0f, 0.0f,
1166 -12.0f, 25.0f, -12.0f, 0.0f,
1167 -36.0f, -12.0f, 43.0f, 0.0f,
1168 0.0f, 0.0f, 0.0f, 1.0f);
1169 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1170 expect_matrix(&expectedmat, &gotmat, 0);
1172 q.x = 1.0f; q.y = 1.0f; q.z = 1.0f; q.w = 0.0f;
1173 axis.x = 1.0f; axis.y = 1.0f; axis.z = 3.0f;
1175 set_matrix(&expectedmat,
1176 25.0f, 0.0f, -20.0f, 0.0f,
1177 0.0f, 25.0f, -20.0f, 0.0f,
1178 -20.0f, -20.0f, 35.0f, 0.0f,
1179 0.0f, 0.0f, 0.0f, 1.0f);
1180 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1181 expect_matrix(&expectedmat, &gotmat, 0);
1183 q.x = 1.0f; q.y = 1.0f; q.z = 0.0f; q.w = 0.0f;
1184 axis.x = 1.0f; axis.y = 1.0f; axis.z = 3.0f;
1186 set_matrix(&expectedmat,
1187 5.0f, -4.0f, 0.0f, 0.0f,
1188 -4.0f, 5.0f, 0.0f, 0.0f,
1189 0.0f, 0.0f, 27.0f, 0.0f,
1190 0.0f, 0.0f, 0.0f, 1.0f);
1191 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1192 expect_matrix(&expectedmat, &gotmat, 0);
1194 q.x = 1.0f; q.y = 0.0f; q.z = 0.0f; q.w = 0.0f;
1195 axis.x = 5.0f; axis.y = 2.0f; axis.z = 1.0f;
1197 set_matrix(&expectedmat,
1198 5.0f, 0.0f, 0.0f, 0.0f,
1199 0.0f, 2.0f, 0.0f, 0.0f,
1200 0.0f, 0.0f, 1.0f, 0.0f,
1201 0.0f, 0.0f, 0.0f, 1.0f);
1202 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1203 expect_matrix(&expectedmat, &gotmat, 0);
1205 q.x = 1.0f; q.y = 0.0f; q.z = 0.0f; q.w = 0.0f;
1206 axis.x = 1.0f; axis.y = 4.0f; axis.z = 1.0f;
1208 set_matrix(&expectedmat,
1209 1.0f, 0.0f, 0.0f, 0.0f,
1210 0.0f, 4.0f, 0.0f, 0.0f,
1211 0.0f, 0.0f, 1.0f, 0.0f,
1212 0.0f, 0.0f, 0.0f, 1.0f);
1213 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1214 expect_matrix(&expectedmat, &gotmat, 0);
1216 q.x = 0.0f; q.y = 1.0f; q.z = 0.0f; q.w = 0.0f;
1217 axis.x = 1.0f; axis.y = 4.0f; axis.z = 1.0f;
1219 set_matrix(&expectedmat,
1220 1.0f, 0.0f, 0.0f, 0.0f,
1221 0.0f, 4.0f, 0.0f, 0.0f,
1222 0.0f, 0.0f, 1.0f, 0.0f,
1223 0.0f, 0.0f, 0.0f, 1.0f);
1224 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1225 expect_matrix(&expectedmat, &gotmat, 0);
1227 q.x = 1.0f; q.y = 0.0f; q.z = 0.0f; q.w = 1.0f;
1228 axis.x = 1.0f; axis.y = 4.0f; axis.z = 1.0f;
1230 set_matrix(&expectedmat,
1231 1.0f, 0.0f, 0.0f, 0.0f,
1232 0.0f, 8.0f, -6.0f, 0.0f,
1233 0.0f, -6.0f, 17.0f, 0.0f,
1234 0.0f, 0.0f, 0.0f, 1.0f);
1235 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1236 expect_matrix(&expectedmat, &gotmat, 0);
1238 q.x = 1.0f; q.y = 0.0f; q.z = 0.0f; q.w = 1.0f;
1239 axis.x = 0.0f; axis.y = 4.0f; axis.z = 0.0f;
1241 set_matrix(&expectedmat,
1242 0.0f, 0.0f, 0.0f, 0.0f,
1243 0.0f, 4.0f, -8.0f, 0.0f,
1244 0.0f, -8.0f, 16.0f, 0.0f,
1245 0.0f, 0.0f, 0.0f, 1.0f);
1246 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1247 expect_matrix(&expectedmat, &gotmat, 0);
1249 q.x = 0.0f; q.y = 1.0f; q.z = 0.0f; q.w = 1.0f;
1250 axis.x = 1.0f; axis.y = 4.0f; axis.z = 1.0f;
1252 set_matrix(&expectedmat,
1253 5.0f, 0.0f, 0.0f, 0.0f,
1254 0.0f, 4.0f, 0.0f, 0.0f,
1255 0.0f, 0.0f, 5.0f, 0.0f,
1256 0.0f, 0.0f, 0.0f, 1.0f);
1257 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1258 expect_matrix(&expectedmat, &gotmat, 0);
1260 q.x = 1.0f; q.y = 0.0f; q.z = 0.0f; q.w = 0.0f;
1261 axis.x = 1.0f; axis.y = 1.0f; axis.z = 3.0f;
1263 set_matrix(&expectedmat,
1264 1.0f, 0.0f, 0.0f, 0.0f,
1265 0.0f, 1.0f, 0.0f, 0.0f,
1266 0.0f, 0.0f, 3.0f, 0.0f,
1267 0.0f, 0.0f, 0.0f, 1.0f);
1268 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1269 expect_matrix(&expectedmat, &gotmat, 0);
1271 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1272 axis.x = 3.0f; axis.y = 3.0f; axis.z = 3.0f;
1274 set_matrix(&expectedmat,
1275 3796587.0f, -1377948.0f, -1589940.0f, 0.0f,
1276 -1377948.0f, 3334059.0f, -1879020.0f, 0.0f,
1277 -1589940.0f, -1879020.0f, 2794443.0f, 0.0f,
1278 0.0f, 0.0f, 0.0f, 1.0f);
1279 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1280 expect_matrix(&expectedmat, &gotmat, 0);
1282 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1283 axis.x = 1.0f; axis.y = 1.0f; axis.z = 1.0f;
1285 set_matrix(&expectedmat,
1286 1265529.0f, -459316.0f, -529980.0f, 0.0f,
1287 -459316.0f, 1111353.0f, -626340.0f, 0.0f,
1288 -529980.0f, -626340.0f, 931481.0f, 0.0f,
1289 0.0f, 0.0f, 0.0f, 1.0f);
1290 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1291 expect_matrix(&expectedmat, &gotmat, 0);
1293 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1294 axis.x = 1.0f; axis.y = 1.0f; axis.z = 3.0f;
1296 set_matrix(&expectedmat,
1297 2457497.0f, -434612.0f, -1423956.0f, 0.0f,
1298 -434612.0f, 1111865.0f, -644868.0f, 0.0f,
1299 -1423956.0f, -644868.0f, 1601963.0f, 0.0f,
1300 0.0f, 0.0f, 0.0f, 1.0f);
1301 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1302 expect_matrix(&expectedmat, &gotmat, 0);
1304 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1305 axis.x = 0.0f; axis.y = 0.0f; axis.z = 3.0f;
1307 set_matrix(&expectedmat,
1308 1787952.0f, 37056.0f, -1340964.0f, 0.0f,
1309 37056.0f, 768.0f, -27792.0f, 0.0f,
1310 -1340964.0f, -27792.0f, 1005723.0f, 0.0f,
1311 0.0f, 0.0f, 0.0f, 1.0f);
1312 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1313 expect_matrix(&expectedmat, &gotmat, 0);
1315 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1316 axis.x = 0.0f; axis.y = 0.0f; axis.z = 1.0f;
1318 set_matrix(&expectedmat,
1319 595984.0f, 12352.0f, -446988.0f, 0.0f,
1320 12352.0f, 256.0f, -9264.0f, 0.0f,
1321 -446988.0f, -9264.0f, 335241.0f, 0.0f,
1322 0.0f, 0.0f, 0.0f, 1.0f);
1323 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1324 expect_matrix(&expectedmat, &gotmat, 0);
1326 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1327 axis.x = 0.0f; axis.y = 3.0f; axis.z = 0.0f;
1329 set_matrix(&expectedmat,
1330 150528.0f, 464352.0f, -513408.0f, 0.0f,
1331 464352.0f, 1432443.0f, -1583772.0f, 0.0f,
1332 -513408.0f, -1583772.0f, 1751088.0f, 0.0f,
1333 0.0f, 0.0f, 0.0f, 1.0f);
1334 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1335 expect_matrix(&expectedmat, &gotmat, 0);
1337 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1338 axis.x = 0.0f; axis.y = 1.0f; axis.z = 0.0f;
1340 set_matrix(&expectedmat,
1341 50176.0f, 154784.0f, -171136.0f, 0.0f,
1342 154784.0f, 477481.0f, -527924.0f, 0.0f,
1343 -171136.0f, -527924.0f, 583696.0f, 0.0f,
1344 0.0f, 0.0f, 0.0f, 1.0f);
1345 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1346 expect_matrix(&expectedmat, &gotmat, 0);
1348 q.x = 11.0f; q.y = 13.0f; q.z = 15.0f; q.w = 17.0f;
1349 axis.x = 1.0f; axis.y = 0.0f; axis.z = 0.0f;
1351 set_matrix(&expectedmat,
1352 619369.0f, -626452.0f, 88144.0f, 0.0f,
1353 -626452.0f, 633616.0f, -89152.0f, 0.0f,
1354 88144.0f, -89152, 12544.0f, 0.0f,
1355 0.0f, 0.0f, 0.0f, 1.0f);
1356 D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1357 expect_matrix(&expectedmat, &gotmat, 0);
1359 /*____________D3DXMatrixTranslation______________*/
1360 set_matrix(&expectedmat,
1361 1.0f, 0.0f, 0.0f, 0.0f,
1362 0.0f, 1.0f, 0.0f, 0.0f,
1363 0.0f, 0.0f, 1.0f, 0.0f,
1364 0.69f, 0.53f, 4.11f, 1.0f);
1365 D3DXMatrixTranslation(&gotmat, 0.69f, 0.53f, 4.11f);
1366 expect_matrix(&expectedmat, &gotmat, 0);
1368 /*____________D3DXMatrixTranspose______________*/
1369 set_matrix(&expectedmat,
1370 10.0f, 11.0f, 19.0f, 2.0f,
1371 5.0f, 20.0f, -21.0f, 3.0f,
1372 7.0f, 16.0f, 30.f, -4.0f,
1373 8.0f, 33.0f, 43.0f, -40.0f);
1374 D3DXMatrixTranspose(&gotmat, &mat);
1375 expect_matrix(&expectedmat, &gotmat, 0);
1378 static void D3DXPlaneTest(void)
1380 D3DXMATRIX mat;
1381 D3DXPLANE expectedplane, gotplane, nulplane, plane;
1382 D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
1383 LPD3DXVECTOR3 funcpointer;
1384 D3DXVECTOR4 vec;
1385 FLOAT expected, got;
1387 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1388 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1389 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1390 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1391 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
1392 U(mat).m[3][3] = -40.0f;
1394 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
1396 vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
1398 /*_______________D3DXPlaneDot________________*/
1399 expected = 42.0f;
1400 got = D3DXPlaneDot(&plane, &vec);
1401 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1402 expected = 0.0f;
1403 got = D3DXPlaneDot(NULL, &vec);
1404 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1405 expected = 0.0f;
1406 got = D3DXPlaneDot(NULL, NULL);
1407 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1409 /*_______________D3DXPlaneDotCoord________________*/
1410 expected = -28.0f;
1411 got = D3DXPlaneDotCoord(&plane, &vec);
1412 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1413 expected = 0.0f;
1414 got = D3DXPlaneDotCoord(NULL, &vec);
1415 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1416 expected = 0.0f;
1417 got = D3DXPlaneDotCoord(NULL, NULL);
1418 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1420 /*_______________D3DXPlaneDotNormal______________*/
1421 expected = -35.0f;
1422 got = D3DXPlaneDotNormal(&plane, &vec);
1423 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1424 expected = 0.0f;
1425 got = D3DXPlaneDotNormal(NULL, &vec);
1426 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1427 expected = 0.0f;
1428 got = D3DXPlaneDotNormal(NULL, NULL);
1429 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1431 /*_______________D3DXPlaneFromPointNormal_______*/
1432 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
1433 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
1434 expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
1435 D3DXPlaneFromPointNormal(&gotplane, &vec1, &vec2);
1436 expect_plane(&expectedplane, &gotplane, 0);
1437 gotplane.a = vec2.x; gotplane.b = vec2.y; gotplane.c = vec2.z;
1438 D3DXPlaneFromPointNormal(&gotplane, &vec1, (D3DXVECTOR3 *)&gotplane);
1439 expect_plane(&expectedplane, &gotplane, 0);
1440 gotplane.a = vec1.x; gotplane.b = vec1.y; gotplane.c = vec1.z;
1441 expectedplane.d = -1826.0f;
1442 D3DXPlaneFromPointNormal(&gotplane, (D3DXVECTOR3 *)&gotplane, &vec2);
1443 expect_plane(&expectedplane, &gotplane, 0);
1445 /*_______________D3DXPlaneFromPoints_______*/
1446 vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
1447 vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
1448 vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
1449 expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
1450 D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
1451 expect_plane(&expectedplane, &gotplane, 64);
1453 /*_______________D3DXPlaneIntersectLine___________*/
1454 vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
1455 vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
1456 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
1457 D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
1458 expect_vec3(&expectedvec, &gotvec, 1);
1459 /* Test a parallel line */
1460 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
1461 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
1462 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
1463 funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
1464 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1466 /*_______________D3DXPlaneNormalize______________*/
1467 expectedplane.a = -3.0f/sqrt(26.0f); expectedplane.b = -1.0f/sqrt(26.0f); expectedplane.c = 4.0f/sqrt(26.0f); expectedplane.d = 7.0/sqrt(26.0f);
1468 D3DXPlaneNormalize(&gotplane, &plane);
1469 expect_plane(&expectedplane, &gotplane, 2);
1470 nulplane.a = 0.0; nulplane.b = 0.0f; nulplane.c = 0.0f; nulplane.d = 0.0f;
1471 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
1472 D3DXPlaneNormalize(&gotplane, &nulplane);
1473 expect_plane(&expectedplane, &gotplane, 0);
1475 /*_______________D3DXPlaneTransform____________*/
1476 expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
1477 D3DXPlaneTransform(&gotplane,&plane,&mat);
1478 expect_plane(&expectedplane, &gotplane, 0);
1481 static void D3DXQuaternionTest(void)
1483 D3DXMATRIX mat;
1484 D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, smallq, smallr, q, r, s, t, u;
1485 BOOL expectedbool, gotbool, equal;
1486 float angle, got, scale, scale2;
1487 LPD3DXQUATERNION funcpointer;
1488 D3DXVECTOR3 axis, expectedvec;
1490 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
1491 q.x = 1.0f; q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
1492 r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
1493 t.x = -1111.0f; t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
1494 u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
1495 smallq.x = 0.1f; smallq.y = 0.2f; smallq.z= 0.3f; smallq.w = 0.4f;
1496 smallr.x = 0.5f; smallr.y = 0.6f; smallr.z= 0.7f; smallr.w = 0.8f;
1498 scale = 0.3f;
1499 scale2 = 0.78f;
1501 /*_______________D3DXQuaternionBaryCentric________________________*/
1502 expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
1503 D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
1504 expect_quaternion(&expectedquat, &gotquat, 1);
1506 /*_______________D3DXQuaternionConjugate________________*/
1507 expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
1508 D3DXQuaternionConjugate(&gotquat,&q);
1509 expect_quaternion(&expectedquat, &gotquat, 0);
1510 /* Test the NULL case */
1511 funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
1512 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1513 funcpointer = D3DXQuaternionConjugate(NULL,NULL);
1514 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1516 /*_______________D3DXQuaternionDot______________________*/
1517 got = D3DXQuaternionDot(&q,&r);
1518 equal = compare_float(got, 55.0f, 0);
1519 ok(equal, "Got unexpected dot %.8e.\n", got);
1520 /* Tests the case NULL */
1521 got = D3DXQuaternionDot(NULL,&r);
1522 equal = compare_float(got, 0.0f, 0);
1523 ok(equal, "Got unexpected dot %.8e.\n", got);
1524 got = D3DXQuaternionDot(NULL,NULL);
1525 equal = compare_float(got, 0.0f, 0);
1526 ok(equal, "Got unexpected dot %.8e.\n", got);
1528 /*_______________D3DXQuaternionExp______________________________*/
1529 expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
1530 D3DXQuaternionExp(&gotquat,&q);
1531 expect_quaternion(&expectedquat, &gotquat, 16);
1532 /* Test the null quaternion */
1533 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
1534 D3DXQuaternionExp(&gotquat,&nul);
1535 expect_quaternion(&expectedquat, &gotquat, 0);
1536 /* Test the case where the norm of the quaternion is <1 */
1537 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
1538 expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
1539 D3DXQuaternionExp(&gotquat,&Nq1);
1540 expect_quaternion(&expectedquat, &gotquat, 8);
1542 /*_______________D3DXQuaternionIdentity________________*/
1543 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
1544 D3DXQuaternionIdentity(&gotquat);
1545 expect_quaternion(&expectedquat, &gotquat, 0);
1546 /* Test the NULL case */
1547 funcpointer = D3DXQuaternionIdentity(NULL);
1548 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1550 /*_______________D3DXQuaternionInverse________________________*/
1551 expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
1552 D3DXQuaternionInverse(&gotquat,&q);
1553 expect_quaternion(&expectedquat, &gotquat, 0);
1555 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 10.0f;
1556 D3DXQuaternionInverse(&gotquat,&gotquat);
1557 expect_quaternion(&expectedquat, &gotquat, 1);
1560 /*_______________D3DXQuaternionIsIdentity________________*/
1561 s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
1562 expectedbool = TRUE;
1563 gotbool = D3DXQuaternionIsIdentity(&s);
1564 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
1565 s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
1566 expectedbool = FALSE;
1567 gotbool = D3DXQuaternionIsIdentity(&q);
1568 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
1569 /* Test the NULL case */
1570 gotbool = D3DXQuaternionIsIdentity(NULL);
1571 ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
1573 /*_______________D3DXQuaternionLength__________________________*/
1574 got = D3DXQuaternionLength(&q);
1575 equal = compare_float(got, 11.0f, 0);
1576 ok(equal, "Got unexpected length %.8e.\n", got);
1577 /* Tests the case NULL. */
1578 got = D3DXQuaternionLength(NULL);
1579 equal = compare_float(got, 0.0f, 0);
1580 ok(equal, "Got unexpected length %.8e.\n", got);
1582 /*_______________D3DXQuaternionLengthSq________________________*/
1583 got = D3DXQuaternionLengthSq(&q);
1584 equal = compare_float(got, 121.0f, 0);
1585 ok(equal, "Got unexpected length %.8e.\n", got);
1586 /* Tests the case NULL */
1587 got = D3DXQuaternionLengthSq(NULL);
1588 equal = compare_float(got, 0.0f, 0);
1589 ok(equal, "Got unexpected length %.8e.\n", got);
1591 /*_______________D3DXQuaternionLn______________________________*/
1592 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
1593 D3DXQuaternionLn(&gotquat,&q);
1594 expect_quaternion(&expectedquat, &gotquat, 0);
1595 expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
1596 D3DXQuaternionLn(&gotquat,&r);
1597 expect_quaternion(&expectedquat, &gotquat, 0);
1598 Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
1599 expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
1600 D3DXQuaternionLn(&gotquat,&Nq);
1601 expect_quaternion(&expectedquat, &gotquat, 32);
1602 Nq.x = 0.0f; Nq.y = 0.0f; Nq.z = 0.0f; Nq.w = 1.0f;
1603 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1604 D3DXQuaternionLn(&gotquat,&Nq);
1605 expect_quaternion(&expectedquat, &gotquat, 0);
1606 Nq.x = 5.4f; Nq.y = 1.2f; Nq.z = -0.3f; Nq.w = -0.3f;
1607 expectedquat.x = 10.616652f; expectedquat.y = 2.359256f; expectedquat.z = -0.589814f; expectedquat.w = 0.0f;
1608 D3DXQuaternionLn(&gotquat,&Nq);
1609 expect_quaternion(&expectedquat, &gotquat, 1);
1610 /* Test the case where the norm of the quaternion is <1 */
1611 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = 0.9f;
1612 expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
1613 D3DXQuaternionLn(&gotquat,&Nq1);
1614 expect_quaternion(&expectedquat, &gotquat, 64);
1615 /* Test the case where the real part of the quaternion is -1.0f */
1616 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = -1.0f;
1617 expectedquat.x = 0.2f; expectedquat.y = 0.1f; expectedquat.z = 0.3f; expectedquat.w = 0.0f;
1618 D3DXQuaternionLn(&gotquat,&Nq1);
1619 expect_quaternion(&expectedquat, &gotquat, 0);
1621 /*_______________D3DXQuaternionMultiply________________________*/
1622 expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
1623 D3DXQuaternionMultiply(&gotquat,&q,&r);
1624 expect_quaternion(&expectedquat, &gotquat, 0);
1626 /*_______________D3DXQuaternionNormalize________________________*/
1627 expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
1628 D3DXQuaternionNormalize(&gotquat,&q);
1629 expect_quaternion(&expectedquat, &gotquat, 1);
1631 /*_______________D3DXQuaternionRotationAxis___________________*/
1632 axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
1633 angle = D3DX_PI/3.0f;
1634 expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
1635 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
1636 expect_quaternion(&expectedquat, &gotquat, 64);
1637 /* Test the nul quaternion */
1638 axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
1639 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
1640 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
1641 expect_quaternion(&expectedquat, &gotquat, 8);
1643 /*_______________D3DXQuaternionRotationMatrix___________________*/
1644 /* test when the trace is >0 */
1645 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1646 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1647 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1648 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1649 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
1650 U(mat).m[3][3] = 48.0f;
1651 expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
1652 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1653 expect_quaternion(&expectedquat, &gotquat, 16);
1654 /* test the case when the greater element is (2,2) */
1655 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1656 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1657 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1658 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1659 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
1660 U(mat).m[3][3] = 48.0f;
1661 expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
1662 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1663 expect_quaternion(&expectedquat, &gotquat, 64);
1664 /* test the case when the greater element is (1,1) */
1665 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1666 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1667 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1668 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1669 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
1670 U(mat).m[3][3] = 48.0f;
1671 expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
1672 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1673 expect_quaternion(&expectedquat, &gotquat, 8);
1674 /* test the case when the trace is near 0 in a matrix which is not a rotation */
1675 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1676 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1677 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1678 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1679 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.9f;
1680 U(mat).m[3][3] = 48.0f;
1681 expectedquat.x = 1.709495f; expectedquat.y = 2.339872f; expectedquat.z = -0.534217f; expectedquat.w = 1.282122f;
1682 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1683 expect_quaternion(&expectedquat, &gotquat, 8);
1684 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
1685 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1686 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1687 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1688 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1689 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.51f;
1690 U(mat).m[3][3] = 48.0f;
1691 expectedquat.x = 1.724923f; expectedquat.y = 2.318944f; expectedquat.z = -0.539039f; expectedquat.w = 1.293692f;
1692 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1693 expect_quaternion(&expectedquat, &gotquat, 8);
1694 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
1695 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1696 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1697 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1698 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1699 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.49f;
1700 U(mat).m[3][3] = 48.0f;
1701 expectedquat.x = 1.725726f; expectedquat.y = 2.317865f; expectedquat.z = -0.539289f; expectedquat.w = 1.294294f;
1702 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1703 expect_quaternion(&expectedquat, &gotquat, 8);
1704 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
1705 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1706 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1707 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1708 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1709 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.01f;
1710 U(mat).m[3][3] = 48.0f;
1711 expectedquat.x = 1.745328f; expectedquat.y = 2.291833f; expectedquat.z = -0.545415f; expectedquat.w = 1.308996f;
1712 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1713 expect_quaternion(&expectedquat, &gotquat, 4);
1714 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
1715 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1716 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1717 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1718 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1719 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.0f;
1720 U(mat).m[3][3] = 48.0f;
1721 expectedquat.x = 1.745743f; expectedquat.y = 2.291288f; expectedquat.z = -0.545545f; expectedquat.w = 1.309307f;
1722 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1723 expect_quaternion(&expectedquat, &gotquat, 8);
1724 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
1725 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1726 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1727 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1728 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1729 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.01f;
1730 U(mat).m[3][3] = 48.0f;
1731 expectedquat.x = 18.408188f; expectedquat.y = 5.970223f; expectedquat.z = -2.985111f; expectedquat.w = 0.502494f;
1732 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1733 expect_quaternion(&expectedquat, &gotquat, 4);
1734 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
1735 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1736 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1737 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1738 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1739 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.5f;
1740 U(mat).m[3][3] = 48.0f;
1741 expectedquat.x = 15.105186f; expectedquat.y = 4.898980f; expectedquat.z = -2.449490f; expectedquat.w = 0.612372f;
1742 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1743 expect_quaternion(&expectedquat, &gotquat, 8);
1744 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
1745 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1746 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1747 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1748 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1749 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.70f;
1750 U(mat).m[3][3] = 48.0f;
1751 expectedquat.x = 14.188852f; expectedquat.y = 4.601790f; expectedquat.z = -2.300895f; expectedquat.w = 0.651920f;
1752 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1753 expect_quaternion(&expectedquat, &gotquat, 4);
1754 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
1755 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1756 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1757 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1758 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1759 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.99f;
1760 U(mat).m[3][3] = 48.0f;
1761 expectedquat.x = 13.114303f; expectedquat.y = 4.253287f; expectedquat.z = -2.126644f; expectedquat.w = 0.705337f;
1762 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1763 expect_quaternion(&expectedquat, &gotquat, 4);
1764 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
1765 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1766 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1767 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1768 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1769 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 2.0f;
1770 U(mat).m[3][3] = 48.0f;
1771 expectedquat.x = 10.680980f; expectedquat.y = 3.464102f; expectedquat.z = -1.732051f; expectedquat.w = 0.866025f;
1772 D3DXQuaternionRotationMatrix(&gotquat,&mat);
1773 expect_quaternion(&expectedquat, &gotquat, 8);
1775 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
1776 expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
1777 D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
1778 expect_quaternion(&expectedquat, &gotquat, 16);
1780 /*_______________D3DXQuaternionSlerp________________________*/
1781 expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
1782 D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
1783 expect_quaternion(&expectedquat, &gotquat, 4);
1784 expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
1785 D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
1786 expect_quaternion(&expectedquat, &gotquat, 2);
1787 expectedquat.x = 0.239485f; expectedquat.y = 0.346580f; expectedquat.z = 0.453676f; expectedquat.w = 0.560772f;
1788 D3DXQuaternionSlerp(&gotquat,&smallq,&smallr,scale);
1789 expect_quaternion(&expectedquat, &gotquat, 32);
1791 /*_______________D3DXQuaternionSquad________________________*/
1792 expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
1793 D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
1794 expect_quaternion(&expectedquat, &gotquat, 2);
1796 /*_______________D3DXQuaternionSquadSetup___________________*/
1797 r.x = 1.0f; r.y = 2.0f; r.z = 4.0f; r.w = 10.0f;
1798 s.x = -3.0f; s.y = 4.0f; s.z = -5.0f; s.w = 7.0;
1799 t.x = -1111.0f; t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
1800 u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
1801 D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
1802 expectedquat.x = 7.121285f; expectedquat.y = 2.159964f; expectedquat.z = -3.855094f; expectedquat.w = 5.362844f;
1803 expect_quaternion(&expectedquat, &gotquat, 2);
1804 expectedquat.x = -1113.492920f; expectedquat.y = 82.679260f; expectedquat.z = -6.696645f; expectedquat.w = -4.090050f;
1805 expect_quaternion(&expectedquat, &Nq, 4);
1806 expectedquat.x = -1111.0f; expectedquat.y = 111.0f; expectedquat.z = -11.0f; expectedquat.w = 1.0f;
1807 expect_quaternion(&expectedquat, &Nq1, 0);
1808 gotquat = s;
1809 D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &gotquat, &t, &u);
1810 expectedquat.x = -1113.492920f; expectedquat.y = 82.679260f; expectedquat.z = -6.696645f; expectedquat.w = -4.090050f;
1811 expect_quaternion(&expectedquat, &Nq, 4);
1812 Nq1 = u;
1813 D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &Nq1);
1814 expect_quaternion(&expectedquat, &Nq, 4);
1815 r.x = 0.2f; r.y = 0.3f; r.z = 1.3f; r.w = -0.6f;
1816 s.x = -3.0f; s.y =-2.0f; s.z = 4.0f; s.w = 0.2f;
1817 t.x = 0.4f; t.y = 8.3f; t.z = -3.1f; t.w = -2.7f;
1818 u.x = 1.1f; u.y = -0.7f; u.z = 9.2f; u.w = 0.0f;
1819 D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &u, &t);
1820 expectedquat.x = -4.139569f; expectedquat.y = -2.469115f; expectedquat.z = 2.364477f; expectedquat.w = 0.465494f;
1821 expect_quaternion(&expectedquat, &gotquat, 16);
1822 expectedquat.x = 2.342533f; expectedquat.y = 2.365127f; expectedquat.z = 8.628538f; expectedquat.w = -0.898356f;
1823 expect_quaternion(&expectedquat, &Nq, 16);
1824 expectedquat.x = 1.1f; expectedquat.y = -0.7f; expectedquat.z = 9.2f; expectedquat.w = 0.0f;
1825 expect_quaternion(&expectedquat, &Nq1, 0);
1826 D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
1827 expectedquat.x = -3.754567f; expectedquat.y = -0.586085f; expectedquat.z = 3.815818f; expectedquat.w = -0.198150f;
1828 expect_quaternion(&expectedquat, &gotquat, 32);
1829 expectedquat.x = 0.140773f; expectedquat.y = -8.737090f; expectedquat.z = -0.516593f; expectedquat.w = 3.053942f;
1830 expect_quaternion(&expectedquat, &Nq, 16);
1831 expectedquat.x = -0.4f; expectedquat.y = -8.3f; expectedquat.z = 3.1f; expectedquat.w = 2.7f;
1832 expect_quaternion(&expectedquat, &Nq1, 0);
1833 r.x = -1.0f; r.y = 0.0f; r.z = 0.0f; r.w = 0.0f;
1834 s.x = 1.0f; s.y =0.0f; s.z = 0.0f; s.w = 0.0f;
1835 t.x = 1.0f; t.y = 0.0f; t.z = 0.0f; t.w = 0.0f;
1836 u.x = -1.0f; u.y = 0.0f; u.z = 0.0f; u.w = 0.0f;
1837 D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
1838 expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1839 expect_quaternion(&expectedquat, &gotquat, 0);
1840 expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1841 expect_quaternion(&expectedquat, &Nq, 0);
1842 expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1843 expect_quaternion(&expectedquat, &Nq1, 0);
1845 /*_______________D3DXQuaternionToAxisAngle__________________*/
1846 Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
1847 expectedvec.x = 1.0f/22.0f; expectedvec.y = 2.0f/22.0f; expectedvec.z = 4.0f/22.0f;
1848 D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
1849 expect_vec3(&expectedvec, &axis, 0);
1850 equal = compare_float(angle, 2.197869f, 1);
1851 ok(equal, "Got unexpected angle %.8e.\n", angle);
1852 /* Test if |w|>1.0f */
1853 expectedvec.x = 1.0f; expectedvec.y = 2.0f; expectedvec.z = 4.0f;
1854 D3DXQuaternionToAxisAngle(&q,&axis,&angle);
1855 expect_vec3(&expectedvec, &axis, 0);
1856 /* Test the null quaternion */
1857 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1858 D3DXQuaternionToAxisAngle(&nul, &axis, &angle);
1859 expect_vec3(&expectedvec, &axis, 0);
1860 equal = compare_float(angle, 3.14159274e+00f, 0);
1861 ok(equal, "Got unexpected angle %.8e.\n", angle);
1863 D3DXQuaternionToAxisAngle(&nul, &axis, NULL);
1864 D3DXQuaternionToAxisAngle(&nul, NULL, &angle);
1865 expect_vec3(&expectedvec, &axis, 0);
1866 equal = compare_float(angle, 3.14159274e+00f, 0);
1867 ok(equal, "Got unexpected angle %.8e.\n", angle);
1870 static void D3DXVector2Test(void)
1872 D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w, x;
1873 LPD3DXVECTOR2 funcpointer;
1874 D3DXVECTOR4 expectedtrans, gottrans;
1875 float coeff1, coeff2, got, scale;
1876 D3DXMATRIX mat;
1877 BOOL equal;
1879 nul.x = 0.0f; nul.y = 0.0f;
1880 u.x = 3.0f; u.y = 4.0f;
1881 v.x = -7.0f; v.y = 9.0f;
1882 w.x = 4.0f; w.y = -3.0f;
1883 x.x = 2.0f; x.y = -11.0f;
1885 set_matrix(&mat,
1886 1.0f, 2.0f, 3.0f, 4.0f,
1887 5.0f, 6.0f, 7.0f, 8.0f,
1888 9.0f, 10.0f, 11.0f, 12.0f,
1889 13.0f, 14.0f, 15.0f, 16.0f);
1891 coeff1 = 2.0f; coeff2 = 5.0f;
1892 scale = -6.5f;
1894 /*_______________D3DXVec2Add__________________________*/
1895 expectedvec.x = -4.0f; expectedvec.y = 13.0f;
1896 D3DXVec2Add(&gotvec,&u,&v);
1897 expect_vec2(&expectedvec, &gotvec, 0);
1898 /* Tests the case NULL */
1899 funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
1900 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1901 funcpointer = D3DXVec2Add(NULL,NULL,NULL);
1902 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1904 /*_______________D3DXVec2BaryCentric___________________*/
1905 expectedvec.x = -12.0f; expectedvec.y = -21.0f;
1906 D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1907 expect_vec2(&expectedvec, &gotvec, 0);
1909 /*_______________D3DXVec2CatmullRom____________________*/
1910 expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
1911 D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1912 expect_vec2(&expectedvec, &gotvec, 0);
1914 /*_______________D3DXVec2CCW__________________________*/
1915 got = D3DXVec2CCW(&u, &v);
1916 equal = compare_float(got, 55.0f, 0);
1917 ok(equal, "Got unexpected ccw %.8e.\n", got);
1918 /* Tests the case NULL. */
1919 got = D3DXVec2CCW(NULL, &v);
1920 equal = compare_float(got, 0.0f, 0);
1921 ok(equal, "Got unexpected ccw %.8e.\n", got);
1922 got = D3DXVec2CCW(NULL, NULL);
1923 equal = compare_float(got, 0.0f, 0);
1924 ok(equal, "Got unexpected ccw %.8e.\n", got);
1926 /*_______________D3DXVec2Dot__________________________*/
1927 got = D3DXVec2Dot(&u, &v);
1928 equal = compare_float(got, 15.0f, 0);
1929 ok(equal, "Got unexpected dot %.8e.\n", got);
1930 /* Tests the case NULL */
1931 got = D3DXVec2Dot(NULL, &v);
1932 equal = compare_float(got, 0.0f, 0);
1933 ok(equal, "Got unexpected dot %.8e.\n", got);
1934 got = D3DXVec2Dot(NULL, NULL);
1935 equal = compare_float(got, 0.0f, 0);
1936 ok(equal, "Got unexpected dot %.8e.\n", got);
1938 /*_______________D3DXVec2Hermite__________________________*/
1939 expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
1940 D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
1941 expect_vec2(&expectedvec, &gotvec, 0);
1943 /*_______________D3DXVec2Length__________________________*/
1944 got = D3DXVec2Length(&u);
1945 equal = compare_float(got, 5.0f, 0);
1946 ok(equal, "Got unexpected length %.8e.\n", got);
1947 /* Tests the case NULL. */
1948 got = D3DXVec2Length(NULL);
1949 equal = compare_float(got, 0.0f, 0);
1950 ok(equal, "Got unexpected length %.8e.\n", got);
1952 /*_______________D3DXVec2LengthSq________________________*/
1953 got = D3DXVec2LengthSq(&u);
1954 equal = compare_float(got, 25.0f, 0);
1955 ok(equal, "Got unexpected length %.8e.\n", got);
1956 /* Tests the case NULL. */
1957 got = D3DXVec2LengthSq(NULL);
1958 equal = compare_float(got, 0.0f, 0);
1959 ok(equal, "Got unexpected length %.8e.\n", got);
1961 /*_______________D3DXVec2Lerp__________________________*/
1962 expectedvec.x = 68.0f; expectedvec.y = -28.5f;
1963 D3DXVec2Lerp(&gotvec, &u, &v, scale);
1964 expect_vec2(&expectedvec, &gotvec, 0);
1965 /* Tests the case NULL. */
1966 funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
1967 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1968 funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
1969 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1971 /*_______________D3DXVec2Maximize__________________________*/
1972 expectedvec.x = 3.0f; expectedvec.y = 9.0f;
1973 D3DXVec2Maximize(&gotvec, &u, &v);
1974 expect_vec2(&expectedvec, &gotvec, 0);
1975 /* Tests the case NULL. */
1976 funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
1977 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1978 funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
1979 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1981 /*_______________D3DXVec2Minimize__________________________*/
1982 expectedvec.x = -7.0f; expectedvec.y = 4.0f;
1983 D3DXVec2Minimize(&gotvec,&u,&v);
1984 expect_vec2(&expectedvec, &gotvec, 0);
1985 /* Tests the case NULL */
1986 funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
1987 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1988 funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
1989 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1991 /*_______________D3DXVec2Normalize_________________________*/
1992 expectedvec.x = 0.6f; expectedvec.y = 0.8f;
1993 D3DXVec2Normalize(&gotvec,&u);
1994 expect_vec2(&expectedvec, &gotvec, 0);
1995 /* Test the nul vector */
1996 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1997 D3DXVec2Normalize(&gotvec,&nul);
1998 expect_vec2(&expectedvec, &gotvec, 0);
2000 /*_______________D3DXVec2Scale____________________________*/
2001 expectedvec.x = -19.5f; expectedvec.y = -26.0f;
2002 D3DXVec2Scale(&gotvec,&u,scale);
2003 expect_vec2(&expectedvec, &gotvec, 0);
2004 /* Tests the case NULL */
2005 funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
2006 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2007 funcpointer = D3DXVec2Scale(NULL,NULL,scale);
2008 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2010 /*_______________D3DXVec2Subtract__________________________*/
2011 expectedvec.x = 10.0f; expectedvec.y = -5.0f;
2012 D3DXVec2Subtract(&gotvec, &u, &v);
2013 expect_vec2(&expectedvec, &gotvec, 0);
2014 /* Tests the case NULL. */
2015 funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
2016 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2017 funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
2018 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2020 /*_______________D3DXVec2Transform_______________________*/
2021 expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
2022 D3DXVec2Transform(&gottrans, &u, &mat);
2023 expect_vec4(&expectedtrans, &gottrans, 0);
2024 gottrans.x = u.x; gottrans.y = u.y;
2025 D3DXVec2Transform(&gottrans, (D3DXVECTOR2 *)&gottrans, &mat);
2026 expect_vec4(&expectedtrans, &gottrans, 0);
2028 /*_______________D3DXVec2TransformCoord_______________________*/
2029 expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
2030 D3DXVec2TransformCoord(&gotvec, &u, &mat);
2031 expect_vec2(&expectedvec, &gotvec, 1);
2032 gotvec.x = u.x; gotvec.y = u.y;
2033 D3DXVec2TransformCoord(&gotvec, &gotvec, &mat);
2034 expect_vec2(&expectedvec, &gotvec, 1);
2036 /*_______________D3DXVec2TransformNormal______________________*/
2037 expectedvec.x = 23.0f; expectedvec.y = 30.0f;
2038 D3DXVec2TransformNormal(&gotvec,&u,&mat);
2039 expect_vec2(&expectedvec, &gotvec, 0);
2042 static void D3DXVector3Test(void)
2044 D3DVIEWPORT9 viewport;
2045 D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w, x;
2046 LPD3DXVECTOR3 funcpointer;
2047 D3DXVECTOR4 expectedtrans, gottrans;
2048 D3DXMATRIX mat, projection, view, world;
2049 float coeff1, coeff2, got, scale;
2050 BOOL equal;
2052 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
2053 u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
2054 v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
2055 w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
2056 x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
2058 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
2059 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
2061 set_matrix(&mat,
2062 1.0f, 2.0f, 3.0f, 4.0f,
2063 5.0f, 6.0f, 7.0f, 8.0f,
2064 9.0f, 10.0f, 11.0f, 12.0f,
2065 13.0f, 14.0f, 15.0f, 16.0f);
2067 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
2068 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
2069 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
2070 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
2071 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
2072 U(view).m[3][3] = -40.0f;
2074 set_matrix(&world,
2075 21.0f, 2.0f, 3.0f, 4.0f,
2076 5.0f, 23.0f, 7.0f, 8.0f,
2077 -8.0f, -7.0f, 25.0f, -5.0f,
2078 -4.0f, -3.0f, -2.0f, 27.0f);
2080 coeff1 = 2.0f; coeff2 = 5.0f;
2081 scale = -6.5f;
2083 /*_______________D3DXVec3Add__________________________*/
2084 expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
2085 D3DXVec3Add(&gotvec,&u,&v);
2086 expect_vec3(&expectedvec, &gotvec, 0);
2087 /* Tests the case NULL */
2088 funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
2089 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2090 funcpointer = D3DXVec3Add(NULL,NULL,NULL);
2091 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2093 /*_______________D3DXVec3BaryCentric___________________*/
2094 expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
2095 D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
2096 expect_vec3(&expectedvec, &gotvec, 0);
2098 /*_______________D3DXVec3CatmullRom____________________*/
2099 expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
2100 D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
2101 expect_vec3(&expectedvec, &gotvec, 0);
2103 /*_______________D3DXVec3Cross________________________*/
2104 expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
2105 D3DXVec3Cross(&gotvec,&u,&v);
2106 expect_vec3(&expectedvec, &gotvec, 0);
2107 expectedvec.x = -277.0f; expectedvec.y = -150.0f; expectedvec.z = -26.0f;
2108 D3DXVec3Cross(&gotvec,&gotvec,&v);
2109 expect_vec3(&expectedvec, &gotvec, 0);
2110 /* Tests the case NULL */
2111 funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
2112 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2113 funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
2114 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2116 /*_______________D3DXVec3Dot__________________________*/
2117 got = D3DXVec3Dot(&u, &v);
2118 equal = compare_float(got, -8.0f, 0);
2119 ok(equal, "Got unexpected dot %.8e.\n", got);
2120 /* Tests the case NULL */
2121 got = D3DXVec3Dot(NULL, &v);
2122 equal = compare_float(got, 0.0f, 0);
2123 ok(equal, "Got unexpected dot %.8e.\n", got);
2124 got = D3DXVec3Dot(NULL, NULL);
2125 equal = compare_float(got, 0.0f, 0);
2126 ok(equal, "Got unexpected dot %.8e.\n", got);
2128 /*_______________D3DXVec3Hermite__________________________*/
2129 expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
2130 D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
2131 expect_vec3(&expectedvec, &gotvec, 0);
2133 /*_______________D3DXVec3Length__________________________*/
2134 got = D3DXVec3Length(&u);
2135 equal = compare_float(got, 11.0f, 0);
2136 ok(equal, "Got unexpected length %.8e.\n", got);
2137 /* Tests the case NULL. */
2138 got = D3DXVec3Length(NULL);
2139 equal = compare_float(got, 0.0f, 0);
2140 ok(equal, "Got unexpected length %.8e.\n", got);
2142 /*_______________D3DXVec3LengthSq________________________*/
2143 got = D3DXVec3LengthSq(&u);
2144 equal = compare_float(got, 121.0f, 0);
2145 ok(equal, "Got unexpected length %.8e.\n", got);
2146 /* Tests the case NULL. */
2147 got = D3DXVec3LengthSq(NULL);
2148 equal = compare_float(got, 0.0f, 0);
2149 ok(equal, "Got unexpected length %.8e.\n", got);
2151 /*_______________D3DXVec3Lerp__________________________*/
2152 expectedvec.x = 54.5f; expectedvec.y = 64.5f; expectedvec.z = 41.0f ;
2153 D3DXVec3Lerp(&gotvec,&u,&v,scale);
2154 expect_vec3(&expectedvec, &gotvec, 0);
2155 /* Tests the case NULL */
2156 funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
2157 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2158 funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
2159 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2161 /*_______________D3DXVec3Maximize__________________________*/
2162 expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
2163 D3DXVec3Maximize(&gotvec,&u,&v);
2164 expect_vec3(&expectedvec, &gotvec, 0);
2165 /* Tests the case NULL */
2166 funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
2167 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2168 funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
2169 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2171 /*_______________D3DXVec3Minimize__________________________*/
2172 expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
2173 D3DXVec3Minimize(&gotvec,&u,&v);
2174 expect_vec3(&expectedvec, &gotvec, 0);
2175 /* Tests the case NULL */
2176 funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
2177 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2178 funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
2179 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2181 /*_______________D3DXVec3Normalize_________________________*/
2182 expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
2183 D3DXVec3Normalize(&gotvec,&u);
2184 expect_vec3(&expectedvec, &gotvec, 1);
2185 /* Test the nul vector */
2186 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
2187 D3DXVec3Normalize(&gotvec,&nul);
2188 expect_vec3(&expectedvec, &gotvec, 0);
2190 /*_______________D3DXVec3Scale____________________________*/
2191 expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
2192 D3DXVec3Scale(&gotvec,&u,scale);
2193 expect_vec3(&expectedvec, &gotvec, 0);
2194 /* Tests the case NULL */
2195 funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
2196 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2197 funcpointer = D3DXVec3Scale(NULL,NULL,scale);
2198 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2200 /*_______________D3DXVec3Subtract_______________________*/
2201 expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
2202 D3DXVec3Subtract(&gotvec,&u,&v);
2203 expect_vec3(&expectedvec, &gotvec, 0);
2204 /* Tests the case NULL */
2205 funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
2206 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2207 funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
2208 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2210 /*_______________D3DXVec3Transform_______________________*/
2211 expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
2212 D3DXVec3Transform(&gottrans, &u, &mat);
2213 expect_vec4(&expectedtrans, &gottrans, 0);
2215 gottrans.x = u.x; gottrans.y = u.y; gottrans.z = u.z;
2216 D3DXVec3Transform(&gottrans, (D3DXVECTOR3 *)&gottrans, &mat);
2217 expect_vec4(&expectedtrans, &gottrans, 0);
2219 /*_______________D3DXVec3TransformCoord_______________________*/
2220 expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
2221 D3DXVec3TransformCoord(&gotvec,&u,&mat);
2222 expect_vec3(&expectedvec, &gotvec, 1);
2224 /*_______________D3DXVec3TransformNormal______________________*/
2225 expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
2226 D3DXVec3TransformNormal(&gotvec,&u,&mat);
2227 expect_vec3(&expectedvec, &gotvec, 0);
2229 /*_______________D3DXVec3Project_________________________*/
2230 expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
2231 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
2232 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
2233 expect_vec3(&expectedvec, &gotvec, 32);
2234 /* World matrix can be omitted */
2235 D3DXMatrixMultiply(&mat,&world,&view);
2236 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&mat,NULL);
2237 expect_vec3(&expectedvec, &gotvec, 32);
2238 /* Projection matrix can be omitted */
2239 D3DXMatrixMultiply(&mat,&view,&projection);
2240 D3DXVec3Project(&gotvec,&u,&viewport,NULL,&mat,&world);
2241 expect_vec3(&expectedvec, &gotvec, 32);
2242 /* View matrix can be omitted */
2243 D3DXMatrixMultiply(&mat,&world,&view);
2244 D3DXVec3Project(&gotvec,&u,&viewport,&projection,NULL,&mat);
2245 expect_vec3(&expectedvec, &gotvec, 32);
2246 /* All matrices can be omitted */
2247 expectedvec.x = 4010.000000f; expectedvec.y = -1695.000000f; expectedvec.z = 1.600000f;
2248 D3DXVec3Project(&gotvec,&u,&viewport,NULL,NULL,NULL);
2249 expect_vec3(&expectedvec, &gotvec, 2);
2250 /* Viewport can be omitted */
2251 expectedvec.x = 1.814305f; expectedvec.y = 0.582097f; expectedvec.z = -0.066555f;
2252 D3DXVec3Project(&gotvec,&u,NULL,&projection,&view,&world);
2253 expect_vec3(&expectedvec, &gotvec, 64);
2255 /*_______________D3DXVec3Unproject_________________________*/
2256 expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
2257 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
2258 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
2259 expect_vec3(&expectedvec, &gotvec, 16);
2260 /* World matrix can be omitted */
2261 D3DXMatrixMultiply(&mat,&world,&view);
2262 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&mat,NULL);
2263 expect_vec3(&expectedvec, &gotvec, 16);
2264 /* Projection matrix can be omitted */
2265 D3DXMatrixMultiply(&mat,&view,&projection);
2266 D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,&mat,&world);
2267 expect_vec3(&expectedvec, &gotvec, 32);
2268 /* View matrix can be omitted */
2269 D3DXMatrixMultiply(&mat,&world,&view);
2270 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,NULL,&mat);
2271 expect_vec3(&expectedvec, &gotvec, 16);
2272 /* All matrices can be omitted */
2273 expectedvec.x = -1.002500f; expectedvec.y = 0.997059f; expectedvec.z = 2.571429f;
2274 D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,NULL,NULL);
2275 expect_vec3(&expectedvec, &gotvec, 4);
2276 /* Viewport can be omitted */
2277 expectedvec.x = -11.018396f; expectedvec.y = 3.218991f; expectedvec.z = 1.380329f;
2278 D3DXVec3Unproject(&gotvec,&u,NULL,&projection,&view,&world);
2279 expect_vec3(&expectedvec, &gotvec, 8);
2282 static void D3DXVector4Test(void)
2284 D3DXVECTOR4 expectedvec, gotvec, u, v, w, x;
2285 LPD3DXVECTOR4 funcpointer;
2286 D3DXVECTOR4 expectedtrans, gottrans;
2287 float coeff1, coeff2, got, scale;
2288 D3DXMATRIX mat;
2289 BOOL equal;
2291 u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
2292 v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
2293 w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
2294 x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
2296 set_matrix(&mat,
2297 1.0f, 2.0f, 3.0f, 4.0f,
2298 5.0f, 6.0f, 7.0f, 8.0f,
2299 9.0f, 10.0f, 11.0f, 12.0f,
2300 13.0f, 14.0f, 15.0f, 16.0f);
2302 coeff1 = 2.0f; coeff2 = 5.0;
2303 scale = -6.5f;
2305 /*_______________D3DXVec4Add__________________________*/
2306 expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
2307 D3DXVec4Add(&gotvec,&u,&v);
2308 expect_vec4(&expectedvec, &gotvec, 0);
2309 /* Tests the case NULL */
2310 funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
2311 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2312 funcpointer = D3DXVec4Add(NULL,NULL,NULL);
2313 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2315 /*_______________D3DXVec4BaryCentric____________________*/
2316 expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
2317 D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
2318 expect_vec4(&expectedvec, &gotvec, 0);
2320 /*_______________D3DXVec4CatmullRom____________________*/
2321 expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
2322 D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
2323 expect_vec4(&expectedvec, &gotvec, 0);
2325 /*_______________D3DXVec4Cross_________________________*/
2326 expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
2327 D3DXVec4Cross(&gotvec,&u,&v,&w);
2328 expect_vec4(&expectedvec, &gotvec, 0);
2330 /*_______________D3DXVec4Dot__________________________*/
2331 got = D3DXVec4Dot(&u, &v);
2332 equal = compare_float(got, 55.0f, 0);
2333 ok(equal, "Got unexpected dot %.8e.\n", got);
2334 /* Tests the case NULL. */
2335 got = D3DXVec4Dot(NULL, &v);
2336 equal = compare_float(got, 0.0f, 0);
2337 ok(equal, "Got unexpected dot %.8e.\n", got);
2338 got = D3DXVec4Dot(NULL, NULL);
2339 equal = compare_float(got, 0.0f, 0);
2340 ok(equal, "Got unexpected dot %.8e.\n", got);
2342 /*_______________D3DXVec4Hermite_________________________*/
2343 expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
2344 D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
2345 expect_vec4(&expectedvec, &gotvec, 0);
2347 /*_______________D3DXVec4Length__________________________*/
2348 got = D3DXVec4Length(&u);
2349 equal = compare_float(got, 11.0f, 0);
2350 ok(equal, "Got unexpected length %.8e.\n", got);
2351 /* Tests the case NULL. */
2352 got = D3DXVec4Length(NULL);
2353 equal = compare_float(got, 0.0f, 0);
2354 ok(equal, "Got unexpected length %.8e.\n", got);
2356 /*_______________D3DXVec4LengthSq________________________*/
2357 got = D3DXVec4LengthSq(&u);
2358 equal = compare_float(got, 121.0f, 0);
2359 ok(equal, "Got unexpected length %.8e.\n", got);
2360 /* Tests the case NULL. */
2361 got = D3DXVec4LengthSq(NULL);
2362 equal = compare_float(got, 0.0f, 0);
2363 ok(equal, "Got unexpected length %.8e.\n", got);
2365 /*_______________D3DXVec4Lerp__________________________*/
2366 expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
2367 D3DXVec4Lerp(&gotvec,&u,&v,scale);
2368 expect_vec4(&expectedvec, &gotvec, 0);
2369 /* Tests the case NULL */
2370 funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
2371 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2372 funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
2373 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2375 /*_______________D3DXVec4Maximize__________________________*/
2376 expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
2377 D3DXVec4Maximize(&gotvec,&u,&v);
2378 expect_vec4(&expectedvec, &gotvec, 0);
2379 /* Tests the case NULL */
2380 funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
2381 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2382 funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
2383 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2385 /*_______________D3DXVec4Minimize__________________________*/
2386 expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
2387 D3DXVec4Minimize(&gotvec,&u,&v);
2388 expect_vec4(&expectedvec, &gotvec, 0);
2389 /* Tests the case NULL */
2390 funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
2391 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2392 funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
2393 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2395 /*_______________D3DXVec4Normalize_________________________*/
2396 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
2397 D3DXVec4Normalize(&gotvec,&u);
2398 expect_vec4(&expectedvec, &gotvec, 1);
2400 /*_______________D3DXVec4Scale____________________________*/
2401 expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
2402 D3DXVec4Scale(&gotvec,&u,scale);
2403 expect_vec4(&expectedvec, &gotvec, 0);
2404 /* Tests the case NULL */
2405 funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
2406 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2407 funcpointer = D3DXVec4Scale(NULL,NULL,scale);
2408 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2410 /*_______________D3DXVec4Subtract__________________________*/
2411 expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
2412 D3DXVec4Subtract(&gotvec,&u,&v);
2413 expect_vec4(&expectedvec, &gotvec, 0);
2414 /* Tests the case NULL */
2415 funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
2416 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2417 funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
2418 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2420 /*_______________D3DXVec4Transform_______________________*/
2421 expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
2422 D3DXVec4Transform(&gottrans,&u,&mat);
2423 expect_vec4(&expectedtrans, &gottrans, 0);
2426 static void test_matrix_stack(void)
2428 ID3DXMatrixStack *stack;
2429 ULONG refcount;
2430 HRESULT hr;
2432 const D3DXMATRIX mat1 = {{{
2433 1.0f, 2.0f, 3.0f, 4.0f,
2434 5.0f, 6.0f, 7.0f, 8.0f,
2435 9.0f, 10.0f, 11.0f, 12.0f,
2436 13.0f, 14.0f, 15.0f, 16.0f
2437 }}};
2439 const D3DXMATRIX mat2 = {{{
2440 17.0f, 18.0f, 19.0f, 20.0f,
2441 21.0f, 22.0f, 23.0f, 24.0f,
2442 25.0f, 26.0f, 27.0f, 28.0f,
2443 29.0f, 30.0f, 31.0f, 32.0f
2444 }}};
2446 hr = D3DXCreateMatrixStack(0, &stack);
2447 ok(SUCCEEDED(hr), "Failed to create a matrix stack, hr %#x\n", hr);
2448 if (FAILED(hr)) return;
2450 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)),
2451 "The top of an empty matrix stack should be an identity matrix\n");
2453 hr = ID3DXMatrixStack_Pop(stack);
2454 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2456 hr = ID3DXMatrixStack_Push(stack);
2457 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2458 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2460 hr = ID3DXMatrixStack_Push(stack);
2461 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2463 hr = ID3DXMatrixStack_LoadMatrix(stack, &mat1);
2464 ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
2465 expect_matrix(&mat1, ID3DXMatrixStack_GetTop(stack), 0);
2467 hr = ID3DXMatrixStack_Push(stack);
2468 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2469 expect_matrix(&mat1, ID3DXMatrixStack_GetTop(stack), 0);
2471 hr = ID3DXMatrixStack_LoadMatrix(stack, &mat2);
2472 ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
2473 expect_matrix(&mat2, ID3DXMatrixStack_GetTop(stack), 0);
2475 hr = ID3DXMatrixStack_Push(stack);
2476 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2477 expect_matrix(&mat2, ID3DXMatrixStack_GetTop(stack), 0);
2479 hr = ID3DXMatrixStack_LoadIdentity(stack);
2480 ok(SUCCEEDED(hr), "LoadIdentity failed, hr %#x\n", hr);
2481 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2483 hr = ID3DXMatrixStack_Pop(stack);
2484 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2485 expect_matrix(&mat2, ID3DXMatrixStack_GetTop(stack), 0);
2487 hr = ID3DXMatrixStack_Pop(stack);
2488 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2489 expect_matrix(&mat1, ID3DXMatrixStack_GetTop(stack), 0);
2491 hr = ID3DXMatrixStack_Pop(stack);
2492 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2493 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2495 hr = ID3DXMatrixStack_Pop(stack);
2496 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2497 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2499 refcount = ID3DXMatrixStack_Release(stack);
2500 ok(!refcount, "Matrix stack has %u references left.\n", refcount);
2503 static void test_Matrix_AffineTransformation2D(void)
2505 D3DXMATRIX exp_mat, got_mat;
2506 D3DXVECTOR2 center, position;
2507 FLOAT angle, scale;
2509 center.x = 3.0f;
2510 center.y = 4.0f;
2512 position.x = -6.0f;
2513 position.y = 7.0f;
2515 angle = D3DX_PI/3.0f;
2517 scale = 20.0f;
2519 U(exp_mat).m[0][0] = 10.0f;
2520 U(exp_mat).m[1][0] = -17.320507f;
2521 U(exp_mat).m[2][0] = 0.0f;
2522 U(exp_mat).m[3][0] = -1.035898f;
2523 U(exp_mat).m[0][1] = 17.320507f;
2524 U(exp_mat).m[1][1] = 10.0f;
2525 U(exp_mat).m[2][1] = 0.0f;
2526 U(exp_mat).m[3][1] = 6.401924f;
2527 U(exp_mat).m[0][2] = 0.0f;
2528 U(exp_mat).m[1][2] = 0.0f;
2529 U(exp_mat).m[2][2] = 1.0f;
2530 U(exp_mat).m[3][2] = 0.0f;
2531 U(exp_mat).m[0][3] = 0.0f;
2532 U(exp_mat).m[1][3] = 0.0f;
2533 U(exp_mat).m[2][3] = 0.0f;
2534 U(exp_mat).m[3][3] = 1.0f;
2536 D3DXMatrixAffineTransformation2D(&got_mat, scale, &center, angle, &position);
2537 expect_matrix(&exp_mat, &got_mat, 2);
2539 /*______________*/
2541 center.x = 3.0f;
2542 center.y = 4.0f;
2544 angle = D3DX_PI/3.0f;
2546 scale = 20.0f;
2548 U(exp_mat).m[0][0] = 10.0f;
2549 U(exp_mat).m[1][0] = -17.320507f;
2550 U(exp_mat).m[2][0] = 0.0f;
2551 U(exp_mat).m[3][0] = 4.964102f;
2552 U(exp_mat).m[0][1] = 17.320507f;
2553 U(exp_mat).m[1][1] = 10.0f;
2554 U(exp_mat).m[2][1] = 0.0f;
2555 U(exp_mat).m[3][1] = -0.598076f;
2556 U(exp_mat).m[0][2] = 0.0f;
2557 U(exp_mat).m[1][2] = 0.0f;
2558 U(exp_mat).m[2][2] = 1.0f;
2559 U(exp_mat).m[3][2] = 0.0f;
2560 U(exp_mat).m[0][3] = 0.0f;
2561 U(exp_mat).m[1][3] = 0.0f;
2562 U(exp_mat).m[2][3] = 0.0f;
2563 U(exp_mat).m[3][3] = 1.0f;
2565 D3DXMatrixAffineTransformation2D(&got_mat, scale, &center, angle, NULL);
2566 expect_matrix(&exp_mat, &got_mat, 8);
2568 /*______________*/
2570 position.x = -6.0f;
2571 position.y = 7.0f;
2573 angle = D3DX_PI/3.0f;
2575 scale = 20.0f;
2577 U(exp_mat).m[0][0] = 10.0f;
2578 U(exp_mat).m[1][0] = -17.320507f;
2579 U(exp_mat).m[2][0] = 0.0f;
2580 U(exp_mat).m[3][0] = -6.0f;
2581 U(exp_mat).m[0][1] = 17.320507f;
2582 U(exp_mat).m[1][1] = 10.0f;
2583 U(exp_mat).m[2][1] = 0.0f;
2584 U(exp_mat).m[3][1] = 7.0f;
2585 U(exp_mat).m[0][2] = 0.0f;
2586 U(exp_mat).m[1][2] = 0.0f;
2587 U(exp_mat).m[2][2] = 1.0f;
2588 U(exp_mat).m[3][2] = 0.0f;
2589 U(exp_mat).m[0][3] = 0.0f;
2590 U(exp_mat).m[1][3] = 0.0f;
2591 U(exp_mat).m[2][3] = 0.0f;
2592 U(exp_mat).m[3][3] = 1.0f;
2594 D3DXMatrixAffineTransformation2D(&got_mat, scale, NULL, angle, &position);
2595 expect_matrix(&exp_mat, &got_mat, 1);
2597 /*______________*/
2599 angle = 5.0f * D3DX_PI/4.0f;
2601 scale = -20.0f;
2603 U(exp_mat).m[0][0] = 14.142133f;
2604 U(exp_mat).m[1][0] = -14.142133f;
2605 U(exp_mat).m[2][0] = 0.0f;
2606 U(exp_mat).m[3][0] = 0.0f;
2607 U(exp_mat).m[0][1] = 14.142133;
2608 U(exp_mat).m[1][1] = 14.142133f;
2609 U(exp_mat).m[2][1] = 0.0f;
2610 U(exp_mat).m[3][1] = 0.0f;
2611 U(exp_mat).m[0][2] = 0.0f;
2612 U(exp_mat).m[1][2] = 0.0f;
2613 U(exp_mat).m[2][2] = 1.0f;
2614 U(exp_mat).m[3][2] = 0.0f;
2615 U(exp_mat).m[0][3] = 0.0f;
2616 U(exp_mat).m[1][3] = 0.0f;
2617 U(exp_mat).m[2][3] = 0.0f;
2618 U(exp_mat).m[3][3] = 1.0f;
2620 D3DXMatrixAffineTransformation2D(&got_mat, scale, NULL, angle, NULL);
2621 expect_matrix(&exp_mat, &got_mat, 8);
2624 static void test_Matrix_Decompose(void)
2626 D3DXMATRIX pm;
2627 D3DXQUATERNION exp_rotation, got_rotation;
2628 D3DXVECTOR3 exp_scale, got_scale, exp_translation, got_translation;
2629 HRESULT hr;
2630 BOOL equal;
2632 /*___________*/
2634 U(pm).m[0][0] = -9.23879206e-01f;
2635 U(pm).m[1][0] = -2.70598412e-01f;
2636 U(pm).m[2][0] = 2.70598441e-01f;
2637 U(pm).m[3][0] = -5.00000000e+00f;
2638 U(pm).m[0][1] = 2.70598471e-01f;
2639 U(pm).m[1][1] = 3.80604863e-02f;
2640 U(pm).m[2][1] = 9.61939573e-01f;
2641 U(pm).m[3][1] = 0.00000000e+00f;
2642 U(pm).m[0][2] = -2.70598441e-01f;
2643 U(pm).m[1][2] = 9.61939573e-01f;
2644 U(pm).m[2][2] = 3.80603075e-02f;
2645 U(pm).m[3][2] = 1.00000000e+01f;
2646 U(pm).m[0][3] = 0.00000000e+00f;
2647 U(pm).m[1][3] = 0.00000000e+00f;
2648 U(pm).m[2][3] = 0.00000000e+00f;
2649 U(pm).m[3][3] = 1.00000000e+00f;
2651 exp_scale.x = 9.99999881e-01f;
2652 exp_scale.y = 9.99999881e-01f;
2653 exp_scale.z = 9.99999881e-01f;
2655 exp_rotation.x = 2.14862776e-08f;
2656 exp_rotation.y = 6.93519890e-01f;
2657 exp_rotation.z = 6.93519890e-01f;
2658 exp_rotation.w = 1.95090637e-01f;
2660 exp_translation.x = -5.0f;
2661 exp_translation.y = 0.0f;
2662 exp_translation.z = 10.0f;
2664 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2665 expect_vec3(&exp_scale, &got_scale, 1);
2666 expect_quaternion(&exp_rotation, &got_rotation, 1);
2667 expect_vec3(&exp_translation, &got_translation, 0);
2669 /*_________*/
2671 U(pm).m[0][0] = -2.255813f;
2672 U(pm).m[1][0] = 1.302324f;
2673 U(pm).m[2][0] = 1.488373f;
2674 U(pm).m[3][0] = 1.0f;
2675 U(pm).m[0][1] = 1.302327f;
2676 U(pm).m[1][1] = -0.7209296f;
2677 U(pm).m[2][1] = 2.60465f;
2678 U(pm).m[3][1] = 2.0f;
2679 U(pm).m[0][2] = 1.488371f;
2680 U(pm).m[1][2] = 2.604651f;
2681 U(pm).m[2][2] = -0.02325551f;
2682 U(pm).m[3][2] = 3.0f;
2683 U(pm).m[0][3] = 0.0f;
2684 U(pm).m[1][3] = 0.0f;
2685 U(pm).m[2][3] = 0.0f;
2686 U(pm).m[3][3] = 1.0f;
2688 exp_scale.x = 2.99999928e+00f;
2689 exp_scale.y = 2.99999905e+00f;
2690 exp_scale.z = 2.99999952e+00f;
2692 exp_rotation.x = 3.52180451e-01f;
2693 exp_rotation.y = 6.16315663e-01f;
2694 exp_rotation.z = 7.04360664e-01f;
2695 exp_rotation.w = 3.38489343e-07f;
2697 exp_translation.x = 1.0f;
2698 exp_translation.y = 2.0f;
2699 exp_translation.z = 3.0f;
2701 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2702 expect_vec3(&exp_scale, &got_scale, 0);
2703 expect_quaternion(&exp_rotation, &got_rotation, 2);
2704 expect_vec3(&exp_translation, &got_translation, 0);
2706 /*_____________*/
2708 U(pm).m[0][0] = 2.427051f;
2709 U(pm).m[1][0] = 0.0f;
2710 U(pm).m[2][0] = 1.763355f;
2711 U(pm).m[3][0] = 5.0f;
2712 U(pm).m[0][1] = 0.0f;
2713 U(pm).m[1][1] = 3.0f;
2714 U(pm).m[2][1] = 0.0f;
2715 U(pm).m[3][1] = 5.0f;
2716 U(pm).m[0][2] = -1.763355f;
2717 U(pm).m[1][2] = 0.0f;
2718 U(pm).m[2][2] = 2.427051f;
2719 U(pm).m[3][2] = 5.0f;
2720 U(pm).m[0][3] = 0.0f;
2721 U(pm).m[1][3] = 0.0f;
2722 U(pm).m[2][3] = 0.0f;
2723 U(pm).m[3][3] = 1.0f;
2725 exp_scale.x = 2.99999976e+00f;
2726 exp_scale.y = 3.00000000e+00f;
2727 exp_scale.z = 2.99999976e+00f;
2729 exp_rotation.x = 0.00000000e+00f;
2730 exp_rotation.y = 3.09016883e-01f;
2731 exp_rotation.z = 0.00000000e+00f;
2732 exp_rotation.w = 9.51056540e-01f;
2734 exp_translation.x = 5.0f;
2735 exp_translation.y = 5.0f;
2736 exp_translation.z = 5.0f;
2738 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2739 expect_vec3(&exp_scale, &got_scale, 1);
2740 expect_quaternion(&exp_rotation, &got_rotation, 1);
2741 expect_vec3(&exp_translation, &got_translation, 0);
2743 /*_____________*/
2745 U(pm).m[0][0] = -9.23879206e-01f;
2746 U(pm).m[1][0] = -2.70598412e-01f;
2747 U(pm).m[2][0] = 2.70598441e-01f;
2748 U(pm).m[3][0] = -5.00000000e+00f;
2749 U(pm).m[0][1] = 2.70598471e-01f;
2750 U(pm).m[1][1] = 3.80604863e-02f;
2751 U(pm).m[2][1] = 9.61939573e-01f;
2752 U(pm).m[3][1] = 0.00000000e+00f;
2753 U(pm).m[0][2] = -2.70598441e-01f;
2754 U(pm).m[1][2] = 9.61939573e-01f;
2755 U(pm).m[2][2] = 3.80603075e-02f;
2756 U(pm).m[3][2] = 1.00000000e+01f;
2757 U(pm).m[0][3] = 0.00000000e+00f;
2758 U(pm).m[1][3] = 0.00000000e+00f;
2759 U(pm).m[2][3] = 0.00000000e+00f;
2760 U(pm).m[3][3] = 1.00000000e+00f;
2762 exp_scale.x = 9.99999881e-01f;
2763 exp_scale.y = 9.99999881e-01f;
2764 exp_scale.z = 9.99999881e-01f;
2766 exp_rotation.x = 2.14862776e-08f;
2767 exp_rotation.y = 6.93519890e-01f;
2768 exp_rotation.z = 6.93519890e-01f;
2769 exp_rotation.w = 1.95090637e-01f;
2771 exp_translation.x = -5.0f;
2772 exp_translation.y = 0.0f;
2773 exp_translation.z = 10.0f;
2775 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2776 expect_vec3(&exp_scale, &got_scale, 1);
2777 expect_quaternion(&exp_rotation, &got_rotation, 1);
2778 expect_vec3(&exp_translation, &got_translation, 0);
2780 /*__________*/
2782 U(pm).m[0][0] = -9.23878908e-01f;
2783 U(pm).m[1][0] = -5.41196704e-01f;
2784 U(pm).m[2][0] = 8.11795175e-01f;
2785 U(pm).m[3][0] = -5.00000000e+00f;
2786 U(pm).m[0][1] = 2.70598322e-01f;
2787 U(pm).m[1][1] = 7.61209577e-02f;
2788 U(pm).m[2][1] = 2.88581824e+00f;
2789 U(pm).m[3][1] = 0.00000000e+00f;
2790 U(pm).m[0][2] = -2.70598352e-01f;
2791 U(pm).m[1][2] = 1.92387879e+00f;
2792 U(pm).m[2][2] = 1.14180908e-01f;
2793 U(pm).m[3][2] = 1.00000000e+01f;
2794 U(pm).m[0][3] = 0.00000000e+00f;
2795 U(pm).m[1][3] = 0.00000000e+00f;
2796 U(pm).m[2][3] = 0.00000000e+00f;
2797 U(pm).m[3][3] = 1.00000000e+00f;
2799 exp_scale.x = 9.99999583e-01f;
2800 exp_scale.y = 1.99999940e+00f;
2801 exp_scale.z = 2.99999928e+00f;
2803 exp_rotation.x = 1.07431388e-08f;
2804 exp_rotation.y = 6.93519890e-01f;
2805 exp_rotation.z = 6.93519831e-01f;
2806 exp_rotation.w = 1.95090622e-01f;
2808 exp_translation.x = -5.0f;
2809 exp_translation.y = 0.0f;
2810 exp_translation.z = 10.0f;
2812 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2813 expect_vec3(&exp_scale, &got_scale, 1);
2814 equal = compare_quaternion(&exp_rotation, &got_rotation, 1);
2815 exp_rotation.x = 0.0f;
2816 equal |= compare_quaternion(&exp_rotation, &got_rotation, 2);
2817 ok(equal, "Got unexpected quaternion {%.8e, %.8e, %.8e, %.8e}.\n",
2818 got_rotation.x, got_rotation.y, got_rotation.z, got_rotation.w);
2819 expect_vec3(&exp_translation, &got_translation, 0);
2821 /*__________*/
2823 U(pm).m[0][0] = 0.7156004f;
2824 U(pm).m[1][0] = -0.5098283f;
2825 U(pm).m[2][0] = -0.4774843f;
2826 U(pm).m[3][0] = -5.0f;
2827 U(pm).m[0][1] = -0.6612288f;
2828 U(pm).m[1][1] = -0.7147621f;
2829 U(pm).m[2][1] = -0.2277977f;
2830 U(pm).m[3][1] = 0.0f;
2831 U(pm).m[0][2] = -0.2251499f;
2832 U(pm).m[1][2] = 0.4787385f;
2833 U(pm).m[2][2] = -0.8485972f;
2834 U(pm).m[3][2] = 10.0f;
2835 U(pm).m[0][3] = 0.0f;
2836 U(pm).m[1][3] = 0.0f;
2837 U(pm).m[2][3] = 0.0f;
2838 U(pm).m[3][3] = 1.0f;
2840 exp_scale.x = 9.99999940e-01f;
2841 exp_scale.y = 1.00000012e+00f;
2842 exp_scale.z = 1.00000012e+00f;
2844 exp_rotation.x = 9.05394852e-01f;
2845 exp_rotation.y = -3.23355347e-01f;
2846 exp_rotation.z = -1.94013178e-01f;
2847 exp_rotation.w = 1.95090592e-01f;
2849 exp_translation.x = -5.0f;
2850 exp_translation.y = 0.0f;
2851 exp_translation.z = 10.0f;
2853 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2854 expect_vec3(&exp_scale, &got_scale, 0);
2855 expect_quaternion(&exp_rotation, &got_rotation, 1);
2856 expect_vec3(&exp_translation, &got_translation, 0);
2858 /*_____________*/
2860 U(pm).m[0][0] = 0.06554436f;
2861 U(pm).m[1][0] = -0.6873012f;
2862 U(pm).m[2][0] = 0.7234092f;
2863 U(pm).m[3][0] = -5.0f;
2864 U(pm).m[0][1] = -0.9617381f;
2865 U(pm).m[1][1] = -0.2367795f;
2866 U(pm).m[2][1] = -0.1378230f;
2867 U(pm).m[3][1] = 0.0f;
2868 U(pm).m[0][2] = 0.2660144f;
2869 U(pm).m[1][2] = -0.6866967f;
2870 U(pm).m[2][2] = -0.6765233f;
2871 U(pm).m[3][2] = 10.0f;
2872 U(pm).m[0][3] = 0.0f;
2873 U(pm).m[1][3] = 0.0f;
2874 U(pm).m[2][3] = 0.0f;
2875 U(pm).m[3][3] = 1.0f;
2877 exp_scale.x = 9.99999940e-01f;
2878 exp_scale.y = 9.99999940e-01f;
2879 exp_scale.z = 9.99999881e-01f;
2881 exp_rotation.x = 7.03357518e-01f;
2882 exp_rotation.y = -5.86131275e-01f;
2883 exp_rotation.z = 3.51678789e-01f;
2884 exp_rotation.w = -1.95090577e-01f;
2886 exp_translation.x = -5.0f;
2887 exp_translation.y = 0.0f;
2888 exp_translation.z = 10.0f;
2890 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2891 expect_vec3(&exp_scale, &got_scale, 1);
2892 expect_quaternion(&exp_rotation, &got_rotation, 2);
2893 expect_vec3(&exp_translation, &got_translation, 0);
2895 /*_________*/
2897 U(pm).m[0][0] = 7.12104797e+00f;
2898 U(pm).m[1][0] = -5.88348627e+00f;
2899 U(pm).m[2][0] = 1.18184204e+01f;
2900 U(pm).m[3][0] = -5.00000000e+00f;
2901 U(pm).m[0][1] = 5.88348627e+00f;
2902 U(pm).m[1][1] = -1.06065865e+01f;
2903 U(pm).m[2][1] = -8.82523251e+00f;
2904 U(pm).m[3][1] = 0.00000000e+00f;
2905 U(pm).m[0][2] = 1.18184204e+01f;
2906 U(pm).m[1][2] = 8.82523155e+00f;
2907 U(pm).m[2][2] = -2.72764111e+00f;
2908 U(pm).m[3][2] = 2.00000000e+00f;
2909 U(pm).m[0][3] = 0.00000000e+00f;
2910 U(pm).m[1][3] = 0.00000000e+00f;
2911 U(pm).m[2][3] = 0.00000000e+00f;
2912 U(pm).m[3][3] = 1.00000000e+00f;
2914 exp_scale.x = 1.49999933e+01f;
2915 exp_scale.y = 1.49999933e+01f;
2916 exp_scale.z = 1.49999943e+01f;
2918 exp_rotation.x = 7.68714130e-01f;
2919 exp_rotation.y = 0.00000000e+00f;
2920 exp_rotation.z = 5.12475967e-01f;
2921 exp_rotation.w = 3.82683903e-01f;
2923 exp_translation.x = -5.0f;
2924 exp_translation.y = 0.0f;
2925 exp_translation.z = 2.0f;
2927 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2928 expect_vec3(&exp_scale, &got_scale, 0);
2929 expect_quaternion(&exp_rotation, &got_rotation, 1);
2930 expect_vec3(&exp_translation, &got_translation, 0);
2932 /*__________*/
2934 U(pm).m[0][0] = 0.0f;
2935 U(pm).m[1][0] = 4.0f;
2936 U(pm).m[2][0] = 5.0f;
2937 U(pm).m[3][0] = -5.0f;
2938 U(pm).m[0][1] = 0.0f;
2939 U(pm).m[1][1] = -10.60660f;
2940 U(pm).m[2][1] = -8.825232f;
2941 U(pm).m[3][1] = 6.0f;
2942 U(pm).m[0][2] = 0.0f;
2943 U(pm).m[1][2] = 8.8252320f;
2944 U(pm).m[2][2] = 2.727645;
2945 U(pm).m[3][2] = 3.0f;
2946 U(pm).m[0][3] = 0.0f;
2947 U(pm).m[1][3] = 0.0f;
2948 U(pm).m[2][3] = 0.0f;
2949 U(pm).m[3][3] = 1.0f;
2951 hr = D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2952 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);
2955 static void test_Matrix_Transformation2D(void)
2957 D3DXMATRIX exp_mat, got_mat;
2958 D3DXVECTOR2 rot_center, sca, sca_center, trans;
2959 FLOAT rot, sca_rot;
2961 rot_center.x = 3.0f;
2962 rot_center.y = 4.0f;
2964 sca.x = 12.0f;
2965 sca.y = -3.0f;
2967 sca_center.x = 9.0f;
2968 sca_center.y = -5.0f;
2970 trans.x = -6.0f;
2971 trans.y = 7.0f;
2973 rot = D3DX_PI/3.0f;
2975 sca_rot = 5.0f*D3DX_PI/4.0f;
2977 U(exp_mat).m[0][0] = -4.245192f;
2978 U(exp_mat).m[1][0] = -0.147116f;
2979 U(exp_mat).m[2][0] = 0.0f;
2980 U(exp_mat).m[3][0] = 45.265373f;
2981 U(exp_mat).m[0][1] = 7.647113f;
2982 U(exp_mat).m[1][1] = 8.745192f;
2983 U(exp_mat).m[2][1] = 0.0f;
2984 U(exp_mat).m[3][1] = -13.401899f;
2985 U(exp_mat).m[0][2] = 0.0f;
2986 U(exp_mat).m[1][2] = 0.0f;
2987 U(exp_mat).m[2][2] = 1.0f;
2988 U(exp_mat).m[3][2] = 0.0f;
2989 U(exp_mat).m[0][3] = 0.0f;
2990 U(exp_mat).m[1][3] = 0.0f;
2991 U(exp_mat).m[2][3] = 0.0f;
2992 U(exp_mat).m[3][3] = 1.0f;
2994 D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, &sca, &rot_center, rot, &trans);
2995 expect_matrix(&exp_mat, &got_mat, 64);
2997 /*_________*/
2999 sca_center.x = 9.0f;
3000 sca_center.y = -5.0f;
3002 trans.x = -6.0f;
3003 trans.y = 7.0f;
3005 rot = D3DX_PI/3.0f;
3007 sca_rot = 5.0f*D3DX_PI/4.0f;
3009 U(exp_mat).m[0][0] = 0.50f;
3010 U(exp_mat).m[1][0] = -0.866025f;
3011 U(exp_mat).m[2][0] = 0.0f;
3012 U(exp_mat).m[3][0] = -6.0f;
3013 U(exp_mat).m[0][1] = 0.866025f;
3014 U(exp_mat).m[1][1] = 0.50f;
3015 U(exp_mat).m[2][1] = 0.0f;
3016 U(exp_mat).m[3][1] = 7.0f;
3017 U(exp_mat).m[0][2] = 0.0f;
3018 U(exp_mat).m[1][2] = 0.0f;
3019 U(exp_mat).m[2][2] = 1.0f;
3020 U(exp_mat).m[3][2] = 0.0f;
3021 U(exp_mat).m[0][3] = 0.0f;
3022 U(exp_mat).m[1][3] = 0.0f;
3023 U(exp_mat).m[2][3] = 0.0f;
3024 U(exp_mat).m[3][3] = 1.0f;
3026 D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, NULL, NULL, rot, &trans);
3027 expect_matrix(&exp_mat, &got_mat, 8);
3029 /*_________*/
3031 U(exp_mat).m[0][0] = 0.50f;
3032 U(exp_mat).m[1][0] = -0.866025f;
3033 U(exp_mat).m[2][0] = 0.0f;
3034 U(exp_mat).m[3][0] = 0.0f;
3035 U(exp_mat).m[0][1] = 0.866025f;
3036 U(exp_mat).m[1][1] = 0.50f;
3037 U(exp_mat).m[2][1] = 0.0f;
3038 U(exp_mat).m[3][1] = 0.0f;
3039 U(exp_mat).m[0][2] = 0.0f;
3040 U(exp_mat).m[1][2] = 0.0f;
3041 U(exp_mat).m[2][2] = 1.0f;
3042 U(exp_mat).m[3][2] = 0.0f;
3043 U(exp_mat).m[0][3] = 0.0f;
3044 U(exp_mat).m[1][3] = 0.0f;
3045 U(exp_mat).m[2][3] = 0.0f;
3046 U(exp_mat).m[3][3] = 1.0f;
3048 D3DXMatrixTransformation2D(&got_mat, NULL, sca_rot, NULL, NULL, rot, NULL);
3049 expect_matrix(&exp_mat, &got_mat, 8);
3052 static void test_D3DXVec_Array(void)
3054 D3DXPLANE inp_plane[5], out_plane[7], exp_plane[7];
3055 D3DXVECTOR4 inp_vec[5], out_vec[7], exp_vec[7];
3056 D3DXMATRIX mat, projection, view, world;
3057 D3DVIEWPORT9 viewport;
3058 unsigned int i;
3060 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
3061 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
3063 memset(out_vec, 0, sizeof(out_vec));
3064 memset(exp_vec, 0, sizeof(exp_vec));
3065 memset(out_plane, 0, sizeof(out_plane));
3066 memset(exp_plane, 0, sizeof(exp_plane));
3068 for (i = 0; i < ARRAY_SIZE(inp_vec); ++i)
3070 inp_plane[i].a = inp_plane[i].c = inp_vec[i].x = inp_vec[i].z = i;
3071 inp_plane[i].b = inp_plane[i].d = inp_vec[i].y = inp_vec[i].w = ARRAY_SIZE(inp_vec) - i;
3074 set_matrix(&mat,
3075 1.0f, 2.0f, 3.0f, 4.0f,
3076 5.0f, 6.0f, 7.0f, 8.0f,
3077 9.0f, 10.0f, 11.0f, 12.0f,
3078 13.0f, 14.0f, 15.0f, 16.0f);
3080 D3DXMatrixPerspectiveFovLH(&projection, D3DX_PI / 4.0f, 20.0f / 17.0f, 1.0f, 1000.0f);
3082 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
3083 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
3084 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
3085 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
3086 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
3087 U(view).m[3][3] = -40.0f;
3089 set_matrix(&world,
3090 21.0f, 2.0f, 3.0f, 4.0f,
3091 5.0f, 23.0f, 7.0f, 8.0f,
3092 -8.0f, -7.0f, 25.0f, -5.0f,
3093 -4.0f, -3.0f, -2.0f, 27.0f);
3095 /* D3DXVec2TransformCoordArray */
3096 exp_vec[1].x = 6.78571403e-01f; exp_vec[1].y = 7.85714269e-01f;
3097 exp_vec[2].x = 6.53846204e-01f; exp_vec[2].y = 7.69230783e-01f;
3098 exp_vec[3].x = 6.25000000e-01f; exp_vec[3].y = 7.50000000e-01f;
3099 exp_vec[4].x = 5.90909123e-01f; exp_vec[4].y = 7.27272749e-01f;
3100 exp_vec[5].x = 5.49999952e-01f; exp_vec[5].y = 6.99999928e-01f;
3101 D3DXVec2TransformCoordArray((D3DXVECTOR2 *)&out_vec[1], sizeof(*out_vec),
3102 (D3DXVECTOR2 *)inp_vec, sizeof(*inp_vec), &mat, ARRAY_SIZE(inp_vec));
3103 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 1);
3105 /* D3DXVec2TransformNormalArray */
3106 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f;
3107 exp_vec[2].x = 21.0f; exp_vec[2].y = 26.0f;
3108 exp_vec[3].x = 17.0f; exp_vec[3].y = 22.0f;
3109 exp_vec[4].x = 13.0f; exp_vec[4].y = 18.0f;
3110 exp_vec[5].x = 9.0f; exp_vec[5].y = 14.0f;
3111 D3DXVec2TransformNormalArray((D3DXVECTOR2 *)&out_vec[1], sizeof(*out_vec),
3112 (D3DXVECTOR2 *)inp_vec, sizeof(*inp_vec), &mat, ARRAY_SIZE(inp_vec));
3113 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 0);
3115 /* D3DXVec3TransformCoordArray */
3116 exp_vec[1].x = 6.78571403e-01f; exp_vec[1].y = 7.85714269e-01f; exp_vec[1].z = 8.92857075e-01f;
3117 exp_vec[2].x = 6.71874940e-01f; exp_vec[2].y = 7.81249940e-01f; exp_vec[2].z = 8.90624940e-01f;
3118 exp_vec[3].x = 6.66666627e-01f; exp_vec[3].y = 7.77777731e-01f; exp_vec[3].z = 8.88888836e-01f;
3119 exp_vec[4].x = 6.62499964e-01f; exp_vec[4].y = 7.74999976e-01f; exp_vec[4].z = 8.87499928e-01f;
3120 exp_vec[5].x = 6.59090877e-01f; exp_vec[5].y = 7.72727251e-01f; exp_vec[5].z = 8.86363566e-01f;
3121 D3DXVec3TransformCoordArray((D3DXVECTOR3 *)&out_vec[1], sizeof(*out_vec),
3122 (D3DXVECTOR3 *)inp_vec, sizeof(*inp_vec), &mat, ARRAY_SIZE(inp_vec));
3123 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 1);
3125 /* D3DXVec3TransformNormalArray */
3126 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f; exp_vec[1].z = 35.0f;
3127 exp_vec[2].x = 30.0f; exp_vec[2].y = 36.0f; exp_vec[2].z = 42.0f;
3128 exp_vec[3].x = 35.0f; exp_vec[3].y = 42.0f; exp_vec[3].z = 49.0f;
3129 exp_vec[4].x = 40.0f; exp_vec[4].y = 48.0f; exp_vec[4].z = 56.0f;
3130 exp_vec[5].x = 45.0f; exp_vec[5].y = 54.0f; exp_vec[5].z = 63.0f;
3131 D3DXVec3TransformNormalArray((D3DXVECTOR3 *)&out_vec[1], sizeof(*out_vec),
3132 (D3DXVECTOR3 *)inp_vec, sizeof(*inp_vec), &mat, ARRAY_SIZE(inp_vec));
3133 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 0);
3135 /* D3DXVec3ProjectArray */
3136 exp_vec[1].x = 1.08955420e+03f; exp_vec[1].y = -2.26590622e+02f; exp_vec[1].z = 2.15272754e-01f;
3137 exp_vec[2].x = 1.06890344e+03f; exp_vec[2].y = 1.03085144e+02f; exp_vec[2].z = 1.83049560e-01f;
3138 exp_vec[3].x = 1.05177905e+03f; exp_vec[3].y = 3.76462280e+02f; exp_vec[3].z = 1.56329080e-01f;
3139 exp_vec[4].x = 1.03734888e+03f; exp_vec[4].y = 6.06827393e+02f; exp_vec[4].z = 1.33812696e-01f;
3140 exp_vec[5].x = 1.02502356e+03f; exp_vec[5].y = 8.03591248e+02f; exp_vec[5].z = 1.14580572e-01f;
3141 D3DXVec3ProjectArray((D3DXVECTOR3 *)&out_vec[1], sizeof(*out_vec), (D3DXVECTOR3 *)inp_vec,
3142 sizeof(*inp_vec), &viewport, &projection, &view, &world, ARRAY_SIZE(inp_vec));
3143 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 8);
3145 /* D3DXVec3UnprojectArray */
3146 exp_vec[1].x = -6.12403107e+00f; exp_vec[1].y = 3.22536016e+00f; exp_vec[1].z = 6.20571136e-01f;
3147 exp_vec[2].x = -3.80710936e+00f; exp_vec[2].y = 2.04657936e+00f; exp_vec[2].z = 4.46894377e-01f;
3148 exp_vec[3].x = -2.92283988e+00f; exp_vec[3].y = 1.59668946e+00f; exp_vec[3].z = 3.80609393e-01f;
3149 exp_vec[4].x = -2.45622563e+00f; exp_vec[4].y = 1.35928988e+00f; exp_vec[4].z = 3.45631927e-01f;
3150 exp_vec[5].x = -2.16789746e+00f; exp_vec[5].y = 1.21259713e+00f; exp_vec[5].z = 3.24018806e-01f;
3151 D3DXVec3UnprojectArray((D3DXVECTOR3 *)&out_vec[1], sizeof(*out_vec), (D3DXVECTOR3 *)inp_vec,
3152 sizeof(*inp_vec), &viewport, &projection, &view, &world, ARRAY_SIZE(inp_vec));
3153 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 4);
3155 /* D3DXVec2TransformArray */
3156 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
3157 exp_vec[2].x = 34.0f; exp_vec[2].y = 40.0f; exp_vec[2].z = 46.0f; exp_vec[2].w = 52.0f;
3158 exp_vec[3].x = 30.0f; exp_vec[3].y = 36.0f; exp_vec[3].z = 42.0f; exp_vec[3].w = 48.0f;
3159 exp_vec[4].x = 26.0f; exp_vec[4].y = 32.0f; exp_vec[4].z = 38.0f; exp_vec[4].w = 44.0f;
3160 exp_vec[5].x = 22.0f; exp_vec[5].y = 28.0f; exp_vec[5].z = 34.0f; exp_vec[5].w = 40.0f;
3161 D3DXVec2TransformArray(&out_vec[1], sizeof(*out_vec), (D3DXVECTOR2 *)inp_vec,
3162 sizeof(*inp_vec), &mat, ARRAY_SIZE(inp_vec));
3163 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 0);
3165 /* D3DXVec3TransformArray */
3166 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
3167 exp_vec[2].x = 43.0f; exp_vec[2].y = 50.0f; exp_vec[2].z = 57.0f; exp_vec[2].w = 64.0f;
3168 exp_vec[3].x = 48.0f; exp_vec[3].y = 56.0f; exp_vec[3].z = 64.0f; exp_vec[3].w = 72.0f;
3169 exp_vec[4].x = 53.0f; exp_vec[4].y = 62.0f; exp_vec[4].z = 71.0f; exp_vec[4].w = 80.0f;
3170 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
3171 D3DXVec3TransformArray(&out_vec[1], sizeof(*out_vec), (D3DXVECTOR3 *)inp_vec,
3172 sizeof(*inp_vec), &mat, ARRAY_SIZE(inp_vec));
3173 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 0);
3175 /* D3DXVec4TransformArray */
3176 exp_vec[1].x = 90.0f; exp_vec[1].y = 100.0f; exp_vec[1].z = 110.0f; exp_vec[1].w = 120.0f;
3177 exp_vec[2].x = 82.0f; exp_vec[2].y = 92.0f; exp_vec[2].z = 102.0f; exp_vec[2].w = 112.0f;
3178 exp_vec[3].x = 74.0f; exp_vec[3].y = 84.0f; exp_vec[3].z = 94.0f; exp_vec[3].w = 104.0f;
3179 exp_vec[4].x = 66.0f; exp_vec[4].y = 76.0f; exp_vec[4].z = 86.0f; exp_vec[4].w = 96.0f;
3180 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
3181 D3DXVec4TransformArray(&out_vec[1], sizeof(*out_vec), inp_vec, sizeof(*inp_vec), &mat, ARRAY_SIZE(inp_vec));
3182 expect_vec4_array(ARRAY_SIZE(exp_vec), exp_vec, out_vec, 0);
3184 /* D3DXPlaneTransformArray */
3185 exp_plane[1].a = 90.0f; exp_plane[1].b = 100.0f; exp_plane[1].c = 110.0f; exp_plane[1].d = 120.0f;
3186 exp_plane[2].a = 82.0f; exp_plane[2].b = 92.0f; exp_plane[2].c = 102.0f; exp_plane[2].d = 112.0f;
3187 exp_plane[3].a = 74.0f; exp_plane[3].b = 84.0f; exp_plane[3].c = 94.0f; exp_plane[3].d = 104.0f;
3188 exp_plane[4].a = 66.0f; exp_plane[4].b = 76.0f; exp_plane[4].c = 86.0f; exp_plane[4].d = 96.0f;
3189 exp_plane[5].a = 58.0f; exp_plane[5].b = 68.0f; exp_plane[5].c = 78.0f; exp_plane[5].d = 88.0f;
3190 D3DXPlaneTransformArray(&out_plane[1], sizeof(*out_plane), inp_plane,
3191 sizeof(*inp_plane), &mat, ARRAY_SIZE(inp_plane));
3192 for (i = 0; i < ARRAY_SIZE(exp_plane); ++i)
3194 BOOL equal = compare_plane(&exp_plane[i], &out_plane[i], 0);
3195 ok(equal, "Got unexpected plane {%.8e, %.8e, %.8e, %.8e} at index %u, expected {%.8e, %.8e, %.8e, %.8e}.\n",
3196 out_plane[i].a, out_plane[i].b, out_plane[i].c, out_plane[i].d, i,
3197 exp_plane[i].a, exp_plane[i].b, exp_plane[i].c, exp_plane[i].d);
3198 if (!equal)
3199 break;
3203 static void test_D3DXFloat_Array(void)
3205 unsigned int i;
3206 void *out = NULL;
3207 D3DXFLOAT16 half;
3208 BOOL equal;
3210 /* Input floats through bit patterns because compilers do not generate reliable INF and NaN values. */
3211 union convert
3213 DWORD d;
3214 float f;
3215 } single;
3217 struct
3219 union convert single_in;
3221 /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32/64 bit math), W7PRO (32 bit math) */
3222 WORD half_ver1, half_ver2;
3224 /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
3225 union convert single_out_ver1, single_out_ver2;
3227 testdata[] =
3229 { { 0x479c4000 }, 0x7c00, 0x7ce2, { 0x47800000 }, { 0x479c4000 } }, /* 80000.0f */
3230 { { 0x477fdf00 }, 0x7bff, 0x7bff, { 0x477fe000 }, { 0x477fe000 } }, /* 65503.0f */
3231 { { 0x477fe000 }, 0x7bff, 0x7bff, { 0x477fe000 }, { 0x477fe000 } }, /* 65504.0f */
3232 { { 0x477ff000 }, 0x7bff, 0x7c00, { 0x477fe000 }, { 0x47800000 } }, /* 65520.0f */
3233 { { 0x477ff100 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65521.0f */
3235 { { 0x477ffe00 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65534.0f */
3236 { { 0x477fff00 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65535.0f */
3237 { { 0x47800000 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65536.0f */
3238 { { 0xc79c4000 }, 0xfc00, 0xfce2, { 0xc7800000 }, { 0xc79c4000 } }, /* -80000.0f */
3239 { { 0xc77fdf00 }, 0xfbff, 0xfbff, { 0xc77fe000 }, { 0xc77fe000 } }, /* -65503.0f */
3241 { { 0xc77fe000 }, 0xfbff, 0xfbff, { 0xc77fe000 }, { 0xc77fe000 } }, /* -65504.0f */
3242 { { 0xc77ff000 }, 0xfbff, 0xfc00, { 0xc77fe000 }, { 0xc7800000 } }, /* -65520.0f */
3243 { { 0xc77ff100 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65521.0f */
3244 { { 0xc77ffe00 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65534.0f */
3245 { { 0xc77fff00 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65535.0f */
3247 { { 0xc7800000 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65536.0f */
3248 { { 0x7f800000 }, 0x7c00, 0x7fff, { 0x47800000 }, { 0x47ffe000 } }, /* INF */
3249 { { 0xff800000 }, 0xffff, 0xffff, { 0xc7ffe000 }, { 0xc7ffe000 } }, /* -INF */
3250 { { 0x7fc00000 }, 0x7fff, 0xffff, { 0x47ffe000 }, { 0xc7ffe000 } }, /* NaN */
3251 { { 0xffc00000 }, 0xffff, 0xffff, { 0xc7ffe000 }, { 0xc7ffe000 } }, /* -NaN */
3253 { { 0x00000000 }, 0x0000, 0x0000, { 0x00000000 }, { 0x00000000 } }, /* 0.0f */
3254 { { 0x80000000 }, 0x8000, 0x8000, { 0x80000000 }, { 0x80000000 } }, /* -0.0f */
3255 { { 0x330007ff }, 0x0000, 0x0000, { 0x00000000 }, { 0x00000000 } }, /* 2.9809595e-08f */
3256 { { 0xb30007ff }, 0x8000, 0x8000, { 0x80000000 }, { 0x80000000 } }, /* -2.9809595e-08f */
3257 { { 0x33000800 }, 0x0001, 0x0000, { 0x33800000 }, { 0x00000000 } }, /* 2.9809598e-08f */
3259 { { 0xb3000800 }, 0x8001, 0x8000, { 0xb3800000 }, { 0x80000000 } }, /* -2.9809598e-08f */
3260 { { 0x33c00000 }, 0x0002, 0x0001, { 0x34000000 }, { 0x33800000 } }, /* 8.9406967e-08f */
3263 /* exception on NULL out or in parameter */
3264 out = D3DXFloat32To16Array(&half, &single.f, 0);
3265 ok(out == &half, "Got %p, expected %p.\n", out, &half);
3267 out = D3DXFloat16To32Array(&single.f, &half, 0);
3268 ok(out == &single.f, "Got %p, expected %p.\n", out, &single.f);
3270 for (i = 0; i < ARRAY_SIZE(testdata); ++i)
3272 out = D3DXFloat32To16Array(&half, &testdata[i].single_in.f, 1);
3273 ok(out == &half, "Got %p, expected %p.\n", out, &half);
3274 ok(half.value == testdata[i].half_ver1 || half.value == testdata[i].half_ver2,
3275 "Got %x, expected %x or %x for index %d.\n", half.value, testdata[i].half_ver1,
3276 testdata[i].half_ver2, i);
3278 out = D3DXFloat16To32Array(&single.f, (D3DXFLOAT16 *)&testdata[i].half_ver1, 1);
3279 ok(out == &single.f, "Got %p, expected %p.\n", out, &single.f);
3280 equal = compare_float(single.f, testdata[i].single_out_ver1.f, 0);
3281 ok(equal, "Got %#x, expected %#x at index %u.\n", single.d, testdata[i].single_out_ver1.d, i);
3283 out = D3DXFloat16To32Array(&single.f, (D3DXFLOAT16 *)&testdata[i].half_ver2, 1);
3284 ok(out == &single.f, "Got %p, expected %p.\n", out, &single.f);
3285 equal = compare_float(single.f, testdata[i].single_out_ver2.f, 0);
3286 ok(equal, "Got %#x, expected %#x at index %u.\n", single.d, testdata[i].single_out_ver2.d, i);
3290 static void test_D3DXSHAdd(void)
3292 float out[50] = {0.0f};
3293 unsigned int i, k;
3294 float *ret;
3295 BOOL equal;
3297 static const float in1[50] =
3299 1.11f, 1.12f, 1.13f, 1.14f, 1.15f, 1.16f, 1.17f, 1.18f,
3300 1.19f, 1.20f, 1.21f, 1.22f, 1.23f, 1.24f, 1.25f, 1.26f,
3301 1.27f, 1.28f, 1.29f, 1.30f, 1.31f, 1.32f, 1.33f, 1.34f,
3302 1.35f, 1.36f, 1.37f, 1.38f, 1.39f, 1.40f, 1.41f, 1.42f,
3303 1.43f, 1.44f, 1.45f, 1.46f, 1.47f, 1.48f, 1.49f, 1.50f,
3304 1.51f, 1.52f, 1.53f, 1.54f, 1.55f, 1.56f, 1.57f, 1.58f,
3305 1.59f, 1.60f,
3307 static const float in2[50] =
3309 2.11f, 2.12f, 2.13f, 2.14f, 2.15f, 2.16f, 2.17f, 2.18f,
3310 2.19f, 2.20f, 2.21f, 2.22f, 2.23f, 2.24f, 2.25f, 2.26f,
3311 2.27f, 2.28f, 2.29f, 2.30f, 2.31f, 2.32f, 2.33f, 2.34f,
3312 2.35f, 2.36f, 2.37f, 2.38f, 2.39f, 2.40f, 2.41f, 2.42f,
3313 2.43f, 2.44f, 2.45f, 2.46f, 2.47f, 2.48f, 2.49f, 2.50f,
3314 2.51f, 2.52f, 2.53f, 2.54f, 2.55f, 2.56f, 2.57f, 2.58f,
3315 2.59f, 2.60f,
3319 * Order is not limited by D3DXSH_MINORDER and D3DXSH_MAXORDER!
3320 * All values will work, test from 0-7 [D3DXSH_MINORDER = 2, D3DXSH_MAXORDER = 6]
3321 * Exceptions will show up when out, in1 or in2 is NULL
3323 for (k = 0; k <= D3DXSH_MAXORDER + 1; k++)
3325 UINT count = k * k;
3327 ret = D3DXSHAdd(&out[0], k, &in1[0], &in2[0]);
3328 ok(ret == out, "%u: D3DXSHAdd() failed, got %p, expected %p\n", k, out, ret);
3330 for (i = 0; i < count; ++i)
3332 equal = compare_float(in1[i] + in2[i], out[i], 0);
3333 ok(equal, "%u-%u: Got %.8e, expected %.8e.\n", k, i, out[i], in1[i] + in2[i]);
3335 equal = compare_float(out[count], 0.0f, 0);
3336 ok(equal, "%u-%u: Got %.8e, expected 0.0.\n", k, k * k, out[count]);
3340 static void test_D3DXSHDot(void)
3342 float a[49], b[49], got;
3343 unsigned int i;
3344 BOOL equal;
3346 static const float expected[] = {0.5f, 0.5f, 25.0f, 262.5f, 1428.0f, 5362.5f, 15873.0f, 39812.5f};
3348 for (i = 0; i < ARRAY_SIZE(a); ++i)
3350 a[i] = i + 1.0f;
3351 b[i] = i + 0.5f;
3354 /* D3DXSHDot computes by using order * order elements */
3355 for (i = 0; i <= D3DXSH_MAXORDER + 1; i++)
3357 got = D3DXSHDot(i, a, b);
3358 equal = compare_float(got, expected[i], 0);
3359 ok(equal, "order %u: Got %.8e, expected %.8e.\n", i, got, expected[i]);
3363 static void test_D3DXSHEvalConeLight(void)
3365 float bout[49], expected, gout[49], rout[49];
3366 unsigned int j, l, order;
3367 D3DXVECTOR3 dir;
3368 HRESULT hr;
3369 BOOL equal;
3371 static const float table[] =
3373 /* Red colour */
3374 1.604815f, -3.131381f, 7.202175f, -2.870432f, 6.759296f, -16.959688f,
3375 32.303082f, -15.546381f, -0.588878f, -5.902123f, 40.084042f, -77.423569f,
3376 137.556320f, -70.971603f, -3.492171f, 7.683092f, -2.129311f, -35.971344f,
3377 183.086548f, -312.414948f, 535.091064f, -286.380371f, -15.950727f, 46.825714f,
3378 -12.127637f, 11.289261f, -12.417809f, -155.039566f, 681.182556f, -1079.733643f,
3379 1807.650513f, -989.755798f, -59.345467f, 201.822815f, -70.726486f, 7.206529f,
3381 3.101155f, -3.128710f, 7.196033f, -2.867984f, -0.224708f, 0.563814f,
3382 -1.073895f, 0.516829f, 0.019577f, 2.059788f, -13.988971f, 27.020128f,
3383 -48.005917f, 24.768450f, 1.218736f, -2.681329f, -0.088639f, -1.497410f,
3384 7.621501f, -13.005165f, 22.274696f, -11.921401f, -0.663995f, 1.949254f,
3385 -0.504848f, 4.168484f, -4.585193f, -57.247314f, 251.522095f, -398.684387f,
3386 667.462891f, -365.460693f, -21.912912f, 74.521721f, -26.115280f, 2.660963f,
3387 /* Green colour */
3388 2.454422f, -4.789170f, 11.015091f, -4.390072f, 10.337747f, -25.938347f,
3389 49.404713f, -23.776817f, -0.900637f, -9.026776f, 61.305000f, -118.412514f,
3390 210.380249f, -108.544792f, -5.340967f, 11.750610f, -3.256593f, -55.014996f,
3391 280.014709f, -477.811066f, 818.374512f, -437.993469f, -24.395227f, 71.615799f,
3392 -18.548151f, 17.265928f, -18.991943f, -237.119324f, 1041.808594f, -1651.357300f,
3393 2764.642090f, -1513.744141f, -90.763657f, 308.670197f, -108.169922f, 11.021750f,
3395 4.742942f, -4.785086f, 11.005697f, -4.386329f, -0.343672f, 0.862303f,
3396 -1.642427f, 0.790444f, 0.029941f, 3.150264f, -21.394896f, 41.324898f,
3397 -73.420807f, 37.881153f, 1.863950f, -4.100857f, -0.135565f, -2.290156f,
3398 11.656413f, -19.890251f, 34.067181f, -18.232729f, -1.015521f, 2.981212f,
3399 -0.772120f, 6.375328f, -7.012648f, -87.554710f, 384.680817f, -609.752563f,
3400 1020.825500f, -558.939819f, -33.513863f, 113.974388f, -39.941013f, 4.069707f,
3401 /* Blue colour */
3402 3.304030f, -6.446959f, 14.828006f, -5.909713f, 13.916198f, -34.917004f,
3403 66.506340f, -32.007256f, -1.212396f, -12.151429f, 82.525963f, -159.401459f,
3404 283.204193f, -146.117996f, -7.189764f, 15.818130f, -4.383876f, -74.058655f,
3405 376.942871f, -643.207214f, 1101.658081f, -589.606628f, -32.839729f, 96.405884f,
3406 -24.968664f, 23.242596f, -25.566080f, -319.199097f, 1402.434692f, -2222.980957f,
3407 3721.633545f, -2037.732544f, -122.181847f, 415.517578f, -145.613358f, 14.836972f,
3409 6.384730f, -6.441462f, 14.815362f, -5.904673f, -0.462635f, 1.160793f,
3410 -2.210959f, 1.064060f, 0.040305f, 4.240739f, -28.800821f, 55.629673f,
3411 -98.835709f, 50.993862f, 2.509163f, -5.520384f, -0.182491f, -3.082903f,
3412 15.691326f, -26.775339f, 45.859665f, -24.544060f, -1.367048f, 4.013170f,
3413 -1.039392f, 8.582172f, -9.440103f, -117.862114f, 517.839600f, -820.820740f,
3414 1374.188232f, -752.419067f, -45.114819f, 153.427063f, -53.766754f, 5.478452f, };
3415 const struct
3417 float *red_received, *green_received, *blue_received;
3418 const float *red_expected, *green_expected, *blue_expected;
3419 float radius, roffset, goffset, boffset;
3421 test[] =
3423 { rout, gout, bout, table, &table[72], &table[144], 0.5f, 1.01f, 1.02f, 1.03f, },
3424 { rout, gout, bout, &table[36], &table[108], &table[180], 1.6f, 1.01f, 1.02f, 1.03f, },
3425 { rout, rout, rout, &table[144], &table[144], &table[144], 0.5f, 1.03f, 1.03f, 1.03f, },
3426 { rout, rout, bout, &table[72], &table[72], &table[144], 0.5, 1.02f, 1.02f, 1.03f, },
3427 { rout, gout, gout, table, &table[144], &table[144], 0.5f, 1.01f, 1.03f, 1.03f, },
3428 { rout, gout, rout, &table[144], &table[72], &table[144], 0.5f, 1.03f, 1.02f, 1.03f, },
3429 /* D3DXSHEvalConeLight accepts NULL green or blue colour. */
3430 { rout, NULL, bout, table, NULL, &table[144], 0.5f, 1.01f, 0.0f, 1.03f, },
3431 { rout, gout, NULL, table, &table[72], NULL, 0.5f, 1.01f, 1.02f, 0.0f, },
3432 { rout, NULL, NULL, table, NULL, NULL, 0.5f, 1.01f, 0.0f, 0.0f, },
3435 dir.x = 1.1f; dir.y = 1.2f; dir.z = 2.76f;
3437 for (l = 0; l < ARRAY_SIZE(test); ++l)
3439 for (order = D3DXSH_MINORDER; order <= D3DXSH_MAXORDER; order++)
3441 for (j = 0; j < 49; j++)
3443 test[l].red_received[j] = 1.01f + j;
3444 if (test[l].green_received)
3445 test[l].green_received[j] = 1.02f + j;
3446 if (test[l].blue_received)
3447 test[l].blue_received[j] = 1.03f + j;
3450 hr = D3DXSHEvalConeLight(order, &dir, test[l].radius, 1.7f, 2.6f, 3.5f, test[l].red_received, test[l].green_received, test[l].blue_received);
3451 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3453 for (j = 0; j < 49; j++)
3455 if (j >= order * order)
3456 expected = j + test[l].roffset;
3457 else
3458 expected = test[l].red_expected[j];
3459 equal = compare_float(test[l].red_received[j], expected, 128);
3460 ok(equal, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3461 l, order, j, expected, test[l].red_received[j]);
3463 if (test[l].green_received)
3465 if (j >= order * order)
3466 expected = j + test[l].goffset;
3467 else
3468 expected = test[l].green_expected[j];
3469 equal = compare_float(test[l].green_received[j], expected, 64);
3470 ok(equal, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3471 l, order, j, expected, test[l].green_received[j]);
3474 if (test[l].blue_received)
3476 if (j >= order * order)
3477 expected = j + test[l].boffset;
3478 else
3479 expected = test[l].blue_expected[j];
3480 equal = compare_float(test[l].blue_received[j], expected, 128);
3481 ok(equal, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3482 l, order, j, expected, test[l].blue_received[j]);
3488 /* Cone light with radius <= 0.0f behaves as a directional light */
3489 for (order = D3DXSH_MINORDER; order <= D3DXSH_MAXORDER; order++)
3491 FLOAT blue[49], green[49], red[49];
3493 for (j = 0; j < 49; j++)
3495 rout[j] = 1.01f + j;
3496 gout[j] = 1.02f + j;
3497 bout[j] = 1.03f + j;
3498 red[j] = 1.01f + j;
3499 green[j] = 1.02f + j;
3500 blue[j] = 1.03f + j;
3503 hr = D3DXSHEvalConeLight(order, &dir, -0.1f, 1.7f, 2.6f, 3.5f, rout, gout, bout);
3504 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3505 D3DXSHEvalDirectionalLight(order, &dir, 1.7f, 2.6f, 3.5f, red, green, blue);
3507 for (j = 0; j < 49; j++)
3509 equal = compare_float(red[j], rout[j], 0);
3510 ok(equal, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3511 l, order, j, red[j], rout[j]);
3513 equal = compare_float(green[j], gout[j], 0);
3514 ok(equal, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3515 l, order, j, green[j], gout[j]);
3517 equal = compare_float(blue[j], bout[j], 0);
3518 ok(equal, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3519 l, order, j, blue[j], bout[j]);
3523 /* D3DXSHEvalConeLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3524 hr = D3DXSHEvalConeLight(7, &dir, 0.5f, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3525 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3526 hr = D3DXSHEvalConeLight(0, &dir, 0.5f, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3527 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3528 hr = D3DXSHEvalConeLight(1, &dir, 0.5f, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3529 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3532 static void test_D3DXSHEvalDirection(void)
3534 float a[49], expected, *received_ptr;
3535 unsigned int i, order;
3536 D3DXVECTOR3 d;
3537 BOOL equal;
3539 static const float table[36] =
3541 2.82094806e-01f, -9.77205038e-01f, 1.46580756e+00f, -4.88602519e-01f, 2.18509698e+00f, -6.55529118e+00f,
3542 8.20018101e+00f, -3.27764559e-00f, -1.63882279e+00f, 1.18008721e+00f, 1.73436680e+01f, -4.02200317e+01f,
3543 4.70202179e+01f, -2.01100159e+01f, -1.30077515e+01f, 6.49047947e+00f, -1.50200577e+01f, 1.06207848e+01f,
3544 1.17325661e+02f, -2.40856750e+02f, 2.71657288e+02f, -1.20428375e+02f, -8.79942474e+01f, 5.84143143e+01f,
3545 -4.38084984e+00f, 2.49425201e+01f, -1.49447693e+02f, 7.82781296e+01f, 7.47791748e+02f, -1.42768787e+03f,
3546 1.57461914e+03f, -7.13843933e+02f, -5.60843811e+02f, 4.30529724e+02f, -4.35889091e+01f, -2.69116650e+01f,
3549 d.x = 1.0; d.y = 2.0f; d.z = 3.0f;
3551 for (order = 0; order <= D3DXSH_MAXORDER + 1; order++)
3553 for (i = 0; i < ARRAY_SIZE(a); ++i)
3554 a[i] = 1.5f + i;
3556 received_ptr = D3DXSHEvalDirection(a, order, &d);
3557 ok(received_ptr == a, "Expected %p, received %p\n", a, received_ptr);
3559 for (i = 0; i < ARRAY_SIZE(a); ++i)
3561 /* if the order is < D3DXSH_MINORDER or order > D3DXSH_MAXORDER or
3562 * the index of the element is greater than order * order - 1,
3563 * D3DXSHEvalDirection() does not modify the output. */
3564 if ((order < D3DXSH_MINORDER) || (order > D3DXSH_MAXORDER) || (i >= order * order))
3565 expected = 1.5f + i;
3566 else
3567 expected = table[i];
3569 equal = compare_float(a[i], expected, 2);
3570 ok(equal, "order %u, index %u: Got unexpected result %.8e, expected %.8e.\n",
3571 order, i, a[i], expected);
3576 static void test_D3DXSHEvalDirectionalLight(void)
3578 float *blue_out, bout[49], expected, gout[49], *green_out, *red_out, rout[49];
3579 unsigned int j, l, order, startindex;
3580 D3DXVECTOR3 dir;
3581 HRESULT hr;
3582 BOOL equal;
3584 static const float table[] =
3586 /* Red colour */
3587 2.008781f, -4.175174f, 9.602900f, -3.827243f, 1.417963f, -2.947181f,
3588 6.778517f, -2.701583f, 7.249108f, -18.188671f, 34.643921f, -16.672949f,
3589 -0.631551f, 1.417963f, -2.947181f, 6.778517f, -2.701583f, 7.249108f,
3590 -18.188671f, 34.643921f, -16.672949f, -0.631551f, -7.794341f, 52.934967f,
3591 -102.245529f, 181.656815f, -93.725060f, -4.611760f, 10.146287f, 1.555186f,
3592 -3.232392f, 7.434503f, -2.963026f, 7.950634f, -19.948866f, 37.996559f,
3593 -18.286459f, -0.692669f, -8.548632f, 58.057705f, -112.140251f, 199.236496f,
3594 -102.795227f, -5.058059f, 11.128186f, -4.189955f, -70.782669f, 360.268829f,
3595 -614.755005f, 1052.926270f, -563.525391f, -31.387066f, 92.141365f, -23.864176f,
3596 1.555186f, -3.232392f, 7.434503f, -2.963026f, 7.950634f, -19.948866f,
3597 37.996559f, -18.286459f, -0.692669f, -8.548632f, 58.057705f, -112.140251f,
3598 199.236496f, -102.795227f, -5.058059f, 11.128186f, -4.189955f, -70.782669f,
3599 360.268829f, -614.755005f, 1052.926270f, -563.525391f, -31.387066f, 92.141365f,
3600 -23.864176f, 34.868664f, -38.354366f, -478.864166f, 2103.939941f, -3334.927734f,
3601 5583.213867f, -3057.017090f, -183.297836f, 623.361633f, -218.449921f, 22.258503f,
3602 /* Green colour */
3603 3.072254f, -6.385560f, 14.686787f, -5.853429f, 2.168650f, -4.507453f,
3604 10.367143f, -4.131832f, 11.086870f, -27.817965f, 52.984818f, -25.499800f,
3605 -0.965902f, 2.168650f, -4.507453f, 10.367143f, -4.131832f, 11.086870f,
3606 -27.817965f, 52.984818f, -25.499800f, -0.965902f, -11.920755f, 80.959351f,
3607 -156.375488f, 277.828033f, -143.344193f, -7.053278f, 15.517849f, 2.378519f,
3608 -4.943659f, 11.370415f, -4.531687f, 12.159794f, -30.510029f, 58.112385f,
3609 -27.967525f, -1.059376f, -13.074378f, 88.794136f, -171.508621f, 304.714630f,
3610 -157.216217f, -7.735855f, 17.019577f, -6.408166f, -108.255844f, 550.999390f,
3611 -940.213501f, 1610.357788f, -861.862305f, -48.003746f, 140.922089f, -36.498150f,
3612 2.378519f, -4.943659f, 11.370415f, -4.531687f, 12.159794f, -30.510029f,
3613 58.112385f, -27.967525f, -1.059376f, -13.074378f, 88.794136f, -171.508621f,
3614 304.714630f, -157.216217f, -7.735855f, 17.019577f, -6.408166f, -108.255844f,
3615 550.999390f, -940.213501f, 1610.357788f, -861.862305f, -48.003746f, 140.922089f,
3616 -36.498150f, 53.328545f, -58.659618f, -732.380493f, 3217.790283f, -5100.477539f,
3617 8539.033203f, -4675.437500f, -280.337860f, 953.376587f, -334.099884f, 34.042416f,
3618 /* Blue colour */
3619 4.135726f, -8.595945f, 19.770674f, -7.879617f, 2.919336f, -6.067726f,
3620 13.955770f, -5.562082f, 14.924634f, -37.447262f, 71.325722f, -34.326656f,
3621 -1.300252f, 2.919336f, -6.067726f, 13.955770f, -5.562082f, 14.924634f,
3622 -37.447262f, 71.325722f, -34.326656f, -1.300252f, -16.047173f, 108.983749f,
3623 -210.505493f, 373.999298f, -192.963348f, -9.494799f, 20.889414f, 3.201853f,
3624 -6.654925f, 15.306328f, -6.100348f, 16.368954f, -41.071194f, 78.228210f,
3625 -37.648590f, -1.426083f, -17.600124f, 119.530563f, -230.876984f, 410.192780f,
3626 -211.637222f, -10.413651f, 22.910971f, -8.626378f, -145.729019f, 741.729919f,
3627 -1265.671997f, 2167.789307f, -1160.199219f, -64.620430f, 189.702820f, -49.132126f,
3628 3.201853f, -6.654925f, 15.306328f, -6.100348f, 16.368954f, -41.071194f,
3629 78.228210f, -37.648590f, -1.426083f, -17.600124f, 119.530563f, -230.876984f,
3630 410.192780f, -211.637222f, -10.413651f, 22.910971f, -8.626378f, -145.729019f,
3631 741.729919f, -1265.671997f, 2167.789307f, -1160.199219f, -64.620430f, 189.702820f,
3632 -49.132126f, 71.788422f, -78.964867f, -985.896790f, 4331.640625f, -6866.027344f,
3633 11494.852539f, -6293.858398f, -377.377899f, 1283.391479f, -449.749817f, 45.826328f, };
3634 const struct
3636 float *red_in, *green_in, *blue_in;
3637 const float *red_out, *green_out, *blue_out;
3638 float roffset, goffset, boffset;
3640 test[] =
3642 { rout, gout, bout, table, &table[90], &table[180], 1.01f, 1.02f, 1.03f, },
3643 { rout, rout, rout, &table[180], &table[180], &table[180], 1.03f, 1.03f, 1.03f, },
3644 { rout, rout, bout, &table[90], &table[90], &table[180], 1.02f, 1.02f, 1.03f, },
3645 { rout, gout, gout, table, &table[180], &table[180], 1.01f, 1.03f, 1.03f, },
3646 { rout, gout, rout, &table[180], &table[90], &table[180], 1.03f, 1.02f, 1.03f, },
3647 /* D3DXSHEvalDirectionaLight accepts NULL green or blue colour. */
3648 { rout, NULL, bout, table, NULL, &table[180], 1.01f, 0.0f, 1.03f, },
3649 { rout, gout, NULL, table, &table[90], NULL, 1.01f, 1.02f, 0.0f, },
3650 { rout, NULL, NULL, table, NULL, NULL, 1.01f, 0.0f, 0.0f, },
3653 dir.x = 1.1f; dir.y= 1.2f; dir.z = 2.76f;
3655 for (l = 0; l < ARRAY_SIZE(test); ++l)
3657 startindex = 0;
3659 for (order = D3DXSH_MINORDER; order <= D3DXSH_MAXORDER; order++)
3661 red_out = test[l].red_in;
3662 green_out = test[l].green_in;
3663 blue_out = test[l].blue_in;
3665 for (j = 0; j < ARRAY_SIZE(rout); ++j)
3667 red_out[j] = 1.01f + j;
3668 if ( green_out )
3669 green_out[j] = 1.02f + j;
3670 if ( blue_out )
3671 blue_out[j] = 1.03f + j;
3674 hr = D3DXSHEvalDirectionalLight(order, &dir, 1.7f, 2.6f, 3.5f, red_out, green_out, blue_out);
3675 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3677 for (j = 0; j < ARRAY_SIZE(rout); ++j)
3679 if ( j >= order * order )
3680 expected = j + test[l].roffset;
3681 else
3682 expected = test[l].red_out[startindex + j];
3683 equal = compare_float(expected, red_out[j], 8);
3684 ok(equal, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3685 l, order, j, expected, red_out[j]);
3687 if ( green_out )
3689 if ( j >= order * order )
3690 expected = j + test[l].goffset;
3691 else
3692 expected = test[l].green_out[startindex + j];
3693 equal = compare_float(expected, green_out[j], 8);
3694 ok(equal, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3695 l, order, j, expected, green_out[j]);
3698 if ( blue_out )
3700 if ( j >= order * order )
3701 expected = j + test[l].boffset;
3702 else
3703 expected = test[l].blue_out[startindex + j];
3704 equal = compare_float(expected, blue_out[j], 4);
3705 ok(equal, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3706 l, order, j, expected, blue_out[j]);
3710 startindex += order * order;
3714 /* D3DXSHEvalDirectionalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set*/
3715 hr = D3DXSHEvalDirectionalLight(7, &dir, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3716 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3717 hr = D3DXSHEvalDirectionalLight(0, &dir, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3718 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3719 hr = D3DXSHEvalDirectionalLight(1, &dir, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3720 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3723 static void test_D3DXSHEvalHemisphereLight(void)
3725 float bout[49], expected, gout[49], rout[49];
3726 unsigned int j, l, order;
3727 D3DXCOLOR bottom, top;
3728 D3DXVECTOR3 dir;
3729 HRESULT hr;
3730 BOOL equal;
3732 static const float table[] =
3734 /* Red colour. */
3735 23.422981f, 15.859521f, -36.476898f, 14.537894f,
3736 /* Green colour. */
3737 19.966694f, 6.096982f, -14.023058f, 5.588900f,
3738 /* Blue colour. */
3739 24.566214f, 8.546826f, -19.657701f, 7.834591f,
3741 const struct
3743 float *red_received, *green_received, *blue_received;
3744 const float *red_expected, *green_expected, *blue_expected;
3745 const float roffset, goffset, boffset;
3747 test[] =
3749 { rout, gout, bout, table, &table[4], &table[8], 1.01f, 1.02f, 1.03f, },
3750 { rout, rout, rout, &table[8], &table[8], &table[8], 1.03f, 1.03f, 1.03f, },
3751 { rout, rout, bout, &table[4], &table[4], &table[8], 1.02f, 1.02f, 1.03f, },
3752 { rout, gout, gout, table, &table[8], &table[8], 1.01f, 1.03f, 1.03f, },
3753 { rout, gout, rout, &table[8], &table[4], &table[8], 1.03f, 1.02f, 1.03f, },
3754 /* D3DXSHEvalHemisphereLight accepts NULL green or blue colour. */
3755 { rout, NULL, bout, table, NULL, &table[8], 1.01f, 1.02f, 1.03f, },
3756 { rout, gout, NULL, table, &table[4], NULL, 1.01f, 1.02f, 1.03f, },
3757 { rout, NULL, NULL, table, NULL, NULL, 1.01f, 1.02f, 1.03f, },
3760 dir.x = 1.1f; dir.y = 1.2f; dir.z = 2.76f;
3761 top.r = 0.1f; top.g = 2.1f; top.b = 2.3f; top.a = 4.3f;
3762 bottom.r = 8.71f; bottom.g = 5.41f; bottom.b = 6.94f; bottom.a = 8.43f;
3764 for (l = 0; l < ARRAY_SIZE(test); ++l)
3765 for (order = D3DXSH_MINORDER; order <= D3DXSH_MAXORDER + 1; order++)
3767 for (j = 0; j < 49; j++)
3769 test[l].red_received[j] = 1.01f + j;
3770 if (test[l].green_received)
3771 test[l].green_received[j] = 1.02f + j;
3772 if (test[l].blue_received)
3773 test[l].blue_received[j] = 1.03f + j;
3776 hr = D3DXSHEvalHemisphereLight(order, &dir, top, bottom, test[l].red_received, test[l].green_received, test[l].blue_received);
3777 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3779 for (j = 0; j < 49; j++)
3781 if (j < 4)
3782 expected = test[l].red_expected[j];
3783 else if (j < order * order)
3784 expected = 0.0f;
3785 else
3786 expected = test[l].roffset + j;
3787 equal = compare_float(test[l].red_received[j], expected, 4);
3788 ok(equal, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3789 l, order, j, expected, test[l].red_received[j]);
3791 if (test[l].green_received)
3793 if (j < 4)
3794 expected = test[l].green_expected[j];
3795 else if (j < order * order)
3796 expected = 0.0f;
3797 else
3798 expected = test[l].goffset + j;
3799 equal = compare_float(expected, test[l].green_received[j], 4);
3800 ok(equal, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3801 l, order, j, expected, test[l].green_received[j]);
3804 if (test[l].blue_received)
3806 if (j < 4)
3807 expected = test[l].blue_expected[j];
3808 else if (j < order * order)
3809 expected = 0.0f;
3810 else
3811 expected = test[l].boffset + j;
3812 equal = compare_float(expected, test[l].blue_received[j], 4);
3813 ok(equal, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3814 l, order, j, expected, test[l].blue_received[j]);
3820 static void test_D3DXSHEvalSphericalLight(void)
3822 float bout[49], expected, gout[49], rout[49];
3823 unsigned int j, l, order;
3824 D3DXVECTOR3 dir;
3825 HRESULT hr;
3826 BOOL equal;
3828 static const float table[] =
3830 /* Red colour. */
3831 3.01317163e+00f, -9.77240128e-01f, 2.24765220e+00f, -8.95803434e-01f, 3.25255224e-35f, -8.16094904e-35f,
3832 8.95199460e-35f, -7.48086982e-35f, -2.83366352e-36f, 6.29281376e-02f, -4.27374053e-01f, 6.19212543e-01f,
3833 -3.04508915e-01f, 5.67611487e-01f, 3.72333533e-02f, -8.19167317e-02f, 1.25205729e-36f, 2.11515287e-35f,
3834 -8.85884025e-35f, 8.22100105e-35f, -1.41290744e-37f, 7.53591749e-35f, 7.71793061e-36f, -2.75340121e-35f,
3835 7.13117824e-36f, 1.24992691e-02f, -1.37487792e-02f, -1.48109290e-01f, 4.34345843e-01f, -2.45986100e-01f,
3836 -1.51757946e-01f, -2.25487254e-01f, -3.78407442e-02f, 1.92801335e-01f, -7.83071154e-02f, 7.97894137e-03f,
3838 4.02519645e-01f, -2.43653315e-01f, 5.60402600e-01f, -2.23348868e-01f, 1.62046875e-01f, -4.06590330e-01f,
3839 4.46001368e-01f, -3.72707796e-01f, -1.41177231e-02f, -4.31995198e-02f, 2.93387896e-01f, -4.25083048e-01f,
3840 2.09042241e-01f, -3.89659453e-01f, -2.55603144e-02f, 5.62349945e-02f, -4.68822967e-03f, -7.92002290e-02f,
3841 3.31712278e-01f, -3.07828893e-01f, 5.29052032e-04f, -2.82176480e-01f, -2.88991817e-02f, 1.03098934e-01f,
3842 -2.67021338e-02f, 7.24339502e-03f, -7.96749298e-03f, -8.58301461e-02f, 2.51705799e-01f, -1.42550295e-01f,
3843 -8.79445626e-02f, -1.30671101e-01f, -2.19289189e-02f, 1.11729432e-01f, -4.53794030e-02f, 4.62384030e-03f,
3845 1.95445306e+00f, -8.56593659e-01f, 1.97016533e+00f, -7.85210840e-01f, 2.31033385e-01f, -5.79683751e-01f,
3846 6.35872835e-01f, -5.31376762e-01f, -2.01279127e-02f, 2.11104646e-02f, -1.43370917e-01f, 2.07726860e-01f,
3847 -1.02153423e-01f, 1.90416285e-01f, 1.24906507e-02f, -2.74805568e-02f, 6.33162467e-03f, 1.06962790e-01f,
3848 -4.47989495e-01f, 4.15734115e-01f, -7.14504011e-04f, 3.81089599e-01f, 3.90293960e-02f, -1.39238860e-01f,
3849 3.60622028e-02f, -4.47359268e-03f, 4.92080277e-03f, 5.30095505e-02f, -1.55456001e-01f, 8.80404774e-02f,
3850 5.43154350e-02f, 8.07037695e-02f, 1.35435180e-02f, -6.90052063e-02f, 2.80267699e-02f, -2.85572968e-03f,
3851 /* Green colour. */
3852 4.60837984e+00f, -1.49460245e+00f, 3.43758549e+00f, -1.37005222e+00f, 4.97449134e-35f, -1.24814507e-34f,
3853 1.36912850e-34f, -1.14413296e-34f, -4.33383805e-36f, 9.62430278e-02f, -6.53630863e-01f, 9.47030887e-01f,
3854 -4.65719486e-01f, 8.68111630e-01f, 5.69451249e-02f, -1.25284405e-01f, 1.91491103e-36f, 3.23493947e-35f,
3855 -1.35488136e-34f, 1.25732949e-34f, -2.16091711e-37f, 1.15255201e-34f, 1.18038931e-35f, -4.21108392e-35f,
3856 1.09065072e-35f, 1.91165280e-02f, -2.10275433e-02f, -2.26520076e-01f, 6.64293599e-01f, -3.76214011e-01f,
3857 -2.32100374e-01f, -3.44862837e-01f, -5.78740756e-02f, 2.94872611e-01f, -1.19763816e-01f, 1.22030860e-02f,
3859 6.15618240e-01f, -3.72646222e-01f, 8.57086273e-01f, -3.41592364e-01f, 2.47836381e-01f, -6.21843994e-01f,
3860 6.82119695e-01f, -5.70023651e-01f, -2.15918104e-02f, -6.60698496e-02f, 4.48710870e-01f, -6.50126972e-01f,
3861 3.19711642e-01f, -5.95949713e-01f, -3.90922430e-02f, 8.60064566e-02f, -7.17023314e-03f, -1.21129754e-01f,
3862 5.07324627e-01f, -4.70797100e-01f, 8.09138350e-04f, -4.31564000e-01f, -4.41987457e-02f, 1.57680712e-01f,
3863 -4.08385549e-02f, 1.10781328e-02f, -1.21855767e-02f, -1.31269627e-01f, 3.84961785e-01f, -2.18018084e-01f,
3864 -1.34503440e-01f, -1.99849906e-01f, -3.35383443e-02f, 1.70880296e-01f, -6.94037884e-02f, 7.07175529e-03f,
3866 2.98916331e+00f, -1.31008433e+00f, 3.01319384e+00f, -1.20091062e+00f, 3.53345154e-01f, -8.86575090e-01f,
3867 9.72511332e-01f, -8.12693818e-01f, -3.07838645e-02f, 3.22865908e-02f, -2.19273153e-01f, 3.17699883e-01f,
3868 -1.56234637e-01f, 2.91224888e-01f, 1.91033469e-02f, -4.20290842e-02f, 9.68366064e-03f, 1.63590138e-01f,
3869 -6.85160360e-01f, 6.35828606e-01f, -1.09277077e-03f, 5.82842878e-01f, 5.96920135e-02f, -2.12953537e-01f,
3870 5.51539537e-02f, -6.84196484e-03f, 7.52593316e-03f, 8.10734249e-02f, -2.37756221e-01f, 1.34650133e-01f,
3871 8.30706600e-02f, 1.23429287e-01f, 2.07136145e-02f, -1.05537368e-01f, 4.28644688e-02f, -4.36758628e-03f,
3872 /* Blue colour. */
3873 6.20358848e+00f, -2.01196491e+00f, 4.62751910e+00f, -1.84430114e+00f, 6.69643089e-35f, -1.68019534e-34f,
3874 1.84305766e-34f, -1.54017904e-34f, -5.83401297e-36f, 1.29557927e-01f, -8.79887732e-01f, 1.27484932e+00f,
3875 -6.26930101e-01f, 1.16861185e+00f, 7.66569017e-02f, -1.68652090e-01f, 2.57776494e-36f, 4.35472637e-35f,
3876 -1.82387882e-34f, 1.69255899e-34f, -2.90892699e-37f, 1.55151238e-34f, 1.58898567e-35f, -5.66876703e-35f,
3877 1.46818371e-35f, 2.57337886e-02f, -2.83063093e-02f, -3.04930882e-01f, 8.94241416e-01f, -5.06441957e-01f,
3878 -3.12442822e-01f, -4.64238452e-01f, -7.79074123e-02f, 3.96943914e-01f, -1.61220527e-01f, 1.64272318e-02f,
3880 8.28716892e-01f, -5.01639163e-01f, 1.15377003e+00f, -4.59835891e-01f, 3.33625909e-01f, -8.37097715e-01f,
3881 9.18238085e-01f, -7.67339558e-01f, -2.90658997e-02f, -8.89401854e-02f, 6.04033886e-01f, -8.75170956e-01f,
3882 4.30381072e-01f, -8.02240028e-01f, -5.26241753e-02f, 1.15777927e-01f, -9.65223728e-03f, -1.63059290e-01f,
3883 6.82937023e-01f, -6.33765350e-01f, 1.08922474e-03f, -5.80951560e-01f, -5.94983136e-02f, 2.12262505e-01f,
3884 -5.49749798e-02f, 1.49128717e-02f, -1.64036616e-02f, -1.76709119e-01f, 5.18217807e-01f, -2.93485893e-01f,
3885 -1.81062330e-01f, -2.69028730e-01f, -4.51477729e-02f, 2.30031176e-01f, -9.34281801e-02f, 9.51967094e-03f,
3887 4.02387383e+00f, -1.76357513e+00f, 4.05622263e+00f, -1.61661051e+00f, 4.75656955e-01f, -1.19346651e+00f,
3888 1.30914992e+00f, -1.09401095e+00f, -4.14398191e-02f, 4.34627200e-02f, -2.95175409e-01f, 4.27672935e-01f,
3889 -2.10315865e-01f, 3.92033517e-01f, 2.57160448e-02f, -5.65776154e-02f, 1.30356975e-02f, 2.20217502e-01f,
3890 -9.22331288e-01f, 8.55923154e-01f, -1.47103763e-03f, 7.84596211e-01f, 8.03546365e-02f, -2.86668233e-01f,
3891 7.42457096e-02f, -9.21033762e-03f, 1.01310642e-02f, 1.09137307e-01f, -3.20056463e-01f, 1.81259801e-01f,
3892 1.11825893e-01f, 1.66154815e-01f, 2.78837128e-02f, -1.42069538e-01f, 5.77021717e-02f, -5.87944329e-03f,
3894 const struct
3896 float *red_received, *green_received, *blue_received;
3897 const float *red_expected, *green_expected, *blue_expected;
3898 float radius, roffset, goffset, boffset;
3900 test[] =
3902 { rout, gout, bout, table, &table[108], &table[216], 17.4f, 1.01f, 1.02f, 1.03f, },
3903 { rout, gout, bout, &table[36], &table[144], &table[252], 1.6f, 1.01f, 1.02f, 1.03f, },
3904 { rout, gout, bout, &table[72], &table[180], &table[288], -3.0f, 1.01f, 1.02f, 1.03f, },
3905 { rout, rout, rout, &table[216], &table[216], &table[216], 17.4f, 1.03f, 1.03f, 1.03f, },
3906 { rout, rout, bout, &table[108], &table[108], &table[216], 17.4, 1.02f, 1.02f, 1.03f, },
3907 { rout, gout, gout, table, &table[216], &table[216], 17.4f, 1.01f, 1.03f, 1.03f, },
3908 { rout, gout, rout, &table[216], &table[108], &table[216], 17.4f, 1.03f, 1.02f, 1.03f, },
3909 /* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */
3910 { rout, NULL, bout, table, NULL, &table[216], 17.4f, 1.01f, 0.0f, 1.03f, },
3911 { rout, gout, NULL, table, &table[108], NULL, 17.4f, 1.01f, 1.02f, 0.0f, },
3912 { rout, NULL, NULL, table, NULL, NULL, 17.4f, 1.01f, 0.0f, 0.0f, },
3915 dir.x = 1.1f; dir.y = 1.2f; dir.z = 2.76f;
3917 for (l = 0; l < ARRAY_SIZE(test); ++l)
3919 for (order = D3DXSH_MINORDER; order <= D3DXSH_MAXORDER; order++)
3921 for (j = 0; j < 49; j++)
3923 test[l].red_received[j] = 1.01f + j;
3924 if (test[l].green_received)
3925 test[l].green_received[j] = 1.02f + j;
3926 if (test[l].blue_received)
3927 test[l].blue_received[j] = 1.03f + j;
3930 hr = D3DXSHEvalSphericalLight(order, &dir, test[l].radius, 1.7f, 2.6f, 3.5f, test[l].red_received, test[l].green_received, test[l].blue_received);
3931 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3933 for (j = 0; j < 49; j++)
3935 if (j >= order * order)
3936 expected = j + test[l].roffset;
3937 else
3938 expected = test[l].red_expected[j];
3939 equal = compare_float(expected, test[l].red_received[j], 4096);
3940 ok(equal || (fabs(expected) < 1.0e-6f && fabs(test[l].red_received[j]) < 1.0e-6f),
3941 "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3942 l, order, j, expected, test[l].red_received[j]);
3944 if (test[l].green_received)
3946 if (j >= order * order)
3947 expected = j + test[l].goffset;
3948 else
3949 expected = test[l].green_expected[j];
3950 equal = compare_float(expected, test[l].green_received[j], 4096);
3951 ok(equal || (fabs(expected) < 1.0e-6f && fabs(test[l].green_received[j]) < 1.0e-6f),
3952 "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3953 l, order, j, expected, test[l].green_received[j]);
3956 if (test[l].blue_received)
3958 if (j >= order * order)
3959 expected = j + test[l].boffset;
3960 else
3961 expected = test[l].blue_expected[j];
3962 equal = compare_float(expected, test[l].blue_received[j], 4096);
3963 ok(equal || (fabs(expected) < 1.0e-6f && fabs(test[l].blue_received[j]) < 1.0e-6f),
3964 "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3965 l, order, j, expected, test[l].blue_received[j]);
3971 /* D3DXSHEvalSphericalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3972 hr = D3DXSHEvalSphericalLight(7, &dir, 17.4f, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3973 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3974 hr = D3DXSHEvalSphericalLight(0, &dir, 17.4f, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3975 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3976 hr = D3DXSHEvalSphericalLight(1, &dir, 17.4f, 1.0f, 2.0f, 3.0f, rout, gout, bout);
3977 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
3980 static void test_D3DXSHMultiply2(void)
3982 float a[20], b[20], c[20];
3983 unsigned int i;
3984 BOOL equal;
3986 /* D3DXSHMultiply2() only modifies the first 4 elements of the array. */
3987 static const float expected[20] =
3989 3.41859412f, 1.69821072f, 1.70385253f, 1.70949447f, 4.0f, 5.0f, 6.0f,
3990 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f,
3991 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f,
3994 for (i = 0; i < ARRAY_SIZE(a); ++i)
3996 a[i] = 1.0f + i / 100.0f;
3997 b[i] = 3.0f - i / 100.0f;
3998 c[i] = i;
4001 D3DXSHMultiply2(c, a, b);
4002 for (i = 0; i < ARRAY_SIZE(expected); ++i)
4004 equal = compare_float(c[i], expected[i], 2);
4005 ok(equal, "Expected[%u] = %.8e, received = %.8e.\n", i, expected[i], c[i]);
4009 static void test_D3DXSHMultiply3(void)
4011 float a[20], b[20], c[20];
4012 unsigned int i;
4013 BOOL equal;
4015 /* D3DXSHMultiply3() only modifies the first 9 elements of the array. */
4016 static const float expected[20] =
4018 7.81391382e+00f, 2.25605774e+00f, 5.94839954e+00f, 4.97089481e+00f, 2.89985824e+00f, 3.59894633e+00f,
4019 1.72657156e+00f, 5.57353783e+00f, 6.22063160e-01f, 9.00000000e+00f, 1.00000000e+01f, 1.10000000e+01f,
4020 1.20000000e+01f, 1.30000000e+01f, 1.40000000e+01f, 1.50000000e+01f, 1.60000000e+01f, 1.70000000e+01f,
4021 1.80000000e+01f, 1.90000000e+01f,
4023 static const float expected_aliased[20] =
4025 4.54092499e+02f, 2.12640405e+00f, 5.57040071e+00f, 1.53303785e+01f, 2.27960873e+01f, 4.36041260e+01f,
4026 4.27384138e+00f, 1.75772034e+02f, 2.37672729e+02f, 1.09000003e+00f, 1.10000002e+00f, 1.11000001e+00f,
4027 1.12000000e+00f, 1.13000000e+00f, 1.13999999e+00f, 1.14999998e+00f, 1.15999997e+00f, 1.16999996e+00f,
4028 1.17999995e+00f, 1.19000006e+00f,
4031 for (i = 0; i < ARRAY_SIZE(a); ++i)
4033 a[i] = 1.0f + i / 100.0f;
4034 b[i] = 3.0f - i / 100.0f;
4035 c[i] = i;
4038 D3DXSHMultiply3(c, a, b);
4039 for (i = 0; i < ARRAY_SIZE(expected); ++i)
4041 equal = compare_float(c[i], expected[i], 4);
4042 ok(equal, "Expected[%u] = %.8e, received = %.8e.\n", i, expected[i], c[i]);
4045 memcpy(c, a, sizeof(c));
4046 D3DXSHMultiply3(c, c, b);
4047 for (i = 0; i < ARRAY_SIZE(expected_aliased); ++i)
4049 equal = compare_float(c[i], expected_aliased[i], 34);
4050 ok(equal, "Expected[%u] = %.8e, received = %.8e.\n", i, expected_aliased[i], c[i]);
4054 static void test_D3DXSHMultiply4(void)
4056 float a[20], b[20], c[20];
4057 unsigned int i;
4058 BOOL equal;
4060 /* D3DXSHMultiply4() only modifies the first 16 elements of the array. */
4061 static const float expected[] =
4063 /* c, a, b */
4064 1.41825991e+01f, 2.61570334e+00f, 1.28286009e+01f, 9.82059574e+00f, 3.03969646e+00f, 4.53044176e+00f,
4065 5.82058382e+00f, 1.22498465e+01f, 2.19434643e+00f, 3.90015244e+00f, 5.41660881e+00f, 5.60181284e+00f,
4066 9.59981740e-01f, 7.03754997e+00f, 3.62523031e+00f, 4.63601470e-01f, 1.60000000e+01f, 1.70000000e+01f,
4067 1.80000000e+01f, 1.90000000e+01f,
4068 /* c, c, b */
4069 -2.11441266e+05f, -2.52915771e+03f, -1.00233936e+04f, -4.41277191e+02f, -1.63994385e+02f, -5.26305115e+02f,
4070 2.96361875e+04f, -3.93183081e+03f, -1.35771113e+04f, -3.97897388e+03f, -1.03303418e+04f, -1.37797871e+04f,
4071 -1.66851094e+04f, -4.49813750e+04f, -7.32697422e+04f, -9.52373359e+04f, 1.60000000e+01f, 1.70000000e+01f,
4072 1.80000000e+01f, 1.90000000e+01f,
4073 /* c, c, c */
4074 2.36682415e-01f, -7.17648506e-01f, -1.80499524e-01f, -7.71235973e-02f, 1.44830629e-01f, 5.73285699e-01f,
4075 -3.37959230e-01f, 5.56938872e-02f, -4.42100227e-01f, 1.47701755e-01f, -5.51566519e-02f, 8.43374059e-02f,
4076 1.79876596e-01f, 9.09878965e-03f, 2.32199892e-01f, 7.41420984e-02f, 1.60000002e+00f, 1.70000005e+00f,
4077 1.80000007e+00f, 1.89999998e+00f,
4080 for (i = 0; i < ARRAY_SIZE(a); ++i)
4082 a[i] = 1.0f + i / 100.0f;
4083 b[i] = 3.0f - i / 100.0f;
4084 c[i] = i;
4087 D3DXSHMultiply4(c, a, b);
4088 for (i = 0; i < ARRAY_SIZE(c); ++i)
4090 equal = compare_float(c[i], expected[i], 16);
4091 ok(equal, "Expected[%u] = %.8e, received = %.8e.\n", i, expected[i], c[i]);
4094 for (i = 0; i < ARRAY_SIZE(b); ++i)
4096 b[i] = 3.0f - i / 100.0f;
4097 c[i] = i;
4100 D3DXSHMultiply4(c, c, b);
4101 for (i = 0; i < ARRAY_SIZE(c); ++i)
4103 equal = compare_float(c[i], expected[20 + i], 32);
4104 ok(equal, "Expected[%u] = %.8e, received = %.8e.\n", i, expected[20 + i], c[i]);
4107 for (i = 0; i < ARRAY_SIZE(c); ++i)
4108 c[i] = 0.1f * i;
4110 D3DXSHMultiply4(c, c, c);
4111 for (i = 0; i < ARRAY_SIZE(c); ++i)
4113 equal = compare_float(c[i], expected[40 + i], 8);
4114 ok(equal, "Expected[%u] = %.8e, received = %.8e.\n", i, expected[40 + i], c[i]);
4118 static void test_D3DXSHRotate(void)
4120 float expected, in[49], out[49], *out_temp, *received_ptr;
4121 unsigned int i, j, l, order;
4122 D3DXMATRIX m[4];
4123 BOOL equal;
4125 static const float table[]=
4127 /* Rotation around the x-axis, π/2. */
4128 1.00999999e+00f, -3.00999999e+00f, 2.00999975e+00f, 4.01000023e+00f, -8.01000023e+00f, -6.00999928e+00f,
4129 -1.13078899e+01f, 5.00999975e+00f, -1.56583869e+00f, 1.09359801e+00f, -1.10099983e+01f, 1.98334141e+01f,
4130 -1.52681913e+01f, -1.90041180e+01f, -3.36488891e+00f, -9.56262684e+00f, 1.20996542e+01f, -2.72131383e-01f,
4131 3.02410126e+01f, 2.69199905e+01f, 3.92368774e+01f, -2.26324463e+01f, 6.70738792e+00f, -1.17682819e+01f,
4132 3.44367194e+00f, -6.07445812e+00f, 1.16183939e+01f, 1.52756083e+00f, 3.78963356e+01f, -5.69012184e+01f,
4133 4.74228935e+01f, 5.03915329e+01f, 1.06181908e+01f, 2.55010109e+01f, 4.92456071e-02f, 1.69833069e+01f,
4135 1.00999999e+00f, -3.00999999e+00f, -3.01000023e+00f, 4.01000023e+00f, -8.01000023e+00f, -6.00999928e+00f,
4136 -1.13078890e+01f, -8.01000023e+00f, 1.42979193e+01f,
4137 /* Rotation around the x-axis, -π/2. */
4138 1.00999999e+00f, 3.00999999e+00f, -2.01000023e+00f, 4.01000023e+00f, 8.01000023e+00f, -6.01000118e+00f,
4139 -1.13078880e+01f, -5.01000071e+00f, -1.56583774e+00f, -1.09359753e+00f, -1.10100021e+01f, -1.98334103e+01f,
4140 1.52681961e+01f, -1.90041142e+01f, 3.36489248e+00f, -9.56262398e+00f, -1.20996523e+01f, -2.72129118e-01f,
4141 -3.02410049e+01f, 2.69200020e+01f, 3.92368736e+01f, 2.26324520e+01f, 6.70738268e+00f, 1.17682877e+01f,
4142 3.44367099e+00f, 6.07445717e+00f, 1.16183996e+01f, -1.52756333e+00f, 3.78963509e+01f, 5.69011993e+01f,
4143 -4.74229126e+01f, 5.03915253e+01f, -1.06182041e+01f, 2.55009995e+01f, -4.92481887e-02f, 1.69833050e+01f,
4145 1.00999999e+00f, 3.00999999e+00f, -3.01000023e+00f, 4.01000023e+00f, 8.01000023e+00f, -6.01000118e+00f,
4146 -1.13078899e+01f, -8.01000023e+00f, 1.42979193e+01f,
4147 /* Yaw π/3, pitch π/4, roll π/5. */
4148 1.00999999e+00f, 4.94489908e+00f, 1.44230127e+00f, 1.62728095e+00f, 2.19220325e-01f, 1.05408239e+01f,
4149 -9.13690281e+00f, 2.76374960e+00f, -7.30904531e+00f, -5.87572050e+00f, 5.30312395e+00f, -8.68215370e+00f,
4150 -2.56833839e+01f, 1.68027866e+00f, -1.88083878e+01f, 7.65365601e+00f, 1.69391327e+01f, -1.73280182e+01f,
4151 1.46297951e+01f, -5.44671021e+01f, -1.22310352e+01f, -4.08985710e+00f, -9.44422245e+00f, 3.05603528e+00f,
4152 1.79257303e-01f, -1.00418749e+01f, 2.30900917e+01f, -2.31887093e+01f, 1.17270985e+01f, -6.51830902e+01f,
4153 4.86715775e+01f, -1.50732088e+01f, 3.87931709e+01f, -2.60395355e+01f, 6.19276857e+00f, -1.76722469e+01f,
4155 1.00999999e+00f, 4.94489908e+00f, -8.91142070e-01f, 4.60769463e+00f, 2.19218358e-01f, 1.07733250e+01f,
4156 -8.20476913e+00f, 1.35638294e+01f, -1.20077667e+01f,
4157 /* Rotation around the z-axis, π/6. */
4158 1.00999999e+00f, 3.74571109e+00f, 3.00999999e+00f, 2.46776199e+00f, 1.03078890e+01f, 9.20981312e+00f,
4159 7.01000023e+00f, 3.93186355e+00f, 1.66212186e-01f, 1.60099983e+01f, 1.85040417e+01f, 1.74059658e+01f,
4160 1.30100002e+01f, 6.12801647e+00f, -2.02994061e+00f, -1.00100012e+01f, 1.31542921e+01f, 2.40099964e+01f,
4161 2.94322453e+01f, 2.83341675e+01f, 2.10100021e+01f, 9.05622101e+00f, -4.95814323e+00f, -1.80100002e+01f,
4162 -2.72360935e+01f, -4.52033186e+00f, 1.68145428e+01f, 3.40099945e+01f, 4.30924950e+01f, 4.19944229e+01f,
4163 3.10100002e+01f, 1.27164707e+01f, -8.61839962e+00f, -2.80100021e+01f, -4.08963470e+01f, -4.41905708e+01f,
4165 1.00999999e+00f, 3.74571109e+00f, 3.00999999e+00f, 1.59990644e+00f, 1.03078890e+01f, 9.20981312e+00f,
4166 7.01000023e+00f, 2.33195710e+00f, -4.42189360e+00f,
4169 D3DXMatrixRotationX(&m[0], -D3DX_PI / 2.0f);
4170 D3DXMatrixRotationX(&m[1], D3DX_PI / 2.0f);
4171 D3DXMatrixRotationYawPitchRoll(&m[2], D3DX_PI / 3.0f, D3DX_PI / 4.0f, D3DX_PI / 5.0f);
4172 D3DXMatrixRotationZ(&m[3], D3DX_PI / 6.0f);
4174 for (l = 0; l < 2; l++)
4176 if (l == 0)
4177 out_temp = out;
4178 else
4179 out_temp = in;
4181 for (j = 0; j < ARRAY_SIZE(m); ++j)
4183 for (order = 0; order <= D3DXSH_MAXORDER; order++)
4185 for (i = 0; i < ARRAY_SIZE(out); ++i)
4187 out[i] = ( i + 1.0f ) * ( i + 1.0f );
4188 in[i] = i + 1.01f;
4191 received_ptr = D3DXSHRotate(out_temp, order, &m[j], in);
4192 ok(received_ptr == out_temp, "Order %u, expected %p, received %p.\n",
4193 order, out, received_ptr);
4195 for (i = 0; i < ARRAY_SIZE(out); ++i)
4197 if ((i > 0) && ((i >= order * order) || (order > D3DXSH_MAXORDER)))
4199 if (l == 0)
4200 expected = ( i + 1.0f ) * ( i + 1.0f );
4201 else
4202 expected = i + 1.01f;
4204 else if ((l == 0) || (order > 3))
4205 expected = table[45 * j + i];
4206 else
4207 expected = table[45 * j + 36 +i];
4208 equal = compare_float(out_temp[i], expected, 4096);
4209 ok(equal, "Order %u index %u, expected %.8e, received %.8e.\n",
4210 order, i, expected, out_temp[i]);
4217 static void test_D3DXSHRotateZ(void)
4219 float expected, in[49], out[49], *out_temp, *received_ptr;
4220 unsigned int end, i, j, l, order, square;
4221 BOOL equal;
4223 static const float angle[] = {D3DX_PI / 3.0f, -D3DX_PI / 3.0f, 4.0f * D3DX_PI / 3.0f};
4224 static const float table[] =
4226 /* Angle π/3. */
4227 1.00999999e+00f, 4.47776222e+00f, 3.00999999e+00f, 2.64288902e-01f, 5.29788828e+00f, 9.94186401e+00f,
4228 7.01000023e+00f, -1.19981313e+00f, -8.84378910e+00f, -1.00100021e+01f, 7.49403954e+00f, 1.81380157e+01f,
4229 1.30100002e+01f, -3.39596605e+00f, -1.70399418e+01f, -1.60099983e+01f, -3.01642971e+01f, -1.80100040e+01f,
4230 1.04222422e+01f, 2.90662193e+01f, 2.10100002e+01f, -6.32417059e+00f, -2.79681454e+01f, -2.40099983e+01f,
4231 2.22609901e+00f, -1.81805649e+01f, -4.38245506e+01f, -2.80100040e+01f, 1.40824928e+01f, 4.27264709e+01f,
4232 3.10100002e+01f, -9.98442554e+00f, -4.16283989e+01f, -3.40099945e+01f, 5.88635778e+00f, 4.05303307e+01f,
4234 1.00999999e+00f, 4.47776222e+00f, 0.00000000e+00f, -5.81678391e+00f, 5.29788828e+00f, 6.93686390e+00f,
4235 0.00000000e+00f, -9.01125050e+00f, -2.29405236e+00f, -1.00100021e+01f, 1.29990416e+01f, 1.21330166e+01f,
4236 0.00000000e+00f, -1.57612505e+01f, -5.62874842e+00f, 0.00000000e+00f, -3.01642971e+01f, -3.29017075e-06f,
4237 1.99272442e+01f, 1.90612202e+01f, 0.00000000e+00f, -2.47612514e+01f, -8.62874794e+00f, 0.00000000e+00f,
4238 -1.30615301e+01f, -1.81805649e+01f, -3.03195534e+01f, -4.66050415e-06f, 2.85874958e+01f, 2.77214737e+01f,
4239 0.00000000e+00f, -3.60112534e+01f, -1.23787460e+01f, 0.00000000e+00f, -1.31287584e+01f, -2.36172504e+01f,
4241 1.00999999e+00f, 3.97776222e+00f, 3.97776222e+00f, 1.11419535e+00f, 7.24579096e+00f, 1.05597591e+01f,
4242 1.05597591e+01f, -9.95159924e-01f, -4.67341393e-01f, 4.67339337e-01f, 1.27653713e+01f, 1.85157013e+01f,
4243 1.85157013e+01f, -1.79728663e+00f, 4.93915796e-01f, -4.93915856e-01f, -2.14123421e+01f, 2.14123383e+01f,
4244 9.22107220e+00f, 2.36717567e+01f, 2.36717567e+01f, 3.85019469e+00f, -2.04687271e+01f, 2.04687233e+01f,
4245 -1.06621027e+01f, -3.65166283e+01f, -1.20612450e+01f, 1.20612402e+01f, 2.25568752e+01f, 3.89999084e+01f,
4246 3.89999084e+01f, -3.48751247e-02f, -1.04279022e+01f, 1.04279003e+01f, -3.68382835e+01f, -2.76528034e+01f,
4247 /* Angle -π/3. */
4248 1.00999999e+00f, -2.46776247e+00f, 3.00999999e+00f, 3.74571109e+00f, -1.03078899e+01f, -3.93186426e+00f,
4249 7.01000023e+00f, 9.20981312e+00f, -1.66213632e-01f, -1.00099983e+01f, -1.85040436e+01f, -6.12801695e+00f,
4250 1.30100002e+01f, 1.74059658e+01f, 2.02993774e+00f, -1.60100021e+01f, 1.31543026e+01f, -1.80099964e+01f,
4251 -2.94322472e+01f, -9.05622101e+00f, 2.10100002e+01f, 2.83341694e+01f, 4.95813942e+00f, -2.40100021e+01f,
4252 -2.72360916e+01f, 4.41905823e+01f, 1.68145580e+01f, -2.80099964e+01f, -4.30924988e+01f, -1.27164736e+01f,
4253 3.10100002e+01f, 4.19944229e+01f, 8.61839294e+00f, -3.40100021e+01f, -4.08963470e+01f, -4.52030993e+00f,
4255 1.00999999e+00f, -2.46776247e+00f, 0.00000000e+00f, -3.20571756e+00f, -1.03078899e+01f, -6.93686390e+00f,
4256 0.00000000e+00f, -9.01125050e+00f, -4.46344614e+00f, -1.00099983e+01f, -1.29990416e+01f, -1.21330166e+01f,
4257 0.00000000e+00f, -1.57612505e+01f, -5.62874842e+00f, 0.00000000e+00f, 1.31543026e+01f, 3.29017075e-06f,
4258 -1.99272442e+01f, -1.90612202e+01f, 0.00000000e+00f, -2.47612514e+01f, -8.62874794e+00f, 0.00000000e+00f,
4259 -5.69598293e+00f, 4.41905823e+01f, 3.03195534e+01f, 4.66050415e-06f, -2.85874958e+01f, -2.77214737e+01f,
4260 0.00000000e+00f, -3.60112534e+01f, -1.23787460e+01f, 0.00000000e+00f, -1.31287584e+01f, -5.74052582e+01f,
4262 1.00999999e+00f, -2.96776223e+00f, -2.96776223e+00f, -6.09195352e-01f, -7.49829102e+00f, -1.06860094e+01f,
4263 -1.06860094e+01f, -1.18367157e+01f, 5.39078045e+00f, -5.39077854e+00f, -1.03036509e+01f, -1.72848415e+01f,
4264 -1.72848415e+01f, -1.75656433e+01f, 4.11427259e+00f, -4.11427307e+00f, 2.37164364e+01f, -2.37164326e+01f,
4265 -8.06902504e+00f, -2.30957317e+01f, -2.30957317e+01f, -1.85358467e+01f, -1.12711067e+01f, 1.12711039e+01f,
4266 -2.07248449e+00f, 3.01493301e+01f, 1.52448931e+01f, -1.52448883e+01f, -2.09650497e+01f, -3.82039986e+01f,
4267 -3.82039986e+01f, -3.72582664e+01f, 5.42667723e+00f, -5.42667913e+00f, -2.33967514e+01f, -9.90355873e+00f,
4268 /* Angle 4π/3. */
4269 1.00999999e+00f, -4.47776222e+00f, 3.00999999e+00f, -2.64288664e-01f, 5.29788685e+00f, -9.94186401e+00f,
4270 7.01000023e+00f, 1.19981360e+00f, -8.84378815e+00f, 1.00100040e+01f, 7.49403811e+00f, -1.81380157e+01f,
4271 1.30100002e+01f, 3.39596677e+00f, -1.70399399e+01f, 1.60099964e+01f, -3.01642933e+01f, 1.80100060e+01f,
4272 1.04222393e+01f, -2.90662193e+01f, 2.10100002e+01f, 6.32417202e+00f, -2.79681435e+01f, 2.40099926e+01f,
4273 2.22610497e+00f, 1.81805515e+01f, -4.38245430e+01f, 2.80100079e+01f, 1.40824890e+01f, -4.27264709e+01f,
4274 3.10100002e+01f, 9.98442745e+00f, -4.16283989e+01f, 3.40099869e+01f, 5.88636589e+00f, -4.05303268e+01f,
4276 1.00999999e+00f, -4.47776222e+00f, 0.00000000e+00f, -1.93892837e+00f, 5.29788685e+00f, -6.93686390e+00f,
4277 0.00000000e+00f, -3.00375080e+00f, -2.29405141e+00f, 1.00100040e+01f, 1.29990396e+01f, -1.21330166e+01f,
4278 0.00000000e+00f, -5.25375128e+00f, -5.62874699e+00f, -5.68378528e-06f, -3.01642933e+01f, 7.00829787e-06f,
4279 1.99272423e+01f, -1.90612202e+01f, 0.00000000e+00f, -8.25375271e+00f, -8.62874603e+00f, -4.09131496e-12f,
4280 -1.30615349e+01f, 1.81805515e+01f, -3.03195534e+01f, 9.92720470e-06f, 2.85874920e+01f, -2.77214737e+01f,
4281 0.00000000e+00f, -1.20037527e+01f, -1.23787422e+01f, -5.79531909e-12f, -1.31287651e+01f, -7.87240028e+00f,
4283 1.00999999e+00f, -3.97776222e+00f, -3.97776222e+00f, 2.86356640e+00f, 6.37110424e+00f, -1.01224155e+01f,
4284 -1.01224155e+01f, 1.05787458e+01f, -7.76929522e+00f, -7.76928997e+00f, 1.68836861e+01f, -2.05748577e+01f,
4285 -2.05748577e+01f, 2.49091301e+01f, -5.72616625e+00f, -5.72616386e+00f, -1.87962208e+01f, -1.87962112e+01f,
4286 2.93253498e+01f, -3.37238922e+01f, -3.37238922e+01f, 4.22584419e+01f, -4.85123205e+00f, -4.85122633e+00f,
4287 -2.53339314e+00f, 3.24522591e+01f, -4.65456696e+01f, -4.65456543e+01f, 5.18603249e+01f, -5.36516304e+01f,
4288 -5.36516304e+01f, 7.17381744e+01f, 4.44061565e+00f, 4.44062901e+00f, 2.58841743e+01f, -1.07481155e+01f,
4291 for (l = 0; l < 3; l++)
4293 if (l == 0)
4294 out_temp = out;
4295 else
4296 out_temp = &in[l - 1];
4298 if (l < 2)
4299 end = 49;
4300 else
4301 end = 48;
4303 for (j = 0; j < ARRAY_SIZE(angle); ++j)
4305 for (order = 0; order <= D3DXSH_MAXORDER + 1; order++)
4307 for (i = 0; i < ARRAY_SIZE(out); ++i)
4309 out[i] = ( i + 1.0f ) * ( i + 1.0f );
4310 in[i] = i + 1.01f;
4313 received_ptr = D3DXSHRotateZ(out_temp, order, angle[j], in);
4314 ok(received_ptr == out_temp, "angle %f, order %u, expected %p, received %p\n", angle[j], order, out_temp, received_ptr);
4316 for (i = 0; i < end; i++)
4318 /* order = 0 or order = 1 behaves like order = D3DXSH_MINORDER */
4319 square = (order <= D3DXSH_MINORDER) ? D3DXSH_MINORDER * D3DXSH_MINORDER : order * order;
4320 if (i >= square || ((order >= D3DXSH_MAXORDER) && (i >= D3DXSH_MAXORDER * D3DXSH_MAXORDER)))
4321 if (l > 0)
4322 expected = i + l + 0.01f;
4323 else
4324 expected = ( i + 1.0f ) * ( i + 1.0f );
4325 else
4326 expected = table[36 * (l + 3 * j) + i];
4327 equal = compare_float(expected, out_temp[i], 512);
4328 ok(equal || (fabs(expected) < 2.0e-5f && fabs(out_temp[i]) < 2.0e-5f),
4329 "angle %.8e, order %u index %u, expected %.8e, received %.8e.\n",
4330 angle[j], order, i, expected, out_temp[i]);
4337 static void test_D3DXSHScale(void)
4339 float a[49], b[49], expected, *received_array;
4340 unsigned int i, order;
4341 BOOL equal;
4343 for (i = 0; i < ARRAY_SIZE(a); ++i)
4345 a[i] = i;
4346 b[i] = i;
4349 for (order = 0; order <= D3DXSH_MAXORDER + 1; order++)
4351 received_array = D3DXSHScale(b, order, a, 5.0f);
4352 ok(received_array == b, "Expected %p, received %p\n", b, received_array);
4354 for (i = 0; i < ARRAY_SIZE(b); ++i)
4356 if (i < order * order)
4357 expected = 5.0f * a[i];
4358 /* D3DXSHScale does not modify the elements of the array after the order * order-th element */
4359 else
4360 expected = a[i];
4361 equal = compare_float(b[i], expected, 0);
4362 ok(equal, "order %u, element %u, expected %.8e, received %.8e.\n", order, i, expected, b[i]);
4367 START_TEST(math)
4369 D3DXColorTest();
4370 D3DXFresnelTest();
4371 D3DXMatrixTest();
4372 D3DXPlaneTest();
4373 D3DXQuaternionTest();
4374 D3DXVector2Test();
4375 D3DXVector3Test();
4376 D3DXVector4Test();
4377 test_matrix_stack();
4378 test_Matrix_AffineTransformation2D();
4379 test_Matrix_Decompose();
4380 test_Matrix_Transformation2D();
4381 test_D3DXVec_Array();
4382 test_D3DXFloat_Array();
4383 test_D3DXSHAdd();
4384 test_D3DXSHDot();
4385 test_D3DXSHEvalConeLight();
4386 test_D3DXSHEvalDirection();
4387 test_D3DXSHEvalDirectionalLight();
4388 test_D3DXSHEvalHemisphereLight();
4389 test_D3DXSHEvalSphericalLight();
4390 test_D3DXSHMultiply2();
4391 test_D3DXSHMultiply3();
4392 test_D3DXSHMultiply4();
4393 test_D3DXSHRotate();
4394 test_D3DXSHRotateZ();
4395 test_D3DXSHScale();