2 * Copyright 2008 David Adam
3 * Copyright 2008 Luis Busquets
4 * Copyright 2008 Philip Nilsson
5 * Copyright 2008 Henri Verbeet
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
28 #define admitted_error 0.0001f
30 #define relative_error(exp, out) ((exp == 0.0f) ? fabs(exp - out) : (fabs(1.0f - (out) / (exp))))
32 #define expect_color(expectedcolor,gotcolor) ok((relative_error(expectedcolor.r, gotcolor.r)<admitted_error)&&(relative_error(expectedcolor.g, gotcolor.g)<admitted_error)&&(relative_error(expectedcolor.b, gotcolor.b)<admitted_error)&&(relative_error(expectedcolor.a, gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
34 static inline BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
38 for (i = 0; i < 4; ++i)
40 for (j = 0; j < 4; ++j)
42 if (relative_error(U(*m1).m[i][j], U(*m2).m[i][j]) > admitted_error)
50 #define expect_mat(expectedmat, gotmat) \
52 const D3DXMATRIX *__m1 = (expectedmat); \
53 const D3DXMATRIX *__m2 = (gotmat); \
54 ok(compare_matrix(__m1, __m2), "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \
55 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
56 U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
57 U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
58 U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
59 U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
60 U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
61 U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
62 U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
63 U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
66 #define compare_rotation(exp, got) \
67 ok(relative_error(exp.w, got.w) < admitted_error && \
68 relative_error(exp.x, got.x) < admitted_error && \
69 relative_error(exp.y, got.y) < admitted_error && \
70 relative_error(exp.z, got.z) < admitted_error, \
71 "Expected rotation = (%f, %f, %f, %f), \
72 got rotation = (%f, %f, %f, %f)\n", \
73 exp.w, exp.x, exp.y, exp.z, got.w, got.x, got.y, got.z)
75 #define compare_scale(exp, got) \
76 ok(relative_error(exp.x, got.x) < admitted_error && \
77 relative_error(exp.y, got.y) < admitted_error && \
78 relative_error(exp.z, got.z) < admitted_error, \
79 "Expected scale = (%f, %f, %f), \
80 got scale = (%f, %f, %f)\n", \
81 exp.x, exp.y, exp.z, got.x, got.y, got.z)
83 #define compare_translation(exp, got) \
84 ok(relative_error(exp.x, got.x) < admitted_error && \
85 relative_error(exp.y, got.y) < admitted_error && \
86 relative_error(exp.z, got.z) < admitted_error, \
87 "Expected translation = (%f, %f, %f), \
88 got translation = (%f, %f, %f)\n", \
89 exp.x, exp.y, exp.z, got.x, got.y, got.z)
91 #define compare_vectors(exp, out) \
92 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
93 ok(relative_error(exp[i].x, out[i].x) < admitted_error && \
94 relative_error(exp[i].y, out[i].y) < admitted_error && \
95 relative_error(exp[i].z, out[i].z) < admitted_error && \
96 relative_error(exp[i].w, out[i].w) < admitted_error, \
97 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
98 out[i].x, out[i].y, out[i].z, out[i].w, \
99 exp[i].x, exp[i].y, exp[i].z, exp[i].w, \
103 #define compare_planes(exp, out) \
104 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
105 ok(relative_error(exp[i].a, out[i].a) < admitted_error && \
106 relative_error(exp[i].b, out[i].b) < admitted_error && \
107 relative_error(exp[i].c, out[i].c) < admitted_error && \
108 relative_error(exp[i].d, out[i].d) < admitted_error, \
109 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
110 out[i].a, out[i].b, out[i].c, out[i].d, \
111 exp[i].a, exp[i].b, exp[i].c, exp[i].d, \
115 #define expect_plane(expectedplane,gotplane) ok((relative_error(expectedplane.a, gotplane.a)<admitted_error)&&(relative_error(expectedplane.b, gotplane.b)<admitted_error)&&(relative_error(expectedplane.c, gotplane.c)<admitted_error)&&(relative_error(expectedplane.d, gotplane.d)<admitted_error),"Expected Plane= (%f, %f, %f, %f)\n , Got Plane= (%f, %f, %f, %f)\n", expectedplane.a, expectedplane.b, expectedplane.c, expectedplane.d, gotplane.a, gotplane.b, gotplane.c, gotplane.d);
117 #define expect_vec(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
119 #define expect_vec3(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
121 #define expect_vec4(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error)&&(relative_error(expectedvec.w, gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
124 static void D3DXColorTest(void)
126 D3DXCOLOR color, color1, color2, expected, got;
127 LPD3DXCOLOR funcpointer;
130 color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
131 color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
132 color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
136 /*_______________D3DXColorAdd________________*/
137 expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f, expected.a = 0.93f;
138 D3DXColorAdd(&got,&color1,&color2);
139 expect_color(expected,got);
140 /* Test the NULL case */
141 funcpointer = D3DXColorAdd(&got,NULL,&color2);
142 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
143 funcpointer = D3DXColorAdd(NULL,NULL,&color2);
144 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
145 funcpointer = D3DXColorAdd(NULL,NULL,NULL);
146 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
148 /*_______________D3DXColorAdjustContrast______*/
149 expected.r = 0.41f; expected.g = 0.575f; expected.b = 0.473f, expected.a = 0.93f;
150 D3DXColorAdjustContrast(&got,&color,scale);
151 expect_color(expected,got);
153 /*_______________D3DXColorAdjustSaturation______*/
154 expected.r = 0.486028f; expected.g = 0.651028f; expected.b = 0.549028f, expected.a = 0.93f;
155 D3DXColorAdjustSaturation(&got,&color,scale);
156 expect_color(expected,got);
158 /*_______________D3DXColorLerp________________*/
159 expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
160 D3DXColorLerp(&got,&color,&color1,scale);
161 expect_color(expected,got);
162 /* Test the NULL case */
163 funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
164 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
165 funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
166 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
167 funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
168 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
170 /*_______________D3DXColorModulate________________*/
171 expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
172 D3DXColorModulate(&got,&color1,&color2);
173 expect_color(expected,got);
174 /* Test the NULL case */
175 funcpointer = D3DXColorModulate(&got,NULL,&color2);
176 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
177 funcpointer = D3DXColorModulate(NULL,NULL,&color2);
178 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
179 funcpointer = D3DXColorModulate(NULL,NULL,NULL);
180 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
182 /*_______________D3DXColorNegative________________*/
183 expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
184 D3DXColorNegative(&got,&color);
185 expect_color(got,expected);
186 /* Test the greater than 1 case */
187 color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
188 expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
189 D3DXColorNegative(&got,&color1);
190 expect_color(got,expected);
191 /* Test the negative case */
192 color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
193 expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
194 D3DXColorNegative(&got,&color1);
195 expect_color(got,expected);
196 /* Test the NULL case */
197 funcpointer = D3DXColorNegative(&got,NULL);
198 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
199 funcpointer = D3DXColorNegative(NULL,NULL);
200 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
202 /*_______________D3DXColorScale________________*/
203 expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
204 D3DXColorScale(&got,&color,scale);
205 expect_color(expected,got);
206 /* Test the NULL case */
207 funcpointer = D3DXColorScale(&got,NULL,scale);
208 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
209 funcpointer = D3DXColorScale(NULL,NULL,scale);
210 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
212 /*_______________D3DXColorSubtract_______________*/
213 expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f, expected.a = 0.82f;
214 D3DXColorSubtract(&got,&color,&color2);
215 expect_color(expected,got);
216 /* Test the NULL case */
217 funcpointer = D3DXColorSubtract(&got,NULL,&color2);
218 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
219 funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
220 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
221 funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
222 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
225 static void D3DXFresnelTest(void)
230 got = D3DXFresnelTerm(0.5f,1.5);
231 ok(relative_error(got, expected) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
234 static void D3DXMatrixTest(void)
236 D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
237 LPD3DXMATRIX funcpointer;
240 D3DXVECTOR3 at, axis, eye, last;
243 FLOAT angle, determinant, expectedfloat, gotfloat;
245 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
246 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
247 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
248 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
249 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
250 U(mat).m[3][3] = -40.0f;
252 U(mat2).m[0][0] = 1.0f; U(mat2).m[1][0] = 2.0f; U(mat2).m[2][0] = 3.0f;
253 U(mat2).m[3][0] = 4.0f; U(mat2).m[0][1] = 5.0f; U(mat2).m[1][1] = 6.0f;
254 U(mat2).m[2][1] = 7.0f; U(mat2).m[3][1] = 8.0f; U(mat2).m[0][2] = -8.0f;
255 U(mat2).m[1][2] = -7.0f; U(mat2).m[2][2] = -6.0f; U(mat2).m[3][2] = -5.0f;
256 U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f;
257 U(mat2).m[3][3] = -1.0f;
259 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
261 q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
262 r.x = 0.87f; r.y = 0.65f; r.z =0.43f; r.w= 0.21f;
264 at.x = -2.0f; at.y = 13.0f; at.z = -9.0f;
265 axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f;
266 eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
267 last.x = 9.7f; last.y = -8.6; last.z = 1.3f;
269 light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3;
271 angle = D3DX_PI/3.0f;
273 /*____________D3DXMatrixAffineTransformation______*/
274 U(expectedmat).m[0][0] = -459.239990f; U(expectedmat).m[0][1] = -576.719971f; U(expectedmat).m[0][2] = -263.440002f; U(expectedmat).m[0][3] = 0.0f;
275 U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f;
276 U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f;
277 U(expectedmat).m[3][0] = -1239.0f; U(expectedmat).m[3][1] = 667.0f; U(expectedmat).m[3][2] = 567.0f; U(expectedmat).m[3][3] = 1.0f;
278 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, &q, &axis);
279 expect_mat(&expectedmat, &gotmat);
281 /* Test the NULL case */
282 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;
283 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, &q, &axis);
284 expect_mat(&expectedmat, &gotmat);
286 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;
287 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, &q, NULL);
288 expect_mat(&expectedmat, &gotmat);
290 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;
291 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, &q, NULL);
292 expect_mat(&expectedmat, &gotmat);
294 U(expectedmat).m[0][0] = 3.56f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
295 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 3.56f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
296 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 3.56f; U(expectedmat).m[2][3] = 0.0f;
297 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;
298 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, NULL, &axis);
299 expect_mat(&expectedmat, &gotmat);
301 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, NULL, &axis);
302 expect_mat(&expectedmat, &gotmat);
304 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;
305 D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, NULL, NULL);
306 expect_mat(&expectedmat, &gotmat);
308 D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, NULL, NULL);
309 expect_mat(&expectedmat, &gotmat);
311 /*____________D3DXMatrixfDeterminant_____________*/
312 expectedfloat = -147888.0f;
313 gotfloat = D3DXMatrixDeterminant(&mat);
314 ok(relative_error(gotfloat, expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
316 /*____________D3DXMatrixInverse______________*/
317 U(expectedmat).m[0][0] = 16067.0f/73944.0f; U(expectedmat).m[0][1] = -10165.0f/147888.0f; U(expectedmat).m[0][2] = -2729.0f/147888.0f; U(expectedmat).m[0][3] = -1631.0f/49296.0f;
318 U(expectedmat).m[1][0] = -565.0f/36972.0f; U(expectedmat).m[1][1] = 2723.0f/73944.0f; U(expectedmat).m[1][2] = -1073.0f/73944.0f; U(expectedmat).m[1][3] = 289.0f/24648.0f;
319 U(expectedmat).m[2][0] = -389.0f/2054.0f; U(expectedmat).m[2][1] = 337.0f/4108.0f; U(expectedmat).m[2][2] = 181.0f/4108.0f; U(expectedmat).m[2][3] = 317.0f/4108.0f;
320 U(expectedmat).m[3][0] = 163.0f/5688.0f; U(expectedmat).m[3][1] = -101.0f/11376.0f; U(expectedmat).m[3][2] = -73.0f/11376.0f; U(expectedmat).m[3][3] = -127.0f/3792.0f;
321 expectedfloat = -147888.0f;
322 D3DXMatrixInverse(&gotmat,&determinant,&mat);
323 expect_mat(&expectedmat, &gotmat);
324 ok(relative_error( determinant, expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, determinant);
325 funcpointer = D3DXMatrixInverse(&gotmat,NULL,&mat2);
326 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
328 /*____________D3DXMatrixIsIdentity______________*/
330 memset(&mat3, 0, sizeof(mat3));
331 got = D3DXMatrixIsIdentity(&mat3);
332 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
333 D3DXMatrixIdentity(&mat3);
335 got = D3DXMatrixIsIdentity(&mat3);
336 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
337 U(mat3).m[0][0] = 0.000009f;
339 got = D3DXMatrixIsIdentity(&mat3);
340 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
341 /* Test the NULL case */
343 got = D3DXMatrixIsIdentity(NULL);
344 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
346 /*____________D3DXMatrixLookatLH_______________*/
347 U(expectedmat).m[0][0] = -0.822465f; U(expectedmat).m[0][1] = -0.409489f; U(expectedmat).m[0][2] = -0.394803f; U(expectedmat).m[0][3] = 0.0f;
348 U(expectedmat).m[1][0] = -0.555856f; U(expectedmat).m[1][1] = 0.431286f; U(expectedmat).m[1][2] = 0.710645f; U(expectedmat).m[1][3] = 0.0f;
349 U(expectedmat).m[2][0] = -0.120729f; U(expectedmat).m[2][1] = 0.803935f; U(expectedmat).m[2][2] = -0.582335f; U(expectedmat).m[2][3] = 0.0f;
350 U(expectedmat).m[3][0] = 4.494634f; U(expectedmat).m[3][1] = 0.809719f; U(expectedmat).m[3][2] = 10.060076f; U(expectedmat).m[3][3] = 1.0f;
351 D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
352 expect_mat(&expectedmat, &gotmat);
354 /*____________D3DXMatrixLookatRH_______________*/
355 U(expectedmat).m[0][0] = 0.822465f; U(expectedmat).m[0][1] = -0.409489f; U(expectedmat).m[0][2] = 0.394803f; U(expectedmat).m[0][3] = 0.0f;
356 U(expectedmat).m[1][0] = 0.555856f; U(expectedmat).m[1][1] = 0.431286f; U(expectedmat).m[1][2] = -0.710645f; U(expectedmat).m[1][3] = 0.0f;
357 U(expectedmat).m[2][0] = 0.120729f; U(expectedmat).m[2][1] = 0.803935f; U(expectedmat).m[2][2] = 0.582335f; U(expectedmat).m[2][3] = 0.0f;
358 U(expectedmat).m[3][0] = -4.494634f; U(expectedmat).m[3][1] = 0.809719f; U(expectedmat).m[3][2] = -10.060076f; U(expectedmat).m[3][3] = 1.0f;
359 D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
360 expect_mat(&expectedmat, &gotmat);
362 /*____________D3DXMatrixMultiply______________*/
363 U(expectedmat).m[0][0] = 73.0f; U(expectedmat).m[0][1] = 193.0f; U(expectedmat).m[0][2] = -197.0f; U(expectedmat).m[0][3] = -77.0f;
364 U(expectedmat).m[1][0] = 231.0f; U(expectedmat).m[1][1] = 551.0f; U(expectedmat).m[1][2] = -489.0f; U(expectedmat).m[1][3] = -169.0;
365 U(expectedmat).m[2][0] = 239.0f; U(expectedmat).m[2][1] = 523.0f; U(expectedmat).m[2][2] = -400.0f; U(expectedmat).m[2][3] = -116.0f;
366 U(expectedmat).m[3][0] = -164.0f; U(expectedmat).m[3][1] = -320.0f; U(expectedmat).m[3][2] = 187.0f; U(expectedmat).m[3][3] = 31.0f;
367 D3DXMatrixMultiply(&gotmat,&mat,&mat2);
368 expect_mat(&expectedmat, &gotmat);
370 /*____________D3DXMatrixMultiplyTranspose____*/
371 U(expectedmat).m[0][0] = 73.0f; U(expectedmat).m[0][1] = 231.0f; U(expectedmat).m[0][2] = 239.0f; U(expectedmat).m[0][3] = -164.0f;
372 U(expectedmat).m[1][0] = 193.0f; U(expectedmat).m[1][1] = 551.0f; U(expectedmat).m[1][2] = 523.0f; U(expectedmat).m[1][3] = -320.0;
373 U(expectedmat).m[2][0] = -197.0f; U(expectedmat).m[2][1] = -489.0f; U(expectedmat).m[2][2] = -400.0f; U(expectedmat).m[2][3] = 187.0f;
374 U(expectedmat).m[3][0] = -77.0f; U(expectedmat).m[3][1] = -169.0f; U(expectedmat).m[3][2] = -116.0f; U(expectedmat).m[3][3] = 31.0f;
375 D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
376 expect_mat(&expectedmat, &gotmat);
378 /*____________D3DXMatrixOrthoLH_______________*/
379 U(expectedmat).m[0][0] = 0.8f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
380 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.270270f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
381 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.151515f; U(expectedmat).m[2][3] = 0.0f;
382 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -0.484848f; U(expectedmat).m[3][3] = 1.0f;
383 D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
384 expect_mat(&expectedmat, &gotmat);
386 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
387 U(expectedmat).m[0][0] = 3.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
388 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.180180f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
389 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.045662f; U(expectedmat).m[2][3] = 0.0f;
390 U(expectedmat).m[3][0] = -1.727272f; U(expectedmat).m[3][1] = -0.567568f; U(expectedmat).m[3][2] = 0.424658f; U(expectedmat).m[3][3] = 1.0f;
391 D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
392 expect_mat(&expectedmat, &gotmat);
394 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
395 U(expectedmat).m[0][0] = 3.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
396 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.180180f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
397 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.045662f; U(expectedmat).m[2][3] = 0.0f;
398 U(expectedmat).m[3][0] = -1.727272f; U(expectedmat).m[3][1] = -0.567568f; U(expectedmat).m[3][2] = 0.424658f; U(expectedmat).m[3][3] = 1.0f;
399 D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
400 expect_mat(&expectedmat, &gotmat);
402 /*____________D3DXMatrixOrthoRH_______________*/
403 U(expectedmat).m[0][0] = 0.8f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
404 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.270270f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
405 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.151515f; U(expectedmat).m[2][3] = 0.0f;
406 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -0.484848f; U(expectedmat).m[3][3] = 1.0f;
407 D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
408 expect_mat(&expectedmat, &gotmat);
410 /*____________D3DXMatrixPerspectiveFovLH_______________*/
411 U(expectedmat).m[0][0] = 13.288858f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
412 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 9.966644f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
413 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.783784f; U(expectedmat).m[2][3] = 1.0f;
414 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
415 D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
416 expect_mat(&expectedmat, &gotmat);
418 /*____________D3DXMatrixPerspectiveFovRH_______________*/
419 U(expectedmat).m[0][0] = 13.288858f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
420 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 9.966644f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
421 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.783784f; U(expectedmat).m[2][3] = -1.0f;
422 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
423 D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
424 expect_mat(&expectedmat, &gotmat);
426 /*____________D3DXMatrixPerspectiveLH_______________*/
427 U(expectedmat).m[0][0] = -24.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
428 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = -6.4f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
429 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.783784f; U(expectedmat).m[2][3] = 1.0f;
430 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
431 D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
432 expect_mat(&expectedmat, &gotmat);
434 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
435 U(expectedmat).m[0][0] = 11.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
436 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.576577f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
437 U(expectedmat).m[2][0] = -1.727273f; U(expectedmat).m[2][1] = -0.567568f; U(expectedmat).m[2][2] = 0.840796f; U(expectedmat).m[2][3] = 1.0f;
438 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -2.690547f; U(expectedmat).m[3][3] = 0.0f;
439 D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
440 expect_mat(&expectedmat, &gotmat);
442 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
443 U(expectedmat).m[0][0] = 11.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
444 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.576577f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
445 U(expectedmat).m[2][0] = 1.727273f; U(expectedmat).m[2][1] = 0.567568f; U(expectedmat).m[2][2] = -0.840796f; U(expectedmat).m[2][3] = -1.0f;
446 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -2.690547f; U(expectedmat).m[3][3] = 0.0f;
447 D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
448 expect_mat(&expectedmat, &gotmat);
450 /*____________D3DXMatrixPerspectiveRH_______________*/
451 U(expectedmat).m[0][0] = -24.0f; U(expectedmat).m[0][1] = -0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
452 U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = -6.4f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
453 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.783784f; U(expectedmat).m[2][3] = -1.0f;
454 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
455 D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
456 expect_mat(&expectedmat, &gotmat);
458 /*____________D3DXMatrixReflect______________*/
459 U(expectedmat).m[0][0] = 0.307692f; U(expectedmat).m[0][1] = -0.230769f; U(expectedmat).m[0][2] = 0.923077f; U(expectedmat).m[0][3] = 0.0f;
460 U(expectedmat).m[1][0] = -0.230769; U(expectedmat).m[1][1] = 0.923077f; U(expectedmat).m[1][2] = 0.307693f; U(expectedmat).m[1][3] = 0.0f;
461 U(expectedmat).m[2][0] = 0.923077f; U(expectedmat).m[2][1] = 0.307693f; U(expectedmat).m[2][2] = -0.230769f; U(expectedmat).m[2][3] = 0.0f;
462 U(expectedmat).m[3][0] = 1.615385f; U(expectedmat).m[3][1] = 0.538462f; U(expectedmat).m[3][2] = -2.153846f; U(expectedmat).m[3][3] = 1.0f;
463 D3DXMatrixReflect(&gotmat,&plane);
464 expect_mat(&expectedmat, &gotmat);
466 /*____________D3DXMatrixRotationAxis_____*/
467 U(expectedmat).m[0][0] = 0.508475f; U(expectedmat).m[0][1] = 0.763805f; U(expectedmat).m[0][2] = 0.397563f; U(expectedmat).m[0][3] = 0.0f;
468 U(expectedmat).m[1][0] = -0.814652f; U(expectedmat).m[1][1] = 0.576271f; U(expectedmat).m[1][2] = -0.065219f; U(expectedmat).m[1][3] = 0.0f;
469 U(expectedmat).m[2][0] = -0.278919f; U(expectedmat).m[2][1] = -0.290713f; U(expectedmat).m[2][2] = 0.915254f; U(expectedmat).m[2][3] = 0.0f;
470 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;
471 D3DXMatrixRotationAxis(&gotmat,&axis,angle);
472 expect_mat(&expectedmat, &gotmat);
474 /*____________D3DXMatrixRotationQuaternion______________*/
475 U(expectedmat).m[0][0] = -129.0f; U(expectedmat).m[0][1] = -162.0f; U(expectedmat).m[0][2] = -74.0f; U(expectedmat).m[0][3] = 0.0f;
476 U(expectedmat).m[1][0] = 146.0f; U(expectedmat).m[1][1] = -99.0f; U(expectedmat).m[1][2] = -78.0f; U(expectedmat).m[1][3] = 0.0f;
477 U(expectedmat).m[2][0] = 102.0f; U(expectedmat).m[2][1] = -34.0f; U(expectedmat).m[2][2] = -33.0f; U(expectedmat).m[2][3] = 0.0f;
478 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;
479 D3DXMatrixRotationQuaternion(&gotmat,&q);
480 expect_mat(&expectedmat, &gotmat);
482 /*____________D3DXMatrixRotationX______________*/
483 U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
484 U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 0.5f; U(expectedmat).m[1][2] = sqrt(3.0f)/2.0f; U(expectedmat).m[1][3] = 0.0f;
485 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = -sqrt(3.0f)/2.0f; U(expectedmat).m[2][2] = 0.5f; U(expectedmat).m[2][3] = 0.0f;
486 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;
487 D3DXMatrixRotationX(&gotmat,angle);
488 expect_mat(&expectedmat, &gotmat);
490 /*____________D3DXMatrixRotationY______________*/
491 U(expectedmat).m[0][0] = 0.5f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = -sqrt(3.0f)/2.0f; U(expectedmat).m[0][3] = 0.0f;
492 U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
493 U(expectedmat).m[2][0] = sqrt(3.0f)/2.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.5f; U(expectedmat).m[2][3] = 0.0f;
494 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;
495 D3DXMatrixRotationY(&gotmat,angle);
496 expect_mat(&expectedmat, &gotmat);
498 /*____________D3DXMatrixRotationYawPitchRoll____*/
499 U(expectedmat).m[0][0] = 0.888777f; U(expectedmat).m[0][1] = 0.091875f; U(expectedmat).m[0][2] = -0.449037f; U(expectedmat).m[0][3] = 0.0f;
500 U(expectedmat).m[1][0] = 0.351713f; U(expectedmat).m[1][1] = 0.491487f; U(expectedmat).m[1][2] = 0.796705f; U(expectedmat).m[1][3] = 0.0f;
501 U(expectedmat).m[2][0] = 0.293893f; U(expectedmat).m[2][1] = -0.866025f; U(expectedmat).m[2][2] = 0.404509f; U(expectedmat).m[2][3] = 0.0f;
502 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;
503 D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
504 expect_mat(&expectedmat, &gotmat);
506 /*____________D3DXMatrixRotationZ______________*/
507 U(expectedmat).m[0][0] = 0.5f; U(expectedmat).m[0][1] = sqrt(3.0f)/2.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
508 U(expectedmat).m[1][0] = -sqrt(3.0f)/2.0f; U(expectedmat).m[1][1] = 0.5f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
509 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 1.0f; U(expectedmat).m[2][3] = 0.0f;
510 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;
511 D3DXMatrixRotationZ(&gotmat,angle);
512 expect_mat(&expectedmat, &gotmat);
514 /*____________D3DXMatrixScaling______________*/
515 U(expectedmat).m[0][0] = 0.69f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
516 U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 0.53f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
517 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 4.11f; U(expectedmat).m[2][3] = 0.0f;
518 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;
519 D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
520 expect_mat(&expectedmat, &gotmat);
522 /*____________D3DXMatrixShadow______________*/
523 U(expectedmat).m[0][0] = 12.786773f; U(expectedmat).m[0][1] = 5.000961f; U(expectedmat).m[0][2] = 4.353778f; U(expectedmat).m[0][3] = 3.706595f;
524 U(expectedmat).m[1][0] = 1.882715; U(expectedmat).m[1][1] = 8.805615f; U(expectedmat).m[1][2] = 1.451259f; U(expectedmat).m[1][3] = 1.235532f;
525 U(expectedmat).m[2][0] = -7.530860f; U(expectedmat).m[2][1] = -6.667949f; U(expectedmat).m[2][2] = 1.333590f; U(expectedmat).m[2][3] = -4.942127f;
526 U(expectedmat).m[3][0] = -13.179006f; U(expectedmat).m[3][1] = -11.668910f; U(expectedmat).m[3][2] = -10.158816f; U(expectedmat).m[3][3] = -1.510094f;
527 D3DXMatrixShadow(&gotmat,&light,&plane);
528 expect_mat(&expectedmat, &gotmat);
530 /*____________D3DXMatrixTransformation______________*/
531 U(expectedmat).m[0][0] = -0.2148f; U(expectedmat).m[0][1] = 1.3116f; U(expectedmat).m[0][2] = 0.4752f; U(expectedmat).m[0][3] = 0.0f;
532 U(expectedmat).m[1][0] = 0.9504f; U(expectedmat).m[1][1] = -0.8836f; U(expectedmat).m[1][2] = 0.9244f; U(expectedmat).m[1][3] = 0.0f;
533 U(expectedmat).m[2][0] = 1.0212f; U(expectedmat).m[2][1] = 0.1936f; U(expectedmat).m[2][2] = -1.3588f; U(expectedmat).m[2][3] = 0.0f;
534 U(expectedmat).m[3][0] = 18.2985f; U(expectedmat).m[3][1] = -29.624001f; U(expectedmat).m[3][2] = 15.683499f; U(expectedmat).m[3][3] = 1.0f;
535 D3DXMatrixTransformation(&gotmat,&at,&q,NULL,&eye,&r,&last);
536 expect_mat(&expectedmat, &gotmat);
538 /*____________D3DXMatrixTranslation______________*/
539 U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
540 U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
541 U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 1.0f; U(expectedmat).m[2][3] = 0.0f;
542 U(expectedmat).m[3][0] = 0.69f; U(expectedmat).m[3][1] = 0.53f; U(expectedmat).m[3][2] = 4.11f; U(expectedmat).m[3][3] = 1.0f;
543 D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
544 expect_mat(&expectedmat, &gotmat);
546 /*____________D3DXMatrixTranspose______________*/
547 U(expectedmat).m[0][0] = 10.0f; U(expectedmat).m[0][1] = 11.0f; U(expectedmat).m[0][2] = 19.0f; U(expectedmat).m[0][3] = 2.0f;
548 U(expectedmat).m[1][0] = 5.0; U(expectedmat).m[1][1] = 20.0f; U(expectedmat).m[1][2] = -21.0f; U(expectedmat).m[1][3] = 3.0f;
549 U(expectedmat).m[2][0] = 7.0f; U(expectedmat).m[2][1] = 16.0f; U(expectedmat).m[2][2] = 30.f; U(expectedmat).m[2][3] = -4.0f;
550 U(expectedmat).m[3][0] = 8.0f; U(expectedmat).m[3][1] = 33.0f; U(expectedmat).m[3][2] = 43.0f; U(expectedmat).m[3][3] = -40.0f;
551 D3DXMatrixTranspose(&gotmat,&mat);
552 expect_mat(&expectedmat, &gotmat);
555 static void D3DXPlaneTest(void)
558 D3DXPLANE expectedplane, gotplane, nulplane, plane;
559 D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
560 LPD3DXVECTOR3 funcpointer;
564 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
565 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
566 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
567 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
568 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
569 U(mat).m[3][3] = -40.0f;
571 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
573 vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
575 /*_______________D3DXPlaneDot________________*/
577 got = D3DXPlaneDot(&plane,&vec),
578 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
580 got = D3DXPlaneDot(NULL,&vec),
581 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
583 got = D3DXPlaneDot(NULL,NULL),
584 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
586 /*_______________D3DXPlaneDotCoord________________*/
588 got = D3DXPlaneDotCoord(&plane,&vec),
589 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
591 got = D3DXPlaneDotCoord(NULL,&vec),
592 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
594 got = D3DXPlaneDotCoord(NULL,NULL),
595 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
597 /*_______________D3DXPlaneDotNormal______________*/
599 got = D3DXPlaneDotNormal(&plane,&vec),
600 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
602 got = D3DXPlaneDotNormal(NULL,&vec),
603 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
605 got = D3DXPlaneDotNormal(NULL,NULL),
606 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
608 /*_______________D3DXPlaneFromPointNormal_______*/
609 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
610 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
611 expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
612 D3DXPlaneFromPointNormal(&gotplane,&vec1,&vec2);
613 expect_plane(expectedplane, gotplane);
615 /*_______________D3DXPlaneFromPoints_______*/
616 vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
617 vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
618 vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
619 expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
620 D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
621 expect_plane(expectedplane, gotplane);
623 /*_______________D3DXPlaneIntersectLine___________*/
624 vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
625 vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
626 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
627 D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
628 expect_vec3(expectedvec, gotvec);
629 /* Test a parallel line */
630 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
631 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
632 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
633 funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
634 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
636 /*_______________D3DXPlaneNormalize______________*/
637 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);
638 D3DXPlaneNormalize(&gotplane, &plane);
639 expect_plane(expectedplane, gotplane);
640 nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
641 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
642 D3DXPlaneNormalize(&gotplane, &nulplane);
643 expect_plane(expectedplane, gotplane);
645 /*_______________D3DXPlaneTransform____________*/
646 expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
647 D3DXPlaneTransform(&gotplane,&plane,&mat);
648 expect_plane(expectedplane, gotplane);
651 static void D3DXQuaternionTest(void)
654 D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, smallq, smallr, q, r, s, t, u;
655 LPD3DXQUATERNION funcpointer;
656 D3DXVECTOR3 axis, expectedvec;
657 FLOAT angle, expected, got, scale, scale2;
658 BOOL expectedbool, gotbool;
660 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
661 q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
662 r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
663 t.x = -1111.0f, t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
664 u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
665 smallq.x = 0.1f; smallq.y = 0.2f; smallq.z= 0.3f; smallq.w = 0.4f;
666 smallr.x = 0.5f; smallr.y = 0.6f; smallr.z= 0.7f; smallr.w = 0.8f;
671 /*_______________D3DXQuaternionBaryCentric________________________*/
672 expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
673 D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
674 expect_vec4(expectedquat,gotquat);
676 /*_______________D3DXQuaternionConjugate________________*/
677 expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
678 D3DXQuaternionConjugate(&gotquat,&q);
679 expect_vec4(expectedquat,gotquat);
680 /* Test the NULL case */
681 funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
682 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
683 funcpointer = D3DXQuaternionConjugate(NULL,NULL);
684 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
686 /*_______________D3DXQuaternionDot______________________*/
688 got = D3DXQuaternionDot(&q,&r);
689 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
690 /* Tests the case NULL */
692 got = D3DXQuaternionDot(NULL,&r);
693 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
695 got = D3DXQuaternionDot(NULL,NULL);
696 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
698 /*_______________D3DXQuaternionExp______________________________*/
699 expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
700 D3DXQuaternionExp(&gotquat,&q);
701 expect_vec4(expectedquat,gotquat);
702 /* Test the null quaternion */
703 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
704 D3DXQuaternionExp(&gotquat,&nul);
705 expect_vec4(expectedquat,gotquat);
706 /* Test the case where the norm of the quaternion is <1 */
707 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
708 expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
709 D3DXQuaternionExp(&gotquat,&Nq1);
710 expect_vec4(expectedquat,gotquat);
712 /*_______________D3DXQuaternionIdentity________________*/
713 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
714 D3DXQuaternionIdentity(&gotquat);
715 expect_vec4(expectedquat,gotquat);
716 /* Test the NULL case */
717 funcpointer = D3DXQuaternionIdentity(NULL);
718 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
720 /*_______________D3DXQuaternionInverse________________________*/
721 expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
722 D3DXQuaternionInverse(&gotquat,&q);
723 expect_vec4(expectedquat,gotquat);
725 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 10.0f;
726 D3DXQuaternionInverse(&gotquat,&gotquat);
727 expect_vec4(expectedquat,gotquat);
730 /*_______________D3DXQuaternionIsIdentity________________*/
731 s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
733 gotbool = D3DXQuaternionIsIdentity(&s);
734 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
735 s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
736 expectedbool = FALSE;
737 gotbool = D3DXQuaternionIsIdentity(&q);
738 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
739 /* Test the NULL case */
740 gotbool = D3DXQuaternionIsIdentity(NULL);
741 ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
743 /*_______________D3DXQuaternionLength__________________________*/
745 got = D3DXQuaternionLength(&q);
746 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
747 /* Tests the case NULL */
749 got = D3DXQuaternionLength(NULL);
750 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
752 /*_______________D3DXQuaternionLengthSq________________________*/
754 got = D3DXQuaternionLengthSq(&q);
755 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
756 /* Tests the case NULL */
758 got = D3DXQuaternionLengthSq(NULL);
759 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
761 /*_______________D3DXQuaternionLn______________________________*/
762 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
763 D3DXQuaternionLn(&gotquat,&q);
764 expect_vec4(expectedquat,gotquat);
765 expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
766 D3DXQuaternionLn(&gotquat,&r);
767 expect_vec4(expectedquat,gotquat);
768 Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
769 expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
770 D3DXQuaternionLn(&gotquat,&Nq);
771 expect_vec4(expectedquat,gotquat);
772 Nq.x = 0.0f; Nq.y = 0.0f; Nq.z = 0.0f; Nq.w = 1.0f;
773 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
774 D3DXQuaternionLn(&gotquat,&Nq);
775 expect_vec4(expectedquat,gotquat);
776 Nq.x = 5.4f; Nq.y = 1.2f; Nq.z = -0.3f; Nq.w = -0.3f;
777 expectedquat.x = 10.616652f; expectedquat.y = 2.359256f; expectedquat.z = -0.589814f; expectedquat.w = 0.0f;
778 D3DXQuaternionLn(&gotquat,&Nq);
779 expect_vec4(expectedquat,gotquat);
780 /* Test the case where the norm of the quaternion is <1 */
781 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = 0.9f;
782 expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
783 D3DXQuaternionLn(&gotquat,&Nq1);
784 expect_vec4(expectedquat,gotquat);
785 /* Test the case where the real part of the quaternion is -1.0f */
786 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w = -1.0f;
787 expectedquat.x = 0.2f; expectedquat.y = 0.1f; expectedquat.z = 0.3f; expectedquat.w = 0.0f;
788 D3DXQuaternionLn(&gotquat,&Nq1);
789 expect_vec4(expectedquat,gotquat);
791 /*_______________D3DXQuaternionMultiply________________________*/
792 expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
793 D3DXQuaternionMultiply(&gotquat,&q,&r);
794 expect_vec4(expectedquat,gotquat);
796 /*_______________D3DXQuaternionNormalize________________________*/
797 expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
798 D3DXQuaternionNormalize(&gotquat,&q);
799 expect_vec4(expectedquat,gotquat);
801 /*_______________D3DXQuaternionRotationAxis___________________*/
802 axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
803 angle = D3DX_PI/3.0f;
804 expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
805 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
806 expect_vec4(expectedquat,gotquat);
807 /* Test the nul quaternion */
808 axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
809 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
810 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
811 expect_vec4(expectedquat,gotquat);
813 /*_______________D3DXQuaternionRotationMatrix___________________*/
814 /* test when the trace is >0 */
815 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
816 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
817 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
818 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
819 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
820 U(mat).m[3][3] = 48.0f;
821 expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
822 D3DXQuaternionRotationMatrix(&gotquat,&mat);
823 expect_vec4(expectedquat,gotquat);
824 /* test the case when the greater element is (2,2) */
825 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
826 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
827 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
828 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
829 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
830 U(mat).m[3][3] = 48.0f;
831 expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
832 D3DXQuaternionRotationMatrix(&gotquat,&mat);
833 expect_vec4(expectedquat,gotquat);
834 /* test the case when the greater element is (1,1) */
835 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
836 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
837 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
838 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
839 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
840 U(mat).m[3][3] = 48.0f;
841 expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
842 D3DXQuaternionRotationMatrix(&gotquat,&mat);
843 expect_vec4(expectedquat,gotquat);
844 /* test the case when the trace is near 0 in a matrix which is not a rotation */
845 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
846 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
847 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
848 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
849 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.9f;
850 U(mat).m[3][3] = 48.0f;
851 expectedquat.x = 1.709495f; expectedquat.y = 2.339872f; expectedquat.z = -0.534217f; expectedquat.w = 1.282122f;
852 D3DXQuaternionRotationMatrix(&gotquat,&mat);
853 expect_vec4(expectedquat,gotquat);
854 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
855 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
856 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
857 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
858 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
859 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.51f;
860 U(mat).m[3][3] = 48.0f;
861 expectedquat.x = 1.724923f; expectedquat.y = 2.318944f; expectedquat.z = -0.539039f; expectedquat.w = 1.293692f;
862 D3DXQuaternionRotationMatrix(&gotquat,&mat);
863 expect_vec4(expectedquat,gotquat);
864 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
865 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
866 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
867 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
868 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
869 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.49f;
870 U(mat).m[3][3] = 48.0f;
871 expectedquat.x = 1.725726f; expectedquat.y = 2.317865f; expectedquat.z = -0.539289f; expectedquat.w = 1.294294f;
872 D3DXQuaternionRotationMatrix(&gotquat,&mat);
873 expect_vec4(expectedquat,gotquat);
874 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
875 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
876 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
877 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
878 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
879 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.01f;
880 U(mat).m[3][3] = 48.0f;
881 expectedquat.x = 1.745328f; expectedquat.y = 2.291833f; expectedquat.z = -0.545415f; expectedquat.w = 1.308996f;
882 D3DXQuaternionRotationMatrix(&gotquat,&mat);
883 expect_vec4(expectedquat,gotquat);
884 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
885 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
886 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
887 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
888 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
889 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.0f;
890 U(mat).m[3][3] = 48.0f;
891 expectedquat.x = 1.745743f; expectedquat.y = 2.291288f; expectedquat.z = -0.545545f; expectedquat.w = 1.309307f;
892 D3DXQuaternionRotationMatrix(&gotquat,&mat);
893 expect_vec4(expectedquat,gotquat);
894 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
895 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
896 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
897 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
898 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
899 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.01f;
900 U(mat).m[3][3] = 48.0f;
901 expectedquat.x = 18.408188f; expectedquat.y = 5.970223f; expectedquat.z = -2.985111f; expectedquat.w = 0.502494f;
902 D3DXQuaternionRotationMatrix(&gotquat,&mat);
903 expect_vec4(expectedquat,gotquat);
904 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
905 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
906 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
907 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
908 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
909 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.5f;
910 U(mat).m[3][3] = 48.0f;
911 expectedquat.x = 15.105186f; expectedquat.y = 4.898980f; expectedquat.z = -2.449490f; expectedquat.w = 0.612372f;
912 D3DXQuaternionRotationMatrix(&gotquat,&mat);
913 expect_vec4(expectedquat,gotquat);
914 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
915 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
916 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
917 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
918 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
919 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.70f;
920 U(mat).m[3][3] = 48.0f;
921 expectedquat.x = 14.188852f; expectedquat.y = 4.601790f; expectedquat.z = -2.300895f; expectedquat.w = 0.651920f;
922 D3DXQuaternionRotationMatrix(&gotquat,&mat);
923 expect_vec4(expectedquat,gotquat);
924 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
925 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
926 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
927 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
928 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
929 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.99f;
930 U(mat).m[3][3] = 48.0f;
931 expectedquat.x = 13.114303f; expectedquat.y = 4.253287f; expectedquat.z = -2.126644f; expectedquat.w = 0.705337f;
932 D3DXQuaternionRotationMatrix(&gotquat,&mat);
933 expect_vec4(expectedquat,gotquat);
934 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
935 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
936 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
937 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
938 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
939 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 2.0f;
940 U(mat).m[3][3] = 48.0f;
941 expectedquat.x = 10.680980f; expectedquat.y = 3.464102f; expectedquat.z = -1.732051f; expectedquat.w = 0.866025f;
942 D3DXQuaternionRotationMatrix(&gotquat,&mat);
943 expect_vec4(expectedquat,gotquat);
945 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
946 expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
947 D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
948 expect_vec4(expectedquat,gotquat);
950 /*_______________D3DXQuaternionSlerp________________________*/
951 expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
952 D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
953 expect_vec4(expectedquat,gotquat);
954 expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
955 D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
956 expect_vec4(expectedquat,gotquat);
957 expectedquat.x = 0.239485f; expectedquat.y = 0.346580f; expectedquat.z = 0.453676f; expectedquat.w = 0.560772f;
958 D3DXQuaternionSlerp(&gotquat,&smallq,&smallr,scale);
959 expect_vec4(expectedquat,gotquat);
961 /*_______________D3DXQuaternionSquad________________________*/
962 expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
963 D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
964 expect_vec4(expectedquat,gotquat);
966 /*_______________D3DXQuaternionSquadSetup___________________*/
967 r.x = 1.0f, r.y = 2.0f; r.z = 4.0f; r.w = 10.0f;
968 s.x = -3.0f; s.y = 4.0f; s.z = -5.0f; s.w = 7.0;
969 t.x = -1111.0f, t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
970 u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
971 D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&t,&u);
972 expectedquat.x = 7.121285f; expectedquat.y = 2.159964f; expectedquat.z = -3.855094f; expectedquat.w = 5.362844f;
973 expect_vec4(expectedquat,gotquat);
974 expectedquat.x = -1113.492920f; expectedquat.y = 82.679260f; expectedquat.z = -6.696645f; expectedquat.w = -4.090050f;
975 expect_vec4(expectedquat,Nq);
976 expectedquat.x = -1111.0f; expectedquat.y = 111.0f; expectedquat.z = -11.0f; expectedquat.w = 1.0f;
977 expect_vec4(expectedquat,Nq1);
978 r.x = 0.2f; r.y = 0.3f; r.z = 1.3f; r.w = -0.6f;
979 s.x = -3.0f; s.y =-2.0f; s.z = 4.0f; s.w = 0.2f;
980 t.x = 0.4f; t.y = 8.3f; t.z = -3.1f; t.w = -2.7f;
981 u.x = 1.1f; u.y = -0.7f; u.z = 9.2f; u.w = 0.0f;
982 D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&u,&t);
983 expectedquat.x = -4.139569f; expectedquat.y = -2.469115f; expectedquat.z = 2.364477f; expectedquat.w = 0.465494f;
984 expect_vec4(expectedquat,gotquat);
985 expectedquat.x = 2.342533f; expectedquat.y = 2.365127f; expectedquat.z = 8.628538f; expectedquat.w = -0.898356f;
986 expect_vec4(expectedquat,Nq);
987 expectedquat.x = 1.1f; expectedquat.y = -0.7f; expectedquat.z = 9.2f; expectedquat.w = 0.0f;
988 expect_vec4(expectedquat,Nq1);
989 D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&t,&u);
990 expectedquat.x = -3.754567f; expectedquat.y = -0.586085f; expectedquat.z = 3.815818f; expectedquat.w = -0.198150f;
991 expect_vec4(expectedquat,gotquat);
992 expectedquat.x = 0.140773f; expectedquat.y = -8.737090f; expectedquat.z = -0.516593f; expectedquat.w = 3.053942f;
993 expect_vec4(expectedquat,Nq);
994 expectedquat.x = -0.4f; expectedquat.y = -8.3f; expectedquat.z = 3.1f; expectedquat.w = 2.7f;
995 expect_vec4(expectedquat,Nq1);
996 r.x = -1.0f; r.y = 0.0f; r.z = 0.0f; r.w = 0.0f;
997 s.x = 1.0f; s.y =0.0f; s.z = 0.0f; s.w = 0.0f;
998 t.x = 1.0f; t.y = 0.0f; t.z = 0.0f; t.w = 0.0f;
999 u.x = -1.0f; u.y = 0.0f; u.z = 0.0f; u.w = 0.0f;
1000 D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&t,&u);
1001 expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1002 expect_vec4(expectedquat,gotquat);
1003 expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1004 expect_vec4(expectedquat,Nq);
1005 expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
1006 expect_vec4(expectedquat,Nq1);
1008 /*_______________D3DXQuaternionToAxisAngle__________________*/
1009 Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
1010 expectedvec.x = 1.0f/22.0f; expectedvec.y = 2.0f/22.0f; expectedvec.z = 4.0f/22.0f;
1011 expected = 2.197869f;
1012 D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
1013 expect_vec3(expectedvec,axis);
1014 ok(relative_error(angle, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
1015 /* Test if |w|>1.0f */
1016 expectedvec.x = 1.0f; expectedvec.y = 2.0f; expectedvec.z = 4.0f;
1017 D3DXQuaternionToAxisAngle(&q,&axis,&angle);
1018 expect_vec3(expectedvec,axis);
1019 /* Test the null quaternion */
1020 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1021 expected = 3.141593f;
1022 D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
1023 expect_vec3(expectedvec,axis);
1024 ok(relative_error(angle, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
1027 static void D3DXVector2Test(void)
1029 D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w, x;
1030 LPD3DXVECTOR2 funcpointer;
1031 D3DXVECTOR4 expectedtrans, gottrans;
1033 FLOAT coeff1, coeff2, expected, got, scale;
1035 nul.x = 0.0f; nul.y = 0.0f;
1036 u.x = 3.0f; u.y = 4.0f;
1037 v.x = -7.0f; v.y = 9.0f;
1038 w.x = 4.0f; w.y = -3.0f;
1039 x.x = 2.0f; x.y = -11.0f;
1041 U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
1042 U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
1043 U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
1044 U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
1046 coeff1 = 2.0f; coeff2 = 5.0f;
1049 /*_______________D3DXVec2Add__________________________*/
1050 expectedvec.x = -4.0f; expectedvec.y = 13.0f;
1051 D3DXVec2Add(&gotvec,&u,&v);
1052 expect_vec(expectedvec,gotvec);
1053 /* Tests the case NULL */
1054 funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
1055 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1056 funcpointer = D3DXVec2Add(NULL,NULL,NULL);
1057 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1059 /*_______________D3DXVec2BaryCentric___________________*/
1060 expectedvec.x = -12.0f; expectedvec.y = -21.0f;
1061 D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1062 expect_vec(expectedvec,gotvec);
1064 /*_______________D3DXVec2CatmullRom____________________*/
1065 expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
1066 D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1067 expect_vec(expectedvec,gotvec);
1069 /*_______________D3DXVec2CCW__________________________*/
1071 got = D3DXVec2CCW(&u,&v);
1072 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1073 /* Tests the case NULL */
1075 got = D3DXVec2CCW(NULL,&v);
1076 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1078 got = D3DXVec2CCW(NULL,NULL);
1079 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1081 /*_______________D3DXVec2Dot__________________________*/
1083 got = D3DXVec2Dot(&u,&v);
1084 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1085 /* Tests the case NULL */
1087 got = D3DXVec2Dot(NULL,&v);
1088 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1090 got = D3DXVec2Dot(NULL,NULL);
1091 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1093 /*_______________D3DXVec2Hermite__________________________*/
1094 expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
1095 D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
1096 expect_vec(expectedvec,gotvec);
1098 /*_______________D3DXVec2Length__________________________*/
1100 got = D3DXVec2Length(&u);
1101 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1102 /* Tests the case NULL */
1104 got = D3DXVec2Length(NULL);
1105 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1107 /*_______________D3DXVec2LengthSq________________________*/
1109 got = D3DXVec2LengthSq(&u);
1110 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1111 /* Tests the case NULL */
1113 got = D3DXVec2LengthSq(NULL);
1114 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1116 /*_______________D3DXVec2Lerp__________________________*/
1117 expectedvec.x = 68.0f; expectedvec.y = -28.5f;
1118 D3DXVec2Lerp(&gotvec,&u,&v,scale);
1119 expect_vec(expectedvec,gotvec);
1120 /* Tests the case NULL */
1121 funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
1122 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1123 funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
1124 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1126 /*_______________D3DXVec2Maximize__________________________*/
1127 expectedvec.x = 3.0f; expectedvec.y = 9.0f;
1128 D3DXVec2Maximize(&gotvec,&u,&v);
1129 expect_vec(expectedvec,gotvec);
1130 /* Tests the case NULL */
1131 funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
1132 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1133 funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
1134 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1136 /*_______________D3DXVec2Minimize__________________________*/
1137 expectedvec.x = -7.0f; expectedvec.y = 4.0f;
1138 D3DXVec2Minimize(&gotvec,&u,&v);
1139 expect_vec(expectedvec,gotvec);
1140 /* Tests the case NULL */
1141 funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
1142 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1143 funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
1144 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1146 /*_______________D3DXVec2Normalize_________________________*/
1147 expectedvec.x = 0.6f; expectedvec.y = 0.8f;
1148 D3DXVec2Normalize(&gotvec,&u);
1149 expect_vec(expectedvec,gotvec);
1150 /* Test the nul vector */
1151 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1152 D3DXVec2Normalize(&gotvec,&nul);
1153 expect_vec(expectedvec,gotvec);
1155 /*_______________D3DXVec2Scale____________________________*/
1156 expectedvec.x = -19.5f; expectedvec.y = -26.0f;
1157 D3DXVec2Scale(&gotvec,&u,scale);
1158 expect_vec(expectedvec,gotvec);
1159 /* Tests the case NULL */
1160 funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
1161 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1162 funcpointer = D3DXVec2Scale(NULL,NULL,scale);
1163 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1165 /*_______________D3DXVec2Subtract__________________________*/
1166 expectedvec.x = 10.0f; expectedvec.y = -5.0f;
1167 D3DXVec2Subtract(&gotvec,&u,&v);
1168 expect_vec(expectedvec,gotvec);
1169 /* Tests the case NULL */
1170 funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
1171 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1172 funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
1173 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1175 /*_______________D3DXVec2Transform_______________________*/
1176 expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
1177 D3DXVec2Transform(&gottrans,&u,&mat);
1178 expect_vec4(expectedtrans,gottrans);
1180 /*_______________D3DXVec2TransformCoord_______________________*/
1181 expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
1182 D3DXVec2TransformCoord(&gotvec,&u,&mat);
1183 expect_vec(expectedvec,gotvec);
1185 /*_______________D3DXVec2TransformNormal______________________*/
1186 expectedvec.x = 23.0f; expectedvec.y = 30.0f;
1187 D3DXVec2TransformNormal(&gotvec,&u,&mat);
1188 expect_vec(expectedvec,gotvec);
1191 static void D3DXVector3Test(void)
1193 D3DVIEWPORT9 viewport;
1194 D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w, x;
1195 LPD3DXVECTOR3 funcpointer;
1196 D3DXVECTOR4 expectedtrans, gottrans;
1197 D3DXMATRIX mat, projection, view, world;
1198 FLOAT coeff1, coeff2, expected, got, scale;
1200 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
1201 u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
1202 v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
1203 w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
1204 x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
1206 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
1207 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
1209 U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
1210 U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
1211 U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
1212 U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
1214 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
1215 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
1216 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
1217 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
1218 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
1219 U(view).m[3][3] = -40.0f;
1221 U(world).m[0][0] = 21.0f; U(world).m[0][1] = 2.0f; U(world).m[0][2] = 3.0f; U(world).m[0][3] = 4.0;
1222 U(world).m[1][0] = 5.0f; U(world).m[1][1] = 23.0f; U(world).m[1][2] = 7.0f; U(world).m[1][3] = 8.0f;
1223 U(world).m[2][0] = -8.0f; U(world).m[2][1] = -7.0f; U(world).m[2][2] = 25.0f; U(world).m[2][3] = -5.0f;
1224 U(world).m[3][0] = -4.0f; U(world).m[3][1] = -3.0f; U(world).m[3][2] = -2.0f; U(world).m[3][3] = 27.0f;
1226 coeff1 = 2.0f; coeff2 = 5.0f;
1229 /*_______________D3DXVec3Add__________________________*/
1230 expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
1231 D3DXVec3Add(&gotvec,&u,&v);
1232 expect_vec3(expectedvec,gotvec);
1233 /* Tests the case NULL */
1234 funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
1235 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1236 funcpointer = D3DXVec3Add(NULL,NULL,NULL);
1237 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1239 /*_______________D3DXVec3BaryCentric___________________*/
1240 expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
1241 D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1243 expect_vec3(expectedvec,gotvec);
1245 /*_______________D3DXVec3CatmullRom____________________*/
1246 expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
1247 D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1248 expect_vec3(expectedvec,gotvec);
1250 /*_______________D3DXVec3Cross________________________*/
1251 expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
1252 D3DXVec3Cross(&gotvec,&u,&v);
1253 expect_vec3(expectedvec,gotvec);
1254 /* Tests the case NULL */
1255 funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
1256 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1257 funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
1258 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1260 /*_______________D3DXVec3Dot__________________________*/
1262 got = D3DXVec3Dot(&u,&v);
1263 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1264 /* Tests the case NULL */
1266 got = D3DXVec3Dot(NULL,&v);
1267 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1269 got = D3DXVec3Dot(NULL,NULL);
1270 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1272 /*_______________D3DXVec3Hermite__________________________*/
1273 expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
1274 D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
1275 expect_vec3(expectedvec,gotvec);
1277 /*_______________D3DXVec3Length__________________________*/
1279 got = D3DXVec3Length(&u);
1280 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1281 /* Tests the case NULL */
1283 got = D3DXVec3Length(NULL);
1284 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1286 /*_______________D3DXVec3LengthSq________________________*/
1288 got = D3DXVec3LengthSq(&u);
1289 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1290 /* Tests the case NULL */
1292 got = D3DXVec3LengthSq(NULL);
1293 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1295 /*_______________D3DXVec3Lerp__________________________*/
1296 expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
1297 D3DXVec3Lerp(&gotvec,&u,&v,scale);
1298 expect_vec3(expectedvec,gotvec);
1299 /* Tests the case NULL */
1300 funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
1301 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1302 funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
1303 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1305 /*_______________D3DXVec3Maximize__________________________*/
1306 expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
1307 D3DXVec3Maximize(&gotvec,&u,&v);
1308 expect_vec3(expectedvec,gotvec);
1309 /* Tests the case NULL */
1310 funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
1311 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1312 funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
1313 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1315 /*_______________D3DXVec3Minimize__________________________*/
1316 expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
1317 D3DXVec3Minimize(&gotvec,&u,&v);
1318 expect_vec3(expectedvec,gotvec);
1319 /* Tests the case NULL */
1320 funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
1321 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1322 funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
1323 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1325 /*_______________D3DXVec3Normalize_________________________*/
1326 expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
1327 D3DXVec3Normalize(&gotvec,&u);
1328 expect_vec3(expectedvec,gotvec);
1329 /* Test the nul vector */
1330 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1331 D3DXVec3Normalize(&gotvec,&nul);
1332 expect_vec3(expectedvec,gotvec);
1334 /*_______________D3DXVec3Scale____________________________*/
1335 expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
1336 D3DXVec3Scale(&gotvec,&u,scale);
1337 expect_vec3(expectedvec,gotvec);
1338 /* Tests the case NULL */
1339 funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
1340 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1341 funcpointer = D3DXVec3Scale(NULL,NULL,scale);
1342 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1344 /*_______________D3DXVec3Subtract_______________________*/
1345 expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
1346 D3DXVec3Subtract(&gotvec,&u,&v);
1347 expect_vec3(expectedvec,gotvec);
1348 /* Tests the case NULL */
1349 funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
1350 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1351 funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
1352 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1354 /*_______________D3DXVec3Transform_______________________*/
1355 expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
1356 D3DXVec3Transform(&gottrans,&u,&mat);
1357 expect_vec4(expectedtrans,gottrans);
1359 /*_______________D3DXVec3TransformCoord_______________________*/
1360 expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
1361 D3DXVec3TransformCoord(&gotvec,&u,&mat);
1362 expect_vec3(expectedvec,gotvec);
1364 /*_______________D3DXVec3TransformNormal______________________*/
1365 expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
1366 D3DXVec3TransformNormal(&gotvec,&u,&mat);
1367 expect_vec3(expectedvec,gotvec);
1369 /*_______________D3DXVec3Project_________________________*/
1370 expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
1371 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1372 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
1373 expect_vec3(expectedvec,gotvec);
1374 /* World matrix can be omitted */
1375 D3DXMatrixMultiply(&mat,&world,&view);
1376 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&mat,NULL);
1377 expect_vec3(expectedvec,gotvec);
1378 /* Projection matrix can be omitted */
1379 D3DXMatrixMultiply(&mat,&view,&projection);
1380 D3DXVec3Project(&gotvec,&u,&viewport,NULL,&mat,&world);
1381 expect_vec3(expectedvec,gotvec);
1382 /* View matrix can be omitted */
1383 D3DXMatrixMultiply(&mat,&world,&view);
1384 D3DXVec3Project(&gotvec,&u,&viewport,&projection,NULL,&mat);
1385 expect_vec3(expectedvec,gotvec);
1386 /* All matrices can be omitted */
1387 expectedvec.x = 4010.000000f; expectedvec.y = -1695.000000f; expectedvec.z = 1.600000f;
1388 D3DXVec3Project(&gotvec,&u,&viewport,NULL,NULL,NULL);
1389 expect_vec3(expectedvec,gotvec);
1390 /* Viewport can be omitted */
1391 expectedvec.x = 1.814305f; expectedvec.y = 0.582097f; expectedvec.z = -0.066555f;
1392 D3DXVec3Project(&gotvec,&u,NULL,&projection,&view,&world);
1393 expect_vec3(expectedvec,gotvec);
1395 /*_______________D3DXVec3Unproject_________________________*/
1396 expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
1397 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1398 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
1399 expect_vec3(expectedvec,gotvec);
1400 /* World matrix can be omitted */
1401 D3DXMatrixMultiply(&mat,&world,&view);
1402 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&mat,NULL);
1403 expect_vec3(expectedvec,gotvec);
1404 /* Projection matrix can be omitted */
1405 D3DXMatrixMultiply(&mat,&view,&projection);
1406 D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,&mat,&world);
1407 expect_vec3(expectedvec,gotvec);
1408 /* View matrix can be omitted */
1409 D3DXMatrixMultiply(&mat,&world,&view);
1410 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,NULL,&mat);
1411 expect_vec3(expectedvec,gotvec);
1412 /* All matrices can be omitted */
1413 expectedvec.x = -1.002500f; expectedvec.y = 0.997059f; expectedvec.z = 2.571429f;
1414 D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,NULL,NULL);
1415 expect_vec3(expectedvec,gotvec);
1416 /* Viewport can be omitted */
1417 expectedvec.x = -11.018396f; expectedvec.y = 3.218991f; expectedvec.z = 1.380329f;
1418 D3DXVec3Unproject(&gotvec,&u,NULL,&projection,&view,&world);
1419 expect_vec3(expectedvec,gotvec);
1422 static void D3DXVector4Test(void)
1424 D3DXVECTOR4 expectedvec, gotvec, u, v, w, x;
1425 LPD3DXVECTOR4 funcpointer;
1426 D3DXVECTOR4 expectedtrans, gottrans;
1428 FLOAT coeff1, coeff2, expected, got, scale;
1430 u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
1431 v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
1432 w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
1433 x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
1435 U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
1436 U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
1437 U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
1438 U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
1440 coeff1 = 2.0f; coeff2 = 5.0;
1443 /*_______________D3DXVec4Add__________________________*/
1444 expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
1445 D3DXVec4Add(&gotvec,&u,&v);
1446 expect_vec4(expectedvec,gotvec);
1447 /* Tests the case NULL */
1448 funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
1449 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1450 funcpointer = D3DXVec4Add(NULL,NULL,NULL);
1451 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1453 /*_______________D3DXVec4BaryCentric____________________*/
1454 expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
1455 D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1456 expect_vec4(expectedvec,gotvec);
1458 /*_______________D3DXVec4CatmullRom____________________*/
1459 expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
1460 D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1461 expect_vec4(expectedvec,gotvec);
1463 /*_______________D3DXVec4Cross_________________________*/
1464 expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
1465 D3DXVec4Cross(&gotvec,&u,&v,&w);
1466 expect_vec4(expectedvec,gotvec);
1468 /*_______________D3DXVec4Dot__________________________*/
1470 got = D3DXVec4Dot(&u,&v);
1471 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1472 /* Tests the case NULL */
1474 got = D3DXVec4Dot(NULL,&v);
1475 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1477 got = D3DXVec4Dot(NULL,NULL);
1478 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1480 /*_______________D3DXVec4Hermite_________________________*/
1481 expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
1482 D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
1483 expect_vec4(expectedvec,gotvec);
1485 /*_______________D3DXVec4Length__________________________*/
1487 got = D3DXVec4Length(&u);
1488 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1489 /* Tests the case NULL */
1491 got = D3DXVec4Length(NULL);
1492 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1494 /*_______________D3DXVec4LengthSq________________________*/
1496 got = D3DXVec4LengthSq(&u);
1497 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1498 /* Tests the case NULL */
1500 got = D3DXVec4LengthSq(NULL);
1501 ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1503 /*_______________D3DXVec4Lerp__________________________*/
1504 expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
1505 D3DXVec4Lerp(&gotvec,&u,&v,scale);
1506 expect_vec4(expectedvec,gotvec);
1507 /* Tests the case NULL */
1508 funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
1509 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1510 funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
1511 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1513 /*_______________D3DXVec4Maximize__________________________*/
1514 expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
1515 D3DXVec4Maximize(&gotvec,&u,&v);
1516 expect_vec4(expectedvec,gotvec);
1517 /* Tests the case NULL */
1518 funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
1519 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1520 funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
1521 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1523 /*_______________D3DXVec4Minimize__________________________*/
1524 expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
1525 D3DXVec4Minimize(&gotvec,&u,&v);
1526 expect_vec4(expectedvec,gotvec);
1527 /* Tests the case NULL */
1528 funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
1529 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1530 funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
1531 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1533 /*_______________D3DXVec4Normalize_________________________*/
1534 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
1535 D3DXVec4Normalize(&gotvec,&u);
1536 expect_vec4(expectedvec,gotvec);
1538 /*_______________D3DXVec4Scale____________________________*/
1539 expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
1540 D3DXVec4Scale(&gotvec,&u,scale);
1541 expect_vec4(expectedvec,gotvec);
1542 /* Tests the case NULL */
1543 funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
1544 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1545 funcpointer = D3DXVec4Scale(NULL,NULL,scale);
1546 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1548 /*_______________D3DXVec4Subtract__________________________*/
1549 expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
1550 D3DXVec4Subtract(&gotvec,&u,&v);
1551 expect_vec4(expectedvec,gotvec);
1552 /* Tests the case NULL */
1553 funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
1554 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1555 funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
1556 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1558 /*_______________D3DXVec4Transform_______________________*/
1559 expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
1560 D3DXVec4Transform(&gottrans,&u,&mat);
1561 expect_vec4(expectedtrans,gottrans);
1564 static void test_matrix_stack(void)
1566 ID3DXMatrixStack *stack;
1570 const D3DXMATRIX mat1 = {{{
1571 1.0f, 2.0f, 3.0f, 4.0f,
1572 5.0f, 6.0f, 7.0f, 8.0f,
1573 9.0f, 10.0f, 11.0f, 12.0f,
1574 13.0f, 14.0f, 15.0f, 16.0f
1577 const D3DXMATRIX mat2 = {{{
1578 17.0f, 18.0f, 19.0f, 20.0f,
1579 21.0f, 22.0f, 23.0f, 24.0f,
1580 25.0f, 26.0f, 27.0f, 28.0f,
1581 29.0f, 30.0f, 31.0f, 32.0f
1584 hr = D3DXCreateMatrixStack(0, &stack);
1585 ok(SUCCEEDED(hr), "Failed to create a matrix stack, hr %#x\n", hr);
1586 if (FAILED(hr)) return;
1588 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)),
1589 "The top of an empty matrix stack should be an identity matrix\n");
1591 hr = ID3DXMatrixStack_Pop(stack);
1592 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1594 hr = ID3DXMatrixStack_Push(stack);
1595 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1596 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1598 hr = ID3DXMatrixStack_Push(stack);
1599 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1601 hr = ID3DXMatrixStack_LoadMatrix(stack, &mat1);
1602 ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
1603 expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1605 hr = ID3DXMatrixStack_Push(stack);
1606 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1607 expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1609 hr = ID3DXMatrixStack_LoadMatrix(stack, &mat2);
1610 ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
1611 expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1613 hr = ID3DXMatrixStack_Push(stack);
1614 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1615 expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1617 hr = ID3DXMatrixStack_LoadIdentity(stack);
1618 ok(SUCCEEDED(hr), "LoadIdentity failed, hr %#x\n", hr);
1619 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1621 hr = ID3DXMatrixStack_Pop(stack);
1622 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1623 expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1625 hr = ID3DXMatrixStack_Pop(stack);
1626 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1627 expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1629 hr = ID3DXMatrixStack_Pop(stack);
1630 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1631 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1633 hr = ID3DXMatrixStack_Pop(stack);
1634 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1635 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1637 refcount = ID3DXMatrixStack_Release(stack);
1638 ok(!refcount, "Matrix stack has %u references left.\n", refcount);
1641 static void test_Matrix_AffineTransformation2D(void)
1643 D3DXMATRIX exp_mat, got_mat;
1644 D3DXVECTOR2 center, position;
1653 angle = D3DX_PI/3.0f;
1657 U(exp_mat).m[0][0] = 10.0f;
1658 U(exp_mat).m[1][0] = -17.320507f;
1659 U(exp_mat).m[2][0] = 0.0f;
1660 U(exp_mat).m[3][0] = -1.035898f;
1661 U(exp_mat).m[0][1] = 17.320507f;
1662 U(exp_mat).m[1][1] = 10.0f;
1663 U(exp_mat).m[2][1] = 0.0f;
1664 U(exp_mat).m[3][1] = 6.401924f;
1665 U(exp_mat).m[0][2] = 0.0f;
1666 U(exp_mat).m[1][2] = 0.0f;
1667 U(exp_mat).m[2][2] = 1.0f;
1668 U(exp_mat).m[3][2] = 0.0f;
1669 U(exp_mat).m[0][3] = 0.0f;
1670 U(exp_mat).m[1][3] = 0.0f;
1671 U(exp_mat).m[2][3] = 0.0f;
1672 U(exp_mat).m[3][3] = 1.0f;
1674 D3DXMatrixAffineTransformation2D(&got_mat, scale, ¢er, angle, &position);
1676 expect_mat(&exp_mat, &got_mat);
1683 angle = D3DX_PI/3.0f;
1687 U(exp_mat).m[0][0] = 10.0f;
1688 U(exp_mat).m[1][0] = -17.320507f;
1689 U(exp_mat).m[2][0] = 0.0f;
1690 U(exp_mat).m[3][0] = 4.964102f;
1691 U(exp_mat).m[0][1] = 17.320507f;
1692 U(exp_mat).m[1][1] = 10.0f;
1693 U(exp_mat).m[2][1] = 0.0f;
1694 U(exp_mat).m[3][1] = -0.598076f;
1695 U(exp_mat).m[0][2] = 0.0f;
1696 U(exp_mat).m[1][2] = 0.0f;
1697 U(exp_mat).m[2][2] = 1.0f;
1698 U(exp_mat).m[3][2] = 0.0f;
1699 U(exp_mat).m[0][3] = 0.0f;
1700 U(exp_mat).m[1][3] = 0.0f;
1701 U(exp_mat).m[2][3] = 0.0f;
1702 U(exp_mat).m[3][3] = 1.0f;
1704 D3DXMatrixAffineTransformation2D(&got_mat, scale, ¢er, angle, NULL);
1706 expect_mat(&exp_mat, &got_mat);
1713 angle = D3DX_PI/3.0f;
1717 U(exp_mat).m[0][0] = 10.0f;
1718 U(exp_mat).m[1][0] = -17.320507f;
1719 U(exp_mat).m[2][0] = 0.0f;
1720 U(exp_mat).m[3][0] = -6.0f;
1721 U(exp_mat).m[0][1] = 17.320507f;
1722 U(exp_mat).m[1][1] = 10.0f;
1723 U(exp_mat).m[2][1] = 0.0f;
1724 U(exp_mat).m[3][1] = 7.0f;
1725 U(exp_mat).m[0][2] = 0.0f;
1726 U(exp_mat).m[1][2] = 0.0f;
1727 U(exp_mat).m[2][2] = 1.0f;
1728 U(exp_mat).m[3][2] = 0.0f;
1729 U(exp_mat).m[0][3] = 0.0f;
1730 U(exp_mat).m[1][3] = 0.0f;
1731 U(exp_mat).m[2][3] = 0.0f;
1732 U(exp_mat).m[3][3] = 1.0f;
1734 D3DXMatrixAffineTransformation2D(&got_mat, scale, NULL, angle, &position);
1736 expect_mat(&exp_mat, &got_mat);
1740 angle = 5.0f * D3DX_PI/4.0f;
1744 U(exp_mat).m[0][0] = 14.142133f;
1745 U(exp_mat).m[1][0] = -14.142133f;
1746 U(exp_mat).m[2][0] = 0.0f;
1747 U(exp_mat).m[3][0] = 0.0f;
1748 U(exp_mat).m[0][1] = 14.142133;
1749 U(exp_mat).m[1][1] = 14.142133f;
1750 U(exp_mat).m[2][1] = 0.0f;
1751 U(exp_mat).m[3][1] = 0.0f;
1752 U(exp_mat).m[0][2] = 0.0f;
1753 U(exp_mat).m[1][2] = 0.0f;
1754 U(exp_mat).m[2][2] = 1.0f;
1755 U(exp_mat).m[3][2] = 0.0f;
1756 U(exp_mat).m[0][3] = 0.0f;
1757 U(exp_mat).m[1][3] = 0.0f;
1758 U(exp_mat).m[2][3] = 0.0f;
1759 U(exp_mat).m[3][3] = 1.0f;
1761 D3DXMatrixAffineTransformation2D(&got_mat, scale, NULL, angle, NULL);
1763 expect_mat(&exp_mat, &got_mat);
1766 static void test_Matrix_Decompose(void)
1769 D3DXQUATERNION exp_rotation, got_rotation;
1770 D3DXVECTOR3 exp_scale, got_scale, exp_translation, got_translation;
1775 U(pm).m[0][0] = -0.9238790f;
1776 U(pm).m[1][0] = -0.2705984f;
1777 U(pm).m[2][0] = 0.2705984f;
1778 U(pm).m[3][0] = -5.0f;
1779 U(pm).m[0][1] = 0.2705984f;
1780 U(pm).m[1][1] = 0.03806049f;
1781 U(pm).m[2][1] = 0.9619395f;
1782 U(pm).m[3][1] = 0.0f;
1783 U(pm).m[0][2] = -0.2705984f;
1784 U(pm).m[1][2] = 0.9619395f;
1785 U(pm).m[2][2] = 0.03806049f;
1786 U(pm).m[3][2] = 10.0f;
1787 U(pm).m[0][3] = 0.0f;
1788 U(pm).m[1][3] = 0.0f;
1789 U(pm).m[2][3] = 0.0f;
1790 U(pm).m[3][3] = 1.0f;
1796 exp_rotation.w = 0.195091f;
1797 exp_rotation.x = 0.0f;
1798 exp_rotation.y = 0.693520f;
1799 exp_rotation.z = 0.693520f;
1801 exp_translation.x = -5.0f;
1802 exp_translation.y = 0.0f;
1803 exp_translation.z = 10.0f;
1805 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1807 compare_scale(exp_scale, got_scale);
1808 compare_rotation(exp_rotation, got_rotation);
1809 compare_translation(exp_translation, got_translation);
1813 U(pm).m[0][0] = -2.255813f;
1814 U(pm).m[1][0] = 1.302324f;
1815 U(pm).m[2][0] = 1.488373f;
1816 U(pm).m[3][0] = 1.0f;
1817 U(pm).m[0][1] = 1.302327f;
1818 U(pm).m[1][1] = -0.7209296f;
1819 U(pm).m[2][1] = 2.60465f;
1820 U(pm).m[3][1] = 2.0f;
1821 U(pm).m[0][2] = 1.488371f;
1822 U(pm).m[1][2] = 2.604651f;
1823 U(pm).m[2][2] = -0.02325551f;
1824 U(pm).m[3][2] = 3.0f;
1825 U(pm).m[0][3] = 0.0f;
1826 U(pm).m[1][3] = 0.0f;
1827 U(pm).m[2][3] = 0.0f;
1828 U(pm).m[3][3] = 1.0f;
1834 exp_rotation.w = 0.0;
1835 exp_rotation.x = 0.352180f;
1836 exp_rotation.y = 0.616316f;
1837 exp_rotation.z = 0.704361f;
1839 exp_translation.x = 1.0f;
1840 exp_translation.y = 2.0f;
1841 exp_translation.z = 3.0f;
1843 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1845 compare_scale(exp_scale, got_scale);
1846 compare_rotation(exp_rotation, got_rotation);
1847 compare_translation(exp_translation, got_translation);
1851 U(pm).m[0][0] = 2.427051f;
1852 U(pm).m[1][0] = 0.0f;
1853 U(pm).m[2][0] = 1.763355f;
1854 U(pm).m[3][0] = 5.0f;
1855 U(pm).m[0][1] = 0.0f;
1856 U(pm).m[1][1] = 3.0f;
1857 U(pm).m[2][1] = 0.0f;
1858 U(pm).m[3][1] = 5.0f;
1859 U(pm).m[0][2] = -1.763355f;
1860 U(pm).m[1][2] = 0.0f;
1861 U(pm).m[2][2] = 2.427051f;
1862 U(pm).m[3][2] = 5.0f;
1863 U(pm).m[0][3] = 0.0f;
1864 U(pm).m[1][3] = 0.0f;
1865 U(pm).m[2][3] = 0.0f;
1866 U(pm).m[3][3] = 1.0f;
1872 exp_rotation.w = 0.951057f;
1873 exp_rotation.x = 0.0f;
1874 exp_rotation.y = 0.309017f;
1875 exp_rotation.z = 0.0f;
1877 exp_translation.x = 5.0f;
1878 exp_translation.y = 5.0f;
1879 exp_translation.z = 5.0f;
1881 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1883 compare_scale(exp_scale, got_scale);
1884 compare_rotation(exp_rotation, got_rotation);
1885 compare_translation(exp_translation, got_translation);
1889 U(pm).m[0][0] = -0.9238790f;
1890 U(pm).m[1][0] = -0.2705984f;
1891 U(pm).m[2][0] = 0.2705984f;
1892 U(pm).m[3][0] = -5.0f;
1893 U(pm).m[0][1] = 0.2705984f;
1894 U(pm).m[1][1] = 0.03806049f;
1895 U(pm).m[2][1] = 0.9619395f;
1896 U(pm).m[3][1] = 0.0f;
1897 U(pm).m[0][2] = -0.2705984f;
1898 U(pm).m[1][2] = 0.9619395f;
1899 U(pm).m[2][2] = 0.03806049f;
1900 U(pm).m[3][2] = 10.0f;
1901 U(pm).m[0][3] = 0.0f;
1902 U(pm).m[1][3] = 0.0f;
1903 U(pm).m[2][3] = 0.0f;
1904 U(pm).m[3][3] = 1.0f;
1910 exp_rotation.w = 0.195091f;
1911 exp_rotation.x = 0.0f;
1912 exp_rotation.y = 0.693520f;
1913 exp_rotation.z = 0.693520f;
1915 exp_translation.x = -5.0f;
1916 exp_translation.y = 0.0f;
1917 exp_translation.z = 10.0f;
1919 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1921 compare_scale(exp_scale, got_scale);
1922 compare_rotation(exp_rotation, got_rotation);
1923 compare_translation(exp_translation, got_translation);
1927 U(pm).m[0][0] = -0.9238790f;
1928 U(pm).m[1][0] = -0.5411968f;
1929 U(pm).m[2][0] = 0.8117952f;
1930 U(pm).m[3][0] = -5.0f;
1931 U(pm).m[0][1] = 0.2705984f;
1932 U(pm).m[1][1] = 0.07612098f;
1933 U(pm).m[2][1] = 2.8858185f;
1934 U(pm).m[3][1] = 0.0f;
1935 U(pm).m[0][2] = -0.2705984f;
1936 U(pm).m[1][2] = 1.9238790f;
1937 U(pm).m[2][2] = 0.11418147f;
1938 U(pm).m[3][2] = 10.0f;
1939 U(pm).m[0][3] = 0.0f;
1940 U(pm).m[1][3] = 0.0f;
1941 U(pm).m[2][3] = 0.0f;
1942 U(pm).m[3][3] = 1.0f;
1948 exp_rotation.w = 0.195091f;
1949 exp_rotation.x = 0.0f;
1950 exp_rotation.y = 0.693520f;
1951 exp_rotation.z = 0.693520f;
1953 exp_translation.x = -5.0f;
1954 exp_translation.y = 0.0f;
1955 exp_translation.z = 10.0f;
1957 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1959 compare_scale(exp_scale, got_scale);
1960 compare_rotation(exp_rotation, got_rotation);
1961 compare_translation(exp_translation, got_translation);
1965 U(pm).m[0][0] = 0.7156004f;
1966 U(pm).m[1][0] = -0.5098283f;
1967 U(pm).m[2][0] = -0.4774843f;
1968 U(pm).m[3][0] = -5.0f;
1969 U(pm).m[0][1] = -0.6612288f;
1970 U(pm).m[1][1] = -0.7147621f;
1971 U(pm).m[2][1] = -0.2277977f;
1972 U(pm).m[3][1] = 0.0f;
1973 U(pm).m[0][2] = -0.2251499f;
1974 U(pm).m[1][2] = 0.4787385f;
1975 U(pm).m[2][2] = -0.8485972f;
1976 U(pm).m[3][2] = 10.0f;
1977 U(pm).m[0][3] = 0.0f;
1978 U(pm).m[1][3] = 0.0f;
1979 U(pm).m[2][3] = 0.0f;
1980 U(pm).m[3][3] = 1.0f;
1986 exp_rotation.w = 0.195091f;
1987 exp_rotation.x = 0.905395f;
1988 exp_rotation.y = -0.323355f;
1989 exp_rotation.z = -0.194013f;
1991 exp_translation.x = -5.0f;
1992 exp_translation.y = 0.0f;
1993 exp_translation.z = 10.0f;
1995 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1997 compare_scale(exp_scale, got_scale);
1998 compare_rotation(exp_rotation, got_rotation);
1999 compare_translation(exp_translation, got_translation);
2003 U(pm).m[0][0] = 0.06554436f;
2004 U(pm).m[1][0] = -0.6873012f;
2005 U(pm).m[2][0] = 0.7234092f;
2006 U(pm).m[3][0] = -5.0f;
2007 U(pm).m[0][1] = -0.9617381f;
2008 U(pm).m[1][1] = -0.2367795f;
2009 U(pm).m[2][1] = -0.1378230f;
2010 U(pm).m[3][1] = 0.0f;
2011 U(pm).m[0][2] = 0.2660144f;
2012 U(pm).m[1][2] = -0.6866967f;
2013 U(pm).m[2][2] = -0.6765233f;
2014 U(pm).m[3][2] = 10.0f;
2015 U(pm).m[0][3] = 0.0f;
2016 U(pm).m[1][3] = 0.0f;
2017 U(pm).m[2][3] = 0.0f;
2018 U(pm).m[3][3] = 1.0f;
2024 exp_rotation.w = -0.195091f;
2025 exp_rotation.x = 0.703358f;
2026 exp_rotation.y = -0.586131f;
2027 exp_rotation.z = 0.351679f;
2029 exp_translation.x = -5.0f;
2030 exp_translation.y = 0.0f;
2031 exp_translation.z = 10.0f;
2033 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2035 compare_scale(exp_scale, got_scale);
2036 compare_rotation(exp_rotation, got_rotation);
2037 compare_translation(exp_translation, got_translation);
2041 U(pm).m[0][0] = 7.121047f;
2042 U(pm).m[1][0] = -5.883487f;
2043 U(pm).m[2][0] = 11.81843f;
2044 U(pm).m[3][0] = -5.0f;
2045 U(pm).m[0][1] = 5.883487f;
2046 U(pm).m[1][1] = -10.60660f;
2047 U(pm).m[2][1] = -8.825232f;
2048 U(pm).m[3][1] = 0.0f;
2049 U(pm).m[0][2] = 11.81843f;
2050 U(pm).m[1][2] = 8.8252320f;
2051 U(pm).m[2][2] = -2.727645f;
2052 U(pm).m[3][2] = 2.0f;
2053 U(pm).m[0][3] = 0.0f;
2054 U(pm).m[1][3] = 0.0f;
2055 U(pm).m[2][3] = 0.0f;
2056 U(pm).m[3][3] = 1.0f;
2058 exp_scale.x = 15.0f;
2059 exp_scale.y = 15.0f;
2060 exp_scale.z = 15.0f;
2062 exp_rotation.w = 0.382684f;
2063 exp_rotation.x = 0.768714f;
2064 exp_rotation.y = 0.0f;
2065 exp_rotation.z = 0.512476f;
2067 exp_translation.x = -5.0f;
2068 exp_translation.y = 0.0f;
2069 exp_translation.z = 2.0f;
2071 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2073 compare_scale(exp_scale, got_scale);
2074 compare_rotation(exp_rotation, got_rotation);
2075 compare_translation(exp_translation, got_translation);
2079 U(pm).m[0][0] = 0.0f;
2080 U(pm).m[1][0] = 4.0f;
2081 U(pm).m[2][0] = 5.0f;
2082 U(pm).m[3][0] = -5.0f;
2083 U(pm).m[0][1] = 0.0f;
2084 U(pm).m[1][1] = -10.60660f;
2085 U(pm).m[2][1] = -8.825232f;
2086 U(pm).m[3][1] = 6.0f;
2087 U(pm).m[0][2] = 0.0f;
2088 U(pm).m[1][2] = 8.8252320f;
2089 U(pm).m[2][2] = 2.727645;
2090 U(pm).m[3][2] = 3.0f;
2091 U(pm).m[0][3] = 0.0f;
2092 U(pm).m[1][3] = 0.0f;
2093 U(pm).m[2][3] = 0.0f;
2094 U(pm).m[3][3] = 1.0f;
2096 hr = D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2097 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);
2100 static void test_Matrix_Transformation2D(void)
2102 D3DXMATRIX exp_mat, got_mat;
2103 D3DXVECTOR2 rot_center, sca, sca_center, trans;
2106 rot_center.x = 3.0f;
2107 rot_center.y = 4.0f;
2112 sca_center.x = 9.0f;
2113 sca_center.y = -5.0f;
2120 sca_rot = 5.0f*D3DX_PI/4.0f;
2122 U(exp_mat).m[0][0] = -4.245192f;
2123 U(exp_mat).m[1][0] = -0.147116f;
2124 U(exp_mat).m[2][0] = 0.0f;
2125 U(exp_mat).m[3][0] = 45.265373f;
2126 U(exp_mat).m[0][1] = 7.647113f;
2127 U(exp_mat).m[1][1] = 8.745192f;
2128 U(exp_mat).m[2][1] = 0.0f;
2129 U(exp_mat).m[3][1] = -13.401899f;
2130 U(exp_mat).m[0][2] = 0.0f;
2131 U(exp_mat).m[1][2] = 0.0f;
2132 U(exp_mat).m[2][2] = 1.0f;
2133 U(exp_mat).m[3][2] = 0.0f;
2134 U(exp_mat).m[0][3] = 0.0f;
2135 U(exp_mat).m[1][3] = 0.0f;
2136 U(exp_mat).m[2][3] = 0.0f;
2137 U(exp_mat).m[3][3] = 1.0f;
2139 D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, &sca, &rot_center, rot, &trans);
2141 expect_mat(&exp_mat, &got_mat);
2145 sca_center.x = 9.0f;
2146 sca_center.y = -5.0f;
2153 sca_rot = 5.0f*D3DX_PI/4.0f;
2155 U(exp_mat).m[0][0] = 0.50f;
2156 U(exp_mat).m[1][0] = -0.866025f;
2157 U(exp_mat).m[2][0] = 0.0f;
2158 U(exp_mat).m[3][0] = -6.0f;
2159 U(exp_mat).m[0][1] = 0.866025f;
2160 U(exp_mat).m[1][1] = 0.50f;
2161 U(exp_mat).m[2][1] = 0.0f;
2162 U(exp_mat).m[3][1] = 7.0f;
2163 U(exp_mat).m[0][2] = 0.0f;
2164 U(exp_mat).m[1][2] = 0.0f;
2165 U(exp_mat).m[2][2] = 1.0f;
2166 U(exp_mat).m[3][2] = 0.0f;
2167 U(exp_mat).m[0][3] = 0.0f;
2168 U(exp_mat).m[1][3] = 0.0f;
2169 U(exp_mat).m[2][3] = 0.0f;
2170 U(exp_mat).m[3][3] = 1.0f;
2172 D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, NULL, NULL, rot, &trans);
2174 expect_mat(&exp_mat, &got_mat);
2178 U(exp_mat).m[0][0] = 0.50f;
2179 U(exp_mat).m[1][0] = -0.866025f;
2180 U(exp_mat).m[2][0] = 0.0f;
2181 U(exp_mat).m[3][0] = 0.0f;
2182 U(exp_mat).m[0][1] = 0.866025f;
2183 U(exp_mat).m[1][1] = 0.50f;
2184 U(exp_mat).m[2][1] = 0.0f;
2185 U(exp_mat).m[3][1] = 0.0f;
2186 U(exp_mat).m[0][2] = 0.0f;
2187 U(exp_mat).m[1][2] = 0.0f;
2188 U(exp_mat).m[2][2] = 1.0f;
2189 U(exp_mat).m[3][2] = 0.0f;
2190 U(exp_mat).m[0][3] = 0.0f;
2191 U(exp_mat).m[1][3] = 0.0f;
2192 U(exp_mat).m[2][3] = 0.0f;
2193 U(exp_mat).m[3][3] = 1.0f;
2195 D3DXMatrixTransformation2D(&got_mat, NULL, sca_rot, NULL, NULL, rot, NULL);
2197 expect_mat(&exp_mat, &got_mat);
2200 static void test_D3DXVec_Array(void)
2203 D3DVIEWPORT9 viewport;
2204 D3DXMATRIX mat, projection, view, world;
2205 D3DXVECTOR4 inp_vec[ARRAY_SIZE];
2206 D3DXVECTOR4 out_vec[ARRAY_SIZE + 2];
2207 D3DXVECTOR4 exp_vec[ARRAY_SIZE + 2];
2208 D3DXPLANE inp_plane[ARRAY_SIZE];
2209 D3DXPLANE out_plane[ARRAY_SIZE + 2];
2210 D3DXPLANE exp_plane[ARRAY_SIZE + 2];
2212 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
2213 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
2215 for (i = 0; i < ARRAY_SIZE + 2; ++i) {
2216 out_vec[i].x = out_vec[i].y = out_vec[i].z = out_vec[i].w = 0.0f;
2217 exp_vec[i].x = exp_vec[i].y = exp_vec[i].z = exp_vec[i].w = 0.0f;
2218 out_plane[i].a = out_plane[i].b = out_plane[i].c = out_plane[i].d = 0.0f;
2219 exp_plane[i].a = exp_plane[i].b = exp_plane[i].c = exp_plane[i].d = 0.0f;
2222 for (i = 0; i < ARRAY_SIZE; ++i) {
2223 inp_plane[i].a = inp_plane[i].c = inp_vec[i].x = inp_vec[i].z = i;
2224 inp_plane[i].b = inp_plane[i].d = inp_vec[i].y = inp_vec[i].w = ARRAY_SIZE - i;
2227 U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
2228 U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
2229 U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
2230 U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
2232 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
2234 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
2235 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
2236 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
2237 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
2238 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
2239 U(view).m[3][3] = -40.0f;
2241 U(world).m[0][0] = 21.0f; U(world).m[0][1] = 2.0f; U(world).m[0][2] = 3.0f; U(world).m[0][3] = 4.0;
2242 U(world).m[1][0] = 5.0f; U(world).m[1][1] = 23.0f; U(world).m[1][2] = 7.0f; U(world).m[1][3] = 8.0f;
2243 U(world).m[2][0] = -8.0f; U(world).m[2][1] = -7.0f; U(world).m[2][2] = 25.0f; U(world).m[2][3] = -5.0f;
2244 U(world).m[3][0] = -4.0f; U(world).m[3][1] = -3.0f; U(world).m[3][2] = -2.0f; U(world).m[3][3] = 27.0f;
2246 /* D3DXVec2TransformCoordArray */
2247 exp_vec[1].x = 0.678571f; exp_vec[1].y = 0.785714f;
2248 exp_vec[2].x = 0.653846f; exp_vec[2].y = 0.769231f;
2249 exp_vec[3].x = 0.625f; exp_vec[3].y = 0.75f;
2250 exp_vec[4].x = 0.590909f; exp_vec[4].y = 8.0f/11.0f;
2251 exp_vec[5].x = 0.55f; exp_vec[5].y = 0.7f;
2252 D3DXVec2TransformCoordArray((D3DXVECTOR2*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2253 compare_vectors(exp_vec, out_vec);
2255 /* D3DXVec2TransformNormalArray */
2256 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f;
2257 exp_vec[2].x = 21.0f; exp_vec[2].y = 26.0f;
2258 exp_vec[3].x = 17.0f; exp_vec[3].y = 22.0f;
2259 exp_vec[4].x = 13.0f; exp_vec[4].y = 18.0f;
2260 exp_vec[5].x = 9.0f; exp_vec[5].y = 14.0f;
2261 D3DXVec2TransformNormalArray((D3DXVECTOR2*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2262 compare_vectors(exp_vec, out_vec);
2264 /* D3DXVec3TransformCoordArray */
2265 exp_vec[1].x = 0.678571f; exp_vec[1].y = 0.785714f; exp_vec[1].z = 0.892857f;
2266 exp_vec[2].x = 0.671875f; exp_vec[2].y = 0.78125f; exp_vec[2].z = 0.890625f;
2267 exp_vec[3].x = 6.0f/9.0f; exp_vec[3].y = 7.0f/9.0f; exp_vec[3].z = 8.0f/9.0f;
2268 exp_vec[4].x = 0.6625f; exp_vec[4].y = 0.775f; exp_vec[4].z = 0.8875f;
2269 exp_vec[5].x = 0.659091f; exp_vec[5].y = 0.772727f; exp_vec[5].z = 0.886364f;
2270 D3DXVec3TransformCoordArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2271 compare_vectors(exp_vec, out_vec);
2273 /* D3DXVec3TransformNormalArray */
2274 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f; exp_vec[1].z = 35.0f;
2275 exp_vec[2].x = 30.0f; exp_vec[2].y = 36.0f; exp_vec[2].z = 42.0f;
2276 exp_vec[3].x = 35.0f; exp_vec[3].y = 42.0f; exp_vec[3].z = 49.0f;
2277 exp_vec[4].x = 40.0f; exp_vec[4].y = 48.0f; exp_vec[4].z = 56.0f;
2278 exp_vec[5].x = 45.0f; exp_vec[5].y = 54.0f; exp_vec[5].z = 63.0f;
2279 D3DXVec3TransformNormalArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2280 compare_vectors(exp_vec, out_vec);
2282 /* D3DXVec3ProjectArray */
2283 exp_vec[1].x = 1089.554199f; exp_vec[1].y = -226.590622f; exp_vec[1].z = 0.215273f;
2284 exp_vec[2].x = 1068.903320f; exp_vec[2].y = 103.085129f; exp_vec[2].z = 0.183050f;
2285 exp_vec[3].x = 1051.778931f; exp_vec[3].y = 376.462250f; exp_vec[3].z = 0.156329f;
2286 exp_vec[4].x = 1037.348877f; exp_vec[4].y = 606.827393f; exp_vec[4].z = 0.133813f;
2287 exp_vec[5].x = 1025.023560f; exp_vec[5].y = 803.591248f; exp_vec[5].z = 0.114581f;
2288 D3DXVec3ProjectArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (CONST D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &viewport, &projection, &view, &world, ARRAY_SIZE);
2289 compare_vectors(exp_vec, out_vec);
2291 /* D3DXVec3UnprojectArray */
2292 exp_vec[1].x = -6.124031f; exp_vec[1].y = 3.225360f; exp_vec[1].z = 0.620571f;
2293 exp_vec[2].x = -3.807109f; exp_vec[2].y = 2.046579f; exp_vec[2].z = 0.446894f;
2294 exp_vec[3].x = -2.922839f; exp_vec[3].y = 1.596689f; exp_vec[3].z = 0.380609f;
2295 exp_vec[4].x = -2.456225f; exp_vec[4].y = 1.359290f; exp_vec[4].z = 0.345632f;
2296 exp_vec[5].x = -2.167897f; exp_vec[5].y = 1.212597f; exp_vec[5].z = 0.324019f;
2297 D3DXVec3UnprojectArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (CONST D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &viewport, &projection, &view, &world, ARRAY_SIZE);
2298 compare_vectors(exp_vec, out_vec);
2300 /* D3DXVec2TransformArray */
2301 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
2302 exp_vec[2].x = 34.0f; exp_vec[2].y = 40.0f; exp_vec[2].z = 46.0f; exp_vec[2].w = 52.0f;
2303 exp_vec[3].x = 30.0f; exp_vec[3].y = 36.0f; exp_vec[3].z = 42.0f; exp_vec[3].w = 48.0f;
2304 exp_vec[4].x = 26.0f; exp_vec[4].y = 32.0f; exp_vec[4].z = 38.0f; exp_vec[4].w = 44.0f;
2305 exp_vec[5].x = 22.0f; exp_vec[5].y = 28.0f; exp_vec[5].z = 34.0f; exp_vec[5].w = 40.0f;
2306 D3DXVec2TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2307 compare_vectors(exp_vec, out_vec);
2309 /* D3DXVec3TransformArray */
2310 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
2311 exp_vec[2].x = 43.0f; exp_vec[2].y = 50.0f; exp_vec[2].z = 57.0f; exp_vec[2].w = 64.0f;
2312 exp_vec[3].x = 48.0f; exp_vec[3].y = 56.0f; exp_vec[3].z = 64.0f; exp_vec[3].w = 72.0f;
2313 exp_vec[4].x = 53.0f; exp_vec[4].y = 62.0f; exp_vec[4].z = 71.0f; exp_vec[4].w = 80.0f;
2314 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
2315 D3DXVec3TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2316 compare_vectors(exp_vec, out_vec);
2318 /* D3DXVec4TransformArray */
2319 exp_vec[1].x = 90.0f; exp_vec[1].y = 100.0f; exp_vec[1].z = 110.0f; exp_vec[1].w = 120.0f;
2320 exp_vec[2].x = 82.0f; exp_vec[2].y = 92.0f; exp_vec[2].z = 102.0f; exp_vec[2].w = 112.0f;
2321 exp_vec[3].x = 74.0f; exp_vec[3].y = 84.0f; exp_vec[3].z = 94.0f; exp_vec[3].w = 104.0f;
2322 exp_vec[4].x = 66.0f; exp_vec[4].y = 76.0f; exp_vec[4].z = 86.0f; exp_vec[4].w = 96.0f;
2323 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
2324 D3DXVec4TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2325 compare_vectors(exp_vec, out_vec);
2327 /* D3DXPlaneTransformArray */
2328 exp_plane[1].a = 90.0f; exp_plane[1].b = 100.0f; exp_plane[1].c = 110.0f; exp_plane[1].d = 120.0f;
2329 exp_plane[2].a = 82.0f; exp_plane[2].b = 92.0f; exp_plane[2].c = 102.0f; exp_plane[2].d = 112.0f;
2330 exp_plane[3].a = 74.0f; exp_plane[3].b = 84.0f; exp_plane[3].c = 94.0f; exp_plane[3].d = 104.0f;
2331 exp_plane[4].a = 66.0f; exp_plane[4].b = 76.0f; exp_plane[4].c = 86.0f; exp_plane[4].d = 96.0f;
2332 exp_plane[5].a = 58.0f; exp_plane[5].b = 68.0f; exp_plane[5].c = 78.0f; exp_plane[5].d = 88.0f;
2333 D3DXPlaneTransformArray(out_plane + 1, sizeof(D3DXPLANE), inp_plane, sizeof(D3DXPLANE), &mat, ARRAY_SIZE);
2334 compare_planes(exp_plane, out_plane);
2337 static void test_D3DXFloat_Array(void)
2339 static const float z = 0.0f;
2340 /* Compilers set different sign bits on 0.0 / 0.0, pick the right ones for NaN and -NaN */
2341 float tmpnan = 0.0f/z;
2342 float nnan = copysignf(1, tmpnan) < 0.0f ? tmpnan : -tmpnan;
2352 /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32/64 bit math), W7PRO (32 bit math) */
2353 WORD half_ver1, half_ver2;
2355 /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
2356 FLOAT single_out_ver1, single_out_ver2;
2358 { 80000.0f, 0x7c00, 0x7ce2, 65536.0f, 80000.0f },
2359 { 65503.0f, 0x7bff, 0x7bff, 65504.0f, 65504.0f },
2360 { 65504.0f, 0x7bff, 0x7bff, 65504.0f, 65504.0f },
2361 { 65520.0f, 0x7bff, 0x7c00, 65504.0f, 65536.0f },
2362 { 65521.0f, 0x7c00, 0x7c00, 65536.0f, 65536.0f },
2363 { 65534.0f, 0x7c00, 0x7c00, 65536.0f, 65536.0f },
2364 { 65535.0f, 0x7c00, 0x7c00, 65535.0f, 65536.0f },
2365 { 65536.0f, 0x7c00, 0x7c00, 65536.0f, 65536.0f },
2366 { -80000.0f, 0xfc00, 0xfce2, -65536.0f, -80000.0f },
2367 { -65503.0f, 0xfbff, 0xfbff, -65504.0f, -65504.0f },
2368 { -65504.0f, 0xfbff, 0xfbff, -65504.0f, -65504.0f },
2369 { -65520.0f, 0xfbff, 0xfc00, -65504.0f, -65536.0f },
2370 { -65521.0f, 0xfc00, 0xfc00, -65536.0f, -65536.0f },
2371 { -65534.0f, 0xfc00, 0xfc00, -65536.0f, -65536.0f },
2372 { -65535.0f, 0xfc00, 0xfc00, -65535.0f, -65536.0f },
2373 { -65536.0f, 0xfc00, 0xfc00, -65536.0f, -65536.0f },
2374 { 1.0f/z, 0x7c00, 0x7fff, 65536.0f, 131008.0f },
2375 { -1.0f/z, 0xffff, 0xffff, -131008.0f, -131008.0f },
2376 { nan, 0x7fff, 0xffff, 131008.0f, -131008.0f },
2377 { nnan, 0xffff, 0xffff, -131008.0f, -131008.0f },
2378 { 0.0f, 0x0, 0x0, 0.0f, 0.0f },
2379 { -0.0f, 0x8000, 0x8000, 0.0f, 0.0f },
2380 { 2.9809595e-08f, 0x0, 0x0, 0.0f, 0.0f },
2381 { -2.9809595e-08f, 0x8000, 0x8000, -0.0f, -0.0f },
2382 { 2.9809598e-08f, 0x1, 0x0, 5.96046e-08f, 5.96046e-08f },
2383 { -2.9809598e-08f, 0x8001, 0x8000, -5.96046e-08f, -5.96046e-08f },
2384 { 8.9406967e-08f, 0x2, 0x1, 1.19209e-07f, 5.96046e-008 }
2387 /* exception on NULL out or in parameter */
2388 out = D3DXFloat32To16Array(&half, &single, 0);
2389 ok(out == &half, "Got %p, expected %p.\n", out, &half);
2391 out = D3DXFloat16To32Array(&single, &half, 0);
2392 ok(out == &single, "Got %p, expected %p.\n", out, &single);
2394 for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++)
2396 out = D3DXFloat32To16Array(&half, &testdata[i].single_in, 1);
2397 ok(out == &half, "Got %p, expected %p.\n", out, &half);
2398 ok(half.value == testdata[i].half_ver1 || half.value == testdata[i].half_ver2,
2399 "Got %x, expected %x or %x for index %d.\n", half.value, testdata[i].half_ver1,
2400 testdata[i].half_ver2, i);
2402 out = D3DXFloat16To32Array(&single, (D3DXFLOAT16 *)&testdata[i].half_ver1, 1);
2403 ok(out == &single, "Got %p, expected %p.\n", out, &single);
2404 ok(relative_error(single, testdata[i].single_out_ver1) < admitted_error,
2405 "Got %g, expected %g for index %d.\n", single, testdata[i].single_out_ver1, i);
2407 out = D3DXFloat16To32Array(&single, (D3DXFLOAT16 *)&testdata[i].half_ver2, 1);
2408 ok(out == &single, "Got %p, expected %p.\n", out, &single);
2409 ok(relative_error(single, testdata[i].single_out_ver2) < admitted_error,
2410 "Got %g, expected %g for index %d.\n", single, testdata[i].single_out_ver2, i);
2414 static void test_D3DXSHAdd(void)
2417 FLOAT *ret = (FLOAT *)0xdeadbeef;
2418 const FLOAT in1[50] =
2420 1.11f, 1.12f, 1.13f, 1.14f, 1.15f, 1.16f, 1.17f, 1.18f,
2421 1.19f, 1.20f, 1.21f, 1.22f, 1.23f, 1.24f, 1.25f, 1.26f,
2422 1.27f, 1.28f, 1.29f, 1.30f, 1.31f, 1.32f, 1.33f, 1.34f,
2423 1.35f, 1.36f, 1.37f, 1.38f, 1.39f, 1.40f, 1.41f, 1.42f,
2424 1.43f, 1.44f, 1.45f, 1.46f, 1.47f, 1.48f, 1.49f, 1.50f,
2425 1.51f, 1.52f, 1.53f, 1.54f, 1.55f, 1.56f, 1.57f, 1.58f,
2428 const FLOAT in2[50] =
2430 2.11f, 2.12f, 2.13f, 2.14f, 2.15f, 2.16f, 2.17f, 2.18f,
2431 2.19f, 2.20f, 2.21f, 2.22f, 2.23f, 2.24f, 2.25f, 2.26f,
2432 2.27f, 2.28f, 2.29f, 2.30f, 2.31f, 2.32f, 2.33f, 2.34f,
2433 2.35f, 2.36f, 2.37f, 2.38f, 2.39f, 2.40f, 2.41f, 2.42f,
2434 2.43f, 2.44f, 2.45f, 2.46f, 2.47f, 2.48f, 2.49f, 2.50f,
2435 2.51f, 2.52f, 2.53f, 2.54f, 2.55f, 2.56f, 2.57f, 2.58f,
2438 FLOAT out[50] = {0.0f};
2441 * Order is not limited by D3DXSH_MINORDER and D3DXSH_MAXORDER!
2442 * All values will work, test from 0-7 [D3DXSH_MINORDER = 2, D3DXSH_MAXORDER = 6]
2443 * Exceptions will show up when out, in1 or in2 are NULL
2445 for (k = 0; k <= D3DXSH_MAXORDER + 1; k++)
2449 ret = D3DXSHAdd(&out[0], k, &in1[0], &in2[0]);
2450 ok(ret == out, "%u: D3DXSHAdd() failed, got %p, expected %p\n", k, out, ret);
2452 for (i = 0; i < count; ++i)
2454 ok(relative_error(in1[i] + in2[i], out[i]) < admitted_error,
2455 "%u-%u: D3DXSHAdd() failed, got %f, expected %f\n", k, i, out[i], in1[i] + in2[i]);
2457 ok(relative_error(out[count], 0.0f) < admitted_error, "%u-%u: D3DXSHAdd() failed, got %f, expected 0.0\n", k, k * k, out[count]);
2461 static void test_D3DXSHDot(void)
2464 FLOAT a[49], b[49], got;
2465 CONST FLOAT expected[] =
2466 { 0.5f, 0.5f, 25.0f, 262.5f, 1428.0f, 5362.0f, 15873.0f, 39812.0f, };
2468 for (i = 0; i < 49; i++)
2474 /* D3DXSHDot computes by using order * order elements */
2475 for (i = 0; i <= D3DXSH_MAXORDER + 1; i++)
2477 got = D3DXSHDot(i, a, b);
2478 ok(relative_error(got, expected[i]) < admitted_error, "order %d: expected %f, received %f\n", i, expected[i], got);
2484 static void test_D3DXSHEvalDirection(void)
2486 unsigned int i, order;
2488 FLOAT a[49], expected[49], *received_ptr;
2489 CONST FLOAT table[36] =
2490 { 0.282095f, -0.977205f, 1.465808f, -0.488603f, 2.185097f, -6.555291f,
2491 8.200181f, -3.277646f, -1.638823f, 1.180087f, 17.343668f, -40.220032f,
2492 47.020218f, -20.110016f, -13.007751f, 6.490479f, -15.020058f, 10.620785f,
2493 117.325661f, -240.856750f, 271.657288f, -120.428375f, -87.994247f, 58.414314f,
2494 -4.380850f, 24.942520f, -149.447693f, 78.278130f, 747.791748f, -1427.687866f,
2495 1574.619141, -713.843933f, -560.843811f, 430.529724, -43.588909, -26.911665, };
2497 d.x = 1.0; d.y = 2.0f; d.z = 3.0f;
2499 for (order = 0; order <= D3DXSH_MAXORDER + 1; order++)
2501 for (i = 0; i < 49; i++)
2504 received_ptr = D3DXSHEvalDirection(a, order, &d);
2505 ok(received_ptr == a, "Expected %p, received %p\n", a, received_ptr);
2507 for (i = 0; i < 49; i++)
2509 /* if the order is < D3DXSH_MINORDER or order > D3DXSH_MAXORDER or the index of the element is greater than order * order - 1, D3DXSHEvalDirection does not modify the output */
2510 if ( (order < D3DXSH_MINORDER) || (order > D3DXSH_MAXORDER) || (i >= order * order) )
2511 expected[i] = 1.5f + i;
2513 expected[i] = table[i];
2515 ok(relative_error(a[i], expected[i]) < admitted_error, "order %u, index %u: expected %f, received %f\n", order, i, expected[i], a[i]);
2520 static void test_D3DXSHEvalDirectionalLight(void)
2523 FLOAT *blue_out, bout[49], expected, gout[49], *green_out, *red_out, rout[49];
2524 static const FLOAT table[] = {
2526 2.008781f, -4.175174f, 9.602900f, -3.827243f, 1.417963f, -2.947181f,
2527 6.778517f, -2.701583f, 7.249108f, -18.188671f, 34.643921f, -16.672949f,
2528 -0.631551f, 1.417963f, -2.947181f, 6.778517f, -2.701583f, 7.249108f,
2529 -18.188671f, 34.643921f, -16.672949f, -0.631551f, -7.794341f, 52.934967f,
2530 -102.245529f, 181.656815f, -93.725060f, -4.611760f, 10.146287f, 1.555186f,
2531 -3.232392f, 7.434503f, -2.963026f, 7.950634f, -19.948866f, 37.996559f,
2532 -18.286459f, -0.692669f, -8.548632f, 58.057705f, -112.140251f, 199.236496f,
2533 -102.795227f, -5.058059f, 11.128186f, -4.189955f, -70.782669f, 360.268829f,
2534 -614.755005f, 1052.926270f, -563.525391f, -31.387066f, 92.141365f, -23.864176f,
2535 1.555186f, -3.232392f, 7.434503f, -2.963026f, 7.950634f, -19.948866f,
2536 37.996559f, -18.286459f, -0.692669f, -8.548632f, 58.057705f, -112.140251f,
2537 199.236496f, -102.795227f, -5.058059f, 11.128186f, -4.189955f, -70.782669f,
2538 360.268829f, -614.755005f, 1052.926270f, -563.525391f, -31.387066f, 92.141365f,
2539 -23.864176f, 34.868664f, -38.354366f, -478.864166f, 2103.939941f, -3334.927734f,
2540 5583.213867f, -3057.017090f, -183.297836f, 623.361633f, -218.449921f, 22.258503f,
2542 3.072254f, -6.385560f, 14.686787f, -5.853429f, 2.168650f, -4.507453f,
2543 10.367143f, -4.131832f, 11.086870f, -27.817965f, 52.984818f, -25.499800f,
2544 -0.965902f, 2.168650f, -4.507453f, 10.367143f, -4.131832f, 11.086870f,
2545 -27.817965f, 52.984818f, -25.499800f, -0.965902f, -11.920755f, 80.959351f,
2546 -156.375488f, 277.828033f, -143.344193f, -7.053278f, 15.517849f, 2.378519f,
2547 -4.943659f, 11.370415f, -4.531687f, 12.159794f, -30.510029f, 58.112385f,
2548 -27.967525f, -1.059376f, -13.074378f, 88.794136f, -171.508621f, 304.714630f,
2549 -157.216217f, -7.735855f, 17.019577f, -6.408166f, -108.255844f, 550.999390f,
2550 -940.213501f, 1610.357788f, -861.862305f, -48.003746f, 140.922089f, -36.498150f,
2551 2.378519f, -4.943659f, 11.370415f, -4.531687f, 12.159794f, -30.510029f,
2552 58.112385f, -27.967525f, -1.059376f, -13.074378f, 88.794136f, -171.508621f,
2553 304.714630f, -157.216217f, -7.735855f, 17.019577f, -6.408166f, -108.255844f,
2554 550.999390f, -940.213501f, 1610.357788f, -861.862305f, -48.003746f, 140.922089f,
2555 -36.498150f, 53.328545f, -58.659618f, -732.380493f, 3217.790283f, -5100.477539f,
2556 8539.033203f, -4675.437500f, -280.337860f, 953.376587f, -334.099884f, 34.042416f,
2558 4.135726f, -8.595945f, 19.770674f, -7.879617f, 2.919336f, -6.067726f,
2559 13.955770f, -5.562082f, 14.924634f, -37.447262f, 71.325722f, -34.326656f,
2560 -1.300252f, 2.919336f, -6.067726f, 13.955770f, -5.562082f, 14.924634f,
2561 -37.447262f, 71.325722f, -34.326656f, -1.300252f, -16.047173f, 108.983749f,
2562 -210.505493f, 373.999298f, -192.963348f, -9.494799f, 20.889414f, 3.201853f,
2563 -6.654925f, 15.306328f, -6.100348f, 16.368954f, -41.071194f, 78.228210f,
2564 -37.648590f, -1.426083f, -17.600124f, 119.530563f, -230.876984f, 410.192780f,
2565 -211.637222f, -10.413651f, 22.910971f, -8.626378f, -145.729019f, 741.729919f,
2566 -1265.671997f, 2167.789307f, -1160.199219f, -64.620430f, 189.702820f, -49.132126f,
2567 3.201853f, -6.654925f, 15.306328f, -6.100348f, 16.368954f, -41.071194f,
2568 78.228210f, -37.648590f, -1.426083f, -17.600124f, 119.530563f, -230.876984f,
2569 410.192780f, -211.637222f, -10.413651f, 22.910971f, -8.626378f, -145.729019f,
2570 741.729919f, -1265.671997f, 2167.789307f, -1160.199219f, -64.620430f, 189.702820f,
2571 -49.132126f, 71.788422f, -78.964867f, -985.896790f, 4331.640625f, -6866.027344f,
2572 11494.852539f, -6293.858398f, -377.377899f, 1283.391479f, -449.749817f, 45.826328f, };
2575 FLOAT *red_in, *green_in, *blue_in;
2576 const FLOAT *red_out, *green_out, *blue_out;
2577 FLOAT roffset, goffset, boffset;
2579 { { rout, gout, bout, table, &table[90], &table[180], 1.01f, 1.02f, 1.03f, },
2580 { rout, rout, rout, &table[180], &table[180], &table[180], 1.03f, 1.03f, 1.03f, },
2581 { rout, rout, bout, &table[90], &table[90], &table[180], 1.02f, 1.02f, 1.03f, },
2582 { rout, gout, gout, table, &table[180], &table[180], 1.01f, 1.03f, 1.03f, },
2583 { rout, gout, rout, &table[180], &table[90], &table[180], 1.03f, 1.02f, 1.03f, },
2584 /* D3DXSHEvalDirectionaLight accepts NULL green or blue colour. */
2585 { rout, NULL, bout, table, NULL, &table[180], 1.01f, 0.0f, 1.03f, },
2586 { rout, gout, NULL, table, &table[90], NULL, 1.01f, 1.02f, 0.0f, },
2587 { rout, NULL, NULL, table, NULL, NULL, 1.01f, 0.0f, 0.0f, }, };
2589 unsigned int j, l, order, startindex;
2591 dir.x = 1.1f; dir.y= 1.2f; dir.z = 2.76f;
2593 for (l = 0; l < sizeof( test ) / sizeof( test[0] ); l++)
2597 for (order = D3DXSH_MINORDER; order <= D3DXSH_MAXORDER; order++)
2599 red_out = test[l].red_in;
2600 green_out = test[l].green_in;
2601 blue_out = test[l].blue_in;
2603 for (j = 0; j < 49; j++)
2605 red_out[j] = 1.01f + j;
2607 green_out[j] = 1.02f + j;
2609 blue_out[j] = 1.03f + j;
2612 hr = D3DXSHEvalDirectionalLight(order, &dir, 1.7f, 2.6f, 3.5f, red_out, green_out, blue_out);
2613 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
2615 for (j = 0; j < 49; j++)
2617 if ( j >= order * order )
2618 expected = j + test[l].roffset;
2620 expected = test[l].red_out[startindex + j];
2621 ok(relative_error(expected, red_out[j]) < admitted_error,
2622 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, red_out[j]);
2626 if ( j >= order * order )
2627 expected = j + test[l].goffset;
2629 expected = test[l].green_out[startindex + j];
2630 ok(relative_error(expected, green_out[j]) < admitted_error,
2631 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, green_out[j]);
2636 if ( j >= order * order )
2637 expected = j + test[l].boffset;
2639 expected = test[l].blue_out[startindex + j];
2640 ok(relative_error(expected, blue_out[j]) < admitted_error,
2641 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, blue_out[j]);
2645 startindex += order * order;
2649 /* D3DXSHEvalDirectionalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set*/
2650 hr = D3DXSHEvalDirectionalLight(7, &dir, 1.0f, 2.0f, 3.0f, rout, gout, bout);
2651 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
2652 hr = D3DXSHEvalDirectionalLight(0, &dir, 1.0f, 2.0f, 3.0f, rout, gout, bout);
2653 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
2654 hr = D3DXSHEvalDirectionalLight(1, &dir, 1.0f, 2.0f, 3.0f, rout, gout, bout);
2655 ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr);
2658 static void test_D3DXSHMultiply2(void)
2661 FLOAT a[20], b[20], c[20];
2662 /* D3DXSHMultiply2 only modifies the first 4 elements of the array */
2663 const FLOAT expected[20] =
2664 { 3.418594f, 1.698211f, 1.703853f, 1.709494f, 4.0f, 5.0f,
2665 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f,
2666 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f };
2668 for (i = 0; i < 20; i++)
2670 a[i] = 1.0f + i / 100.0f;
2671 b[i] = 3.0f - i / 100.0f;
2675 D3DXSHMultiply2(c, a, b);
2676 for (i = 0; i < 20; i++)
2677 ok(relative_error(c[i], expected[i]) < admitted_error, "Expected[%d] = %f, received = %f\n", i, expected[i], c[i]);
2680 static void test_D3DXSHMultiply3(void)
2683 FLOAT a[20], b[20], c[20];
2684 /* D3DXSHMultiply3 only modifies the first 9 elements of the array */
2685 const FLOAT expected[20] =
2686 { 7.813913f, 2.256058f, 5.9484005f, 4.970894f, 2.899858f, 3.598946f,
2687 1.726572f, 5.573538f, 0.622063f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f,
2688 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f };
2690 for (i = 0; i < 20; i++)
2692 a[i] = 1.0f + i / 100.0f;
2693 b[i] = 3.0f - i / 100.0f;
2697 D3DXSHMultiply3(c, a, b);
2698 for (i = 0; i < 20; i++)
2699 ok(relative_error(c[i], expected[i]) < admitted_error, "Expected[%d] = %f, received = %f\n", i, expected[i], c[i]);
2702 static void test_D3DXSHMultiply4(void)
2705 FLOAT a[20], b[20], c[20];
2706 /* D3DXSHMultiply4 only modifies the first 16 elements of the array */
2707 const FLOAT expected[] =
2709 14.182599f, 2.615703f, 12.828601f, 9.820596f, 3.039696f, 4.530442f,
2710 5.820584f, 12.249846f, 2.194346f, 3.900152f, 5.416609f, 5.601813f,
2711 0.959982f, 7.037550f, 3.625230f, 0.463601f, 16.0f, 17.0f, 18.0f, 19.0f,
2713 -211441.265625f, -2529.157715f, -10023.393555f, -441.277191f, -163.994385f,
2714 -526.305115f, 29636.187500f, -3931.830811f, -13577.111328f, -3978.973877f,
2715 -10330.341797f, -13779.787109f, -16685.109375f, -44981.375000f, -73269.742188f,
2716 -95237.335938f, 16.0f, 17.0f, 18.0f, 19.0f,
2718 0.236682f, -0.717649f, -0.180500f, -0.077124f, 0.144831f, 0.573286f,
2719 -0.337959f, 0.055694f, -0.442100f, 0.147702f, -0.055157f, 0.084337f,
2720 0.179877f, 0.009099f, 0.232200f, 0.074142f, 1.6f, 1.7f, 1.8f, 1.9f, };
2722 for (i = 0; i < 20; i++)
2724 a[i] = 1.0f + i / 100.0f;
2725 b[i] = 3.0f - i / 100.0f;
2729 D3DXSHMultiply4(c, a, b);
2730 for (i = 0; i < 20; i++)
2731 ok(relative_error(c[i], expected[i]) < admitted_error, "Expected[%d] = %f, received = %f\n", i, expected[i], c[i]);
2733 for (i = 0; i < 20; i++)
2735 b[i] = 3.0f - i / 100.0f;
2739 D3DXSHMultiply4(c, c, b);
2740 for (i = 0; i < 20; i++)
2741 ok(relative_error(c[i], expected[20 + i]) < admitted_error, "Expected[%d] = %f, received = %f\n", i, expected[20 + i], c[i]);
2743 for (i = 0; i < 20; i++)
2746 D3DXSHMultiply4(c, c, c);
2747 for (i = 0; i < 20; i++)
2748 ok(relative_error(c[i], expected[40 + i]) < admitted_error, "Expected[%d] = %f, received = %f\n", i, expected[40 + i], c[i]);
2751 static void test_D3DXSHRotate(void)
2754 FLOAT expected, in[49], out[49], *out_temp, *received_ptr;
2755 static const FLOAT table[]=
2756 { /* Rotation around X-axis Pi/2 */
2757 1.01f, -3.01f, 2.01f, 4.01f, -8.01f, -6.01f,
2758 -11.307890f, 5.01f, -1.565839f, 1.093598f, -11.01f, 19.833414f,
2759 -15.268191f, -19.004118f, -3.364889f, -9.562627f, 12.099654f, -0.272131f,
2760 30.241013f, 26.919991f, 39.236877f, -22.632446f, 6.707388f, -11.768282f,
2761 3.443672f, -6.07445f, 11.61839f, 1.527561f, 37.89633f, -56.9012f,
2762 47.42289f, 50.39153f, 10.61819f, 25.50101f, 0.049241f, 16.98330f,
2764 1.01f, -3.01f, -3.01f, 4.01f, -8.01f, -6.01f, -11.307889f, -8.01f, 14.297919f,
2765 /* Rotation around X-axis -Pi/2 */
2766 1.01f, 3.01f, -2.01f, 4.01f, 8.01f, -6.01f,
2767 -11.307890f, -5.01f, -1.565839f, -1.093598f, -11.01f, -19.833414f,
2768 15.268191f, -19.004118f, 3.364889f, -9.562627f, -12.099654f, -0.272131f,
2769 -30.241013f, 26.919991f, 39.236877f, 22.632446f, 6.707388f, 11.768282f,
2770 3.443672f, 6.07445f, 11.61839f, -1.527561f, 37.89633f, 56.9012f,
2771 -47.42289f, 50.39153f, -10.61819f, 25.50101f, -0.049248f, 16.98330f,
2773 1.01f, 3.01f, -3.01f, 4.01f, 8.01f, -6.01f, -11.307890f, -8.01f, 14.297919f,
2774 /* Yaw Pi/3, Pitch Pi/4, Roll Pi/5 */
2775 1.01f, 4.944899f, 1.442301f, 1.627281f, 0.219220f, 10.540824f,
2776 -9.136903f, 2.763750f, -7.30904f, -5.875721f, 5.303124f, -8.682154f,
2777 -25.683384f, 1.680279f, -18.808388f, 7.653656f, 16.939133f, -17.328018f,
2778 14.629795f, -54.467102f, -12.231035f, -4.089857f, -9.444222f, 3.056035f,
2779 0.179257f, -10.041875f, 23.090092f, -23.188709f, 11.727098f, -65.183090f,
2780 48.671577f, -15.073209f, 38.793171f, -26.039536f, 6.192769f, -17.672247f,
2782 1.01f, 4.944899f, -0.891142f, 4.607695f, 0.219218f, 10.773325f,
2783 -8.204769f, 13.563829f, -12.007767f,
2784 /* Rotation around Z-axis Pi/6 */
2785 1.01f, 3.745711f, 3.01f, 2.467762f, 10.307889f, 9.209813f,
2786 7.01f, 3.931864f, 0.166212f, 16.01f, 18.504042f, 17.405966f,
2787 13.01f, 6.128016f, -2.029941f, -10.01f, 13.154292f, 24.01f,
2788 29.432245f, 28.334167f, 21.01f, 9.056221f, -4.958143f, -18.01f,
2789 -27.236094f, -4.520332f, 16.814543f, 34.01f, 43.092495f, 41.994423f,
2790 31.01f, 12.716471f, -8.618400f, -28.01f, -40.896347f, -44.190571,
2792 1.01f, 3.745711f, 3.01f, 1.599906f, 10.307889f, 9.209813f,
2793 7.01f, 2.331957f, -4.421894f, };
2794 unsigned int i, j, l, order;
2796 D3DXMatrixRotationX(&m[0], -D3DX_PI / 2.0f);
2797 D3DXMatrixRotationX(&m[1], D3DX_PI / 2.0f);
2798 D3DXMatrixRotationYawPitchRoll(&m[2], D3DX_PI / 3.0f, D3DX_PI / 4.0f, D3DX_PI / 5.0f);
2799 D3DXMatrixRotationZ(&m[3], D3DX_PI / 6.0f);
2801 for (l = 0; l < 2; l++)
2808 for (j = 0; j < 4; j++)
2810 for (order = 0; order <= D3DXSH_MAXORDER; order++)
2812 for (i = 0; i < 49; i++)
2814 out[i] = ( i + 1.0f ) * ( i + 1.0f );
2818 received_ptr = D3DXSHRotate(out_temp, order, &m[j], in);
2819 ok(received_ptr == out_temp, "Order %u, expected %p, received %p\n", order, out, received_ptr);
2821 for (i = 0; i < 49; i++)
2823 if ((i > 0) && ((i >= order * order) || (order > D3DXSH_MAXORDER)))
2826 expected = ( i + 1.0f ) * ( i + 1.0f );
2828 expected = i + 1.01f;
2830 else if ((l == 0) || (order > 3))
2831 expected = table[45 * j + i];
2833 expected = table[45 * j + 36 +i];
2834 ok(relative_error(out_temp[i], expected) < admitted_error,
2835 "Order %u index %u, expected %f, received %f\n", order, i, expected, out_temp[i]);
2842 static void test_D3DXSHRotateZ(void)
2844 unsigned int end, i, j, l, order, square;
2845 FLOAT expected, in[49], out[49], *out_temp, *received_ptr;
2846 const FLOAT angle[] = { D3DX_PI / 3.0f, -D3DX_PI / 3.0f, 4.0f * D3DX_PI / 3.0f, }, table[] =
2847 { /* Angle = D3DX_PI / 3.0f */
2848 1.01f, 4.477762f, 3.010000f, 0.264289f, 5.297888f, 9.941864f,
2849 7.010000f, -1.199813f, -8.843789f, -10.010002f, 7.494040f, 18.138016f,
2850 13.010000, -3.395966f, -17.039942f, -16.009998f, -30.164297f, -18.010004f,
2851 10.422242f, 29.066219f, 21.010000f, -6.324171f, -27.968145f, -24.009998f,
2852 2.226099f, -18.180565, -43.824551f, -28.010004f, 14.082493f, 42.726471f,
2853 31.010000f, -9.984426f, -41.628399f, -34.009995f, 5.886358f, 40.530331f,
2855 1.01f, 4.477762f, 0.0f, -5.816784f, 5.297888f, 6.936864f,
2856 0.0f, -9.011250f, -2.294052f, -10.010002f, 12.999042f, 12.133017f,
2857 0.0f, -15.761250f, -5.628748f, 0.0f, -30.164297f, 0.0f,
2858 19.927244f, 19.061220f, 0.0f, -24.761251f, -8.628748f, 0.0f,
2859 -13.061530f, -18.180565f, -30.319553f, 0.0f, 28.587496f, 27.721474f,
2860 0.0f, -36.011253f, -12.378746f, 0.0f, -13.128758f, -23.617250f,
2862 1.010000f, 3.977762f, 3.977762f, 1.114195f, 7.245791f, 10.559759f,
2863 10.559759f, -0.995160f, -0.467341f, 0.467339f, 12.765371f, 18.515701f,
2864 18.515701f, -1.797287f, 0.493916f, -0.493916f, -21.412342f, 21.412338f,
2865 9.221072f, 23.671757f, 23.671757f, 3.850195f, -20.468727f, 20.468723f,
2866 -10.662103f, -36.516628f, -12.061245f, 12.061240f, 22.556875f, 38.999908f,
2867 38.999908f, -0.034875f, -10.427902f, 10.427900f, -36.838284f, -27.652803f,
2868 /* Angle = -D3DX_PI / 3.0f */
2869 1.01f, -2.467762f, 3.010000f, 3.745711f, -10.307890f, -3.931864f,
2870 7.010000f, 9.209813f, -0.166214f, -10.010002f, -18.504044f, -6.128017f,
2871 13.010000f, 17.405966f, 2.029938f, -16.009998f, 13.154303f, -18.010004f,
2872 -29.432247f, -9.056221f, 21.010000f, 28.334169f, 4.958139f, -24.010002f,
2873 -27.236092f, 44.190582f, 16.814558f, -28.009996f, -43.092499f, -12.716474f,
2874 31.010000f, 41.994423f, 8.618393f, -34.010002f, -40.896347f, -4.520310f,
2876 1.01f, -2.467762f, 0.0f, -3.205718f, -10.307890f, -6.936864f,
2877 0.0f, -9.011250f, -4.463446f, -10.009998f, -12.999042f, -12.133017f,
2878 0.0f, -15.761250f, -5.628748f, 0.0f, 13.154303f, 0.0f,
2879 -19.927244f, -19.061220f, 0.0f, -24.761251f, -8.628748f, 0.0f,
2880 -5.695983f, 44.190582f, 30.319553f, 0.0f, -28.587496f, -27.721474f,
2881 0.0f, -36.011253f, -12.378746f, 0.0f, -13.128758f, -57.405258f,
2883 1.010000f, -2.967762f, -2.967762f, -0.609195f, -7.498291f, -10.686009f,
2884 -10.686009f, -11.836716f, 5.390780f, -5.390779f, -10.303651f, -17.284842f,
2885 -17.284842f, -17.565643f, 4.114273f, -4.114273f, 23.716436f, -23.716433f,
2886 -8.069025f, -23.095732f, -23.095732f, -18.535847f, -11.271107f, 11.271104f,
2887 -2.072484f, 30.149330f, 15.244893f, -15.244888f, -20.965050f, -38.203999f,
2888 -38.203999f, -37.258266f, 5.426677f, -5.426679f, -23.396751f, -9.903559f,
2889 /* Angle = 4.0f * D3DX_PI / 3.0f */
2890 1.01f, -4.477762f, 3.010000f, -0.264289f, 5.297887f, -9.941864f,
2891 7.010000f, 1.199814f, -8.843788f, 10.010004f, 7.494038f, -18.138016f,
2892 13.010000f, 3.395967f, -17.039940f, 16.009996f, -30.164293f, 18.010006f,
2893 10.422239f, -29.066219f, 21.010000f, 6.324172f, -27.968143f, 24.009993f,
2894 2.226105f, 18.180552f, -43.824543f, 28.010008f, 14.082489f, -42.726471f,
2895 31.010000f, 9.984427f, -41.628399f, 34.009987f, 5.886366f, -40.530327f,
2897 1.01f, -4.477762f, 0.0f, -1.938928f, 5.297887f, -6.936864f,
2898 0.0f, -3.003751f, -2.294051f, 10.010004f, 12.999040f, -12.133017f,
2899 0.0f, -5.253751f, -5.628747f, 0.0f, -30.164293f, 0.0f,
2900 19.927242f, -19.061220f, 0.0f, -8.253753f, -8.628746f, 0.0f,
2901 -13.061535f, 18.180552f, -30.319553f, 0.0f, 28.587492f, -27.721474f,
2902 0.0f, -12.003753f, -12.378742f, 0.0f, -13.128765f, -7.872400f,
2904 1.010000f, -3.977762f, -3.977762f, 2.863566f, 6.371104f, -10.122416f,
2905 -10.122416f, 10.578746f, -7.769295f, -7.769290f, 16.883686f, -20.574858f,
2906 -20.574858f, 24.909130f, -5.726166f, -5.726164f, -18.796221f, -18.796211f,
2907 29.325350f, -33.723892f, -33.723892f, 42.258442f, -4.851232f, -4.851226f,
2908 -2.533393f, 32.452259f, -46.545670f, -46.545654f, 51.860325f, -53.651630f,
2909 -53.651630f, 71.738174f, 4.440616f, 4.440629f, 25.884174f, -10.748116f, };
2911 for (l = 0; l < 3; l++)
2916 out_temp = &in[l - 1];
2923 for (j = 0; j < 3; j++)
2925 for (order = 0; order <= D3DXSH_MAXORDER + 1; order++)
2927 for (i = 0; i < 49; i++)
2929 out[i] = ( i + 1.0f ) * ( i + 1.0f );
2933 received_ptr = D3DXSHRotateZ(out_temp, order, angle[j], in);
2934 ok(received_ptr == out_temp, "angle %f, order %u, expected %p, received %p\n", angle[j], order, out_temp, received_ptr);
2936 for (i = 0; i < end; i++)
2938 /* order = 0 or order = 1 behaves like order = D3DXSH_MINORDER */
2939 square = (order <= D3DXSH_MINORDER) ? D3DXSH_MINORDER * D3DXSH_MINORDER : order * order;
2940 if (i >= square || ((order >= D3DXSH_MAXORDER) && (i >= D3DXSH_MAXORDER * D3DXSH_MAXORDER)))
2942 expected = i + l + 0.01f;
2944 expected = ( i + 1.0f ) * ( i + 1.0f );
2946 expected = table[36 * (l + 3 * j) + i];
2947 ok(relative_error(expected, out_temp[i]) < admitted_error, "angle %f, order %u index %u, expected %f, received %f\n", angle[j], order, i, expected, out_temp[i]);
2954 static void test_D3DXSHScale(void)
2956 unsigned int i, order;
2957 FLOAT a[49], b[49], expected, *received_array;
2959 for (i = 0; i < 49; i++)
2965 for (order = 0; order <= D3DXSH_MAXORDER + 1; order++)
2967 received_array = D3DXSHScale(b, order, a, 5.0f);
2968 ok(received_array == b, "Expected %p, received %p\n", b, received_array);
2970 for (i = 0; i < 49; i++)
2972 if (i < order * order)
2973 expected = 5.0f * a[i];
2974 /* D3DXSHScale does not modify the elements of the array after the order * order-th element */
2977 ok(relative_error(b[i], expected) < admitted_error, "order %d, element %d, expected %f, received %f\n", order, i, expected, b[i]);
2988 D3DXQuaternionTest();
2992 test_matrix_stack();
2993 test_Matrix_AffineTransformation2D();
2994 test_Matrix_Decompose();
2995 test_Matrix_Transformation2D();
2996 test_D3DXVec_Array();
2997 test_D3DXFloat_Array();
3000 test_D3DXSHEvalDirection();
3001 test_D3DXSHEvalDirectionalLight();
3002 test_D3DXSHMultiply2();
3003 test_D3DXSHMultiply3();
3004 test_D3DXSHMultiply4();
3005 test_D3DXSHRotate();
3006 test_D3DXSHRotateZ();