2 * Copyright 2008 David Adam
3 * Copyright 2008 Philip Nilsson
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/test.h"
25 #define admitted_error 0.0001f
27 #define relative_error(exp, out) ((exp == out) ? 0.0f : (fabs(out - exp) / fabs(exp)))
29 #define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(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);
31 static inline BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
35 for (i = 0; i < 4; ++i)
37 for (j = 0; j < 4; ++j)
39 if (fabs(U(*m1).m[i][j] - U(*m2).m[i][j]) > admitted_error)
47 #define expect_mat(expectedmat, gotmat) \
49 const D3DXMATRIX *__m1 = (expectedmat); \
50 const D3DXMATRIX *__m2 = (gotmat); \
51 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" \
52 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
53 U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
54 U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
55 U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
56 U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
57 U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
58 U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
59 U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
60 U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
63 #define compare_rotation(exp, got) \
64 ok(fabs(exp.w - got.w) < admitted_error && \
65 fabs(exp.x - got.x) < admitted_error && \
66 fabs(exp.y - got.y) < admitted_error && \
67 fabs(exp.z - got.z) < admitted_error, \
68 "Expected rotation = (%f, %f, %f, %f), \
69 got rotation = (%f, %f, %f, %f)\n", \
70 exp.w, exp.x, exp.y, exp.z, got.w, got.x, got.y, got.z)
72 #define compare_scale(exp, got) \
73 ok(fabs(exp.x - got.x) < admitted_error && \
74 fabs(exp.y - got.y) < admitted_error && \
75 fabs(exp.z - got.z) < admitted_error, \
76 "Expected scale = (%f, %f, %f), \
77 got scale = (%f, %f, %f)\n", \
78 exp.x, exp.y, exp.z, got.x, got.y, got.z)
80 #define compare_translation(exp, got) \
81 ok(fabs(exp.x - got.x) < admitted_error && \
82 fabs(exp.y - got.y) < admitted_error && \
83 fabs(exp.z - got.z) < admitted_error, \
84 "Expected translation = (%f, %f, %f), \
85 got translation = (%f, %f, %f)\n", \
86 exp.x, exp.y, exp.z, got.x, got.y, got.z)
88 #define compare_vectors(exp, out) \
89 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
90 ok(relative_error(exp[i].x, out[i].x) < admitted_error && \
91 relative_error(exp[i].y, out[i].y) < admitted_error && \
92 relative_error(exp[i].z, out[i].z) < admitted_error && \
93 relative_error(exp[i].w, out[i].w) < admitted_error, \
94 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
95 out[i].x, out[i].y, out[i].z, out[i].w, \
96 exp[i].x, exp[i].y, exp[i].z, exp[i].w, \
100 #define compare_planes(exp, out) \
101 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
102 ok(relative_error(exp[i].a, out[i].a) < admitted_error && \
103 relative_error(exp[i].b, out[i].b) < admitted_error && \
104 relative_error(exp[i].c, out[i].c) < admitted_error && \
105 relative_error(exp[i].d, out[i].d) < admitted_error, \
106 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
107 out[i].a, out[i].b, out[i].c, out[i].d, \
108 exp[i].a, exp[i].b, exp[i].c, exp[i].d, \
111 #define expect_plane(expectedplane,gotplane) ok((fabs(expectedplane.a-gotplane.a)<admitted_error)&&(fabs(expectedplane.b-gotplane.b)<admitted_error)&&(fabs(expectedplane.c-gotplane.c)<admitted_error)&&(fabs(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);
113 #define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
115 #define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(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);
117 #define expect_vec4(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error)&&(fabs(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);
120 static void D3DXColorTest(void)
122 D3DXCOLOR color, color1, color2, expected, got;
123 LPD3DXCOLOR funcpointer;
126 color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
127 color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
128 color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
132 /*_______________D3DXColorAdd________________*/
133 expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f, expected.a = 0.93f;
134 D3DXColorAdd(&got,&color1,&color2);
135 expect_color(expected,got);
136 /* Test the NULL case */
137 funcpointer = D3DXColorAdd(&got,NULL,&color2);
138 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
139 funcpointer = D3DXColorAdd(NULL,NULL,&color2);
140 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
141 funcpointer = D3DXColorAdd(NULL,NULL,NULL);
142 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
144 /*_______________D3DXColorAdjustContrast______*/
145 expected.r = 0.41f; expected.g = 0.575f; expected.b = 0.473f, expected.a = 0.93f;
146 D3DXColorAdjustContrast(&got,&color,scale);
147 expect_color(expected,got);
149 /*_______________D3DXColorAdjustSaturation______*/
150 expected.r = 0.486028f; expected.g = 0.651028f; expected.b = 0.549028f, expected.a = 0.93f;
151 D3DXColorAdjustSaturation(&got,&color,scale);
152 expect_color(expected,got);
154 /*_______________D3DXColorLerp________________*/
155 expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
156 D3DXColorLerp(&got,&color,&color1,scale);
157 expect_color(expected,got);
158 /* Test the NULL case */
159 funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
160 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
161 funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
162 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
163 funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
164 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
166 /*_______________D3DXColorModulate________________*/
167 expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
168 D3DXColorModulate(&got,&color1,&color2);
169 expect_color(expected,got);
170 /* Test the NULL case */
171 funcpointer = D3DXColorModulate(&got,NULL,&color2);
172 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
173 funcpointer = D3DXColorModulate(NULL,NULL,&color2);
174 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
175 funcpointer = D3DXColorModulate(NULL,NULL,NULL);
176 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
178 /*_______________D3DXColorNegative________________*/
179 expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
180 D3DXColorNegative(&got,&color);
181 expect_color(got,expected);
182 /* Test the greater than 1 case */
183 color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
184 expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
185 D3DXColorNegative(&got,&color1);
186 expect_color(got,expected);
187 /* Test the negative case */
188 color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
189 expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
190 D3DXColorNegative(&got,&color1);
191 expect_color(got,expected);
192 /* Test the NULL case */
193 funcpointer = D3DXColorNegative(&got,NULL);
194 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
195 funcpointer = D3DXColorNegative(NULL,NULL);
196 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
198 /*_______________D3DXColorScale________________*/
199 expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
200 D3DXColorScale(&got,&color,scale);
201 expect_color(expected,got);
202 /* Test the NULL case */
203 funcpointer = D3DXColorScale(&got,NULL,scale);
204 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
205 funcpointer = D3DXColorScale(NULL,NULL,scale);
206 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
208 /*_______________D3DXColorSubtract_______________*/
209 expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f, expected.a = 0.82f;
210 D3DXColorSubtract(&got,&color,&color2);
211 expect_color(expected,got);
212 /* Test the NULL case */
213 funcpointer = D3DXColorSubtract(&got,NULL,&color2);
214 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
215 funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
216 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
217 funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
218 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
221 static void D3DXFresnelTest(void)
226 got = D3DXFresnelTerm(0.5f,1.5);
227 ok( fabs(got - expected) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
230 static void D3DXMatrixTest(void)
232 D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
233 LPD3DXMATRIX funcpointer;
236 D3DXVECTOR3 at, axis, eye, last, scaling;
239 FLOAT angle, determinant, expectedfloat, gotfloat;
241 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
242 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
243 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
244 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
245 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
246 U(mat).m[3][3] = -40.0f;
248 U(mat2).m[0][0] = 1.0f; U(mat2).m[1][0] = 2.0f; U(mat2).m[2][0] = 3.0f;
249 U(mat2).m[3][0] = 4.0f; U(mat2).m[0][1] = 5.0f; U(mat2).m[1][1] = 6.0f;
250 U(mat2).m[2][1] = 7.0f; U(mat2).m[3][1] = 8.0f; U(mat2).m[0][2] = -8.0f;
251 U(mat2).m[1][2] = -7.0f; U(mat2).m[2][2] = -6.0f; U(mat2).m[3][2] = -5.0f;
252 U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f;
253 U(mat2).m[3][3] = -1.0f;
255 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
257 q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
258 r.x = 0.87f; r.y = 0.65f; r.z =0.43f; r.w= 0.21f;
260 at.x = -2.0f; at.y = 13.0f; at.z = -9.0f;
261 axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f;
262 eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
263 last.x = 9.7f; last.y = -8.6; last.z = 1.3f;
264 scaling.x = 0.03f; scaling.y =0.05f; scaling.z = 0.06f;
266 light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3;
268 angle = D3DX_PI/3.0f;
270 /*____________D3DXMatrixAffineTransformation______*/
271 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;
272 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;
273 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;
274 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;
275 D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis);
276 expect_mat(&expectedmat, &gotmat);
277 /* Test the NULL case */
278 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;
279 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;
280 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;
281 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;
282 D3DXMatrixAffineTransformation(&gotmat,3.56f,NULL,&q,&axis);
283 expect_mat(&expectedmat, &gotmat);
285 /*____________D3DXMatrixfDeterminant_____________*/
286 expectedfloat = -147888.0f;
287 gotfloat = D3DXMatrixDeterminant(&mat);
288 ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
290 /*____________D3DXMatrixInverse______________*/
291 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;
292 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;
293 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;
294 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;
295 expectedfloat = -147888.0f;
296 D3DXMatrixInverse(&gotmat,&determinant,&mat);
297 expect_mat(&expectedmat, &gotmat);
298 ok(fabs( determinant - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, determinant);
299 funcpointer = D3DXMatrixInverse(&gotmat,NULL,&mat2);
300 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
302 /*____________D3DXMatrixIsIdentity______________*/
304 memset(&mat3, 0, sizeof(mat3));
305 got = D3DXMatrixIsIdentity(&mat3);
306 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
307 D3DXMatrixIdentity(&mat3);
309 got = D3DXMatrixIsIdentity(&mat3);
310 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
311 U(mat3).m[0][0] = 0.000009f;
313 got = D3DXMatrixIsIdentity(&mat3);
314 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
315 /* Test the NULL case */
317 got = D3DXMatrixIsIdentity(NULL);
318 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
320 /*____________D3DXMatrixLookatLH_______________*/
321 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;
322 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;
323 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;
324 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;
325 D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
326 expect_mat(&expectedmat, &gotmat);
328 /*____________D3DXMatrixLookatRH_______________*/
329 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;
330 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;
331 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;
332 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;
333 D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
334 expect_mat(&expectedmat, &gotmat);
336 /*____________D3DXMatrixMultiply______________*/
337 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;
338 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;
339 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;
340 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;
341 D3DXMatrixMultiply(&gotmat,&mat,&mat2);
342 expect_mat(&expectedmat, &gotmat);
344 /*____________D3DXMatrixMultiplyTranspose____*/
345 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;
346 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;
347 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;
348 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;
349 D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
350 expect_mat(&expectedmat, &gotmat);
352 /*____________D3DXMatrixOrthoLH_______________*/
353 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;
354 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;
355 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;
356 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;
357 D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
358 expect_mat(&expectedmat, &gotmat);
360 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
361 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;
362 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;
363 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;
364 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;
365 D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
366 expect_mat(&expectedmat, &gotmat);
368 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
369 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;
370 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;
371 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;
372 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;
373 D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
374 expect_mat(&expectedmat, &gotmat);
376 /*____________D3DXMatrixOrthoRH_______________*/
377 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;
378 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;
379 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;
380 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;
381 D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
382 expect_mat(&expectedmat, &gotmat);
384 /*____________D3DXMatrixPerspectiveFovLH_______________*/
385 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;
386 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;
387 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;
388 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;
389 D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
390 expect_mat(&expectedmat, &gotmat);
392 /*____________D3DXMatrixPerspectiveFovRH_______________*/
393 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;
394 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;
395 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;
396 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;
397 D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
398 expect_mat(&expectedmat, &gotmat);
400 /*____________D3DXMatrixPerspectiveLH_______________*/
401 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;
402 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;
403 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;
404 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;
405 D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
406 expect_mat(&expectedmat, &gotmat);
408 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
409 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;
410 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;
411 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;
412 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;
413 D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
414 expect_mat(&expectedmat, &gotmat);
416 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
417 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;
418 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;
419 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;
420 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;
421 D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
422 expect_mat(&expectedmat, &gotmat);
424 /*____________D3DXMatrixPerspectiveRH_______________*/
425 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;
426 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;
427 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;
428 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;
429 D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
430 expect_mat(&expectedmat, &gotmat);
432 /*____________D3DXMatrixReflect______________*/
433 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;
434 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;
435 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;
436 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;
437 D3DXMatrixReflect(&gotmat,&plane);
438 expect_mat(&expectedmat, &gotmat);
440 /*____________D3DXMatrixRotationAxis_____*/
441 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;
442 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;
443 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;
444 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;
445 D3DXMatrixRotationAxis(&gotmat,&axis,angle);
446 expect_mat(&expectedmat, &gotmat);
448 /*____________D3DXMatrixRotationQuaternion______________*/
449 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;
450 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;
451 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;
452 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;
453 D3DXMatrixRotationQuaternion(&gotmat,&q);
454 expect_mat(&expectedmat, &gotmat);
456 /*____________D3DXMatrixRotationX______________*/
457 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;
458 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;
459 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;
460 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;
461 D3DXMatrixRotationX(&gotmat,angle);
462 expect_mat(&expectedmat, &gotmat);
464 /*____________D3DXMatrixRotationY______________*/
465 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;
466 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;
467 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;
468 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;
469 D3DXMatrixRotationY(&gotmat,angle);
470 expect_mat(&expectedmat, &gotmat);
472 /*____________D3DXMatrixRotationYawPitchRoll____*/
473 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;
474 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;
475 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;
476 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;
477 D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
478 expect_mat(&expectedmat, &gotmat);
480 /*____________D3DXMatrixRotationZ______________*/
481 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;
482 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;
483 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;
484 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;
485 D3DXMatrixRotationZ(&gotmat,angle);
486 expect_mat(&expectedmat, &gotmat);
488 /*____________D3DXMatrixScaling______________*/
489 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;
490 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;
491 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;
492 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;
493 D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
494 expect_mat(&expectedmat, &gotmat);
496 /*____________D3DXMatrixShadow______________*/
497 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;
498 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;
499 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;
500 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;
501 D3DXMatrixShadow(&gotmat,&light,&plane);
502 expect_mat(&expectedmat, &gotmat);
504 /*____________D3DXMatrixTransformation______________*/
505 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;
506 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;
507 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;
508 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;
509 D3DXMatrixTransformation(&gotmat,&at,&q,NULL,&eye,&r,&last);
510 expect_mat(&expectedmat, &gotmat);
512 /*____________D3DXMatrixTranslation______________*/
513 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;
514 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;
515 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;
516 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;
517 D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
518 expect_mat(&expectedmat, &gotmat);
520 /*____________D3DXMatrixTranspose______________*/
521 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;
522 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;
523 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;
524 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;
525 D3DXMatrixTranspose(&gotmat,&mat);
526 expect_mat(&expectedmat, &gotmat);
529 static void D3DXPlaneTest(void)
532 D3DXPLANE expectedplane, gotplane, nulplane, plane;
533 D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
534 LPD3DXVECTOR3 funcpointer;
538 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
539 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
540 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
541 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
542 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
543 U(mat).m[3][3] = -40.0f;
545 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
547 vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
549 /*_______________D3DXPlaneDot________________*/
551 got = D3DXPlaneDot(&plane,&vec),
552 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
554 got = D3DXPlaneDot(NULL,&vec),
555 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
557 got = D3DXPlaneDot(NULL,NULL),
558 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
560 /*_______________D3DXPlaneDotCoord________________*/
562 got = D3DXPlaneDotCoord(&plane,&vec),
563 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
565 got = D3DXPlaneDotCoord(NULL,&vec),
566 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
568 got = D3DXPlaneDotCoord(NULL,NULL),
569 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
571 /*_______________D3DXPlaneDotNormal______________*/
573 got = D3DXPlaneDotNormal(&plane,&vec),
574 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
576 got = D3DXPlaneDotNormal(NULL,&vec),
577 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
579 got = D3DXPlaneDotNormal(NULL,NULL),
580 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
582 /*_______________D3DXPlaneFromPointNormal_______*/
583 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
584 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
585 expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
586 D3DXPlaneFromPointNormal(&gotplane,&vec1,&vec2);
587 expect_plane(expectedplane, gotplane);
589 /*_______________D3DXPlaneFromPoints_______*/
590 vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
591 vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
592 vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
593 expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
594 D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
595 expect_plane(expectedplane, gotplane);
597 /*_______________D3DXPlaneIntersectLine___________*/
598 vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
599 vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
600 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
601 D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
602 expect_vec3(expectedvec, gotvec);
603 /* Test a parallel line */
604 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
605 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
606 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
607 funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
608 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
610 /*_______________D3DXPlaneNormalize______________*/
611 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);
612 D3DXPlaneNormalize(&gotplane, &plane);
613 expect_plane(expectedplane, gotplane);
614 nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
615 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
616 D3DXPlaneNormalize(&gotplane, &nulplane);
617 expect_plane(expectedplane, gotplane);
618 nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
619 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
620 D3DXPlaneNormalize(&gotplane, &nulplane);
621 expect_plane(expectedplane, gotplane);
623 /*_______________D3DXPlaneTransform____________*/
624 expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
625 D3DXPlaneTransform(&gotplane,&plane,&mat);
626 expect_plane(expectedplane, gotplane);
629 static void D3DXQuaternionTest(void)
632 D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, smallq, smallr, q, r, s, t, u;
633 LPD3DXQUATERNION funcpointer;
634 D3DXVECTOR3 axis, expectedvec;
635 FLOAT angle, expected, got, scale, scale2;
636 BOOL expectedbool, gotbool;
638 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
639 q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
640 r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
641 t.x = -1111.0f, t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
642 u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
643 smallq.x = 0.1f; smallq.y = 0.2f; smallq.z= 0.3f; smallq.w = 0.4f;
644 smallr.x = 0.5f; smallr.y = 0.6f; smallr.z= 0.7f; smallr.w = 0.8f;
649 /*_______________D3DXQuaternionBaryCentric________________________*/
650 expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
651 D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
652 expect_vec4(expectedquat,gotquat);
654 /*_______________D3DXQuaternionConjugate________________*/
655 expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
656 D3DXQuaternionConjugate(&gotquat,&q);
657 expect_vec4(expectedquat,gotquat);
658 /* Test the NULL case */
659 funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
660 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
661 funcpointer = D3DXQuaternionConjugate(NULL,NULL);
662 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
664 /*_______________D3DXQuaternionDot______________________*/
666 got = D3DXQuaternionDot(&q,&r);
667 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
668 /* Tests the case NULL */
670 got = D3DXQuaternionDot(NULL,&r);
671 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
673 got = D3DXQuaternionDot(NULL,NULL);
674 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
676 /*_______________D3DXQuaternionExp______________________________*/
677 expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
678 D3DXQuaternionExp(&gotquat,&q);
679 expect_vec4(expectedquat,gotquat);
680 /* Test the null quaternion */
681 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
682 D3DXQuaternionExp(&gotquat,&nul);
683 expect_vec4(expectedquat,gotquat);
684 /* Test the case where the norm of the quaternion is <1 */
685 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
686 expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
687 D3DXQuaternionExp(&gotquat,&Nq1);
688 expect_vec4(expectedquat,gotquat);
690 /*_______________D3DXQuaternionIdentity________________*/
691 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
692 D3DXQuaternionIdentity(&gotquat);
693 expect_vec4(expectedquat,gotquat);
694 /* Test the NULL case */
695 funcpointer = D3DXQuaternionIdentity(NULL);
696 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
698 /*_______________D3DXQuaternionInverse________________________*/
699 expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
700 D3DXQuaternionInverse(&gotquat,&q);
701 expect_vec4(expectedquat,gotquat);
703 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 10.0f;
704 D3DXQuaternionInverse(&gotquat,&gotquat);
705 expect_vec4(expectedquat,gotquat);
708 /*_______________D3DXQuaternionIsIdentity________________*/
709 s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
711 gotbool = D3DXQuaternionIsIdentity(&s);
712 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
713 s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
714 expectedbool = FALSE;
715 gotbool = D3DXQuaternionIsIdentity(&q);
716 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
717 /* Test the NULL case */
718 gotbool = D3DXQuaternionIsIdentity(NULL);
719 ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
721 /*_______________D3DXQuaternionLength__________________________*/
723 got = D3DXQuaternionLength(&q);
724 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
725 /* Tests the case NULL */
727 got = D3DXQuaternionLength(NULL);
728 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
730 /*_______________D3DXQuaternionLengthSq________________________*/
732 got = D3DXQuaternionLengthSq(&q);
733 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
734 /* Tests the case NULL */
736 got = D3DXQuaternionLengthSq(NULL);
737 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
739 /*_______________D3DXQuaternionLn______________________________*/
740 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
741 D3DXQuaternionLn(&gotquat,&q);
742 expect_vec4(expectedquat,gotquat);
743 expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
744 D3DXQuaternionLn(&gotquat,&r);
745 expect_vec4(expectedquat,gotquat);
746 Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
747 expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
748 D3DXQuaternionLn(&gotquat,&Nq);
749 expect_vec4(expectedquat,gotquat);
750 /* Test the cas where the norm of the quaternion is <1 */
751 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
752 expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
753 D3DXQuaternionLn(&gotquat,&Nq1);
754 todo_wine{ expect_vec4(expectedquat,gotquat) };
756 /*_______________D3DXQuaternionMultiply________________________*/
757 expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
758 D3DXQuaternionMultiply(&gotquat,&q,&r);
759 expect_vec4(expectedquat,gotquat);
761 /*_______________D3DXQuaternionNormalize________________________*/
762 expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
763 D3DXQuaternionNormalize(&gotquat,&q);
764 expect_vec4(expectedquat,gotquat);
765 /* Test the nul quaternion */
766 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
767 D3DXQuaternionNormalize(&gotquat,&nul);
768 expect_vec4(expectedquat,gotquat);
770 /*_______________D3DXQuaternionRotationAxis___________________*/
771 axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
772 angle = D3DX_PI/3.0f;
773 expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
774 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
775 expect_vec4(expectedquat,gotquat);
776 /* Test the nul quaternion */
777 axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
778 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
779 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
780 expect_vec4(expectedquat,gotquat);
782 /*_______________D3DXQuaternionRotationMatrix___________________*/
783 /* test when the trace is >0 */
784 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
785 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
786 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
787 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
788 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
789 U(mat).m[3][3] = 48.0f;
790 expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
791 D3DXQuaternionRotationMatrix(&gotquat,&mat);
792 expect_vec4(expectedquat,gotquat);
793 /* test the case when the greater element is (2,2) */
794 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
795 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
796 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
797 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
798 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
799 U(mat).m[3][3] = 48.0f;
800 expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
801 D3DXQuaternionRotationMatrix(&gotquat,&mat);
802 expect_vec4(expectedquat,gotquat);
803 /* test the case when the greater element is (1,1) */
804 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
805 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
806 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
807 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
808 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
809 U(mat).m[3][3] = 48.0f;
810 expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
811 D3DXQuaternionRotationMatrix(&gotquat,&mat);
812 expect_vec4(expectedquat,gotquat);
813 /* test the case when the trace is near 0 in a matrix which is not a rotation */
814 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
815 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
816 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
817 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
818 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.9f;
819 U(mat).m[3][3] = 48.0f;
820 expectedquat.x = 1.709495f; expectedquat.y = 2.339872f; expectedquat.z = -0.534217f; expectedquat.w = 1.282122f;
821 D3DXQuaternionRotationMatrix(&gotquat,&mat);
822 expect_vec4(expectedquat,gotquat);
823 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
824 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
825 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
826 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
827 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
828 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.51f;
829 U(mat).m[3][3] = 48.0f;
830 expectedquat.x = 1.724923f; expectedquat.y = 2.318944f; expectedquat.z = -0.539039f; expectedquat.w = 1.293692f;
831 D3DXQuaternionRotationMatrix(&gotquat,&mat);
832 expect_vec4(expectedquat,gotquat);
833 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
834 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
835 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
836 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
837 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
838 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.49f;
839 U(mat).m[3][3] = 48.0f;
840 expectedquat.x = 1.725726f; expectedquat.y = 2.317865f; expectedquat.z = -0.539289f; expectedquat.w = 1.294294f;
841 D3DXQuaternionRotationMatrix(&gotquat,&mat);
842 expect_vec4(expectedquat,gotquat);
843 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
844 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
845 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
846 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
847 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
848 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.01f;
849 U(mat).m[3][3] = 48.0f;
850 expectedquat.x = 1.745328f; expectedquat.y = 2.291833f; expectedquat.z = -0.545415f; expectedquat.w = 1.308996f;
851 D3DXQuaternionRotationMatrix(&gotquat,&mat);
852 expect_vec4(expectedquat,gotquat);
853 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
854 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
855 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
856 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
857 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
858 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.0f;
859 U(mat).m[3][3] = 48.0f;
860 expectedquat.x = 1.745743f; expectedquat.y = 2.291288f; expectedquat.z = -0.545545f; expectedquat.w = 1.309307f;
861 D3DXQuaternionRotationMatrix(&gotquat,&mat);
862 expect_vec4(expectedquat,gotquat);
863 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
864 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
865 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
866 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
867 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
868 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.01f;
869 U(mat).m[3][3] = 48.0f;
870 expectedquat.x = 18.408188f; expectedquat.y = 5.970223f; expectedquat.z = -2.985111f; expectedquat.w = 0.502494f;
871 D3DXQuaternionRotationMatrix(&gotquat,&mat);
872 expect_vec4(expectedquat,gotquat);
873 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
874 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
875 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
876 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
877 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
878 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.5f;
879 U(mat).m[3][3] = 48.0f;
880 expectedquat.x = 15.105186f; expectedquat.y = 4.898980f; expectedquat.z = -2.449490f; expectedquat.w = 0.612372f;
881 D3DXQuaternionRotationMatrix(&gotquat,&mat);
882 expect_vec4(expectedquat,gotquat);
883 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
884 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
885 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
886 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
887 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
888 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.70f;
889 U(mat).m[3][3] = 48.0f;
890 expectedquat.x = 14.188852f; expectedquat.y = 4.601790f; expectedquat.z = -2.300895f; expectedquat.w = 0.651920f;
891 D3DXQuaternionRotationMatrix(&gotquat,&mat);
892 expect_vec4(expectedquat,gotquat);
893 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
894 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
895 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
896 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
897 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
898 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.99f;
899 U(mat).m[3][3] = 48.0f;
900 expectedquat.x = 13.114303f; expectedquat.y = 4.253287f; expectedquat.z = -2.126644f; expectedquat.w = 0.705337f;
901 D3DXQuaternionRotationMatrix(&gotquat,&mat);
902 expect_vec4(expectedquat,gotquat);
903 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
904 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
905 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
906 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
907 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
908 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 2.0f;
909 U(mat).m[3][3] = 48.0f;
910 expectedquat.x = 10.680980f; expectedquat.y = 3.464102f; expectedquat.z = -1.732051f; expectedquat.w = 0.866025f;
911 D3DXQuaternionRotationMatrix(&gotquat,&mat);
912 expect_vec4(expectedquat,gotquat);
914 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
915 expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
916 D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
917 expect_vec4(expectedquat,gotquat);
919 /*_______________D3DXQuaternionSlerp________________________*/
920 expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
921 D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
922 expect_vec4(expectedquat,gotquat);
923 expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
924 D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
925 expect_vec4(expectedquat,gotquat);
926 expectedquat.x = 0.239485f; expectedquat.y = 0.346580f; expectedquat.z = 0.453676f; expectedquat.w = 0.560772f;
927 D3DXQuaternionSlerp(&gotquat,&smallq,&smallr,scale);
928 expect_vec4(expectedquat,gotquat);
930 /*_______________D3DXQuaternionSquad________________________*/
931 expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
932 D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
933 expect_vec4(expectedquat,gotquat);
935 /*_______________D3DXQuaternionToAxisAngle__________________*/
936 Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
937 expectedvec.x = 1.0f/22.0f; expectedvec.y = 2.0f/22.0f; expectedvec.z = 4.0f/22.0f;
938 expected = 2.197869f;
939 D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
940 expect_vec3(expectedvec,axis);
941 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
942 /* Test if |w|>1.0f */
943 expectedvec.x = 1.0f; expectedvec.y = 2.0f; expectedvec.z = 4.0f;
945 D3DXQuaternionToAxisAngle(&q,&axis,&angle);
946 expect_vec3(expectedvec,axis);
947 /* Test the null quaternion */
948 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
949 expected = 3.141593f;
950 D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
951 expect_vec3(expectedvec,axis);
952 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
955 static void D3DXVector2Test(void)
957 D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
958 LPD3DXVECTOR2 funcpointer;
959 D3DXVECTOR4 expectedtrans, gottrans;
961 FLOAT coeff1, coeff2, expected, got, scale;
963 nul.x = 0.0f; nul.y = 0.0f;
964 u.x = 3.0f; u.y = 4.0f;
965 v.x = -7.0f; v.y = 9.0f;
966 w.x = 4.0f; w.y = -3.0f;
967 x.x = 2.0f; x.y = -11.0f;
969 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;
970 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;
971 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;
972 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;
974 coeff1 = 2.0f; coeff2 = 5.0f;
977 /*_______________D3DXVec2Add__________________________*/
978 expectedvec.x = -4.0f; expectedvec.y = 13.0f;
979 D3DXVec2Add(&gotvec,&u,&v);
980 expect_vec(expectedvec,gotvec);
981 /* Tests the case NULL */
982 funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
983 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
984 funcpointer = D3DXVec2Add(NULL,NULL,NULL);
985 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
987 /*_______________D3DXVec2BaryCentric___________________*/
988 expectedvec.x = -12.0f; expectedvec.y = -21.0f;
989 D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
990 expect_vec(expectedvec,gotvec);
992 /*_______________D3DXVec2CatmullRom____________________*/
993 expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
994 D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
995 expect_vec(expectedvec,gotvec);
997 /*_______________D3DXVec2CCW__________________________*/
999 got = D3DXVec2CCW(&u,&v);
1000 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1001 /* Tests the case NULL */
1003 got = D3DXVec2CCW(NULL,&v);
1004 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1006 got = D3DXVec2CCW(NULL,NULL);
1007 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1009 /*_______________D3DXVec2Dot__________________________*/
1011 got = D3DXVec2Dot(&u,&v);
1012 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1013 /* Tests the case NULL */
1015 got = D3DXVec2Dot(NULL,&v);
1016 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1018 got = D3DXVec2Dot(NULL,NULL);
1019 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1021 /*_______________D3DXVec2Hermite__________________________*/
1022 expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
1023 D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
1024 expect_vec(expectedvec,gotvec);
1026 /*_______________D3DXVec2Length__________________________*/
1028 got = D3DXVec2Length(&u);
1029 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1030 /* Tests the case NULL */
1032 got = D3DXVec2Length(NULL);
1033 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1035 /*_______________D3DXVec2LengthSq________________________*/
1037 got = D3DXVec2LengthSq(&u);
1038 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1039 /* Tests the case NULL */
1041 got = D3DXVec2LengthSq(NULL);
1042 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1044 /*_______________D3DXVec2Lerp__________________________*/
1045 expectedvec.x = 68.0f; expectedvec.y = -28.5f;
1046 D3DXVec2Lerp(&gotvec,&u,&v,scale);
1047 expect_vec(expectedvec,gotvec);
1048 /* Tests the case NULL */
1049 funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
1050 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1051 funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
1052 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1054 /*_______________D3DXVec2Maximize__________________________*/
1055 expectedvec.x = 3.0f; expectedvec.y = 9.0f;
1056 D3DXVec2Maximize(&gotvec,&u,&v);
1057 expect_vec(expectedvec,gotvec);
1058 /* Tests the case NULL */
1059 funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
1060 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1061 funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
1062 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1064 /*_______________D3DXVec2Minimize__________________________*/
1065 expectedvec.x = -7.0f; expectedvec.y = 4.0f;
1066 D3DXVec2Minimize(&gotvec,&u,&v);
1067 expect_vec(expectedvec,gotvec);
1068 /* Tests the case NULL */
1069 funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
1070 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1071 funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
1072 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1074 /*_______________D3DXVec2Normalize_________________________*/
1075 expectedvec.x = 0.6f; expectedvec.y = 0.8f;
1076 D3DXVec2Normalize(&gotvec,&u);
1077 expect_vec(expectedvec,gotvec);
1078 /* Test the nul vector */
1079 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1080 D3DXVec2Normalize(&gotvec,&nul);
1081 expect_vec(expectedvec,gotvec);
1083 /*_______________D3DXVec2Scale____________________________*/
1084 expectedvec.x = -19.5f; expectedvec.y = -26.0f;
1085 D3DXVec2Scale(&gotvec,&u,scale);
1086 expect_vec(expectedvec,gotvec);
1087 /* Tests the case NULL */
1088 funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
1089 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1090 funcpointer = D3DXVec2Scale(NULL,NULL,scale);
1091 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1093 /*_______________D3DXVec2Subtract__________________________*/
1094 expectedvec.x = 10.0f; expectedvec.y = -5.0f;
1095 D3DXVec2Subtract(&gotvec,&u,&v);
1096 expect_vec(expectedvec,gotvec);
1097 /* Tests the case NULL */
1098 funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
1099 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1100 funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
1101 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1103 /*_______________D3DXVec2Transform_______________________*/
1104 expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
1105 D3DXVec2Transform(&gottrans,&u,&mat);
1106 expect_vec4(expectedtrans,gottrans);
1108 /*_______________D3DXVec2TransformCoord_______________________*/
1109 expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
1110 D3DXVec2TransformCoord(&gotvec,&u,&mat);
1111 expect_vec(expectedvec,gotvec);
1112 /* Test the nul projected vector */
1113 nulproj.x = -2.0f; nulproj.y = -1.0f;
1114 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1115 D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
1116 expect_vec(expectedvec,gotvec);
1118 /*_______________D3DXVec2TransformNormal______________________*/
1119 expectedvec.x = 23.0f; expectedvec.y = 30.0f;
1120 D3DXVec2TransformNormal(&gotvec,&u,&mat);
1121 expect_vec(expectedvec,gotvec);
1124 static void D3DXVector3Test(void)
1126 D3DVIEWPORT9 viewport;
1127 D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
1128 LPD3DXVECTOR3 funcpointer;
1129 D3DXVECTOR4 expectedtrans, gottrans;
1130 D3DXMATRIX mat, projection, view, world;
1131 FLOAT coeff1, coeff2, expected, got, scale;
1133 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
1134 u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
1135 v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
1136 w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
1137 x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
1139 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
1140 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
1142 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;
1143 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;
1144 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;
1145 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;
1147 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
1148 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
1149 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
1150 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
1151 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
1152 U(view).m[3][3] = -40.0f;
1154 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;
1155 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;
1156 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;
1157 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;
1159 coeff1 = 2.0f; coeff2 = 5.0f;
1162 /*_______________D3DXVec3Add__________________________*/
1163 expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
1164 D3DXVec3Add(&gotvec,&u,&v);
1165 expect_vec3(expectedvec,gotvec);
1166 /* Tests the case NULL */
1167 funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
1168 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1169 funcpointer = D3DXVec3Add(NULL,NULL,NULL);
1170 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1172 /*_______________D3DXVec3BaryCentric___________________*/
1173 expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
1174 D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1176 expect_vec3(expectedvec,gotvec);
1178 /*_______________D3DXVec3CatmullRom____________________*/
1179 expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
1180 D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1181 expect_vec3(expectedvec,gotvec);
1183 /*_______________D3DXVec3Cross________________________*/
1184 expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
1185 D3DXVec3Cross(&gotvec,&u,&v);
1186 expect_vec3(expectedvec,gotvec);
1187 /* Tests the case NULL */
1188 funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
1189 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1190 funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
1191 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1193 /*_______________D3DXVec3Dot__________________________*/
1195 got = D3DXVec3Dot(&u,&v);
1196 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1197 /* Tests the case NULL */
1199 got = D3DXVec3Dot(NULL,&v);
1200 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1202 got = D3DXVec3Dot(NULL,NULL);
1203 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1205 /*_______________D3DXVec3Hermite__________________________*/
1206 expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
1207 D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
1208 expect_vec3(expectedvec,gotvec);
1210 /*_______________D3DXVec3Length__________________________*/
1212 got = D3DXVec3Length(&u);
1213 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1214 /* Tests the case NULL */
1216 got = D3DXVec3Length(NULL);
1217 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1219 /*_______________D3DXVec3LengthSq________________________*/
1221 got = D3DXVec3LengthSq(&u);
1222 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1223 /* Tests the case NULL */
1225 got = D3DXVec3LengthSq(NULL);
1226 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1228 /*_______________D3DXVec3Lerp__________________________*/
1229 expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
1230 D3DXVec3Lerp(&gotvec,&u,&v,scale);
1231 expect_vec3(expectedvec,gotvec);
1232 /* Tests the case NULL */
1233 funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
1234 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1235 funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
1236 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1238 /*_______________D3DXVec3Maximize__________________________*/
1239 expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
1240 D3DXVec3Maximize(&gotvec,&u,&v);
1241 expect_vec3(expectedvec,gotvec);
1242 /* Tests the case NULL */
1243 funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
1244 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1245 funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
1246 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1248 /*_______________D3DXVec3Minimize__________________________*/
1249 expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
1250 D3DXVec3Minimize(&gotvec,&u,&v);
1251 expect_vec3(expectedvec,gotvec);
1252 /* Tests the case NULL */
1253 funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
1254 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1255 funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
1256 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1258 /*_______________D3DXVec3Normalize_________________________*/
1259 expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
1260 D3DXVec3Normalize(&gotvec,&u);
1261 expect_vec3(expectedvec,gotvec);
1262 /* Test the nul vector */
1263 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1264 D3DXVec3Normalize(&gotvec,&nul);
1265 expect_vec3(expectedvec,gotvec);
1267 /*_______________D3DXVec3Project_________________________*/
1268 expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
1269 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1270 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
1271 expect_vec3(expectedvec,gotvec);
1273 /*_______________D3DXVec3Scale____________________________*/
1274 expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
1275 D3DXVec3Scale(&gotvec,&u,scale);
1276 expect_vec3(expectedvec,gotvec);
1277 /* Tests the case NULL */
1278 funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
1279 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1280 funcpointer = D3DXVec3Scale(NULL,NULL,scale);
1281 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1283 /*_______________D3DXVec3Subtract_______________________*/
1284 expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
1285 D3DXVec3Subtract(&gotvec,&u,&v);
1286 expect_vec3(expectedvec,gotvec);
1287 /* Tests the case NULL */
1288 funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
1289 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1290 funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
1291 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1293 /*_______________D3DXVec3Transform_______________________*/
1294 expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
1295 D3DXVec3Transform(&gottrans,&u,&mat);
1296 expect_vec4(expectedtrans,gottrans);
1298 /*_______________D3DXVec3TransformCoord_______________________*/
1299 expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
1300 D3DXVec3TransformCoord(&gotvec,&u,&mat);
1301 expect_vec3(expectedvec,gotvec);
1302 /* Test the nul projected vector */
1303 nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
1304 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1305 D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
1306 expect_vec3(expectedvec,gotvec);
1308 /*_______________D3DXVec3TransformNormal______________________*/
1309 expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
1310 D3DXVec3TransformNormal(&gotvec,&u,&mat);
1311 expect_vec3(expectedvec,gotvec);
1313 /*_______________D3DXVec3Unproject_________________________*/
1314 expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
1315 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1316 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
1317 expect_vec3(expectedvec,gotvec);
1320 static void D3DXVector4Test(void)
1322 D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
1323 LPD3DXVECTOR4 funcpointer;
1324 D3DXVECTOR4 expectedtrans, gottrans;
1326 FLOAT coeff1, coeff2, expected, got, scale;
1328 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
1329 u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
1330 v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
1331 w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
1332 x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
1334 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;
1335 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;
1336 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;
1337 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;
1339 coeff1 = 2.0f; coeff2 = 5.0;
1342 /*_______________D3DXVec4Add__________________________*/
1343 expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
1344 D3DXVec4Add(&gotvec,&u,&v);
1345 expect_vec4(expectedvec,gotvec);
1346 /* Tests the case NULL */
1347 funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
1348 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1349 funcpointer = D3DXVec4Add(NULL,NULL,NULL);
1350 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1352 /*_______________D3DXVec4BaryCentric____________________*/
1353 expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
1354 D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1355 expect_vec4(expectedvec,gotvec);
1357 /*_______________D3DXVec4CatmullRom____________________*/
1358 expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
1359 D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1360 expect_vec4(expectedvec,gotvec);
1362 /*_______________D3DXVec4Cross_________________________*/
1363 expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
1364 D3DXVec4Cross(&gotvec,&u,&v,&w);
1365 expect_vec4(expectedvec,gotvec);
1367 /*_______________D3DXVec4Dot__________________________*/
1369 got = D3DXVec4Dot(&u,&v);
1370 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1371 /* Tests the case NULL */
1373 got = D3DXVec4Dot(NULL,&v);
1374 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1376 got = D3DXVec4Dot(NULL,NULL);
1377 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1379 /*_______________D3DXVec4Hermite_________________________*/
1380 expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
1381 D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
1382 expect_vec4(expectedvec,gotvec);
1384 /*_______________D3DXVec4Length__________________________*/
1386 got = D3DXVec4Length(&u);
1387 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1388 /* Tests the case NULL */
1390 got = D3DXVec4Length(NULL);
1391 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1393 /*_______________D3DXVec4LengthSq________________________*/
1395 got = D3DXVec4LengthSq(&u);
1396 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1397 /* Tests the case NULL */
1399 got = D3DXVec4LengthSq(NULL);
1400 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1402 /*_______________D3DXVec4Lerp__________________________*/
1403 expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
1404 D3DXVec4Lerp(&gotvec,&u,&v,scale);
1405 expect_vec4(expectedvec,gotvec);
1406 /* Tests the case NULL */
1407 funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
1408 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1409 funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
1410 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1412 /*_______________D3DXVec4Maximize__________________________*/
1413 expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
1414 D3DXVec4Maximize(&gotvec,&u,&v);
1415 expect_vec4(expectedvec,gotvec);
1416 /* Tests the case NULL */
1417 funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
1418 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1419 funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
1420 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1422 /*_______________D3DXVec4Minimize__________________________*/
1423 expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
1424 D3DXVec4Minimize(&gotvec,&u,&v);
1425 expect_vec4(expectedvec,gotvec);
1426 /* Tests the case NULL */
1427 funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
1428 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1429 funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
1430 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1432 /*_______________D3DXVec4Normalize_________________________*/
1433 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
1434 D3DXVec4Normalize(&gotvec,&u);
1435 expect_vec4(expectedvec,gotvec);
1436 /* Test the nul vector */
1437 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
1438 D3DXVec4Normalize(&gotvec,&nul);
1439 expect_vec4(expectedvec,gotvec);
1441 /*_______________D3DXVec4Scale____________________________*/
1442 expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
1443 D3DXVec4Scale(&gotvec,&u,scale);
1444 expect_vec4(expectedvec,gotvec);
1445 /* Tests the case NULL */
1446 funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
1447 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1448 funcpointer = D3DXVec4Scale(NULL,NULL,scale);
1449 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1451 /*_______________D3DXVec4Subtract__________________________*/
1452 expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
1453 D3DXVec4Subtract(&gotvec,&u,&v);
1454 expect_vec4(expectedvec,gotvec);
1455 /* Tests the case NULL */
1456 funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
1457 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1458 funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
1459 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1461 /*_______________D3DXVec4Transform_______________________*/
1462 expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
1463 D3DXVec4Transform(&gottrans,&u,&mat);
1464 expect_vec4(expectedtrans,gottrans);
1467 static void test_matrix_stack(void)
1469 ID3DXMatrixStack *stack;
1473 const D3DXMATRIX mat1 = {{{
1474 1.0f, 2.0f, 3.0f, 4.0f,
1475 5.0f, 6.0f, 7.0f, 8.0f,
1476 9.0f, 10.0f, 11.0f, 12.0f,
1477 13.0f, 14.0f, 15.0f, 16.0f
1480 const D3DXMATRIX mat2 = {{{
1481 17.0f, 18.0f, 19.0f, 20.0f,
1482 21.0f, 22.0f, 23.0f, 24.0f,
1483 25.0f, 26.0f, 27.0f, 28.0f,
1484 29.0f, 30.0f, 31.0f, 32.0f
1487 hr = D3DXCreateMatrixStack(0, &stack);
1488 ok(SUCCEEDED(hr), "Failed to create a matrix stack, hr %#x\n", hr);
1489 if (FAILED(hr)) return;
1491 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)),
1492 "The top of an empty matrix stack should be an identity matrix\n");
1494 hr = ID3DXMatrixStack_Pop(stack);
1495 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1497 hr = ID3DXMatrixStack_Push(stack);
1498 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1499 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1501 hr = ID3DXMatrixStack_Push(stack);
1502 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1504 hr = ID3DXMatrixStack_LoadMatrix(stack, NULL);
1505 ok(hr == D3DERR_INVALIDCALL, "LoadMatrix returned %#x, expected D3DERR_INVALIDCALL\n", hr);
1507 hr = ID3DXMatrixStack_LoadMatrix(stack, &mat1);
1508 ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
1509 expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1511 hr = ID3DXMatrixStack_Push(stack);
1512 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1513 expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1515 hr = ID3DXMatrixStack_LoadMatrix(stack, &mat2);
1516 ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
1517 expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1519 hr = ID3DXMatrixStack_Push(stack);
1520 ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1521 expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1523 hr = ID3DXMatrixStack_LoadIdentity(stack);
1524 ok(SUCCEEDED(hr), "LoadIdentity failed, hr %#x\n", hr);
1525 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1527 hr = ID3DXMatrixStack_Pop(stack);
1528 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1529 expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1531 hr = ID3DXMatrixStack_Pop(stack);
1532 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1533 expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1535 hr = ID3DXMatrixStack_Pop(stack);
1536 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1537 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1539 hr = ID3DXMatrixStack_Pop(stack);
1540 ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1541 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1543 hr = ID3DXMatrixStack_MultMatrix(stack, NULL);
1544 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1546 hr = ID3DXMatrixStack_MultMatrixLocal(stack, NULL);
1547 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1549 hr = ID3DXMatrixStack_RotateAxis(stack, NULL, 2.0f);
1550 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1552 hr = ID3DXMatrixStack_RotateAxisLocal(stack, NULL, 2.0f);
1553 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1555 refcount = ID3DXMatrixStack_Release(stack);
1556 ok(!refcount, "Matrix stack has %u references left.\n", refcount);
1559 static void test_Matrix_AffineTransformation2D(void)
1561 D3DXMATRIX exp_mat, got_mat;
1562 D3DXVECTOR2 center, position;
1571 angle = D3DX_PI/3.0f;
1575 U(exp_mat).m[0][0] = 10.0f;
1576 U(exp_mat).m[1][0] = -17.320507f;
1577 U(exp_mat).m[2][0] = 0.0f;
1578 U(exp_mat).m[3][0] = -1.035898f;
1579 U(exp_mat).m[0][1] = 17.320507f;
1580 U(exp_mat).m[1][1] = 10.0f;
1581 U(exp_mat).m[2][1] = 0.0f;
1582 U(exp_mat).m[3][1] = 6.401924f;
1583 U(exp_mat).m[0][2] = 0.0f;
1584 U(exp_mat).m[1][2] = 0.0f;
1585 U(exp_mat).m[2][2] = 1.0f;
1586 U(exp_mat).m[3][2] = 0.0f;
1587 U(exp_mat).m[0][3] = 0.0f;
1588 U(exp_mat).m[1][3] = 0.0f;
1589 U(exp_mat).m[2][3] = 0.0f;
1590 U(exp_mat).m[3][3] = 1.0f;
1592 D3DXMatrixAffineTransformation2D(&got_mat, scale, ¢er, angle, &position);
1594 expect_mat(&exp_mat, &got_mat);
1601 angle = D3DX_PI/3.0f;
1605 U(exp_mat).m[0][0] = 10.0f;
1606 U(exp_mat).m[1][0] = -17.320507f;
1607 U(exp_mat).m[2][0] = 0.0f;
1608 U(exp_mat).m[3][0] = 4.964102f;
1609 U(exp_mat).m[0][1] = 17.320507f;
1610 U(exp_mat).m[1][1] = 10.0f;
1611 U(exp_mat).m[2][1] = 0.0f;
1612 U(exp_mat).m[3][1] = -0.598076f;
1613 U(exp_mat).m[0][2] = 0.0f;
1614 U(exp_mat).m[1][2] = 0.0f;
1615 U(exp_mat).m[2][2] = 1.0f;
1616 U(exp_mat).m[3][2] = 0.0f;
1617 U(exp_mat).m[0][3] = 0.0f;
1618 U(exp_mat).m[1][3] = 0.0f;
1619 U(exp_mat).m[2][3] = 0.0f;
1620 U(exp_mat).m[3][3] = 1.0f;
1622 D3DXMatrixAffineTransformation2D(&got_mat, scale, ¢er, angle, NULL);
1624 expect_mat(&exp_mat, &got_mat);
1631 angle = D3DX_PI/3.0f;
1635 U(exp_mat).m[0][0] = 10.0f;
1636 U(exp_mat).m[1][0] = -17.320507f;
1637 U(exp_mat).m[2][0] = 0.0f;
1638 U(exp_mat).m[3][0] = -6.0f;
1639 U(exp_mat).m[0][1] = 17.320507f;
1640 U(exp_mat).m[1][1] = 10.0f;
1641 U(exp_mat).m[2][1] = 0.0f;
1642 U(exp_mat).m[3][1] = 7.0f;
1643 U(exp_mat).m[0][2] = 0.0f;
1644 U(exp_mat).m[1][2] = 0.0f;
1645 U(exp_mat).m[2][2] = 1.0f;
1646 U(exp_mat).m[3][2] = 0.0f;
1647 U(exp_mat).m[0][3] = 0.0f;
1648 U(exp_mat).m[1][3] = 0.0f;
1649 U(exp_mat).m[2][3] = 0.0f;
1650 U(exp_mat).m[3][3] = 1.0f;
1652 D3DXMatrixAffineTransformation2D(&got_mat, scale, NULL, angle, &position);
1654 expect_mat(&exp_mat, &got_mat);
1658 angle = 5.0f * D3DX_PI/4.0f;
1662 U(exp_mat).m[0][0] = 14.142133f;
1663 U(exp_mat).m[1][0] = -14.142133f;
1664 U(exp_mat).m[2][0] = 0.0f;
1665 U(exp_mat).m[3][0] = 0.0f;
1666 U(exp_mat).m[0][1] = 14.142133;
1667 U(exp_mat).m[1][1] = 14.142133f;
1668 U(exp_mat).m[2][1] = 0.0f;
1669 U(exp_mat).m[3][1] = 0.0f;
1670 U(exp_mat).m[0][2] = 0.0f;
1671 U(exp_mat).m[1][2] = 0.0f;
1672 U(exp_mat).m[2][2] = 1.0f;
1673 U(exp_mat).m[3][2] = 0.0f;
1674 U(exp_mat).m[0][3] = 0.0f;
1675 U(exp_mat).m[1][3] = 0.0f;
1676 U(exp_mat).m[2][3] = 0.0f;
1677 U(exp_mat).m[3][3] = 1.0f;
1679 D3DXMatrixAffineTransformation2D(&got_mat, scale, NULL, angle, NULL);
1681 expect_mat(&exp_mat, &got_mat);
1684 static void test_Matrix_Decompose(void)
1687 D3DXQUATERNION exp_rotation, got_rotation;
1688 D3DXVECTOR3 exp_scale, got_scale, exp_translation, got_translation;
1693 U(pm).m[0][0] = -0.9238790f;
1694 U(pm).m[1][0] = -0.2705984f;
1695 U(pm).m[2][0] = 0.2705984f;
1696 U(pm).m[3][0] = -5.0f;
1697 U(pm).m[0][1] = 0.2705984f;
1698 U(pm).m[1][1] = 0.03806049f;
1699 U(pm).m[2][1] = 0.9619395f;
1700 U(pm).m[3][1] = 0.0f;
1701 U(pm).m[0][2] = -0.2705984f;
1702 U(pm).m[1][2] = 0.9619395f;
1703 U(pm).m[2][2] = 0.03806049f;
1704 U(pm).m[3][2] = 10.0f;
1705 U(pm).m[0][3] = 0.0f;
1706 U(pm).m[1][3] = 0.0f;
1707 U(pm).m[2][3] = 0.0f;
1708 U(pm).m[3][3] = 1.0f;
1714 exp_rotation.w = 0.195091f;
1715 exp_rotation.x = 0.0f;
1716 exp_rotation.y = 0.693520f;
1717 exp_rotation.z = 0.693520f;
1719 exp_translation.x = -5.0f;
1720 exp_translation.y = 0.0f;
1721 exp_translation.z = 10.0f;
1723 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1725 compare_scale(exp_scale, got_scale);
1726 compare_rotation(exp_rotation, got_rotation);
1727 compare_translation(exp_translation, got_translation);
1731 U(pm).m[0][0] = -2.255813f;
1732 U(pm).m[1][0] = 1.302324f;
1733 U(pm).m[2][0] = 1.488373f;
1734 U(pm).m[3][0] = 1.0f;
1735 U(pm).m[0][1] = 1.302327f;
1736 U(pm).m[1][1] = -0.7209296f;
1737 U(pm).m[2][1] = 2.60465f;
1738 U(pm).m[3][1] = 2.0f;
1739 U(pm).m[0][2] = 1.488371f;
1740 U(pm).m[1][2] = 2.604651f;
1741 U(pm).m[2][2] = -0.02325551f;
1742 U(pm).m[3][2] = 3.0f;
1743 U(pm).m[0][3] = 0.0f;
1744 U(pm).m[1][3] = 0.0f;
1745 U(pm).m[2][3] = 0.0f;
1746 U(pm).m[3][3] = 1.0f;
1752 exp_rotation.w = 0.0;
1753 exp_rotation.x = 0.352180f;
1754 exp_rotation.y = 0.616316f;
1755 exp_rotation.z = 0.704361f;
1757 exp_translation.x = 1.0f;
1758 exp_translation.y = 2.0f;
1759 exp_translation.z = 3.0f;
1761 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1763 compare_scale(exp_scale, got_scale);
1764 compare_rotation(exp_rotation, got_rotation);
1765 compare_translation(exp_translation, got_translation);
1769 U(pm).m[0][0] = 2.427051f;
1770 U(pm).m[1][0] = 0.0f;
1771 U(pm).m[2][0] = 1.763355f;
1772 U(pm).m[3][0] = 5.0f;
1773 U(pm).m[0][1] = 0.0f;
1774 U(pm).m[1][1] = 3.0f;
1775 U(pm).m[2][1] = 0.0f;
1776 U(pm).m[3][1] = 5.0f;
1777 U(pm).m[0][2] = -1.763355f;
1778 U(pm).m[1][2] = 0.0f;
1779 U(pm).m[2][2] = 2.427051f;
1780 U(pm).m[3][2] = 5.0f;
1781 U(pm).m[0][3] = 0.0f;
1782 U(pm).m[1][3] = 0.0f;
1783 U(pm).m[2][3] = 0.0f;
1784 U(pm).m[3][3] = 1.0f;
1790 exp_rotation.w = 0.951057f;
1791 exp_rotation.x = 0.0f;
1792 exp_rotation.y = 0.309017f;
1793 exp_rotation.z = 0.0f;
1795 exp_translation.x = 5.0f;
1796 exp_translation.y = 5.0f;
1797 exp_translation.z = 5.0f;
1799 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1801 compare_scale(exp_scale, got_scale);
1802 compare_rotation(exp_rotation, got_rotation);
1803 compare_translation(exp_translation, got_translation);
1807 U(pm).m[0][0] = -0.9238790f;
1808 U(pm).m[1][0] = -0.2705984f;
1809 U(pm).m[2][0] = 0.2705984f;
1810 U(pm).m[3][0] = -5.0f;
1811 U(pm).m[0][1] = 0.2705984f;
1812 U(pm).m[1][1] = 0.03806049f;
1813 U(pm).m[2][1] = 0.9619395f;
1814 U(pm).m[3][1] = 0.0f;
1815 U(pm).m[0][2] = -0.2705984f;
1816 U(pm).m[1][2] = 0.9619395f;
1817 U(pm).m[2][2] = 0.03806049f;
1818 U(pm).m[3][2] = 10.0f;
1819 U(pm).m[0][3] = 0.0f;
1820 U(pm).m[1][3] = 0.0f;
1821 U(pm).m[2][3] = 0.0f;
1822 U(pm).m[3][3] = 1.0f;
1828 exp_rotation.w = 0.195091f;
1829 exp_rotation.x = 0.0f;
1830 exp_rotation.y = 0.693520f;
1831 exp_rotation.z = 0.693520f;
1833 exp_translation.x = -5.0f;
1834 exp_translation.y = 0.0f;
1835 exp_translation.z = 10.0f;
1837 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1839 compare_scale(exp_scale, got_scale);
1840 compare_rotation(exp_rotation, got_rotation);
1841 compare_translation(exp_translation, got_translation);
1845 U(pm).m[0][0] = -0.9238790f;
1846 U(pm).m[1][0] = -0.5411968f;
1847 U(pm).m[2][0] = 0.8117952f;
1848 U(pm).m[3][0] = -5.0f;
1849 U(pm).m[0][1] = 0.2705984f;
1850 U(pm).m[1][1] = 0.07612098f;
1851 U(pm).m[2][1] = 2.8858185f;
1852 U(pm).m[3][1] = 0.0f;
1853 U(pm).m[0][2] = -0.2705984f;
1854 U(pm).m[1][2] = 1.9238790f;
1855 U(pm).m[2][2] = 0.11418147f;
1856 U(pm).m[3][2] = 10.0f;
1857 U(pm).m[0][3] = 0.0f;
1858 U(pm).m[1][3] = 0.0f;
1859 U(pm).m[2][3] = 0.0f;
1860 U(pm).m[3][3] = 1.0f;
1866 exp_rotation.w = 0.195091f;
1867 exp_rotation.x = 0.0f;
1868 exp_rotation.y = 0.693520f;
1869 exp_rotation.z = 0.693520f;
1871 exp_translation.x = -5.0f;
1872 exp_translation.y = 0.0f;
1873 exp_translation.z = 10.0f;
1875 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1877 compare_scale(exp_scale, got_scale);
1878 compare_rotation(exp_rotation, got_rotation);
1879 compare_translation(exp_translation, got_translation);
1883 U(pm).m[0][0] = 0.7156004f;
1884 U(pm).m[1][0] = -0.5098283f;
1885 U(pm).m[2][0] = -0.4774843f;
1886 U(pm).m[3][0] = -5.0f;
1887 U(pm).m[0][1] = -0.6612288f;
1888 U(pm).m[1][1] = -0.7147621f;
1889 U(pm).m[2][1] = -0.2277977f;
1890 U(pm).m[3][1] = 0.0f;
1891 U(pm).m[0][2] = -0.2251499f;
1892 U(pm).m[1][2] = 0.4787385f;
1893 U(pm).m[2][2] = -0.8485972f;
1894 U(pm).m[3][2] = 10.0f;
1895 U(pm).m[0][3] = 0.0f;
1896 U(pm).m[1][3] = 0.0f;
1897 U(pm).m[2][3] = 0.0f;
1898 U(pm).m[3][3] = 1.0f;
1904 exp_rotation.w = 0.195091f;
1905 exp_rotation.x = 0.905395f;
1906 exp_rotation.y = -0.323355f;
1907 exp_rotation.z = -0.194013f;
1909 exp_translation.x = -5.0f;
1910 exp_translation.y = 0.0f;
1911 exp_translation.z = 10.0f;
1913 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1915 compare_scale(exp_scale, got_scale);
1916 compare_rotation(exp_rotation, got_rotation);
1917 compare_translation(exp_translation, got_translation);
1921 U(pm).m[0][0] = 0.06554436f;
1922 U(pm).m[1][0] = -0.6873012f;
1923 U(pm).m[2][0] = 0.7234092f;
1924 U(pm).m[3][0] = -5.0f;
1925 U(pm).m[0][1] = -0.9617381f;
1926 U(pm).m[1][1] = -0.2367795f;
1927 U(pm).m[2][1] = -0.1378230f;
1928 U(pm).m[3][1] = 0.0f;
1929 U(pm).m[0][2] = 0.2660144f;
1930 U(pm).m[1][2] = -0.6866967f;
1931 U(pm).m[2][2] = -0.6765233f;
1932 U(pm).m[3][2] = 10.0f;
1933 U(pm).m[0][3] = 0.0f;
1934 U(pm).m[1][3] = 0.0f;
1935 U(pm).m[2][3] = 0.0f;
1936 U(pm).m[3][3] = 1.0f;
1942 exp_rotation.w = -0.195091f;
1943 exp_rotation.x = 0.703358f;
1944 exp_rotation.y = -0.586131f;
1945 exp_rotation.z = 0.351679f;
1947 exp_translation.x = -5.0f;
1948 exp_translation.y = 0.0f;
1949 exp_translation.z = 10.0f;
1951 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1953 compare_scale(exp_scale, got_scale);
1954 compare_rotation(exp_rotation, got_rotation);
1955 compare_translation(exp_translation, got_translation);
1959 U(pm).m[0][0] = 7.121047f;
1960 U(pm).m[1][0] = -5.883487f;
1961 U(pm).m[2][0] = 11.81843f;
1962 U(pm).m[3][0] = -5.0f;
1963 U(pm).m[0][1] = 5.883487f;
1964 U(pm).m[1][1] = -10.60660f;
1965 U(pm).m[2][1] = -8.825232f;
1966 U(pm).m[3][1] = 0.0f;
1967 U(pm).m[0][2] = 11.81843f;
1968 U(pm).m[1][2] = 8.8252320f;
1969 U(pm).m[2][2] = -2.727645f;
1970 U(pm).m[3][2] = 2.0f;
1971 U(pm).m[0][3] = 0.0f;
1972 U(pm).m[1][3] = 0.0f;
1973 U(pm).m[2][3] = 0.0f;
1974 U(pm).m[3][3] = 1.0f;
1976 exp_scale.x = 15.0f;
1977 exp_scale.y = 15.0f;
1978 exp_scale.z = 15.0f;
1980 exp_rotation.w = 0.382684f;
1981 exp_rotation.x = 0.768714f;
1982 exp_rotation.y = 0.0f;
1983 exp_rotation.z = 0.512476f;
1985 exp_translation.x = -5.0f;
1986 exp_translation.y = 0.0f;
1987 exp_translation.z = 2.0f;
1989 D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
1991 compare_scale(exp_scale, got_scale);
1992 compare_rotation(exp_rotation, got_rotation);
1993 compare_translation(exp_translation, got_translation);
1997 U(pm).m[0][0] = 0.0f;
1998 U(pm).m[1][0] = 4.0f;
1999 U(pm).m[2][0] = 5.0f;
2000 U(pm).m[3][0] = -5.0f;
2001 U(pm).m[0][1] = 0.0f;
2002 U(pm).m[1][1] = -10.60660f;
2003 U(pm).m[2][1] = -8.825232f;
2004 U(pm).m[3][1] = 6.0f;
2005 U(pm).m[0][2] = 0.0f;
2006 U(pm).m[1][2] = 8.8252320f;
2007 U(pm).m[2][2] = 2.727645;
2008 U(pm).m[3][2] = 3.0f;
2009 U(pm).m[0][3] = 0.0f;
2010 U(pm).m[1][3] = 0.0f;
2011 U(pm).m[2][3] = 0.0f;
2012 U(pm).m[3][3] = 1.0f;
2014 hr = D3DXMatrixDecompose(&got_scale, &got_rotation, &got_translation, &pm);
2015 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);
2018 static void test_Matrix_Transformation2D(void)
2020 D3DXMATRIX exp_mat, got_mat;
2021 D3DXVECTOR2 rot_center, sca, sca_center, trans;
2024 rot_center.x = 3.0f;
2025 rot_center.y = 4.0f;
2030 sca_center.x = 9.0f;
2031 sca_center.y = -5.0f;
2038 sca_rot = 5.0f*D3DX_PI/4.0f;
2040 U(exp_mat).m[0][0] = -4.245192f;
2041 U(exp_mat).m[1][0] = -0.147116f;
2042 U(exp_mat).m[2][0] = 0.0f;
2043 U(exp_mat).m[3][0] = 45.265373f;
2044 U(exp_mat).m[0][1] = 7.647113f;
2045 U(exp_mat).m[1][1] = 8.745192f;
2046 U(exp_mat).m[2][1] = 0.0f;
2047 U(exp_mat).m[3][1] = -13.401899f;
2048 U(exp_mat).m[0][2] = 0.0f;
2049 U(exp_mat).m[1][2] = 0.0f;
2050 U(exp_mat).m[2][2] = 1.0f;
2051 U(exp_mat).m[3][2] = 0.0f;
2052 U(exp_mat).m[0][3] = 0.0f;
2053 U(exp_mat).m[1][3] = 0.0f;
2054 U(exp_mat).m[2][3] = 0.0f;
2055 U(exp_mat).m[3][3] = 1.0f;
2057 D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, &sca, &rot_center, rot, &trans);
2059 expect_mat(&exp_mat, &got_mat);
2063 sca_center.x = 9.0f;
2064 sca_center.y = -5.0f;
2071 sca_rot = 5.0f*D3DX_PI/4.0f;
2073 U(exp_mat).m[0][0] = 0.50f;
2074 U(exp_mat).m[1][0] = -0.866025f;
2075 U(exp_mat).m[2][0] = 0.0f;
2076 U(exp_mat).m[3][0] = -6.0f;
2077 U(exp_mat).m[0][1] = 0.866025f;
2078 U(exp_mat).m[1][1] = 0.50f;
2079 U(exp_mat).m[2][1] = 0.0f;
2080 U(exp_mat).m[3][1] = 7.0f;
2081 U(exp_mat).m[0][2] = 0.0f;
2082 U(exp_mat).m[1][2] = 0.0f;
2083 U(exp_mat).m[2][2] = 1.0f;
2084 U(exp_mat).m[3][2] = 0.0f;
2085 U(exp_mat).m[0][3] = 0.0f;
2086 U(exp_mat).m[1][3] = 0.0f;
2087 U(exp_mat).m[2][3] = 0.0f;
2088 U(exp_mat).m[3][3] = 1.0f;
2090 D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, NULL, NULL, rot, &trans);
2092 expect_mat(&exp_mat, &got_mat);
2096 U(exp_mat).m[0][0] = 0.50f;
2097 U(exp_mat).m[1][0] = -0.866025f;
2098 U(exp_mat).m[2][0] = 0.0f;
2099 U(exp_mat).m[3][0] = 0.0f;
2100 U(exp_mat).m[0][1] = 0.866025f;
2101 U(exp_mat).m[1][1] = 0.50f;
2102 U(exp_mat).m[2][1] = 0.0f;
2103 U(exp_mat).m[3][1] = 0.0f;
2104 U(exp_mat).m[0][2] = 0.0f;
2105 U(exp_mat).m[1][2] = 0.0f;
2106 U(exp_mat).m[2][2] = 1.0f;
2107 U(exp_mat).m[3][2] = 0.0f;
2108 U(exp_mat).m[0][3] = 0.0f;
2109 U(exp_mat).m[1][3] = 0.0f;
2110 U(exp_mat).m[2][3] = 0.0f;
2111 U(exp_mat).m[3][3] = 1.0f;
2113 D3DXMatrixTransformation2D(&got_mat, NULL, sca_rot, NULL, NULL, rot, NULL);
2115 expect_mat(&exp_mat, &got_mat);
2118 static void test_D3DXVec_Array(void)
2121 D3DVIEWPORT9 viewport;
2122 D3DXMATRIX mat, projection, view, world;
2123 D3DXVECTOR4 inp_vec[ARRAY_SIZE];
2124 D3DXVECTOR4 out_vec[ARRAY_SIZE + 2];
2125 D3DXVECTOR4 exp_vec[ARRAY_SIZE + 2];
2126 D3DXPLANE inp_plane[ARRAY_SIZE];
2127 D3DXPLANE out_plane[ARRAY_SIZE + 2];
2128 D3DXPLANE exp_plane[ARRAY_SIZE + 2];
2130 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
2131 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
2133 for (i = 0; i < ARRAY_SIZE + 2; ++i) {
2134 out_vec[i].x = out_vec[i].y = out_vec[i].z = out_vec[i].w = 0.0f;
2135 exp_vec[i].x = exp_vec[i].y = exp_vec[i].z = exp_vec[i].w = 0.0f;
2136 out_plane[i].a = out_plane[i].b = out_plane[i].c = out_plane[i].d = 0.0f;
2137 exp_plane[i].a = exp_plane[i].b = exp_plane[i].c = exp_plane[i].d = 0.0f;
2140 for (i = 0; i < ARRAY_SIZE; ++i) {
2141 inp_plane[i].a = inp_plane[i].c = inp_vec[i].x = inp_vec[i].z = i;
2142 inp_plane[i].b = inp_plane[i].d = inp_vec[i].y = inp_vec[i].w = ARRAY_SIZE - i;
2145 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;
2146 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;
2147 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;
2148 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;
2150 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
2152 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
2153 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
2154 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
2155 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
2156 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
2157 U(view).m[3][3] = -40.0f;
2159 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;
2160 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;
2161 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;
2162 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;
2164 /* D3DXVec2TransformCoordArray */
2165 exp_vec[1].x = 0.678571f; exp_vec[1].y = 0.785714f;
2166 exp_vec[2].x = 0.653846f; exp_vec[2].y = 0.769231f;
2167 exp_vec[3].x = 0.625f; exp_vec[3].y = 0.75f;
2168 exp_vec[4].x = 0.590909f; exp_vec[4].y = 8.0f/11.0f;
2169 exp_vec[5].x = 0.55f; exp_vec[5].y = 0.7f;
2170 D3DXVec2TransformCoordArray((D3DXVECTOR2*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2171 compare_vectors(exp_vec, out_vec);
2173 /* D3DXVec2TransformNormalArray */
2174 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f;
2175 exp_vec[2].x = 21.0f; exp_vec[2].y = 26.0f;
2176 exp_vec[3].x = 17.0f; exp_vec[3].y = 22.0f;
2177 exp_vec[4].x = 13.0f; exp_vec[4].y = 18.0f;
2178 exp_vec[5].x = 9.0f; exp_vec[5].y = 14.0f;
2179 D3DXVec2TransformNormalArray((D3DXVECTOR2*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2180 compare_vectors(exp_vec, out_vec);
2182 /* D3DXVec3TransformCoordArray */
2183 exp_vec[1].x = 0.678571f; exp_vec[1].y = 0.785714f; exp_vec[1].z = 0.892857f;
2184 exp_vec[2].x = 0.671875f; exp_vec[2].y = 0.78125f; exp_vec[2].z = 0.890625f;
2185 exp_vec[3].x = 6.0f/9.0f; exp_vec[3].y = 7.0f/9.0f; exp_vec[3].z = 8.0f/9.0f;
2186 exp_vec[4].x = 0.6625f; exp_vec[4].y = 0.775f; exp_vec[4].z = 0.8875f;
2187 exp_vec[5].x = 0.659091f; exp_vec[5].y = 0.772727f; exp_vec[5].z = 0.886364f;
2188 D3DXVec3TransformCoordArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2189 compare_vectors(exp_vec, out_vec);
2191 /* D3DXVec3TransformNormalArray */
2192 exp_vec[1].x = 25.0f; exp_vec[1].y = 30.0f; exp_vec[1].z = 35.0f;
2193 exp_vec[2].x = 30.0f; exp_vec[2].y = 36.0f; exp_vec[2].z = 42.0f;
2194 exp_vec[3].x = 35.0f; exp_vec[3].y = 42.0f; exp_vec[3].z = 49.0f;
2195 exp_vec[4].x = 40.0f; exp_vec[4].y = 48.0f; exp_vec[4].z = 56.0f;
2196 exp_vec[5].x = 45.0f; exp_vec[5].y = 54.0f; exp_vec[5].z = 63.0f;
2197 D3DXVec3TransformNormalArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2198 compare_vectors(exp_vec, out_vec);
2200 /* D3DXVec3ProjectArray */
2201 exp_vec[1].x = 1089.554199f; exp_vec[1].y = -226.590622f; exp_vec[1].z = 0.215273f;
2202 exp_vec[2].x = 1068.903320f; exp_vec[2].y = 103.085129f; exp_vec[2].z = 0.183050f;
2203 exp_vec[3].x = 1051.778931f; exp_vec[3].y = 376.462250f; exp_vec[3].z = 0.156329f;
2204 exp_vec[4].x = 1037.348877f; exp_vec[4].y = 606.827393f; exp_vec[4].z = 0.133813f;
2205 exp_vec[5].x = 1025.023560f; exp_vec[5].y = 803.591248f; exp_vec[5].z = 0.114581f;
2206 D3DXVec3ProjectArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (CONST D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &viewport, &projection, &view, &world, ARRAY_SIZE);
2207 compare_vectors(exp_vec, out_vec);
2209 /* D3DXVec3UnprojectArray */
2210 exp_vec[1].x = -6.124031f; exp_vec[1].y = 3.225360f; exp_vec[1].z = 0.620571f;
2211 exp_vec[2].x = -3.807109f; exp_vec[2].y = 2.046579f; exp_vec[2].z = 0.446894f;
2212 exp_vec[3].x = -2.922839f; exp_vec[3].y = 1.596689f; exp_vec[3].z = 0.380609f;
2213 exp_vec[4].x = -2.456225f; exp_vec[4].y = 1.359290f; exp_vec[4].z = 0.345632f;
2214 exp_vec[5].x = -2.167897f; exp_vec[5].y = 1.212597f; exp_vec[5].z = 0.324019f;
2215 D3DXVec3UnprojectArray((D3DXVECTOR3*)(out_vec + 1), sizeof(D3DXVECTOR4), (CONST D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &viewport, &projection, &view, &world, ARRAY_SIZE);
2216 compare_vectors(exp_vec, out_vec);
2218 /* D3DXVec2TransformArray */
2219 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
2220 exp_vec[2].x = 34.0f; exp_vec[2].y = 40.0f; exp_vec[2].z = 46.0f; exp_vec[2].w = 52.0f;
2221 exp_vec[3].x = 30.0f; exp_vec[3].y = 36.0f; exp_vec[3].z = 42.0f; exp_vec[3].w = 48.0f;
2222 exp_vec[4].x = 26.0f; exp_vec[4].y = 32.0f; exp_vec[4].z = 38.0f; exp_vec[4].w = 44.0f;
2223 exp_vec[5].x = 22.0f; exp_vec[5].y = 28.0f; exp_vec[5].z = 34.0f; exp_vec[5].w = 40.0f;
2224 D3DXVec2TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), (D3DXVECTOR2*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2225 compare_vectors(exp_vec, out_vec);
2227 /* D3DXVec3TransformArray */
2228 exp_vec[1].x = 38.0f; exp_vec[1].y = 44.0f; exp_vec[1].z = 50.0f; exp_vec[1].w = 56.0f;
2229 exp_vec[2].x = 43.0f; exp_vec[2].y = 50.0f; exp_vec[2].z = 57.0f; exp_vec[2].w = 64.0f;
2230 exp_vec[3].x = 48.0f; exp_vec[3].y = 56.0f; exp_vec[3].z = 64.0f; exp_vec[3].w = 72.0f;
2231 exp_vec[4].x = 53.0f; exp_vec[4].y = 62.0f; exp_vec[4].z = 71.0f; exp_vec[4].w = 80.0f;
2232 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
2233 D3DXVec3TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), (D3DXVECTOR3*)inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2234 compare_vectors(exp_vec, out_vec);
2236 /* D3DXVec4TransformArray */
2237 exp_vec[1].x = 90.0f; exp_vec[1].y = 100.0f; exp_vec[1].z = 110.0f; exp_vec[1].w = 120.0f;
2238 exp_vec[2].x = 82.0f; exp_vec[2].y = 92.0f; exp_vec[2].z = 102.0f; exp_vec[2].w = 112.0f;
2239 exp_vec[3].x = 74.0f; exp_vec[3].y = 84.0f; exp_vec[3].z = 94.0f; exp_vec[3].w = 104.0f;
2240 exp_vec[4].x = 66.0f; exp_vec[4].y = 76.0f; exp_vec[4].z = 86.0f; exp_vec[4].w = 96.0f;
2241 exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f; exp_vec[5].z = 78.0f; exp_vec[5].w = 88.0f;
2242 D3DXVec4TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
2243 compare_vectors(exp_vec, out_vec);
2245 /* D3DXPlaneTransformArray */
2246 exp_plane[1].a = 90.0f; exp_plane[1].b = 100.0f; exp_plane[1].c = 110.0f; exp_plane[1].d = 120.0f;
2247 exp_plane[2].a = 82.0f; exp_plane[2].b = 92.0f; exp_plane[2].c = 102.0f; exp_plane[2].d = 112.0f;
2248 exp_plane[3].a = 74.0f; exp_plane[3].b = 84.0f; exp_plane[3].c = 94.0f; exp_plane[3].d = 104.0f;
2249 exp_plane[4].a = 66.0f; exp_plane[4].b = 76.0f; exp_plane[4].c = 86.0f; exp_plane[4].d = 96.0f;
2250 exp_plane[5].a = 58.0f; exp_plane[5].b = 68.0f; exp_plane[5].c = 78.0f; exp_plane[5].d = 88.0f;
2251 D3DXPlaneTransformArray(out_plane + 1, sizeof(D3DXPLANE), inp_plane, sizeof(D3DXPLANE), &mat, ARRAY_SIZE);
2252 compare_planes(exp_plane, out_plane);
2261 D3DXQuaternionTest();
2265 test_matrix_stack();
2266 test_Matrix_AffineTransformation2D();
2267 test_Matrix_Decompose();
2268 test_Matrix_Transformation2D();
2269 test_D3DXVec_Array();