ReactOS  0.4.15-dev-1177-g6cb3b62
math.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 David Adam
3  * Copyright 2008 Luis Busquets
4  * Copyright 2008 Philip Nilsson
5  * Copyright 2008 Henri Verbeet
6  *
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.
11  *
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.
16  *
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
20  */
21 
22 #include "wine/test.h"
23 #include "d3dx9.h"
24 #include <math.h>
25 
26 static BOOL compare_float(float f, float g, unsigned int ulps)
27 {
28  int x = *(int *)&f;
29  int y = *(int *)&g;
30 
31  if (x < 0)
32  x = INT_MIN - x;
33  if (y < 0)
34  y = INT_MIN - y;
35 
36  if (abs(x - y) > ulps)
37  return FALSE;
38 
39  return TRUE;
40 }
41 
42 static BOOL compare_vec2(const D3DXVECTOR2 *v1, const D3DXVECTOR2 *v2, unsigned int ulps)
43 {
44  return compare_float(v1->x, v2->x, ulps) && compare_float(v1->y, v2->y, ulps);
45 }
46 
47 static BOOL compare_vec3(const D3DXVECTOR3 *v1, const D3DXVECTOR3 *v2, unsigned int ulps)
48 {
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);
52 }
53 
54 static BOOL compare_vec4(const D3DXVECTOR4 *v1, const D3DXVECTOR4 *v2, unsigned int ulps)
55 {
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);
60 }
61 
62 static BOOL compare_color(const D3DXCOLOR *c1, const D3DXCOLOR *c2, unsigned int ulps)
63 {
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);
68 }
69 
70 static BOOL compare_plane(const D3DXPLANE *p1, const D3DXPLANE *p2, unsigned int ulps)
71 {
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);
76 }
77 
78 static BOOL compare_quaternion(const D3DXQUATERNION *q1, const D3DXQUATERNION *q2, unsigned int ulps)
79 {
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);
84 }
85 
86 static BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2, unsigned int ulps)
87 {
88  unsigned int i, j;
89 
90  for (i = 0; i < 4; ++i)
91  {
92  for (j = 0; j < 4; ++j)
93  {
94  if (!compare_float(U(*m1).m[i][j], U(*m2).m[i][j], ulps))
95  return FALSE;
96  }
97  }
98 
99  return TRUE;
100 }
101 
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)
104 {
106  ok_(__FILE__, line)(equal,
107  "Got unexpected vector {%.8e, %.8e}, expected {%.8e, %.8e}.\n",
108  vector->x, vector->y, expected->x, expected->y);
109 }
110 
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)
113 {
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);
118 }
119 
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)
122 {
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);
127 }
128 
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)
131 {
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);
136 }
137 
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)
140 {
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);
145 }
146 
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)
150 {
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);
156 }
157 
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)
160 {
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]);
175 }
176 
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)
180 {
181  BOOL equal;
182  unsigned int i;
183 
184  for (i = 0; i < count; ++i)
185  {
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;
193  }
194 }
195 
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)
201 {
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;
206 }
207 
208 static void D3DXColorTest(void)
209 {
210  D3DXCOLOR color, color1, color2, expected, got;
211  LPD3DXCOLOR funcpointer;
212  FLOAT scale;
213 
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;
217 
218  scale = 0.3f;
219 
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);
231 
232 /*_______________D3DXColorAdjustContrast______*/
233  expected.r = 0.41f; expected.g = 0.575f; expected.b = 0.473f, expected.a = 0.93f;
235  expect_color(&expected, &got, 0);
236 
237 /*_______________D3DXColorAdjustSaturation______*/
238  expected.r = 0.486028f; expected.g = 0.651028f; expected.b = 0.549028f, expected.a = 0.93f;
240  expect_color(&expected, &got, 16);
241 
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);
253 
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);
265 
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);
285 
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);
295 
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);
307 }
308 
309 static void D3DXFresnelTest(void)
310 {
311  float fresnel;
312  BOOL equal;
313 
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);
317 }
318 
319 static void D3DXMatrixTest(void)
320 {
321  D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
322  BOOL expected, got, equal;
323  float angle, determinant;
324  D3DXMATRIX *funcpointer;
326  D3DXQUATERNION q, r;
327  D3DXVECTOR3 at, axis, eye, last;
329 
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;
336 
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;
343 
344  plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
345 
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;
348 
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;
353 
354  light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3;
355 
356  angle = D3DX_PI/3.0f;
357 
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);
366 
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);
371 
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);
375 
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);
379 
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);
387 
388  D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, NULL, &axis);
389  expect_matrix(&expectedmat, &gotmat, 0);
390 
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);
394 
395  D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, NULL, NULL);
396  expect_matrix(&expectedmat, &gotmat, 0);
397 
398 /*____________D3DXMatrixfDeterminant_____________*/
399  determinant = D3DXMatrixDeterminant(&mat);
400  equal = compare_float(determinant, -147888.0f, 0);
401  ok(equal, "Got unexpected determinant %.8e.\n", determinant);
402 
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  funcpointer = D3DXMatrixInverse(&gotmat,NULL,&mat2);
414  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
415 
416 /*____________D3DXMatrixIsIdentity______________*/
417  expected = FALSE;
418  memset(&mat3, 0, sizeof(mat3));
419  got = D3DXMatrixIsIdentity(&mat3);
420  ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
421  D3DXMatrixIdentity(&mat3);
422  expected = TRUE;
423  got = D3DXMatrixIsIdentity(&mat3);
424  ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
425  U(mat3).m[0][0] = 0.000009f;
426  expected = FALSE;
427  got = D3DXMatrixIsIdentity(&mat3);
428  ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
429  /* Test the NULL case */
430  expected = FALSE;
431  got = D3DXMatrixIsIdentity(NULL);
432  ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
433 
434 /*____________D3DXMatrixLookAtLH_______________*/
435  set_matrix(&expectedmat,
436  -0.82246518f, -0.40948939f, -0.39480308f, 0.0f,
437  -0.55585691f, 0.43128574f, 0.71064550f, 0.0f,
438  -0.12072885f, 0.80393475f, -0.58233452f, 0.0f,
439  4.4946337f, 0.80971903f, 10.060076f, 1.0f);
440  D3DXMatrixLookAtLH(&gotmat, &eye, &at, &axis);
441  expect_matrix(&expectedmat, &gotmat, 32);
442 
443 /*____________D3DXMatrixLookAtRH_______________*/
444  set_matrix(&expectedmat,
445  0.82246518f, -0.40948939f, 0.39480308f, 0.0f,
446  0.55585691f, 0.43128574f, -0.71064550f, 0.0f,
447  0.12072885f, 0.80393475f, 0.58233452f, 0.0f,
448  -4.4946337f, 0.80971903f, -10.060076f, 1.0f);
449  D3DXMatrixLookAtRH(&gotmat, &eye, &at, &axis);
450  expect_matrix(&expectedmat, &gotmat, 32);
451 
452 /*____________D3DXMatrixMultiply______________*/
453  set_matrix(&expectedmat,
454  73.0f, 193.0f, -197.0f, -77.0f,
455  231.0f, 551.0f, -489.0f, -169.0f,
456  239.0f, 523.0f, -400.0f, -116.0f,
457  -164.0f, -320.0f, 187.0f, 31.0f);
458  D3DXMatrixMultiply(&gotmat, &mat, &mat2);
459  expect_matrix(&expectedmat, &gotmat, 0);
460 
461 /*____________D3DXMatrixMultiplyTranspose____*/
462  set_matrix(&expectedmat,
463  73.0f, 231.0f, 239.0f, -164.0f,
464  193.0f, 551.0f, 523.0f, -320.0f,
465  -197.0f, -489.0f, -400.0f, 187.0f,
466  -77.0f, -169.0f, -116.0f, 31.0f);
467  D3DXMatrixMultiplyTranspose(&gotmat, &mat, &mat2);
468  expect_matrix(&expectedmat, &gotmat, 0);
469 
470 /*____________D3DXMatrixOrthoLH_______________*/
471  set_matrix(&expectedmat,
472  0.8f, 0.0f, 0.0f, 0.0f,
473  0.0f, 0.27027027f, 0.0f, 0.0f,
474  0.0f, 0.0f, -0.15151515f, 0.0f,
475  0.0f, 0.0f, -0.48484848f, 1.0f);
476  D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
477  expect_matrix(&expectedmat, &gotmat, 16);
478 
479 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
480  set_matrix(&expectedmat,
481  3.6363636f, 0.0f, 0.0f, 0.0f,
482  0.0f, 0.18018018f, 0.0f, 0.0f,
483  0.0f, 0.0f, -0.045662100f, 0.0f,
484  -1.7272727f, -0.56756757f, 0.42465753f, 1.0f);
485  D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
486  expect_matrix(&expectedmat, &gotmat, 32);
487 
488 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
489  set_matrix(&expectedmat,
490  3.6363636f, 0.0f, 0.0f, 0.0f,
491  0.0f, 0.18018018f, 0.0f, 0.0f,
492  0.0f, 0.0f, 0.045662100f, 0.0f,
493  -1.7272727f, -0.56756757f, 0.42465753f, 1.0f);
494  D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
495  expect_matrix(&expectedmat, &gotmat, 32);
496 
497 /*____________D3DXMatrixOrthoRH_______________*/
498  set_matrix(&expectedmat,
499  0.8f, 0.0f, 0.0f, 0.0f,
500  0.0f, 0.27027027f, 0.0f, 0.0f,
501  0.0f, 0.0f, 0.15151515f, 0.0f,
502  0.0f, 0.0f, -0.48484848f, 1.0f);
503  D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
504  expect_matrix(&expectedmat, &gotmat, 16);
505 
506 /*____________D3DXMatrixPerspectiveFovLH_______________*/
507  set_matrix(&expectedmat,
508  13.288858f, 0.0f, 0.0f, 0.0f,
509  0.0f, 9.9666444f, 0.0f, 0.0f,
510  0.0f, 0.0f, 0.78378378f, 1.0f,
511  0.0f, 0.0f, 1.8810811f, 0.0f);
512  D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
513  expect_matrix(&expectedmat, &gotmat, 4);
514 
515 /*____________D3DXMatrixPerspectiveFovRH_______________*/
516  set_matrix(&expectedmat,
517  13.288858f, 0.0f, 0.0f, 0.0f,
518  0.0f, 9.9666444f, 0.0f, 0.0f,
519  0.0f, 0.0f, -0.78378378f, -1.0f,
520  0.0f, 0.0f, 1.8810811f, 0.0f);
521  D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
522  expect_matrix(&expectedmat, &gotmat, 4);
523 
524 /*____________D3DXMatrixPerspectiveLH_______________*/
525  set_matrix(&expectedmat,
526  -24.0f, 0.0f, 0.0f, 0.0f,
527  0.0f, -6.4f, 0.0f, 0.0f,
528  0.0f, 0.0f, 0.78378378f, 1.0f,
529  0.0f, 0.0f, 1.8810811f, 0.0f);
530  D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
531  expect_matrix(&expectedmat, &gotmat, 4);
532 
533 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
534  set_matrix(&expectedmat,
535  11.636364f, 0.0f, 0.0f, 0.0f,
536  0.0f, 0.57657658f, 0.0f, 0.0f,
537  -1.7272727f, -0.56756757f, 0.84079602f, 1.0f,
538  0.0f, 0.0f, -2.6905473f, 0.0f);
539  D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
540  expect_matrix(&expectedmat, &gotmat, 8);
541 
542 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
543  set_matrix(&expectedmat,
544  11.636364f, 0.0f, 0.0f, 0.0f,
545  0.0f, 0.57657658f, 0.0f, 0.0f,
546  1.7272727f, 0.56756757f, -0.84079602f, -1.0f,
547  0.0f, 0.0f, -2.6905473f, 0.0f);
548  D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
549  expect_matrix(&expectedmat, &gotmat, 8);
550 
551 /*____________D3DXMatrixPerspectiveRH_______________*/
552  set_matrix(&expectedmat,
553  -24.0f, -0.0f, 0.0f, 0.0f,
554  0.0f, -6.4f, 0.0f, 0.0f,
555  0.0f, 0.0f, -0.78378378f, -1.0f,
556  0.0f, 0.0f, 1.8810811f, 0.0f);
557  D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
558  expect_matrix(&expectedmat, &gotmat, 4);
559 
560 /*____________D3DXMatrixReflect______________*/
561  set_matrix(&expectedmat,
562  0.30769235f, -0.23076922f, 0.92307687f, 0.0f,
563  -0.23076922, 0.92307693f, 0.30769232f, 0.0f,
564  0.92307687f, 0.30769232f, -0.23076922f, 0.0f,
565  1.6153846f, 0.53846157f, -2.1538463f, 1.0f);
566  D3DXMatrixReflect(&gotmat, &plane);
567  expect_matrix(&expectedmat, &gotmat, 32);
568 
569 /*____________D3DXMatrixRotationAxis_____*/
570  set_matrix(&expectedmat,
571  0.50847453f, 0.76380461f, 0.39756277f, 0.0f,
572  -0.81465209f, 0.57627118f, -0.065219201f, 0.0f,
573  -0.27891868f, -0.29071301f, 0.91525424f, 0.0f,
574  0.0f, 0.0f, 0.0f, 1.0f);
575  D3DXMatrixRotationAxis(&gotmat, &axis, angle);
576  expect_matrix(&expectedmat, &gotmat, 32);
577 
578 /*____________D3DXMatrixRotationQuaternion______________*/
579  set_matrix(&expectedmat,
580  -129.0f, -162.0f, -74.0f, 0.0f,
581  146.0f, -99.0f, -78.0f, 0.0f,
582  102.0f, -34.0f, -33.0f, 0.0f,
583  0.0f, 0.0f, 0.0f, 1.0f);
584  D3DXMatrixRotationQuaternion(&gotmat, &q);
585  expect_matrix(&expectedmat, &gotmat, 0);
586 
587 /*____________D3DXMatrixRotationX______________*/
588  set_matrix(&expectedmat,
589  1.0f, 0.0f, 0.0f, 0.0f,
590  0.0f, 0.5f, sqrt(3.0f)/2.0f, 0.0f,
591  0.0f, -sqrt(3.0f)/2.0f, 0.5f, 0.0f,
592  0.0f, 0.0f, 0.0f, 1.0f);
593  D3DXMatrixRotationX(&gotmat, angle);
594  expect_matrix(&expectedmat, &gotmat, 1);
595 
596 /*____________D3DXMatrixRotationY______________*/
597  set_matrix(&expectedmat,
598  0.5f, 0.0f, -sqrt(3.0f)/2.0f, 0.0f,
599  0.0f, 1.0f, 0.0f, 0.0f,
600  sqrt(3.0f)/2.0f, 0.0f, 0.5f, 0.0f,
601  0.0f, 0.0f, 0.0f, 1.0f);
602  D3DXMatrixRotationY(&gotmat, angle);
603  expect_matrix(&expectedmat, &gotmat, 1);
604 
605 /*____________D3DXMatrixRotationYawPitchRoll____*/
606  set_matrix(&expectedmat,
607  0.88877726f, 0.091874748f, -0.44903678f, 0.0f,
608  0.35171318f, 0.49148652f, 0.79670501f, 0.0f,
609  0.29389259f, -0.86602545f, 0.40450847f, 0.0f,
610  0.0f, 0.0f, 0.0f, 1.0f);
611  D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f * angle / 5.0f, angle, 3.0f * angle / 17.0f);
612  expect_matrix(&expectedmat, &gotmat, 64);
613 
614 /*____________D3DXMatrixRotationZ______________*/
615  set_matrix(&expectedmat,
616  0.5f, sqrt(3.0f)/2.0f, 0.0f, 0.0f,
617  -sqrt(3.0f)/2.0f, 0.5f, 0.0f, 0.0f,
618  0.0f, 0.0f, 1.0f, 0.0f,
619  0.0f, 0.0f, 0.0f, 1.0f);
620  D3DXMatrixRotationZ(&gotmat, angle);
621  expect_matrix(&expectedmat, &gotmat, 1);
622 
623 /*____________D3DXMatrixScaling______________*/
624  set_matrix(&expectedmat,
625  0.69f, 0.0f, 0.0f, 0.0f,
626  0.0f, 0.53f, 0.0f, 0.0f,
627  0.0f, 0.0f, 4.11f, 0.0f,
628  0.0f, 0.0f, 0.0f, 1.0f);
629  D3DXMatrixScaling(&gotmat, 0.69f, 0.53f, 4.11f);
630  expect_matrix(&expectedmat, &gotmat, 0);
631 
632 /*____________D3DXMatrixShadow______________*/
633  set_matrix(&expectedmat,
634  12.786773f, 5.0009613f, 4.3537784f, 3.7065949f,
635  1.8827150f, 8.8056154f, 1.4512594f, 1.2355317f,
636  -7.5308599f, -6.6679487f, 1.3335901f, -4.9421268f,
637  -13.179006f, -11.668910f, -10.158816f, -1.5100943f);
638  D3DXMatrixShadow(&gotmat, &light, &plane);
639  expect_matrix(&expectedmat, &gotmat, 8);
640 
641 /*____________D3DXMatrixTransformation______________*/
642  set_matrix(&expectedmat,
643  1.0f, 0.0f, 0.0f, 0.0f,
644  0.0f, 1.0f, 0.0f, 0.0f,
645  0.0f, 0.0f, 1.0f, 0.0f,
646  0.0f, 0.0f, 0.0f, 1.0f);
648  expect_matrix(&expectedmat, &gotmat, 0);
649 
650  set_matrix(&expectedmat,
651  1.0f, 0.0f, 0.0f, 0.0f,
652  0.0f, 1.0f, 0.0f, 0.0f,
653  0.0f, 0.0f, 1.0f, 0.0f,
654  9.7f, -8.6f, 1.3f, 1.0f);
656  expect_matrix(&expectedmat, &gotmat, 0);
657 
658  set_matrix(&expectedmat,
659  -0.2148f, 1.3116f, 0.4752f, 0.0f,
660  0.9504f, -0.8836f, 0.9244f, 0.0f,
661  1.0212f, 0.1936f, -1.3588f, 0.0f,
662  0.0f, 0.0f, 0.0f, 1.0f);
663  D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, NULL, &r, NULL);
664  expect_matrix(&expectedmat, &gotmat, 8);
665 
666  set_matrix(&expectedmat,
667  1.0f, 0.0f, 0.0f, 0.0f,
668  0.0f, 1.0f, 0.0f, 0.0f,
669  0.0f, 0.0f, 1.0f, 0.0f,
670  0.0f, 0.0f, 0.0f, 1.0f);
671  D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, NULL, NULL);
672  expect_matrix(&expectedmat, &gotmat, 0);
673 
674  set_matrix(&expectedmat,
675  1.0f, 0.0f, 0.0f, 0.0f,
676  0.0f, -3.0f, 0.0f, 0.0f,
677  0.0f, 0.0f, 7.0f, 0.0f,
678  0.0f, 0.0f, 0.0f, 1.0f);
679  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, NULL, NULL);
680  expect_matrix(&expectedmat, &gotmat, 0);
681 
682  set_matrix(&expectedmat,
683  1.0f, 0.0f, 0.0f, 0.0f,
684  0.0f, 1.0f, 0.0f, 0.0f,
685  0.0f, 0.0f, 1.0f, 0.0f,
686  0.0f, 0.0f, 0.0f, 1.0f);
687  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, NULL, NULL);
688  expect_matrix(&expectedmat, &gotmat, 0);
689 
690  set_matrix(&expectedmat,
691  1.0f, 0.0f, 0.0f, 0.0f,
692  0.0f, 1.0f, 0.0f, 0.0f,
693  0.0f, 0.0f, 1.0f, 0.0f,
694  0.0f, 0.0f, 0.0f, 1.0f);
695  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, NULL, NULL);
696  expect_matrix(&expectedmat, &gotmat, 0);
697 
698  set_matrix(&expectedmat,
699  -0.2148f, 1.3116f, 0.4752f, 0.0f,
700  0.9504f, -0.8836f, 0.9244f, 0.0f,
701  1.0212f, 0.1936f, -1.3588f, 0.0f,
702  9.7f, -8.6f, 1.3f, 1.0f);
703  D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, NULL, &r, &last);
704  expect_matrix(&expectedmat, &gotmat, 8);
705 
706  set_matrix(&expectedmat,
707  1.0f, 0.0f, 0.0f, 0.0f,
708  0.0f, 1.0f, 0.0f, 0.0f,
709  0.0f, 0.0f, 1.0f, 0.0f,
710  9.7f, -8.6f, 1.3f, 1.0f);
711  D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, NULL, &last);
712  expect_matrix(&expectedmat, &gotmat, 0);
713 
714  set_matrix(&expectedmat,
715  1.0f, 0.0f, 0.0f, 0.0f,
716  0.0f, -3.0f, 0.0f, 0.0f,
717  0.0f, 0.0f, 7.0f, 0.0f,
718  9.7f, -8.6f, 1.3f, 1.0f);
719  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, NULL, &last);
720  expect_matrix(&expectedmat, &gotmat, 0);
721 
722  set_matrix(&expectedmat,
723  1.0f, 0.0f, 0.0f, 0.0f,
724  0.0f, 1.0f, 0.0f, 0.0f,
725  0.0f, 0.0f, 1.0f, 0.0f,
726  9.7f, -8.6f, 1.3f, 1.0f);
727  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, NULL, &last);
728  expect_matrix(&expectedmat, &gotmat, 0);
729 
730  set_matrix(&expectedmat,
731  1.0f, 0.0f, 0.0f, 0.0f,
732  0.0f, 1.0f, 0.0f, 0.0f,
733  0.0f, 0.0f, 1.0f, 0.0f,
734  9.7f, -8.6f, 1.3f, 1.0f);
735  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, NULL, &last);
736  expect_matrix(&expectedmat, &gotmat, 0);
737 
738  set_matrix(&expectedmat,
739  -0.2148f, 1.3116f, 0.4752f, 0.0f,
740  0.9504f, -0.8836f, 0.9244f, 0.0f,
741  1.0212f, 0.1936f, -1.3588f, 0.0f,
742  8.5985f, -21.024f, 14.383499, 1.0f);
743  D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, &r, NULL);
744  expect_matrix(&expectedmat, &gotmat, 8);
745 
746  set_matrix(&expectedmat,
747  -0.2148f, 1.3116f, 0.4752f, 0.0f,
748  -2.8512f, 2.6508f, -2.7732f, 0.0f,
749  7.148399f, 1.3552f, -9.5116f, 0.0f,
750  0.0f, 0.0f, 0.0f, 1.0f);
751  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, &r, NULL);
752  expect_matrix(&expectedmat, &gotmat, 8);
753 
754  set_matrix(&expectedmat,
755  -0.2148f, 1.3116f, 0.4752f, 0.0f,
756  0.9504f, -0.8836f, 0.9244f, 0.0f,
757  1.0212f, 0.1936f, -1.3588f, 0.0f,
758  0.0f, 0.0f, 0.0f, 1.0f);
759  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, &r, NULL);
760  expect_matrix(&expectedmat, &gotmat, 8);
761 
762  set_matrix(&expectedmat,
763  -0.2148f, 1.3116f, 0.4752f, 0.0f,
764  0.9504f, -0.8836f, 0.9244f, 0.0f,
765  1.0212f, 0.1936f, -1.3588f, 0.0f,
766  0.0f, 0.0f, 0.0f, 1.0f);
767  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, &r, NULL);
768  expect_matrix(&expectedmat, &gotmat, 8);
769 
770  set_matrix(&expectedmat,
771  1.0f, 0.0f, 0.0f, 0.0f,
772  0.0f, -3.0f, 0.0f, 0.0f,
773  0.0f, 0.0f, 7.0f, 0.0f,
774  0.0f, 0.0f, 0.0f, 1.0f);
775  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, NULL, NULL);
776  expect_matrix(&expectedmat, &gotmat, 0);
777 
778  set_matrix(&expectedmat,
779  1.0f, 0.0f, 0.0f, 0.0f,
780  0.0f, 1.0f, 0.0f, 0.0f,
781  0.0f, 0.0f, 1.0f, 0.0f,
782  0.0f, 0.0f, 0.0f, 1.0f);
783  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, NULL, NULL);
784  expect_matrix(&expectedmat, &gotmat, 0);
785 
786  set_matrix(&expectedmat,
787  1.0f, 0.0f, 0.0f, 0.0f,
788  0.0f, 1.0f, 0.0f, 0.0f,
789  0.0f, 0.0f, 1.0f, 0.0f,
790  0.0f, 0.0f, 0.0f, 1.0f);
791  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, NULL, NULL);
792  expect_matrix(&expectedmat, &gotmat, 0);
793 
794  set_matrix(&expectedmat,
795  25521.0f, 39984.0f, 20148.0f, 0.0f,
796  39984.0f, 4933.0f, -3324.0f, 0.0f,
797  20148.0f, -3324.0f, -5153.0f, 0.0f,
798  0.0f, 0.0f, 0.0f, 1.0f);
799  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
800  expect_matrix(&expectedmat, &gotmat, 0);
801 
802  set_matrix(&expectedmat,
803  1.0f, 0.0f, 0.0f, 0.0f,
804  0.0f, -3.0f, 0.0f, 0.0f,
805  0.0f, 0.0f, 7.0f, 0.0f,
806  0.0f, 52.0f, 54.0f, 1.0f);
807  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, NULL, NULL);
808  expect_matrix(&expectedmat, &gotmat, 0);
809 
810  set_matrix(&expectedmat,
811  1.0f, 0.0f, 0.0f, 0.0f,
812  0.0f, 1.0f, 0.0f, 0.0f,
813  0.0f, 0.0f, 1.0f, 0.0f,
814  0.0f, 0.0f, 0.0f, 1.0f);
815  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, NULL, NULL);
816  expect_matrix(&expectedmat, &gotmat, 0);
817 
818  set_matrix(&expectedmat,
819  -0.2148f, 1.3116f, 0.4752f, 0.0f,
820  0.9504f, -0.8836f, 0.9244f, 0.0f,
821  1.0212f, 0.1936f, -1.3588f, 0.0f,
822  18.2985f, -29.624001f, 15.683499f, 1.0f);
823  D3DXMatrixTransformation(&gotmat, NULL, NULL, NULL, &eye, &r, &last);
824  expect_matrix(&expectedmat, &gotmat, 8);
825 
826  set_matrix(&expectedmat,
827  -0.2148f, 1.3116f, 0.4752f, 0.0f,
828  -2.8512f, 2.6508f, -2.7732f, 0.0f,
829  7.148399f, 1.3552f, -9.5116f, 0.0f,
830  9.7f, -8.6f, 1.3f, 1.0f);
831  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, NULL, &r, &last);
832  expect_matrix(&expectedmat, &gotmat, 8);
833 
834  set_matrix(&expectedmat,
835  -0.2148f, 1.3116f, 0.4752f, 0.0f,
836  0.9504f, -0.8836f, 0.9244f, 0.0f,
837  1.0212f, 0.1936f, -1.3588f, 0.0f,
838  9.7f, -8.6f, 1.3f, 1.0f);
839  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, NULL, &r, &last);
840  expect_matrix(&expectedmat, &gotmat, 8);
841 
842  set_matrix(&expectedmat,
843  -0.2148f, 1.3116f, 0.4752f, 0.0f,
844  0.9504f, -0.8836f, 0.9244f, 0.0f,
845  1.0212f, 0.1936f, -1.3588f, 0.0f,
846  9.7f, -8.6f, 1.3f, 1.0f);
847  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, NULL, &r, &last);
848  expect_matrix(&expectedmat, &gotmat, 8);
849 
850  set_matrix(&expectedmat,
851  1.0f, 0.0f, 0.0f, 0.0f,
852  0.0f, -3.0f, 0.0f, 0.0f,
853  0.0f, 0.0f, 7.0f, 0.0f,
854  9.7f, -8.6f, 1.3f, 1.0f);
855  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, NULL, &last);
856  expect_matrix(&expectedmat, &gotmat, 0);
857 
858  set_matrix(&expectedmat,
859  1.0f, 0.0f, 0.0f, 0.0f,
860  0.0f, 1.0f, 0.0f, 0.0f,
861  0.0f, 0.0f, 1.0f, 0.0f,
862  9.7f, -8.6f, 1.3f, 1.0f);
863  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, NULL, &last);
864  expect_matrix(&expectedmat, &gotmat, 0);
865 
866  set_matrix(&expectedmat,
867  1.0f, 0.0f, 0.0f, 0.0f,
868  0.0f, 1.0f, 0.0f, 0.0f,
869  0.0f, 0.0f, 1.0f, 0.0f,
870  9.7f, -8.6f, 1.3f, 1.0f);
871  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, NULL, &last);
872  expect_matrix(&expectedmat, &gotmat, 0);
873 
874  set_matrix(&expectedmat,
875  25521.0f, 39984.0f, 20148.0f, 0.0f,
876  39984.0f, 4933.0f, -3324.0f, 0.0f,
877  20148.0f, -3324.0f, -5153.0f, 0.0f,
878  9.7f, -8.6f, 1.3f, 1.0f);
879  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, &last);
880  expect_matrix(&expectedmat, &gotmat, 0);
881 
882  set_matrix(&expectedmat,
883  1.0f, 0.0f, 0.0f, 0.0f,
884  0.0f, -3.0f, 0.0f, 0.0f,
885  0.0f, 0.0f, 7.0f, 0.0f,
886  9.7f, 43.400002f, 55.299999f, 1.0f);
887  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, NULL, &last);
888  expect_matrix(&expectedmat, &gotmat, 0);
889 
890  set_matrix(&expectedmat,
891  1.0f, 0.0f, 0.0f, 0.0f,
892  0.0f, 1.0f, 0.0f, 0.0f,
893  0.0f, 0.0f, 1.0f, 0.0f,
894  9.7f, -8.6f, 1.3f, 1.0f);
895  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, NULL, &last);
896  expect_matrix(&expectedmat, &gotmat, 0);
897 
898  set_matrix(&expectedmat,
899  -0.2148f, 1.3116f, 0.4752f, 0.0f,
900  -2.8512f, 2.6508f, -2.7732f, 0.0f,
901  7.148399f, 1.3552f, -9.5116f, 0.0f,
902  8.5985f, -21.024f, 14.383499, 1.0f);
903  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, &r, NULL);
904  expect_matrix(&expectedmat, &gotmat, 8);
905 
906  set_matrix(&expectedmat,
907  -0.2148f, 1.3116f, 0.4752f, 0.0f,
908  0.9504f, -0.8836f, 0.9244f, 0.0f,
909  1.0212f, 0.1936f, -1.3588f, 0.0f,
910  8.5985f, -21.024f, 14.383499, 1.0f);
911  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, &r, NULL);
912  expect_matrix(&expectedmat, &gotmat, 8);
913 
914  set_matrix(&expectedmat,
915  -0.2148f, 1.3116f, 0.4752f, 0.0f,
916  0.9504f, -0.8836f, 0.9244f, 0.0f,
917  1.0212f, 0.1936f, -1.3588f, 0.0f,
918  8.5985f, -21.024f, 14.383499, 1.0f);
919  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, &r, NULL);
920  expect_matrix(&expectedmat, &gotmat, 8);
921 
922  set_matrix(&expectedmat,
923  53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
924  -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
925  -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
926  0.0f, 0.0f, 0.0f, 1.0f);
927  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, &r, NULL);
928  expect_matrix(&expectedmat, &gotmat, 32);
929 
930  set_matrix(&expectedmat,
931  -0.2148f, 1.3116f, 0.4752f, 0.0f,
932  -2.8512f, 2.6508f, -2.7732f, 0.0f,
933  7.148399f, 1.3552f, -9.5116f, 0.0f,
934  104.565598f, -35.492798f, -25.306400f, 1.0f);
935  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, &r, NULL);
936  expect_matrix(&expectedmat, &gotmat, 8);
937 
938  set_matrix(&expectedmat,
939  -0.2148f, 1.3116f, 0.4752f, 0.0f,
940  0.9504f, -0.8836f, 0.9244f, 0.0f,
941  1.0212f, 0.1936f, -1.3588f, 0.0f,
942  0.0f, 0.0f, 0.0f, 1.0f);
943  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, &r, NULL);
944  expect_matrix(&expectedmat, &gotmat, 8);
945 
946  set_matrix(&expectedmat,
947  25521.0f, 39984.0f, 20148.0f, 0.0f,
948  39984.0f, 4933.0f, -3324.0f, 0.0f,
949  20148.0f, -3324.0f, -5153.0f, 0.0f,
950  0.0f, 0.0f, 0.0f, 1.0f);
951  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, NULL, NULL);
952  expect_matrix(&expectedmat, &gotmat, 0);
953 
954  set_matrix(&expectedmat,
955  1.0f, 0.0f, 0.0f, 0.0f,
956  0.0f, -3.0f, 0.0f, 0.0f,
957  0.0f, 0.0f, 7.0f, 0.0f,
958  0.0f, 52.0f, 54.0f, 1.0f);
959  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, NULL, NULL);
960  expect_matrix(&expectedmat, &gotmat, 0);
961 
962  set_matrix(&expectedmat,
963  1.0f, 0.0f, 0.0f, 0.0f,
964  0.0f, 1.0f, 0.0f, 0.0f,
965  0.0f, 0.0f, 1.0f, 0.0f,
966  0.0f, 0.0f, 0.0f, 1.0f);
967  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, NULL, NULL);
968  expect_matrix(&expectedmat, &gotmat, 0);
969 
970  set_matrix(&expectedmat,
971  25521.0f, 39984.0f, 20148.0f, 0.0f,
972  39984.0f, 4933.0f, -3324.0f, 0.0f,
973  20148.0f, -3324.0f, -5153.0f, 0.0f,
974  -287420.0f, -14064.0f, 37122.0f, 1.0f);
975  D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, NULL, NULL);
976  expect_matrix(&expectedmat, &gotmat, 0);
977 
978  set_matrix(&expectedmat,
979  -0.2148f, 1.3116f, 0.4752f, 0.0f,
980  -2.8512f, 2.6508f, -2.7732f, 0.0f,
981  7.148399f, 1.3552f, -9.5116f, 0.0f,
982  18.2985f, -29.624001f, 15.683499f, 1.0f);
983  D3DXMatrixTransformation(&gotmat, NULL, NULL, &axis, &eye, &r, &last);
984  expect_matrix(&expectedmat, &gotmat, 8);
985 
986  set_matrix(&expectedmat,
987  -0.2148f, 1.3116f, 0.4752f, 0.0f,
988  0.9504f, -0.8836f, 0.9244f, 0.0f,
989  1.0212f, 0.1936f, -1.3588f, 0.0f,
990  18.2985f, -29.624001f, 15.683499f, 1.0f);
991  D3DXMatrixTransformation(&gotmat, NULL, &q, NULL, &eye, &r, &last);
992  expect_matrix(&expectedmat, &gotmat, 8);
993 
994  set_matrix(&expectedmat,
995  -0.2148f, 1.3116f, 0.4752f, 0.0f,
996  0.9504f, -0.8836f, 0.9244f, 0.0f,
997  1.0212f, 0.1936f, -1.3588f, 0.0f,
998  18.2985f, -29.624001f, 15.683499f, 1.0f);
999  D3DXMatrixTransformation(&gotmat, &at, NULL, NULL, &eye, &r, &last);
1000  expect_matrix(&expectedmat, &gotmat, 8);
1001 
1002  set_matrix(&expectedmat,
1003  53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1004  -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1005  -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1006  9.7f, -8.6f, 1.3f, 1.0f);
1007  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, &r, &last);
1008  expect_matrix(&expectedmat, &gotmat, 32);
1009 
1010  set_matrix(&expectedmat,
1011  -0.2148f, 1.3116f, 0.4752f, 0.0f,
1012  -2.8512f, 2.6508f, -2.7732f, 0.0f,
1013  7.148399f, 1.3552f, -9.5116f, 0.0f,
1014  114.265594f, -44.092796f, -24.006401f, 1.0f);
1015  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, NULL, &r, &last);
1016  expect_matrix(&expectedmat, &gotmat, 8);
1017 
1018  set_matrix(&expectedmat,
1019  -0.2148f, 1.3116f, 0.4752f, 0.0f,
1020  0.9504f, -0.8836f, 0.9244f, 0.0f,
1021  1.0212f, 0.1936f, -1.3588f, 0.0f,
1022  9.7f, -8.6f, 1.3f, 1.0f);
1023  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, NULL, &r, &last);
1024  expect_matrix(&expectedmat, &gotmat, 8);
1025 
1026  set_matrix(&expectedmat,
1027  25521.0f, 39984.0f, 20148.0f, 0.0f,
1028  39984.0f, 4933.0f, -3324.0f, 0.0f,
1029  20148.0f, -3324.0f, -5153.0f, 0.0f,
1030  9.7f, -8.6f, 1.3f, 1.0f);
1031  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, NULL, &last);
1032  expect_matrix(&expectedmat, &gotmat, 0);
1033 
1034  set_matrix(&expectedmat,
1035  1.0f, 0.0f, 0.0f, 0.0f,
1036  0.0f, -3.0f, 0.0f, 0.0f,
1037  0.0f, 0.0f, 7.0f, 0.0f,
1038  9.7f, 43.400002f, 55.299999f, 1.0f);
1039  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, NULL, &last);
1040  expect_matrix(&expectedmat, &gotmat, 0);
1041 
1042  set_matrix(&expectedmat,
1043  1.0f, 0.0f, 0.0f, 0.0f,
1044  0.0f, 1.0f, 0.0f, 0.0f,
1045  0.0f, 0.0f, 1.0f, 0.0f,
1046  9.7f, -8.6f, 1.3f, 1.0f);
1047  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, NULL, &last);
1048  expect_matrix(&expectedmat, &gotmat, 0);
1049 
1050  set_matrix(&expectedmat,
1051  25521.0f, 39984.0f, 20148.0f, 0.0f,
1052  39984.0f, 4933.0f, -3324.0f, 0.0f,
1053  20148.0f, -3324.0f, -5153.0f, 0.0f,
1054  -287410.3125f, -14072.599609f, 37123.300781f, 1.0f);
1055  D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, NULL, &last);
1056  expect_matrix(&expectedmat, &gotmat, 0);
1057 
1058  set_matrix(&expectedmat,
1059  53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1060  -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1061  -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1062  8.598499f, -21.024f, 14.383499f, 1.0f);
1063  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, &r, NULL);
1064  expect_matrix(&expectedmat, &gotmat, 32);
1065 
1066  set_matrix(&expectedmat,
1067  -0.2148f, 1.3116f, 0.4752f, 0.0f,
1068  -2.8512f, 2.6508f, -2.7732f, 0.0f,
1069  7.148399f, 1.3552f, -9.5116f, 0.0f,
1070  113.164093f, -56.5168f, -10.922897f, 1.0f);
1071  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, &r, NULL);
1072  expect_matrix(&expectedmat, &gotmat, 8);
1073 
1074  set_matrix(&expectedmat,
1075  -0.2148f, 1.3116f, 0.4752f, 0.0f,
1076  0.9504f, -0.8836f, 0.9244f, 0.0f,
1077  1.0212f, 0.1936f, -1.3588f, 0.0f,
1078  8.5985f, -21.024f, 14.383499, 1.0f);
1079  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, &r, NULL);
1080  expect_matrix(&expectedmat, &gotmat, 8);
1081 
1082  set_matrix(&expectedmat,
1083  53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1084  -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1085  -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1086  86280.34375f, -357366.3125f, -200024.125f, 1.0f);
1087  D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, &r, NULL);
1088  expect_matrix(&expectedmat, &gotmat, 32);
1089 
1090  set_matrix(&expectedmat,
1091  25521.0f, 39984.0f, 20148.0f, 0.0f,
1092  39984.0f, 4933.0f, -3324.0f, 0.0f,
1093  20148.0f, -3324.0f, -5153.0f, 0.0f,
1094  -287410.3125f, -14064.0f, 37122.0f, 1.0f);
1095  D3DXMatrixTransformation(&gotmat, &at, &q, &axis, &eye, NULL, NULL);
1096  expect_matrix(&expectedmat, &gotmat, 512);
1097 
1098  set_matrix(&expectedmat,
1099  53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1100  -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1101  -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1102  86280.34375f, -357366.3125f, -200009.75f, 1.0f);
1103  D3DXMatrixTransformation(&gotmat, &at, &q, &axis, &eye, &r, NULL);
1104  expect_matrix(&expectedmat, &gotmat, 2048);
1105 
1106  set_matrix(&expectedmat,
1107  25521.0f, 39984.0f, 20148.0f, 0.0f,
1108  39984.0f, 4933.0f, -3324.0f, 0.0f,
1109  20148.0f, -3324.0f, -5153.0f, 0.0f,
1110  -287410.3125f, -14072.599609f, 37123.300781f, 1.0f);
1111  D3DXMatrixTransformation(&gotmat, &at, &q, &axis, &eye, NULL, &last);
1112  expect_matrix(&expectedmat, &gotmat, 0);
1113 
1114  set_matrix(&expectedmat,
1115  53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1116  -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1117  -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1118  86290.046875f, -357374.90625f, -200022.828125f, 1.0f);
1119  D3DXMatrixTransformation(&gotmat, &at, &q, &axis, NULL, &r, &last);
1120  expect_matrix(&expectedmat, &gotmat, 32);
1121 
1122  set_matrix(&expectedmat,
1123  -0.21480007f, 1.3116000f, 0.47520003f, 0.0f,
1124  0.95040143f, -0.88360137f, 0.92439979f, 0.0f,
1125  1.0212044f, 0.19359307f, -1.3588026f, 0.0f,
1126  18.298532f, -29.624001f, 15.683499f, 1.0f);
1127  D3DXMatrixTransformation(&gotmat, &at, &q, NULL, &eye, &r, &last);
1128  expect_matrix(&expectedmat, &gotmat, 512);
1129 
1130  set_matrix(&expectedmat,
1131  -0.2148f, 1.3116f, 0.4752f, 0.0f,
1132  -2.8512f, 2.6508f, -2.7732f, 0.0f,
1133  7.148399f, 1.3552f, -9.5116f, 0.0f,
1134  122.86409f, -65.116798f, -9.622897f, 1.0f);
1135  D3DXMatrixTransformation(&gotmat, &at, NULL, &axis, &eye, &r, &last);
1136  expect_matrix(&expectedmat, &gotmat, 8);
1137 
1138  set_matrix(&expectedmat,
1139  53094.015625f, 2044.133789f, 21711.687500f, 0.0f,
1140  -7294.705078f, 47440.683594f, 28077.113281, 0.0f,
1141  -12749.161133f, 28365.580078f, 13503.520508f, 0.0f,
1142  18.2985f, -29.624001f, 15.683499f, 1.0f);
1143  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, &eye, &r, &last);
1144  expect_matrix(&expectedmat, &gotmat, 32);
1145 
1146  q.x = 1.0f, q.y = 1.0f, q.z = 1.0f, q.w = 1.0f,
1147  axis.x = 1.0f, axis.y = 1.0f, axis.z = 2.0f,
1148 
1149  set_matrix(&expectedmat,
1150  41.0f, -12.0f, -24.0f, 0.0f,
1151  -12.0f, 25.0f, -12.0f, 0.0f,
1152  -24.0f, -12.0f, 34.0f, 0.0f,
1153  0.0f, 0.0f, 0.0f, 1.0f);
1154  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1155  expect_matrix(&expectedmat, &gotmat, 0);
1156 
1157  q.x = 1.0f, q.y = 1.0f, q.z = 1.0f, q.w = 1.0f,
1158  axis.x = 1.0f, axis.y = 1.0f, axis.z = 3.0f,
1159 
1160  set_matrix(&expectedmat,
1161  57.0f, -12.0f, -36.0f, 0.0f,
1162  -12.0f, 25.0f, -12.0f, 0.0f,
1163  -36.0f, -12.0f, 43.0f, 0.0f,
1164  0.0f, 0.0f, 0.0f, 1.0f);
1165  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1166  expect_matrix(&expectedmat, &gotmat, 0);
1167 
1168  q.x = 1.0f, q.y = 1.0f, q.z = 1.0f, q.w = 0.0f,
1169  axis.x = 1.0f, axis.y = 1.0f, axis.z = 3.0f,
1170 
1171  set_matrix(&expectedmat,
1172  25.0f, 0.0f, -20.0f, 0.0f,
1173  0.0f, 25.0f, -20.0f, 0.0f,
1174  -20.0f, -20.0f, 35.0f, 0.0f,
1175  0.0f, 0.0f, 0.0f, 1.0f);
1176  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1177  expect_matrix(&expectedmat, &gotmat, 0);
1178 
1179  q.x = 1.0f, q.y = 1.0f, q.z = 0.0f, q.w = 0.0f,
1180  axis.x = 1.0f, axis.y = 1.0f, axis.z = 3.0f,
1181 
1182  set_matrix(&expectedmat,
1183  5.0f, -4.0f, 0.0f, 0.0f,
1184  -4.0f, 5.0f, 0.0f, 0.0f,
1185  0.0f, 0.0f, 27.0f, 0.0f,
1186  0.0f, 0.0f, 0.0f, 1.0f);
1187  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1188  expect_matrix(&expectedmat, &gotmat, 0);
1189 
1190  q.x = 1.0f, q.y = 0.0f, q.z = 0.0f, q.w = 0.0f,
1191  axis.x = 5.0f, axis.y = 2.0f, axis.z = 1.0f,
1192 
1193  set_matrix(&expectedmat,
1194  5.0f, 0.0f, 0.0f, 0.0f,
1195  0.0f, 2.0f, 0.0f, 0.0f,
1196  0.0f, 0.0f, 1.0f, 0.0f,
1197  0.0f, 0.0f, 0.0f, 1.0f);
1198  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1199  expect_matrix(&expectedmat, &gotmat, 0);
1200 
1201  q.x = 1.0f, q.y = 0.0f, q.z = 0.0f, q.w = 0.0f,
1202  axis.x = 1.0f, axis.y = 4.0f, axis.z = 1.0f,
1203 
1204  set_matrix(&expectedmat,
1205  1.0f, 0.0f, 0.0f, 0.0f,
1206  0.0f, 4.0f, 0.0f, 0.0f,
1207  0.0f, 0.0f, 1.0f, 0.0f,
1208  0.0f, 0.0f, 0.0f, 1.0f);
1209  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1210  expect_matrix(&expectedmat, &gotmat, 0);
1211 
1212  q.x = 0.0f, q.y = 1.0f, q.z = 0.0f, q.w = 0.0f,
1213  axis.x = 1.0f, axis.y = 4.0f, axis.z = 1.0f,
1214 
1215  set_matrix(&expectedmat,
1216  1.0f, 0.0f, 0.0f, 0.0f,
1217  0.0f, 4.0f, 0.0f, 0.0f,
1218  0.0f, 0.0f, 1.0f, 0.0f,
1219  0.0f, 0.0f, 0.0f, 1.0f);
1220  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1221  expect_matrix(&expectedmat, &gotmat, 0);
1222 
1223  q.x = 1.0f, q.y = 0.0f, q.z = 0.0f, q.w = 1.0f,
1224  axis.x = 1.0f, axis.y = 4.0f, axis.z = 1.0f,
1225 
1226  set_matrix(&expectedmat,
1227  1.0f, 0.0f, 0.0f, 0.0f,
1228  0.0f, 8.0f, -6.0f, 0.0f,
1229  0.0f, -6.0f, 17.0f, 0.0f,
1230  0.0f, 0.0f, 0.0f, 1.0f);
1231  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1232  expect_matrix(&expectedmat, &gotmat, 0);
1233 
1234  q.x = 1.0f, q.y = 0.0f, q.z = 0.0f, q.w = 1.0f,
1235  axis.x = 0.0f, axis.y = 4.0f, axis.z = 0.0f,
1236 
1237  set_matrix(&expectedmat,
1238  0.0f, 0.0f, 0.0f, 0.0f,
1239  0.0f, 4.0f, -8.0f, 0.0f,
1240  0.0f, -8.0f, 16.0f, 0.0f,
1241  0.0f, 0.0f, 0.0f, 1.0f);
1242  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1243  expect_matrix(&expectedmat, &gotmat, 0);
1244 
1245  q.x = 0.0f, q.y = 1.0f, q.z = 0.0f, q.w = 1.0f,
1246  axis.x = 1.0f, axis.y = 4.0f, axis.z = 1.0f,
1247 
1248  set_matrix(&expectedmat,
1249  5.0f, 0.0f, 0.0f, 0.0f,
1250  0.0f, 4.0f, 0.0f, 0.0f,
1251  0.0f, 0.0f, 5.0f, 0.0f,
1252  0.0f, 0.0f, 0.0f, 1.0f);
1253  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1254  expect_matrix(&expectedmat, &gotmat, 0);
1255 
1256  q.x = 1.0f, q.y = 0.0f, q.z = 0.0f, q.w = 0.0f,
1257  axis.x = 1.0f, axis.y = 1.0f, axis.z = 3.0f,
1258 
1259  set_matrix(&expectedmat,
1260  1.0f, 0.0f, 0.0f, 0.0f,
1261  0.0f, 1.0f, 0.0f, 0.0f,
1262  0.0f, 0.0f, 3.0f, 0.0f,
1263  0.0f, 0.0f, 0.0f, 1.0f);
1264  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1265  expect_matrix(&expectedmat, &gotmat, 0);
1266 
1267  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1268  axis.x = 3.0f, axis.y = 3.0f, axis.z = 3.0f,
1269 
1270  set_matrix(&expectedmat,
1271  3796587.0f, -1377948.0f, -1589940.0f, 0.0f,
1272  -1377948.0f, 3334059.0f, -1879020.0f, 0.0f,
1273  -1589940.0f, -1879020.0f, 2794443.0f, 0.0f,
1274  0.0f, 0.0f, 0.0f, 1.0f);
1275  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1276  expect_matrix(&expectedmat, &gotmat, 0);
1277 
1278  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1279  axis.x = 1.0f, axis.y = 1.0f, axis.z = 1.0f,
1280 
1281  set_matrix(&expectedmat,
1282  1265529.0f, -459316.0f, -529980.0f, 0.0f,
1283  -459316.0f, 1111353.0f, -626340.0f, 0.0f,
1284  -529980.0f, -626340.0f, 931481.0f, 0.0f,
1285  0.0f, 0.0f, 0.0f, 1.0f);
1286  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1287  expect_matrix(&expectedmat, &gotmat, 0);
1288 
1289  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1290  axis.x = 1.0f, axis.y = 1.0f, axis.z = 3.0f,
1291 
1292  set_matrix(&expectedmat,
1293  2457497.0f, -434612.0f, -1423956.0f, 0.0f,
1294  -434612.0f, 1111865.0f, -644868.0f, 0.0f,
1295  -1423956.0f, -644868.0f, 1601963.0f, 0.0f,
1296  0.0f, 0.0f, 0.0f, 1.0f);
1297  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1298  expect_matrix(&expectedmat, &gotmat, 0);
1299 
1300  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1301  axis.x = 0.0f, axis.y = 0.0f, axis.z = 3.0f,
1302 
1303  set_matrix(&expectedmat,
1304  1787952.0f, 37056.0f, -1340964.0f, 0.0f,
1305  37056.0f, 768.0f, -27792.0f, 0.0f,
1306  -1340964.0f, -27792.0f, 1005723.0f, 0.0f,
1307  0.0f, 0.0f, 0.0f, 1.0f);
1308  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1309  expect_matrix(&expectedmat, &gotmat, 0);
1310 
1311  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1312  axis.x = 0.0f, axis.y = 0.0f, axis.z = 1.0f,
1313 
1314  set_matrix(&expectedmat,
1315  595984.0f, 12352.0f, -446988.0f, 0.0f,
1316  12352.0f, 256.0f, -9264.0f, 0.0f,
1317  -446988.0f, -9264.0f, 335241.0f, 0.0f,
1318  0.0f, 0.0f, 0.0f, 1.0f);
1319  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1320  expect_matrix(&expectedmat, &gotmat, 0);
1321 
1322  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1323  axis.x = 0.0f, axis.y = 3.0f, axis.z = 0.0f,
1324 
1325  set_matrix(&expectedmat,
1326  150528.0f, 464352.0f, -513408.0f, 0.0f,
1327  464352.0f, 1432443.0f, -1583772.0f, 0.0f,
1328  -513408.0f, -1583772.0f, 1751088.0f, 0.0f,
1329  0.0f, 0.0f, 0.0f, 1.0f);
1330  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1331  expect_matrix(&expectedmat, &gotmat, 0);
1332 
1333  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1334  axis.x = 0.0f, axis.y = 1.0f, axis.z = 0.0f,
1335 
1336  set_matrix(&expectedmat,
1337  50176.0f, 154784.0f, -171136.0f, 0.0f,
1338  154784.0f, 477481.0f, -527924.0f, 0.0f,
1339  -171136.0f, -527924.0f, 583696.0f, 0.0f,
1340  0.0f, 0.0f, 0.0f, 1.0f);
1341  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1342  expect_matrix(&expectedmat, &gotmat, 0);
1343 
1344  q.x = 11.0f, q.y = 13.0f, q.z = 15.0f, q.w = 17.0f,
1345  axis.x = 1.0f, axis.y = 0.0f, axis.z = 0.0f,
1346 
1347  set_matrix(&expectedmat,
1348  619369.0f, -626452.0f, 88144.0f, 0.0f,
1349  -626452.0f, 633616.0f, -89152.0f, 0.0f,
1350  88144.0f, -89152, 12544.0f, 0.0f,
1351  0.0f, 0.0f, 0.0f, 1.0f);
1352  D3DXMatrixTransformation(&gotmat, NULL, &q, &axis, NULL, NULL, NULL);
1353  expect_matrix(&expectedmat, &gotmat, 0);
1354 
1355 /*____________D3DXMatrixTranslation______________*/
1356  set_matrix(&expectedmat,
1357  1.0f, 0.0f, 0.0f, 0.0f,
1358  0.0f, 1.0f, 0.0f, 0.0f,
1359  0.0f, 0.0f, 1.0f, 0.0f,
1360  0.69f, 0.53f, 4.11f, 1.0f);
1361  D3DXMatrixTranslation(&gotmat, 0.69f, 0.53f, 4.11f);
1362  expect_matrix(&expectedmat, &gotmat, 0);
1363 
1364 /*____________D3DXMatrixTranspose______________*/
1365  set_matrix(&expectedmat,
1366  10.0f, 11.0f, 19.0f, 2.0f,
1367  5.0f, 20.0f, -21.0f, 3.0f,
1368  7.0f, 16.0f, 30.f, -4.0f,
1369  8.0f, 33.0f, 43.0f, -40.0f);
1370  D3DXMatrixTranspose(&gotmat, &mat);
1371  expect_matrix(&expectedmat, &gotmat, 0);
1372 }
1373 
1374 static void D3DXPlaneTest(void)
1375 {
1376  D3DXMATRIX mat;
1377  D3DXPLANE expectedplane, gotplane, nulplane, plane;
1378  D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
1379  LPD3DXVECTOR3 funcpointer;
1380  D3DXVECTOR4 vec;
1381  FLOAT expected, got;
1382 
1383  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1384  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1385  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1386  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1387  U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
1388  U(mat).m[3][3] = -40.0f;
1389 
1390  plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
1391 
1392  vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
1393 
1394 /*_______________D3DXPlaneDot________________*/
1395  expected = 42.0f;
1396  got = D3DXPlaneDot(&plane,&vec),
1397  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1398  expected = 0.0f;
1399  got = D3DXPlaneDot(NULL,&vec),
1400  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1401  expected = 0.0f;
1402  got = D3DXPlaneDot(NULL,NULL),
1403  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1404 
1405 /*_______________D3DXPlaneDotCoord________________*/
1406  expected = -28.0f;
1407  got = D3DXPlaneDotCoord(&plane,&vec),
1408  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1409  expected = 0.0f;
1410  got = D3DXPlaneDotCoord(NULL,&vec),
1411  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1412  expected = 0.0f;
1413  got = D3DXPlaneDotCoord(NULL,NULL),
1414  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1415 
1416 /*_______________D3DXPlaneDotNormal______________*/
1417  expected = -35.0f;
1418  got = D3DXPlaneDotNormal(&plane,&vec),
1419  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1420  expected = 0.0f;
1421  got = D3DXPlaneDotNormal(NULL,&vec),
1422  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1423  expected = 0.0f;
1424  got = D3DXPlaneDotNormal(NULL,NULL),
1425  ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
1426 
1427 /*_______________D3DXPlaneFromPointNormal_______*/
1428  vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
1429  vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
1430  expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
1431  D3DXPlaneFromPointNormal(&gotplane, &vec1, &vec2);
1432  expect_plane(&expectedplane, &gotplane, 0);
1433  gotplane.a = vec2.x; gotplane.b = vec2.y; gotplane.c = vec2.z;
1434  D3DXPlaneFromPointNormal(&gotplane, &vec1, (D3DXVECTOR3 *)&gotplane);
1435  expect_plane(&expectedplane, &gotplane, 0);
1436  gotplane.a = vec1.x; gotplane.b = vec1.y; gotplane.c = vec1.z;
1437  expectedplane.d = -1826.0f;
1438  D3DXPlaneFromPointNormal(&gotplane, (D3DXVECTOR3 *)&gotplane, &vec2);
1439  expect_plane(&expectedplane, &gotplane, 0);
1440 
1441 /*_______________D3DXPlaneFromPoints_______*/
1442  vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
1443  vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
1444  vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
1445  expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
1446  D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
1447  expect_plane(&expectedplane, &gotplane, 64);
1448 
1449 /*_______________D3DXPlaneIntersectLine___________*/
1450  vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
1451  vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
1452  expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
1453  D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
1454  expect_vec3(&expectedvec, &gotvec, 1);
1455  /* Test a parallel line */
1456  vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
1457  vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
1458  expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
1459  funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
1460  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1461 
1462 /*_______________D3DXPlaneNormalize______________*/
1463  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);
1464  D3DXPlaneNormalize(&gotplane, &plane);
1465  expect_plane(&expectedplane, &gotplane, 2);
1466  nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
1467  expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
1468  D3DXPlaneNormalize(&gotplane, &nulplane);
1469  expect_plane(&expectedplane, &gotplane, 0);
1470 
1471 /*_______________D3DXPlaneTransform____________*/
1472  expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
1473  D3DXPlaneTransform(&gotplane,&plane,&mat);
1474  expect_plane(&expectedplane, &gotplane, 0);
1475 }
1476 
1477 static void D3DXQuaternionTest(void)
1478 {
1479  D3DXMATRIX mat;
1480  D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, smallq, smallr, q, r, s, t, u;
1481  BOOL expectedbool, gotbool, equal;
1482  float angle, got, scale, scale2;
1483  LPD3DXQUATERNION funcpointer;
1484  D3DXVECTOR3 axis, expectedvec;
1485 
1486  nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
1487  q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
1488  r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
1489  t.x = -1111.0f, t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
1490  u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
1491  smallq.x = 0.1f; smallq.y = 0.2f; smallq.z= 0.3f; smallq.w = 0.4f;
1492  smallr.x = 0.5f; smallr.y = 0.6f; smallr.z= 0.7f; smallr.w = 0.8f;
1493 
1494  scale = 0.3f;
1495  scale2 = 0.78f;
1496 
1497 /*_______________D3DXQuaternionBaryCentric________________________*/
1498  expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
1499  D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
1500  expect_quaternion(&expectedquat, &gotquat, 1);
1501 
1502 /*_______________D3DXQuaternionConjugate________________*/
1503  expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
1504  D3DXQuaternionConjugate(&gotquat,&q);
1505  expect_quaternion(&expectedquat, &gotquat, 0);
1506  /* Test the NULL case */
1507  funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
1508  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1509  funcpointer = D3DXQuaternionConjugate(NULL,NULL);
1510  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1511 
1512 /*_______________D3DXQuaternionDot______________________*/
1513  got = D3DXQuaternionDot(&q,&r);
1514  equal = compare_float(got, 55.0f, 0);
1515  ok(equal, "Got unexpected dot %.8e.\n", got);
1516  /* Tests the case NULL */
1517  got = D3DXQuaternionDot(NULL,&r);
1518  equal = compare_float(got, 0.0f, 0);
1519  ok(equal, "Got unexpected dot %.8e.\n", got);
1520  got = D3DXQuaternionDot(NULL,NULL);
1521  equal = compare_float(got, 0.0f, 0);
1522  ok(equal, "Got unexpected dot %.8e.\n", got);
1523 
1524 /*_______________D3DXQuaternionExp______________________________*/
1525  expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
1526  D3DXQuaternionExp(&gotquat,&q);
1527  expect_quaternion(&expectedquat, &gotquat, 16);
1528  /* Test the null quaternion */
1529  expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
1530  D3DXQuaternionExp(&gotquat,&nul);
1531  expect_quaternion(&expectedquat, &gotquat, 0);
1532  /* Test the case where the norm of the quaternion is <1 */
1533  Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
1534  expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
1535  D3DXQuaternionExp(&gotquat,&Nq1);
1536  expect_quaternion(&expectedquat, &gotquat, 8);
1537 
1538 /*_______________D3DXQuaternionIdentity________________*/
1539  expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
1540  D3DXQuaternionIdentity(&gotquat);
1541  expect_quaternion(&expectedquat, &gotquat, 0);
1542  /* Test the NULL case */
1543  funcpointer = D3DXQuaternionIdentity(NULL);
1544  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1545 
1546 /*_______________D3DXQuaternionInverse________________________*/
1547  expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
1548  D3DXQuaternionInverse(&gotquat,&q);
1549  expect_quaternion(&expectedquat, &gotquat, 0);
1550 
1551  expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 10.0f;
1552  D3DXQuaternionInverse(&gotquat,&gotquat);
1553  expect_quaternion(&expectedquat, &gotquat, 1);
1554 
1555 
1556 /*_______________D3DXQuaternionIsIdentity________________*/
1557  s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
1558  expectedbool = TRUE;
1559  gotbool = D3DXQuaternionIsIdentity(&s);
1560  ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
1561  s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
1562  expectedbool = FALSE;
1563  gotbool = D3DXQuaternionIsIdentity(&q);
1564  ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
1565  /* Test the NULL case */
1566  gotbool = D3DXQuaternionIsIdentity(NULL);
1567  ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
1568 
1569 /*_______________D3DXQuaternionLength__________________________*/
1570  got = D3DXQuaternionLength(&q);
1571  equal = compare_float(got, 11.0f, 0);
1572  ok(equal, "Got unexpected length %.8e.\n", got);
1573  /* Tests the case NULL. */
1574  got = D3DXQuaternionLength(NULL);
1575  equal = compare_float(got, 0.0f, 0);
1576  ok(equal, "Got unexpected length %.8e.\n", got);
1577 
1578 /*_______________D3DXQuaternionLengthSq________________________*/
1579  got = D3DXQuaternionLengthSq(&q);
1580  equal = compare_float(got, 121.0f, 0);
1581  ok(equal, "Got unexpected length %.8e.\n", got);
1582  /* Tests the case NULL */
1583  got = D3DXQuaternionLengthSq(NULL);
1584  equal = compare_float(got, 0.0f, 0);
1585  ok(equal, "Got unexpected length %.8e.\n", got);
1586 
1587 /*_______________D3DXQuaternionLn______________________________*/
1588  expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
1589  D3DXQuaternionLn(&gotquat,&q);
1590  expect_quaternion(&expectedquat, &gotquat, 0);
1591  expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
1592  D3DXQuaternionLn(&gotquat,&r);
1593  expect_quaternion(&expectedquat, &gotquat, 0);
1594  Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
1595  expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
1596  D3DXQuaternionLn(&gotquat,&Nq);
1597  expect_quaternion(&expectedquat, &gotquat, 32);
1598  Nq.x = 0.0f; Nq.y = 0.0f; Nq.z = 0.0f; Nq.w = 1.0f;
1599  expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1600  D3DXQuaternionLn(&gotquat,&Nq);
1601  expect_quaternion(&expectedquat, &gotquat, 0);
1602  Nq.x = 5.4f; Nq.y = 1.2f; Nq.z = -0.3f; Nq.w = -0.3f;
1603  expectedquat.x = 10.616652f; expectedquat.y = 2.359256f; expectedquat.z = -0.589814f; expectedquat.w = 0.0f;
1604  D3DXQuaternionLn(&gotquat,&Nq);
1605  expect_quaternion(&expectedquat, &gotquat, 1);
1606  /* Test the case where the norm of the quaternion is <1 */
1607  Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = 0.9f;
1608  expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
1609  D3DXQuaternionLn(&gotquat,&Nq1);
1610  expect_quaternion(&expectedquat, &gotquat, 64);
1611  /* Test the case where the real part of the quaternion is -1.0f */
1612  Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = -1.0f;
1613  expectedquat.x = 0.2f; expectedquat.y = 0.1f; expectedquat.z = 0.3f; expectedquat.w = 0.0f;
1614  D3DXQuaternionLn(&gotquat,&Nq1);
1615  expect_quaternion(&expectedquat, &gotquat, 0);
1616 
1617 /*_______________D3DXQuaternionMultiply________________________*/
1618  expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
1619  D3DXQuaternionMultiply(&gotquat,&q,&r);
1620  expect_quaternion(&expectedquat, &gotquat, 0);
1621 
1622 /*_______________D3DXQuaternionNormalize________________________*/
1623  expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
1624  D3DXQuaternionNormalize(&gotquat,&q);
1625  expect_quaternion(&expectedquat, &gotquat, 1);
1626 
1627 /*_______________D3DXQuaternionRotationAxis___________________*/
1628  axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
1629  angle = D3DX_PI/3.0f;
1630  expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
1631  D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
1632  expect_quaternion(&expectedquat, &gotquat, 64);
1633  /* Test the nul quaternion */
1634  axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
1635  expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
1636  D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
1637  expect_quaternion(&expectedquat, &gotquat, 8);
1638 
1639 /*_______________D3DXQuaternionRotationMatrix___________________*/
1640  /* test when the trace is >0 */
1641  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1642  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1643  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1644  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1645  U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
1646  U(mat).m[3][3] = 48.0f;
1647  expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
1648  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1649  expect_quaternion(&expectedquat, &gotquat, 16);
1650  /* test the case when the greater element is (2,2) */
1651  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1652  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1653  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1654  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1655  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
1656  U(mat).m[3][3] = 48.0f;
1657  expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
1658  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1659  expect_quaternion(&expectedquat, &gotquat, 64);
1660  /* test the case when the greater element is (1,1) */
1661  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1662  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1663  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1664  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1665  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
1666  U(mat).m[3][3] = 48.0f;
1667  expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
1668  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1669  expect_quaternion(&expectedquat, &gotquat, 8);
1670  /* test the case when the trace is near 0 in a matrix which is not a rotation */
1671  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1672  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1673  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1674  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1675  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.9f;
1676  U(mat).m[3][3] = 48.0f;
1677  expectedquat.x = 1.709495f; expectedquat.y = 2.339872f; expectedquat.z = -0.534217f; expectedquat.w = 1.282122f;
1678  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1679  expect_quaternion(&expectedquat, &gotquat, 8);
1680  /* test the case when the trace is 0.49 in a matrix which is not a rotation */
1681  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1682  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1683  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1684  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1685  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.51f;
1686  U(mat).m[3][3] = 48.0f;
1687  expectedquat.x = 1.724923f; expectedquat.y = 2.318944f; expectedquat.z = -0.539039f; expectedquat.w = 1.293692f;
1688  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1689  expect_quaternion(&expectedquat, &gotquat, 8);
1690  /* test the case when the trace is 0.51 in a matrix which is not a rotation */
1691  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1692  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1693  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1694  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1695  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.49f;
1696  U(mat).m[3][3] = 48.0f;
1697  expectedquat.x = 1.725726f; expectedquat.y = 2.317865f; expectedquat.z = -0.539289f; expectedquat.w = 1.294294f;
1698  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1699  expect_quaternion(&expectedquat, &gotquat, 8);
1700  /* test the case when the trace is 0.99 in a matrix which is not a rotation */
1701  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1702  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1703  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1704  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1705  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.01f;
1706  U(mat).m[3][3] = 48.0f;
1707  expectedquat.x = 1.745328f; expectedquat.y = 2.291833f; expectedquat.z = -0.545415f; expectedquat.w = 1.308996f;
1708  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1709  expect_quaternion(&expectedquat, &gotquat, 4);
1710  /* test the case when the trace is 1.0 in a matrix which is not a rotation */
1711  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1712  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1713  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1714  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1715  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.0f;
1716  U(mat).m[3][3] = 48.0f;
1717  expectedquat.x = 1.745743f; expectedquat.y = 2.291288f; expectedquat.z = -0.545545f; expectedquat.w = 1.309307f;
1718  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1719  expect_quaternion(&expectedquat, &gotquat, 8);
1720  /* test the case when the trace is 1.01 in a matrix which is not a rotation */
1721  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1722  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1723  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1724  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1725  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.01f;
1726  U(mat).m[3][3] = 48.0f;
1727  expectedquat.x = 18.408188f; expectedquat.y = 5.970223f; expectedquat.z = -2.985111f; expectedquat.w = 0.502494f;
1728  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1729  expect_quaternion(&expectedquat, &gotquat, 4);
1730  /* test the case when the trace is 1.5 in a matrix which is not a rotation */
1731  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1732  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1733  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1734  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1735  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.5f;
1736  U(mat).m[3][3] = 48.0f;
1737  expectedquat.x = 15.105186f; expectedquat.y = 4.898980f; expectedquat.z = -2.449490f; expectedquat.w = 0.612372f;
1738  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1739  expect_quaternion(&expectedquat, &gotquat, 8);
1740  /* test the case when the trace is 1.7 in a matrix which is not a rotation */
1741  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1742  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1743  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1744  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1745  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.70f;
1746  U(mat).m[3][3] = 48.0f;
1747  expectedquat.x = 14.188852f; expectedquat.y = 4.601790f; expectedquat.z = -2.300895f; expectedquat.w = 0.651920f;
1748  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1749  expect_quaternion(&expectedquat, &gotquat, 4);
1750  /* test the case when the trace is 1.99 in a matrix which is not a rotation */
1751  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1752  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1753  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1754  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1755  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.99f;
1756  U(mat).m[3][3] = 48.0f;
1757  expectedquat.x = 13.114303f; expectedquat.y = 4.253287f; expectedquat.z = -2.126644f; expectedquat.w = 0.705337f;
1758  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1759  expect_quaternion(&expectedquat, &gotquat, 4);
1760  /* test the case when the trace is 2.0 in a matrix which is not a rotation */
1761  U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
1762  U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
1763  U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
1764  U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
1765  U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 2.0f;
1766  U(mat).m[3][3] = 48.0f;
1767  expectedquat.x = 10.680980f; expectedquat.y = 3.464102f; expectedquat.z = -1.732051f; expectedquat.w = 0.866025f;
1768  D3DXQuaternionRotationMatrix(&gotquat,&mat);
1769  expect_quaternion(&expectedquat, &gotquat, 8);
1770 
1771 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
1772  expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
1774  expect_quaternion(&expectedquat, &gotquat, 16);
1775 
1776 /*_______________D3DXQuaternionSlerp________________________*/
1777  expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
1778  D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
1779  expect_quaternion(&expectedquat, &gotquat, 4);
1780  expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
1781  D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
1782  expect_quaternion(&expectedquat, &gotquat, 2);
1783  expectedquat.x = 0.239485f; expectedquat.y = 0.346580f; expectedquat.z = 0.453676f; expectedquat.w = 0.560772f;
1784  D3DXQuaternionSlerp(&gotquat,&smallq,&smallr,scale);
1785  expect_quaternion(&expectedquat, &gotquat, 32);
1786 
1787 /*_______________D3DXQuaternionSquad________________________*/
1788  expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
1789  D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
1790  expect_quaternion(&expectedquat, &gotquat, 2);
1791 
1792 /*_______________D3DXQuaternionSquadSetup___________________*/
1793  r.x = 1.0f, r.y = 2.0f; r.z = 4.0f; r.w = 10.0f;
1794  s.x = -3.0f; s.y = 4.0f; s.z = -5.0f; s.w = 7.0;
1795  t.x = -1111.0f, t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
1796  u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
1797  D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
1798  expectedquat.x = 7.121285f; expectedquat.y = 2.159964f; expectedquat.z = -3.855094f; expectedquat.w = 5.362844f;
1799  expect_quaternion(&expectedquat, &gotquat, 2);
1800  expectedquat.x = -1113.492920f; expectedquat.y = 82.679260f; expectedquat.z = -6.696645f; expectedquat.w = -4.090050f;
1801  expect_quaternion(&expectedquat, &Nq, 4);
1802  expectedquat.x = -1111.0f; expectedquat.y = 111.0f; expectedquat.z = -11.0f; expectedquat.w = 1.0f;
1803  expect_quaternion(&expectedquat, &Nq1, 0);
1804  gotquat = s;
1805  D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &gotquat, &t, &u);
1806  expectedquat.x = -1113.492920f; expectedquat.y = 82.679260f; expectedquat.z = -6.696645f; expectedquat.w = -4.090050f;
1807  expect_quaternion(&expectedquat, &Nq, 4);
1808  Nq1 = u;
1809  D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &Nq1);
1810  expect_quaternion(&expectedquat, &Nq, 4);
1811  r.x = 0.2f; r.y = 0.3f; r.z = 1.3f; r.w = -0.6f;
1812  s.x = -3.0f; s.y =-2.0f; s.z = 4.0f; s.w = 0.2f;
1813  t.x = 0.4f; t.y = 8.3f; t.z = -3.1f; t.w = -2.7f;
1814  u.x = 1.1f; u.y = -0.7f; u.z = 9.2f; u.w = 0.0f;
1815  D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &u, &t);
1816  expectedquat.x = -4.139569f; expectedquat.y = -2.469115f; expectedquat.z = 2.364477f; expectedquat.w = 0.465494f;
1817  expect_quaternion(&expectedquat, &gotquat, 16);
1818  expectedquat.x = 2.342533f; expectedquat.y = 2.365127f; expectedquat.z = 8.628538f; expectedquat.w = -0.898356f;
1819  expect_quaternion(&expectedquat, &Nq, 16);
1820  expectedquat.x = 1.1f; expectedquat.y = -0.7f; expectedquat.z = 9.2f; expectedquat.w = 0.0f;
1821  expect_quaternion(&expectedquat, &Nq1, 0);
1822  D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
1823  expectedquat.x = -3.754567f; expectedquat.y = -0.586085f; expectedquat.z = 3.815818f; expectedquat.w = -0.198150f;
1824  expect_quaternion(&expectedquat, &gotquat, 32);
1825  expectedquat.x = 0.140773f; expectedquat.y = -8.737090f; expectedquat.z = -0.516593f; expectedquat.w = 3.053942f;
1826  expect_quaternion(&expectedquat, &Nq, 16);
1827  expectedquat.x = -0.4f; expectedquat.y = -8.3f; expectedquat.z = 3.1f; expectedquat.w = 2.7f;
1828  expect_quaternion(&expectedquat, &Nq1, 0);
1829  r.x = -1.0f; r.y = 0.0f; r.z = 0.0f; r.w = 0.0f;
1830  s.x = 1.0f; s.y =0.0f; s.z = 0.0f; s.w = 0.0f;
1831  t.x = 1.0f; t.y = 0.0f; t.z = 0.0f; t.w = 0.0f;
1832  u.x = -1.0f; u.y = 0.0f; u.z = 0.0f; u.w = 0.0f;
1833  D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
1834  expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1835  expect_quaternion(&expectedquat, &gotquat, 0);
1836  expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1837  expect_quaternion(&expectedquat, &Nq, 0);
1838  expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1839  expect_quaternion(&expectedquat, &Nq1, 0);
1840 
1841 /*_______________D3DXQuaternionToAxisAngle__________________*/
1842  Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
1843  expectedvec.x = 1.0f/22.0f; expectedvec.y = 2.0f/22.0f; expectedvec.z = 4.0f/22.0f;
1844  D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
1845  expect_vec3(&expectedvec, &axis, 0);
1846  equal = compare_float(angle, 2.197869f, 1);
1847  ok(equal, "Got unexpected angle %.8e.\n", angle);
1848  /* Test if |w|>1.0f */
1849  expectedvec.x = 1.0f; expectedvec.y = 2.0f; expectedvec.z = 4.0f;
1851  expect_vec3(&expectedvec, &axis, 0);
1852  /* Test the null quaternion */
1853  expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1854  D3DXQuaternionToAxisAngle(&nul, &axis, &angle);
1855  expect_vec3(&expectedvec, &axis, 0);
1856  equal = compare_float(angle, 3.14159274e+00f, 0);
1857  ok(equal, "Got unexpected angle %.8e.\n", angle);
1858 
1859  D3DXQuaternionToAxisAngle(&nul, &axis, NULL);
1861  expect_vec3(&expectedvec, &axis, 0);
1862  equal = compare_float(angle, 3.14159274e+00f, 0);
1863  ok(equal, "Got unexpected angle %.8e.\n", angle);
1864 }
1865 
1866 static void D3DXVector2Test(void)
1867 {
1868  D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w, x;
1869  LPD3DXVECTOR2 funcpointer;
1870  D3DXVECTOR4 expectedtrans, gottrans;
1871  float coeff1, coeff2, got, scale;
1872  D3DXMATRIX mat;
1873  BOOL equal;
1874 
1875  nul.x = 0.0f; nul.y = 0.0f;
1876  u.x = 3.0f; u.y = 4.0f;
1877  v.x = -7.0f; v.y = 9.0f;
1878  w.x = 4.0f; w.y = -3.0f;
1879  x.x = 2.0f; x.y = -11.0f;
1880 
1881  set_matrix(&mat,
1882  1.0f, 2.0f, 3.0f, 4.0f,
1883  5.0f, 6.0f, 7.0f, 8.0f,
1884  9.0f, 10.0f, 11.0f, 12.0f,
1885  13.0f, 14.0f, 15.0f, 16.0f);
1886 
1887  coeff1 = 2.0f; coeff2 = 5.0f;
1888  scale = -6.5f;
1889 
1890 /*_______________D3DXVec2Add__________________________*/
1891  expectedvec.x = -4.0f; expectedvec.y = 13.0f;
1892  D3DXVec2Add(&gotvec,&u,&v);
1893  expect_vec2(&expectedvec, &gotvec, 0);
1894  /* Tests the case NULL */
1895  funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
1896  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1897  funcpointer = D3DXVec2Add(NULL,NULL,NULL);
1898  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1899 
1900 /*_______________D3DXVec2BaryCentric___________________*/
1901  expectedvec.x = -12.0f; expectedvec.y = -21.0f;
1902  D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1903  expect_vec2(&expectedvec, &gotvec, 0);
1904 
1905 /*_______________D3DXVec2CatmullRom____________________*/
1906  expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
1907  D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1908  expect_vec2(&expectedvec, &gotvec, 0);
1909 
1910 /*_______________D3DXVec2CCW__________________________*/
1911  got = D3DXVec2CCW(&u, &v);
1912  equal = compare_float(got, 55.0f, 0);
1913  ok(equal, "Got unexpected ccw %.8e.\n", got);
1914  /* Tests the case NULL. */
1915  got = D3DXVec2CCW(NULL, &v);
1916  equal = compare_float(got, 0.0f, 0);
1917  ok(equal, "Got unexpected ccw %.8e.\n", got);
1918  got = D3DXVec2CCW(NULL, NULL);
1919  equal = compare_float(got, 0.0f, 0);
1920  ok(equal, "Got unexpected ccw %.8e.\n", got);
1921 
1922 /*_______________D3DXVec2Dot__________________________*/
1923  got = D3DXVec2Dot(&u, &v);
1924  equal = compare_float(got, 15.0f, 0);
1925  ok(equal, "Got unexpected dot %.8e.\n", got);
1926  /* Tests the case NULL */
1927  got = D3DXVec2Dot(NULL, &v);
1928  equal = compare_float(got, 0.0f, 0);
1929  ok(equal, "Got unexpected dot %.8e.\n", got);
1930  got = D3DXVec2Dot(NULL, NULL);
1931  equal = compare_float(got, 0.0f, 0);
1932  ok(equal, "Got unexpected dot %.8e.\n", got);
1933 
1934 /*_______________D3DXVec2Hermite__________________________*/
1935  expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
1936  D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
1937  expect_vec2(&expectedvec, &gotvec, 0);
1938 
1939 /*_______________D3DXVec2Length__________________________*/
1940  got = D3DXVec2Length(&u);
1941  equal = compare_float(got, 5.0f, 0);
1942  ok(equal, "Got unexpected length %.8e.\n", got);
1943  /* Tests the case NULL. */
1944  got = D3DXVec2Length(NULL);
1945  equal = compare_float(got, 0.0f, 0);
1946  ok(equal, "Got unexpected length %.8e.\n", got);
1947 
1948 /*_______________D3DXVec2LengthSq________________________*/
1949  got = D3DXVec2LengthSq(&u);
1950  equal = compare_float(got, 25.0f, 0);
1951  ok(equal, "Got unexpected length %.8e.\n", got);
1952  /* Tests the case NULL. */
1953  got = D3DXVec2LengthSq(NULL);
1954  equal = compare_float(got, 0.0f, 0);
1955  ok(equal, "Got unexpected length %.8e.\n", got);
1956 
1957 /*_______________D3DXVec2Lerp__________________________*/
1958  expectedvec.x = 68.0f; expectedvec.y = -28.5f;
1959  D3DXVec2Lerp(&gotvec, &u, &v, scale);
1960  expect_vec2(&expectedvec, &gotvec, 0);
1961  /* Tests the case NULL. */
1962  funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
1963  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1964  funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
1965  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1966 
1967 /*_______________D3DXVec2Maximize__________________________*/
1968  expectedvec.x = 3.0f; expectedvec.y = 9.0f;
1969  D3DXVec2Maximize(&gotvec, &u, &v);
1970  expect_vec2(&expectedvec, &gotvec, 0);
1971  /* Tests the case NULL. */
1972  funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
1973  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1974  funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
1975  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1976 
1977 /*_______________D3DXVec2Minimize__________________________*/
1978  expectedvec.x = -7.0f; expectedvec.y = 4.0f;
1979  D3DXVec2Minimize(&gotvec,&u,&v);
1980  expect_vec2(&expectedvec, &gotvec, 0);
1981  /* Tests the case NULL */
1982  funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
1983  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1984  funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
1985  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1986 
1987 /*_______________D3DXVec2Normalize_________________________*/
1988  expectedvec.x = 0.6f; expectedvec.y = 0.8f;
1989  D3DXVec2Normalize(&gotvec,&u);
1990  expect_vec2(&expectedvec, &gotvec, 0);
1991  /* Test the nul vector */
1992  expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1993  D3DXVec2Normalize(&gotvec,&nul);
1994  expect_vec2(&expectedvec, &gotvec, 0);
1995 
1996 /*_______________D3DXVec2Scale____________________________*/
1997  expectedvec.x = -19.5f; expectedvec.y = -26.0f;
1998  D3DXVec2Scale(&gotvec,&u,scale);
1999  expect_vec2(&expectedvec, &gotvec, 0);
2000  /* Tests the case NULL */
2001  funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
2002  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2003  funcpointer = D3DXVec2Scale(NULL,NULL,scale);
2004  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2005 
2006 /*_______________D3DXVec2Subtract__________________________*/
2007  expectedvec.x = 10.0f; expectedvec.y = -5.0f;
2008  D3DXVec2Subtract(&gotvec, &u, &v);
2009  expect_vec2(&expectedvec, &gotvec, 0);
2010  /* Tests the case NULL. */
2011  funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
2012  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2013  funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
2014  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2015 
2016 /*_______________D3DXVec2Transform_______________________*/
2017  expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
2018  D3DXVec2Transform(&gottrans, &u, &mat);
2019  expect_vec4(&expectedtrans, &gottrans, 0);
2020  gottrans.x = u.x; gottrans.y = u.y;
2021  D3DXVec2Transform(&gottrans, (D3DXVECTOR2 *)&gottrans, &mat);
2022  expect_vec4(&expectedtrans, &gottrans, 0);
2023 
2024 /*_______________D3DXVec2TransformCoord_______________________*/
2025  expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
2026  D3DXVec2TransformCoord(&gotvec, &u, &mat);
2027  expect_vec2(&expectedvec, &gotvec, 1);
2028  gotvec.x = u.x; gotvec.y = u.y;
2029  D3DXVec2TransformCoord(&gotvec, (D3DXVECTOR2 *)&gotvec, &mat);
2030  expect_vec2(&expectedvec, &gotvec, 1);
2031 
2032  /*_______________D3DXVec2TransformNormal______________________*/
2033  expectedvec.x = 23.0f; expectedvec.y = 30.0f;
2034  D3DXVec2TransformNormal(&gotvec,&u,&mat);
2035  expect_vec2(&expectedvec, &gotvec, 0);
2036 }
2037 
2038 static void D3DXVector3Test(void)
2039 {
2040  D3DVIEWPORT9 viewport;
2041  D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w, x;
2042  LPD3DXVECTOR3 funcpointer;
2043  D3DXVECTOR4 expectedtrans, gottrans;
2044  D3DXMATRIX mat, projection, view, world;
2045  float coeff1, coeff2, got, scale;
2046  BOOL equal;
2047 
2048  nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
2049  u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
2050  v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
2051  w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
2052  x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
2053 
2054  viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
2055  viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
2056 
2057  set_matrix(&mat,
2058  1.0f, 2.0f, 3.0f, 4.0f,
2059  5.0f, 6.0f, 7.0f, 8.0f,
2060  9.0f, 10.0f, 11.0f, 12.0f,
2061  13.0f, 14.0f, 15.0f, 16.0f);
2062 
2063  U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
2064  U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
2065  U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
2066  U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
2067  U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
2068  U(view).m[3][3] = -40.0f;
2069 
2070  set_matrix(&world,
2071  21.0f, 2.0f, 3.0f, 4.0f,
2072  5.0f, 23.0f, 7.0f, 8.0f,
2073  -8.0f, -7.0f, 25.0f, -5.0f,
2074  -4.0f, -3.0f, -2.0f, 27.0f);
2075 
2076  coeff1 = 2.0f; coeff2 = 5.0f;
2077  scale = -6.5f;
2078 
2079 /*_______________D3DXVec3Add__________________________*/
2080  expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
2081  D3DXVec3Add(&gotvec,&u,&v);
2082  expect_vec3(&expectedvec, &gotvec, 0);
2083  /* Tests the case NULL */
2084  funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
2085  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2086  funcpointer = D3DXVec3Add(NULL,NULL,NULL);
2087  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2088 
2089 /*_______________D3DXVec3BaryCentric___________________*/
2090  expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
2091  D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
2092  expect_vec3(&expectedvec, &gotvec, 0);
2093 
2094 /*_______________D3DXVec3CatmullRom____________________*/
2095  expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
2096  D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
2097  expect_vec3(&expectedvec, &gotvec, 0);
2098 
2099 /*_______________D3DXVec3Cross________________________*/
2100  expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
2101  D3DXVec3Cross(&gotvec,&u,&v);
2102  expect_vec3(&expectedvec, &gotvec, 0);
2103  expectedvec.x = -277.0f; expectedvec.y = -150.0f; expectedvec.z = -26.0f;
2104  D3DXVec3Cross(&gotvec,&gotvec,&v);
2105  expect_vec3(&expectedvec, &gotvec, 0);
2106  /* Tests the case NULL */
2107  funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
2108  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2109  funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
2110  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2111 
2112 /*_______________D3DXVec3Dot__________________________*/
2113  got = D3DXVec3Dot(&u, &v);
2114  equal = compare_float(got, -8.0f, 0);
2115  ok(equal, "Got unexpected dot %.8e.\n", got);
2116  /* Tests the case NULL */
2117  got = D3DXVec3Dot(NULL, &v);
2118  equal = compare_float(got, 0.0f, 0);
2119  ok(equal, "Got unexpected dot %.8e.\n", got);
2120  got = D3DXVec3Dot(NULL, NULL);
2121  equal = compare_float(got, 0.0f, 0);
2122  ok(equal, "Got unexpected dot %.8e.\n", got);
2123 
2124 /*_______________D3DXVec3Hermite__________________________*/
2125  expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
2126  D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
2127  expect_vec3(&expectedvec, &gotvec, 0);
2128 
2129 /*_______________D3DXVec3Length__________________________*/
2130  got = D3DXVec3Length(&u);
2131  equal = compare_float(got, 11.0f, 0);
2132  ok(equal, "Got unexpected length %.8e.\n", got);
2133  /* Tests the case NULL. */
2134  got = D3DXVec3Length(NULL);
2135  equal = compare_float(got, 0.0f, 0);
2136  ok(equal, "Got unexpected length %.8e.\n", got);
2137 
2138 /*_______________D3DXVec3LengthSq________________________*/
2139  got = D3DXVec3LengthSq(&u);
2140  equal = compare_float(got, 121.0f, 0);
2141  ok(equal, "Got unexpected length %.8e.\n", got);
2142  /* Tests the case NULL. */
2143  got = D3DXVec3LengthSq(NULL);
2144  equal = compare_float(got, 0.0f, 0);
2145  ok(equal, "Got unexpected length %.8e.\n", got);
2146 
2147 /*_______________D3DXVec3Lerp__________________________*/
2148  expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
2149  D3DXVec3Lerp(&gotvec,&u,&v,scale);
2150  expect_vec3(&expectedvec, &gotvec, 0);
2151  /* Tests the case NULL */
2152  funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
2153  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2154  funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
2155  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2156 
2157 /*_______________D3DXVec3Maximize__________________________*/
2158  expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
2159  D3DXVec3Maximize(&gotvec,&u,&v);
2160  expect_vec3(&expectedvec, &gotvec, 0);
2161  /* Tests the case NULL */
2162  funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
2163  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2164  funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
2165  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2166 
2167 /*_______________D3DXVec3Minimize__________________________*/
2168  expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
2169  D3DXVec3Minimize(&gotvec,&u,&v);
2170  expect_vec3(&expectedvec, &gotvec, 0);
2171  /* Tests the case NULL */
2172  funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
2173  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2174  funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
2175  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2176 
2177 /*_______________D3DXVec3Normalize_________________________*/
2178  expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
2179  D3DXVec3Normalize(&gotvec,&u);
2180  expect_vec3(&expectedvec, &gotvec, 1);
2181  /* Test the nul vector */
2182  expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
2183  D3DXVec3Normalize(&gotvec,&nul);
2184  expect_vec3(&expectedvec, &gotvec, 0);
2185 
2186 /*_______________D3DXVec3Scale____________________________*/
2187  expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
2188  D3DXVec3Scale(&gotvec,&u,scale);
2189  expect_vec3(&expectedvec, &gotvec, 0);
2190  /* Tests the case NULL */
2191  funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
2192  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2193  funcpointer = D3DXVec3Scale(NULL,NULL,scale);
2194  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2195 
2196 /*_______________D3DXVec3Subtract_______________________*/
2197  expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
2198  D3DXVec3Subtract(&gotvec,&u,&v);
2199  expect_vec3(&expectedvec, &gotvec, 0);
2200  /* Tests the case NULL */
2201  funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
2202  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2203  funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
2204  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2205 
2206 /*_______________D3DXVec3Transform_______________________*/
2207  expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
2208  D3DXVec3Transform(&gottrans, &u, &mat);
2209  expect_vec4(&expectedtrans, &gottrans, 0);
2210 
2211  gottrans.x = u.x; gottrans.y = u.y; gottrans.z = u.z;
2212  D3DXVec3Transform(&gottrans, (D3DXVECTOR3 *)&gottrans, &mat);
2213  expect_vec4(&expectedtrans, &gottrans, 0);
2214 
2215 /*_______________D3DXVec3TransformCoord_______________________*/
2216  expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
2217  D3DXVec3TransformCoord(&gotvec,&u,&mat);
2218  expect_vec3(&expectedvec, &gotvec, 1);
2219 
2220 /*_______________D3DXVec3TransformNormal______________________*/
2221  expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
2222  D3DXVec3TransformNormal(&gotvec,&u,&mat);
2223  expect_vec3(&expectedvec, &gotvec, 0);
2224 
2225 /*_______________D3DXVec3Project_________________________*/
2226  expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
2227  D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
2228  D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
2229  expect_vec3(&expectedvec, &gotvec, 32);
2230  /* World matrix can be omitted */
2231  D3DXMatrixMultiply(&mat,&world,&view);
2232  D3DXVec3Project(&gotvec,&u,&viewport,&projection,&mat,NULL);
2233  expect_vec3(&expectedvec, &gotvec, 32);
2234  /* Projection matrix can be omitted */
2235  D3DXMatrixMultiply(&mat,&view,&projection);
2236  D3DXVec3Project(&gotvec,&u,&viewport,NULL,&mat,&world);
2237  expect_vec3(&expectedvec, &gotvec, 32);
2238  /* View matrix can be omitted */
2239  D3DXMatrixMultiply(&mat,&world,&view);
2240  D3DXVec3Project(&gotvec,&u,&viewport,&projection,NULL,&mat);
2241  expect_vec3(&expectedvec, &gotvec, 32);
2242  /* All matrices can be omitted */
2243  expectedvec.x = 4010.000000f; expectedvec.y = -1695.000000f; expectedvec.z = 1.600000f;
2244  D3DXVec3Project(&gotvec,&u,&viewport,NULL,NULL,NULL);
2245  expect_vec3(&expectedvec, &gotvec, 2);
2246  /* Viewport can be omitted */
2247  expectedvec.x = 1.814305f; expectedvec.y = 0.582097f; expectedvec.z = -0.066555f;
2248  D3DXVec3Project(&gotvec,&u,NULL,&projection,&view,&world);
2249  expect_vec3(&expectedvec, &gotvec, 64);
2250 
2251 /*_______________D3DXVec3Unproject_________________________*/
2252  expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
2253  D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
2254  D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
2255  expect_vec3(&expectedvec, &gotvec, 16);
2256  /* World matrix can be omitted */
2257  D3DXMatrixMultiply(&mat,&world,&view);
2258  D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&mat,NULL);
2259  expect_vec3(&expectedvec, &gotvec, 16);
2260  /* Projection matrix can be omitted */
2261  D3DXMatrixMultiply(&mat,&view,&projection);
2262  D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,&mat,&world);
2263  expect_vec3(&expectedvec, &gotvec, 32);
2264  /* View matrix can be omitted */
2265  D3DXMatrixMultiply(&mat,&world,&view);
2266  D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,NULL,&mat);
2267  expect_vec3(&expectedvec, &gotvec, 16);
2268  /* All matrices can be omitted */
2269  expectedvec.x = -1.002500f; expectedvec.y = 0.997059f; expectedvec.z = 2.571429f;
2270  D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,NULL,NULL);
2271  expect_vec3(&expectedvec, &gotvec, 4);
2272  /* Viewport can be omitted */
2273  expectedvec.x = -11.018396f; expectedvec.y = 3.218991f; expectedvec.z = 1.380329f;
2274  D3DXVec3Unproject(&gotvec,&u,NULL,&projection,&view,&world);
2275  expect_vec3(&expectedvec, &gotvec, 8);
2276 }
2277 
2278 static void D3DXVector4Test(void)
2279 {
2280  D3DXVECTOR4 expectedvec, gotvec, u, v, w, x;
2281  LPD3DXVECTOR4 funcpointer;
2282  D3DXVECTOR4 expectedtrans, gottrans;
2283  float coeff1, coeff2, got, scale;
2284  D3DXMATRIX mat;
2285  BOOL equal;
2286 
2287  u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
2288  v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
2289  w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
2290  x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
2291 
2292  set_matrix(&mat,
2293  1.0f, 2.0f, 3.0f, 4.0f,
2294  5.0f, 6.0f, 7.0f, 8.0f,
2295  9.0f, 10.0f, 11.0f, 12.0f,
2296  13.0f, 14.0f, 15.0f, 16.0f);
2297 
2298  coeff1 = 2.0f; coeff2 = 5.0;
2299  scale = -6.5f;
2300 
2301 /*_______________D3DXVec4Add__________________________*/
2302  expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
2303  D3DXVec4Add(&gotvec,&u,&v);
2304  expect_vec4(&expectedvec, &gotvec, 0);
2305  /* Tests the case NULL */
2306  funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
2307  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2308  funcpointer = D3DXVec4Add(NULL,NULL,NULL);
2309  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2310 
2311 /*_______________D3DXVec4BaryCentric____________________*/
2312  expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
2313  D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
2314  expect_vec4(&expectedvec, &gotvec, 0);
2315 
2316 /*_______________D3DXVec4CatmullRom____________________*/
2317  expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
2318  D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
2319  expect_vec4(&expectedvec, &gotvec, 0);
2320 
2321 /*_______________D3DXVec4Cross_________________________*/
2322  expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
2323  D3DXVec4Cross(&gotvec,&u,&v,&w);
2324  expect_vec4(&expectedvec, &gotvec, 0);
2325 
2326 /*_______________D3DXVec4Dot__________________________*/
2327  got = D3DXVec4Dot(&u, &v);
2328  equal = compare_float(got, 55.0f, 0);
2329  ok(equal, "Got unexpected dot %.8e.\n", got);
2330  /* Tests the case NULL. */
2331  got = D3DXVec4Dot(NULL, &v);
2332  equal = compare_float(got, 0.0f, 0);
2333  ok(equal, "Got unexpected dot %.8e.\n", got);
2334  got = D3DXVec4Dot(NULL, NULL);
2335  equal = compare_float(got, 0.0f, 0);
2336  ok(equal, "Got unexpected dot %.8e.\n", got);
2337 
2338 /*_______________D3DXVec4Hermite_________________________*/
2339  expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
2340  D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
2341  expect_vec4(&expectedvec, &gotvec, 0);
2342 
2343 /*_______________D3DXVec4Length__________________________*/
2344  got = D3DXVec4Length(&u);
2345  equal = compare_float(got, 11.0f, 0);
2346  ok(equal, "Got unexpected length %.8e.\n", got);
2347  /* Tests the case NULL. */
2348  got = D3DXVec4Length(NULL);
2349  equal = compare_float(got, 0.0f, 0);
2350  ok(equal, "Got unexpected length %.8e.\n", got);
2351 
2352 /*_______________D3DXVec4LengthSq________________________*/
2353  got = D3DXVec4LengthSq(&u);
2354  equal = compare_float(got, 121.0f, 0);
2355  ok(equal, "Got unexpected length %.8e.\n", got);
2356  /* Tests the case NULL. */
2357  got = D3DXVec4LengthSq(NULL);
2358  equal = compare_float(got, 0.0f, 0);
2359  ok(equal, "Got unexpected length %.8e.\n", got);
2360 
2361 /*_______________D3DXVec4Lerp__________________________*/
2362  expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
2363  D3DXVec4Lerp(&gotvec,&u,&v,scale);
2364  expect_vec4(&expectedvec, &gotvec, 0);
2365  /* Tests the case NULL */
2366  funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
2367  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2368  funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
2369  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2370 
2371 /*_______________D3DXVec4Maximize__________________________*/
2372  expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
2373  D3DXVec4Maximize(&gotvec,&u,&v);
2374  expect_vec4(&expectedvec, &gotvec, 0);
2375  /* Tests the case NULL */
2376  funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
2377  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2378  funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
2379  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2380 
2381 /*_______________D3DXVec4Minimize__________________________*/
2382  expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
2383  D3DXVec4Minimize(&gotvec,&u,&v);
2384  expect_vec4(&expectedvec, &gotvec, 0);
2385  /* Tests the case NULL */
2386  funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
2387  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2388  funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
2389  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2390 
2391 /*_______________D3DXVec4Normalize_________________________*/
2392  expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
2393  D3DXVec4Normalize(&gotvec,&u);
2394  expect_vec4(&expectedvec, &gotvec, 1);
2395 
2396 /*_______________D3DXVec4Scale____________________________*/
2397  expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
2398  D3DXVec4Scale(&gotvec,&u,scale);
2399  expect_vec4(&expectedvec, &gotvec, 0);
2400  /* Tests the case NULL */
2401  funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
2402  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2403  funcpointer = D3DXVec4Scale(NULL,NULL,scale);
2404  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2405 
2406 /*_______________D3DXVec4Subtract__________________________*/
2407  expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
2408  D3DXVec4Subtract(&gotvec,&u,&v);
2409  expect_vec4(&expectedvec, &gotvec, 0);
2410  /* Tests the case NULL */
2411  funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
2412  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2413  funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
2414  ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
2415 
2416 /*_______________D3DXVec4Transform_______________________*/
2417  expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
2418  D3DXVec4Transform(&gottrans,&u,&mat);
2419  expect_vec4(&expectedtrans, &gottrans, 0);
2420 }
2421 
2422 static void test_matrix_stack(void)
2423 {
2424  ID3DXMatrixStack *stack;
2425  ULONG refcount;
2426  HRESULT hr;
2427 
2428  const D3DXMATRIX mat1 = {{{
2429  1.0f, 2.0f, 3.0f, 4.0f,
2430  5.0f, 6.0f, 7.0f, 8.0f,
2431  9.0f, 10.0f, 11.0f, 12.0f,
2432  13.0f, 14.0f, 15.0f, 16.0f
2433  }}};
2434 
2435  const D3DXMATRIX mat2 = {{{
2436  17.0f, 18.0f, 19.0f, 20.0f,
2437  21.0f, 22.0f, 23.0f, 24.0f,
2438  25.0f, 26.0f, 27.0f, 28.0f,
2439  29.0f, 30.0f, 31.0f, 32.0f
2440  }}};
2441 
2443  ok(SUCCEEDED(hr), "Failed to create a matrix stack, hr %#x\n", hr);
2444  if (FAILED(hr)) return;
2445 
2446  ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)),
2447  "The top of an empty matrix stack should be an identity matrix\n");
2448 
2450  ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2451 
2453  ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2454  ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2455 
2457  ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2458 
2460  ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
2462 
2464  ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2466 
2468  ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
2470 
2472  ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
2474 
2476  ok(SUCCEEDED(hr), "LoadIdentity failed, hr %#x\n", hr);
2477  ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2478 
2480  ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2482 
2484  ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2486 
2488  ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2489  ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2490 
2492  ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
2493  ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
2494 
2495  refcount = ID3DXMatrixStack_Release(stack);
2496  ok(!refcount, "Matrix stack has %u references left.\n", refcount);
2497 }
2498 
2500 {
2501  D3DXMATRIX exp_mat, got_mat;
2502  D3DXVECTOR2 center, position;
2503  FLOAT angle, scale;
2504 
2505  center.x = 3.0f;
2506  center.y = 4.0f;
2507 
2508  position.x = -6.0f;
2509  position.y = 7.0f;
2510 
2511  angle = D3DX_PI/3.0f;
2512 
2513  scale = 20.0f;
2514 
2515  U(exp_mat).m[0][0] = 10.0f;
2516  U(exp_mat).m[1][0] = -17.320507f;
2517  U(exp_mat).m[2][0] = 0.0f;
2518  U(exp_mat).m[3][0] = -1.035898f;
2519  U(exp_mat).m[0][1] = 17.320507f;
2520  U(exp_mat).m[1][1] = 10.0f;
2521  U(exp_mat).m[2][1] = 0.0f;
2522  U(exp_mat).m[3][1] = 6.401924f;
2523  U(exp_mat).m[0][2] = 0.0f;
2524  U(exp_mat).m[1][2] = 0.0f;
2525  U(exp_mat).m[2][2] = 1.0f;
2526  U(exp_mat).m[3][2] = 0.0f;
2527  U(exp_mat).m[0][3] = 0.0f;
2528  U(exp_mat).m[1][3] = 0.0f;
2529  U(exp_mat).m[2][3] = 0.0f;
2530  U(exp_mat).m[3][3] = 1.0f;
2531 
2532  D3DXMatrixAffineTransformation2D(&got_mat, scale, &center, angle, &position);
2533  expect_matrix(&exp_mat, &got_mat, 2);
2534 
2535 /*______________*/
2536 
2537  center.x = 3.0f;
2538  center.y = 4.0f;
2539 
2540  angle = D3DX_PI/3.0f;
2541 
2542  scale = 20.0f;
2543 
2544  U(exp_mat).m[0][0] = 10.0f;
2545  U(exp_mat).m[1][0] = -17.320507f;
2546  U(exp_mat).m[2][0] = 0.0f;
2547  U(exp_mat).m[3][0] = 4.964102f;
2548  U(exp_mat).m[0][1] = 17.320507f;
2549  U(exp_mat).m[1][1] = 10.0f;
2550  U(exp_mat).m[2][1] = 0.0f;
2551  U(exp_mat).m[3][1] = -0.598076f;
2552  U(exp_mat).m[0][2] = 0.0f;
2553  U(exp_mat).m[1][2] = 0.0f;
2554  U(exp_mat).m[2][2] = 1.0f;
2555  U(exp_mat).m[3][2] = 0.0f;
2556  U(exp_mat).m[0][3] = 0.0f;
2557  U(exp_mat).m[1][3] = 0.0f;
2558  U(exp_mat).m[2][3] = 0.0f;
2559  U(exp_mat).m[3][3] = 1.0f;
2560 
2561  D3DXMatrixAffineTransformation2D(&got_mat, scale, &center, angle, NULL);
2562  expect_matrix(&exp_mat, &got_mat, 8);
2563 
2564 /*______________*/
2565 
2566  position.x = -6.0f;
2567  position.y = 7.0f;
2568 
2569  angle = D3DX_PI/3.0f;
2570 
2571  scale = 20.0f;
2572 
2573  U(exp_mat).m[0][0] = 10.0f;
2574  U(exp_mat).m[1][0] = -17.320507f;
2575  U(exp_mat).m[2][0] = 0.0f;
2576  U(exp_mat).m[3][0] = -6.0f;
2577  U(exp_mat).m[0][1] = 17.320507f;
2578  U(exp_mat).m[1][1] = 10.0f;
2579  U(exp_mat).m[2][1] = 0.0f;
2580  U(exp_mat).m[3][1] = 7.0f;
2581  U(exp_mat).m[0][2] = 0.0f;
2582  U(exp_mat).m[1][2] = 0.0f;
2583  U(exp_mat).m[2][2] = 1.0f;
2584  U(exp_mat).m[3][2] = 0.0f;
2585  U(exp_mat).m[0][3] = 0.0f;
2586  U(exp_mat).m[1][3] = 0.0f;
2587  U(exp_mat).m[2][3] = 0.0f;
2588  U(exp_mat).m[3][3] = 1.0f;
2589 
2590  D3DXMatrixAffineTransformation2D(&got_mat, scale, NULL, angle, &position);
2591  expect_matrix(&exp_mat, &got_mat, 1);
2592 
2593 /*______________*/
2594 
2595  angle = 5.0f * D3DX_PI/4.0f;
2596 
2597  scale = -20.0f;
2598 
2599  U(exp_mat).m[0][0] = 14.142133f;
2600  U(exp_mat).m[1][0] = -14.142133f;
2601  U(exp_mat).m[2][0] = 0.0f;
2602  U(exp_mat).m[3][0] = 0.0f;
2603  U(exp_mat).m[0][1] = 14.142133;
2604  U(exp_mat).m[1][1] = 14.142133f;
2605  U(exp_mat).m[2][1] = 0.0f;
2606  U(exp_mat).m[3][1] = 0.0f;
2607  U(exp_mat).m[0][2] = 0.0f;
2608  U(exp_mat).m[1][2] = 0.0f;
2609  U(exp_mat).m[2][2] = 1.0f;
2610  U(exp_mat).m[3][2] = 0.0f;
2611  U(exp_mat).m[0][3] = 0.0f;
2612  U(exp_mat).m[1][3] = 0.0f;
2613  U(exp_mat).m[2][3] = 0.0f;
2614  U(exp_mat).m[3][3] = 1.0f;
2615 
2617  expect_matrix(&exp_mat, &got_mat, 8);
2618 }
2619 
2620 static void test_Matrix_Decompose(void)
2621 {
2622  D3DXMATRIX pm;
2623  D3DXQUATERNION exp_rotation, got_rotation;
2624  D3DXVECTOR3 exp_scale, got_scale, exp_translation, got_translation;
2625  HRESULT hr;
2626  BOOL equal;
2627 
2628 /*___________*/
2629 
2630  U(pm).m[0][0] = -9.23879206e-01f;
2631  U(pm).m[1][0] = -2.70598412e-01f;
2632  U(pm).m[2][0] = 2.70598441e-01f;
2633  U(pm).m[3][0] = -5.00000000e+00f;
2634  U(pm).m[0][1] = 2.70598471e-01f;
2635  U(pm).m[1][1] = 3.80604863e-02f;
2636  U(pm).m[2][1] = 9.61939573e-01f;
2637  U(pm).m[3][1] = 0.00000000e+00f;
2638  U(pm).m[0][2] = -2.70598441e-01f;
2639  U(pm).m[1][2] = 9.61939573e-01f;
2640  U(pm).m[2][2] = 3.80603075e-02f;
2641  U(pm).m[3][2] = 1.00000000e+01f;
2642  U(pm).m[0][3] = 0.00000000e+00f;
2643  U(pm).m[1][3] = 0.00000000e+00f;
2644  U(pm).m[2][3] = 0.00000000e+00f;
2645  U(pm).m[3][3] = 1.00000000e+00f;
2646 
2647  exp_scale.x = 9.99999881e-01f;
2648  exp_scale.y = 9.99999881e-01f;
2649  exp_scale.z = 9.99999881e-01f;
2650 
2651  exp_rotation.x = 2.14862776e-08f;
2652  exp_rotation.y = 6.93519890e-01f;
2653  exp_rotation.z = 6.93519890e-01f;
2654  exp_rotation.w = 1.95090637e-01f;
2655 
2656  exp_translation.x = -5.0f;
2657  exp_translation.y = 0.0f;
2658  exp_translation.z = 10.0f;
2659 
2660  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2661  expect_vec3(&exp_scale, &got_scale, 1);
2662  expect_quaternion(&exp_rotation, &got_rotation, 1);
2663  expect_vec3(&exp_translation, &got_translation, 0);
2664 
2665 /*_________*/
2666 
2667  U(pm).m[0][0] = -2.255813f;
2668  U(pm).m[1][0] = 1.302324f;
2669  U(pm).m[2][0] = 1.488373f;
2670  U(pm).m[3][0] = 1.0f;
2671  U(pm).m[0][1] = 1.302327f;
2672  U(pm).m[1][1] = -0.7209296f;
2673  U(pm).m[2][1] = 2.60465f;
2674  U(pm).m[3][1] = 2.0f;
2675  U(pm).m[0][2] = 1.488371f;
2676  U(pm).m[1][2] = 2.604651f;
2677  U(pm).m[2][2] = -0.02325551f;
2678  U(pm).m[3][2] = 3.0f;
2679  U(pm).m[0][3] = 0.0f;
2680  U(pm).m[1][3] = 0.0f;
2681  U(pm).m[2][3] = 0.0f;
2682  U(pm).m[3][3] = 1.0f;
2683 
2684  exp_scale.x = 2.99999928e+00f;
2685  exp_scale.y = 2.99999905e+00f;
2686  exp_scale.z = 2.99999952e+00f;
2687 
2688  exp_rotation.x = 3.52180451e-01f;
2689  exp_rotation.y = 6.16315663e-01f;
2690  exp_rotation.z = 7.04360664e-01f;
2691  exp_rotation.w = 3.38489343e-07f;
2692 
2693  exp_translation.x = 1.0f;
2694  exp_translation.y = 2.0f;
2695  exp_translation.z = 3.0f;
2696 
2697  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2698  expect_vec3(&exp_scale, &got_scale, 0);
2699  expect_quaternion(&exp_rotation, &got_rotation, 2);
2700  expect_vec3(&exp_translation, &got_translation, 0);
2701 
2702 /*_____________*/
2703 
2704  U(pm).m[0][0] = 2.427051f;
2705  U(pm).m[1][0] = 0.0f;
2706  U(pm).m[2][0] = 1.763355f;
2707  U(pm).m[3][0] = 5.0f;
2708  U(pm).m[0][1] = 0.0f;
2709  U(pm).m[1][1] = 3.0f;
2710  U(pm).m[2][1] = 0.0f;
2711  U(pm).m[3][1] = 5.0f;
2712  U(pm).m[0][2] = -1.763355f;
2713  U(pm).m[1][2] = 0.0f;
2714  U(pm).m[2][2] = 2.427051f;
2715  U(pm).m[3][2] = 5.0f;
2716  U(pm).m[0][3] = 0.0f;
2717  U(pm).m[1][3] = 0.0f;
2718  U(pm).m[2][3] = 0.0f;
2719  U(pm).m[3][3] = 1.0f;
2720 
2721  exp_scale.x = 2.99999976e+00f;
2722  exp_scale.y = 3.00000000e+00f;
2723  exp_scale.z = 2.99999976e+00f;
2724 
2725  exp_rotation.x = 0.00000000e+00f;
2726  exp_rotation.y = 3.09016883e-01f;
2727  exp_rotation.z = 0.00000000e+00f;
2728  exp_rotation.w = 9.51056540e-01f;
2729 
2730  exp_translation.x = 5.0f;
2731  exp_translation.y = 5.0f;
2732  exp_translation.z = 5.0f;
2733 
2734  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2735  expect_vec3(&exp_scale, &got_scale, 1);
2736  expect_quaternion(&exp_rotation, &got_rotation, 1);
2737  expect_vec3(&exp_translation, &got_translation, 0);
2738 
2739 /*_____________*/
2740 
2741  U(pm).m[0][0] = -9.23879206e-01f;
2742  U(pm).m[1][0] = -2.70598412e-01f;
2743  U(pm).m[2][0] = 2.70598441e-01f;
2744  U(pm).m[3][0] = -5.00000000e+00f;
2745  U(pm).m[0][1] = 2.70598471e-01f;
2746  U(pm).m[1][1] = 3.80604863e-02f;
2747  U(pm).m[2][1] = 9.61939573e-01f;
2748  U(pm).m[3][1] = 0.00000000e+00f;
2749  U(pm).m[0][2] = -2.70598441e-01f;
2750  U(pm).m[1][2] = 9.61939573e-01f;
2751  U(pm).m[2][2] = 3.80603075e-02f;
2752  U(pm).m[3][2] = 1.00000000e+01f;
2753  U(pm).m[0][3] = 0.00000000e+00f;
2754  U(pm).m[1][3] = 0.00000000e+00f;
2755  U(pm).m[2][3] = 0.00000000e+00f;
2756  U(pm).m[3][3] = 1.00000000e+00f;
2757 
2758  exp_scale.x = 9.99999881e-01f;
2759  exp_scale.y = 9.99999881e-01f;
2760  exp_scale.z = 9.99999881e-01f;
2761 
2762  exp_rotation.x = 2.14862776e-08f;
2763  exp_rotation.y = 6.93519890e-01f;
2764  exp_rotation.z = 6.93519890e-01f;
2765  exp_rotation.w = 1.95090637e-01f;
2766 
2767  exp_translation.x = -5.0f;
2768  exp_translation.y = 0.0f;
2769  exp_translation.z = 10.0f;
2770 
2771  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2772  expect_vec3(&exp_scale, &got_scale, 1);
2773  expect_quaternion(&exp_rotation, &got_rotation, 1);
2774  expect_vec3(&exp_translation, &got_translation, 0);
2775 
2776 /*__________*/
2777 
2778  U(pm).m[0][0] = -9.23878908e-01f;
2779  U(pm).m[1][0] = -5.41196704e-01f;
2780  U(pm).m[2][0] = 8.11795175e-01f;
2781  U(pm).m[3][0] = -5.00000000e+00f;
2782  U(pm).m[0][1] = 2.70598322e-01f;
2783  U(pm).m[1][1] = 7.61209577e-02f;
2784  U(pm).m[2][1] = 2.88581824e+00f;
2785  U(pm).m[3][1] = 0.00000000e+00f;
2786  U(pm).m[0][2] = -2.70598352e-01f;
2787  U(pm).m[1][2] = 1.92387879e+00f;
2788  U(pm).m[2][2] = 1.14180908e-01f;
2789  U(pm).m[3][2] = 1.00000000e+01f;
2790  U(pm).m[0][3] = 0.00000000e+00f;
2791  U(pm).m[1][3] = 0.00000000e+00f;
2792  U(pm).m[2][3] = 0.00000000e+00f;
2793  U(pm).m[3][3] = 1.00000000e+00f;
2794 
2795  exp_scale.x = 9.99999583e-01f;
2796  exp_scale.y = 1.99999940e+00f;
2797  exp_scale.z = 2.99999928e+00f;
2798 
2799  exp_rotation.x = 1.07431388e-08f;
2800  exp_rotation.y = 6.93519890e-01f;
2801  exp_rotation.z = 6.93519831e-01f;
2802  exp_rotation.w = 1.95090622e-01f;
2803 
2804  exp_translation.x = -5.0f;
2805  exp_translation.y = 0.0f;
2806  exp_translation.z = 10.0f;
2807 
2808  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2809  expect_vec3(&exp_scale, &got_scale, 1);
2810  equal = compare_quaternion(&exp_rotation, &got_rotation, 1);
2811  exp_rotation.x = 0.0f;
2812  equal |= compare_quaternion(&exp_rotation, &got_rotation, 2);
2813  ok(equal, "Got unexpected quaternion {%.8e, %.8e, %.8e, %.8e}.\n",
2814  got_rotation.x, got_rotation.y, got_rotation.z, got_rotation.w);
2815  expect_vec3(&exp_translation, &got_translation, 0);
2816 
2817 /*__________*/
2818 
2819  U(pm).m[0][0] = 0.7156004f;
2820  U(pm).m[1][0] = -0.5098283f;
2821  U(pm).m[2][0] = -0.4774843f;
2822  U(pm).m[3][0] = -5.0f;
2823  U(pm).m[0][1] = -0.6612288f;
2824  U(pm).m[1][1] = -0.7147621f;
2825  U(pm).m[2][1] = -0.2277977f;
2826  U(pm).m[3][1] = 0.0f;
2827  U(pm).m[0][2] = -0.2251499f;
2828  U(pm).m[1][2] = 0.4787385f;
2829  U(pm).m[2][2] = -0.8485972f;
2830  U(pm).m[3][2] = 10.0f;
2831  U(pm).m[0][3] = 0.0f;
2832  U(pm).m[1][3] = 0.0f;
2833  U(pm).m[2][3] = 0.0f;
2834  U(pm).m[3][3] = 1.0f;
2835 
2836  exp_scale.x = 9.99999940e-01f;
2837  exp_scale.y = 1.00000012e+00f;
2838  exp_scale.z = 1.00000012e+00f;
2839 
2840  exp_rotation.x = 9.05394852e-01f;
2841  exp_rotation.y = -3.23355347e-01f;
2842  exp_rotation.z = -1.94013178e-01f;
2843  exp_rotation.w = 1.95090592e-01f;
2844 
2845  exp_translation.x = -5.0f;
2846  exp_translation.y = 0.0f;
2847  exp_translation.z = 10.0f;
2848 
2849  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2850  expect_vec3(&exp_scale, &got_scale, 0);
2851  expect_quaternion(&exp_rotation, &got_rotation, 1);
2852  expect_vec3(&exp_translation, &got_translation, 0);
2853 
2854 /*_____________*/
2855 
2856  U(pm).m[0][0] = 0.06554436f;
2857  U(pm).m[1][0] = -0.6873012f;
2858  U(pm).m[2][0] = 0.7234092f;
2859  U(pm).m[3][0] = -5.0f;
2860  U(pm).m[0][1] = -0.9617381f;
2861  U(pm).m[1][1] = -0.2367795f;
2862  U(pm).m[2][1] = -0.1378230f;
2863  U(pm).m[3][1] = 0.0f;
2864  U(pm).m[0][2] = 0.2660144f;
2865  U(pm).m[1][2] = -0.6866967f;
2866  U(pm).m[2][2] = -0.6765233f;
2867  U(pm).m[3][2] = 10.0f;
2868  U(pm).m[0][3] = 0.0f;
2869  U(pm).m[1][3] = 0.0f;
2870  U(pm).m[2][3] = 0.0f;
2871  U(pm).m[3][3] = 1.0f;
2872 
2873  exp_scale.x = 9.99999940e-01f;
2874  exp_scale.y = 9.99999940e-01f;
2875  exp_scale.z = 9.99999881e-01f;
2876 
2877  exp_rotation.x = 7.03357518e-01f;
2878  exp_rotation.y = -5.86131275e-01f;
2879  exp_rotation.z = 3.51678789e-01f;
2880  exp_rotation.w = -1.95090577e-01f;
2881 
2882  exp_translation.x = -5.0f;
2883  exp_translation.y = 0.0f;
2884  exp_translation.z = 10.0f;
2885 
2886  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2887  expect_vec3(&exp_scale, &got_scale, 1);
2888  expect_quaternion(&exp_rotation, &got_rotation, 2);
2889  expect_vec3(&exp_translation, &got_translation, 0);
2890 
2891 /*_________*/
2892 
2893  U(pm).m[0][0] = 7.12104797e+00f;
2894  U(pm).m[1][0] = -5.88348627e+00f;
2895  U(pm).m[2][0] = 1.18184204e+01f;
2896  U(pm).m[3][0] = -5.00000000e+00f;
2897  U(pm).m[0][1] = 5.88348627e+00f;
2898  U(pm).m[1][1] = -1.06065865e+01f;
2899  U(pm).m[2][1] = -8.82523251e+00f;
2900  U(pm).m[3][1] = 0.00000000e+00f;
2901  U(pm).m[0][2] = 1.18184204e+01f;
2902  U(pm).m[1][2] = 8.82523155e+00f;
2903  U(pm).m[2][2] = -2.72764111e+00f;
2904  U(pm).m[3][2] = 2.00000000e+00f;
2905  U(pm).m[0][3] = 0.00000000e+00f;
2906  U(pm).m[1][3] = 0.00000000e+00f;
2907  U(pm).m[2][3] = 0.00000000e+00f;
2908  U(pm).m[3][3] = 1.00000000e+00f;
2909 
2910  exp_scale.x = 1.49999933e+01f;
2911  exp_scale.y = 1.49999933e+01f;
2912  exp_scale.z = 1.49999943e+01f;
2913 
2914  exp_rotation.x = 7.68714130e-01f;
2915  exp_rotation.y = 0.00000000e+00f;
2916  exp_rotation.z = 5.12475967e-01f;
2917  exp_rotation.w = 3.82683903e-01f;
2918 
2919  exp_translation.x = -5.0f;
2920  exp_translation.y = 0.0f;
2921  exp_translation.z = 2.0f;
2922 
2923  D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2924  expect_vec3(&exp_scale, &got_scale, 0);
2925  expect_quaternion(&exp_rotation, &got_rotation, 1);
2926  expect_vec3(&exp_translation, &got_translation, 0);
2927 
2928 /*__________*/
2929 
2930  U(pm).m[0][0] = 0.0f;
2931  U(pm).m[1][0] = 4.0f;
2932  U(pm).m[2][0] = 5.0f;
2933  U(pm).m[3][0] = -5.0f;
2934  U(pm).m[0][1] = 0.0f;
2935  U(pm).m[1][1] = -10.60660f;
2936  U(pm).m[2][1] = -8.825232f;
2937  U(pm).m[3][1] = 6.0f;
2938  U(pm).m[0][2] = 0.0f;
2939  U(pm).m[1][2] = 8.8252320f;
2940  U(pm).m[2][2] = 2.727645;
2941  U(pm).m[3][2] = 3.0f;
2942  U(pm).m[0][3] = 0.0f;
2943  U(pm).m[1][3] = 0.0f;
2944  U(pm).m[2][3] = 0.0f;
2945  U(pm).m[3][3] = 1.0f;