2 * Copyright 2007 David Adam
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
24 #define admitted_error 0.0001f
26 #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);
28 #define expect_mat(expectedmat,gotmat)\
35 if (fabs(U(expectedmat).m[i][j]-U(gotmat).m[i][j])>admitted_error) \
41 ok(equal, "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" \
42 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
43 U(expectedmat).m[0][0],U(expectedmat).m[0][1],U(expectedmat).m[0][2],U(expectedmat).m[0][3], \
44 U(expectedmat).m[1][0],U(expectedmat).m[1][1],U(expectedmat).m[1][2],U(expectedmat).m[1][3], \
45 U(expectedmat).m[2][0],U(expectedmat).m[2][1],U(expectedmat).m[2][2],U(expectedmat).m[2][3], \
46 U(expectedmat).m[3][0],U(expectedmat).m[3][1],U(expectedmat).m[3][2],U(expectedmat).m[3][3], \
47 U(gotmat).m[0][0],U(gotmat).m[0][1],U(gotmat).m[0][2],U(gotmat).m[0][3], \
48 U(gotmat).m[1][0],U(gotmat).m[1][1],U(gotmat).m[1][2],U(gotmat).m[1][3], \
49 U(gotmat).m[2][0],U(gotmat).m[2][1],U(gotmat).m[2][2],U(gotmat).m[2][3], \
50 U(gotmat).m[3][0],U(gotmat).m[3][1],U(gotmat).m[3][2],U(gotmat).m[3][3]); \
53 #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);
55 #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);
57 #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);
59 #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);
61 static void D3DXColorTest(void)
63 D3DXCOLOR color, color1, color2, expected, got;
64 LPD3DXCOLOR funcpointer;
67 color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
68 color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
69 color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
73 /*_______________D3DXColorAdd________________*/
74 expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f, expected.a = 0.93f;
75 D3DXColorAdd(&got,&color1,&color2);
76 expect_color(expected,got);
77 /* Test the NULL case */
78 funcpointer = D3DXColorAdd(&got,NULL,&color2);
79 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
80 funcpointer = D3DXColorAdd(NULL,NULL,&color2);
81 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
82 funcpointer = D3DXColorAdd(NULL,NULL,NULL);
83 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
85 /*_______________D3DXColorAdjustContrast______*/
86 expected.r = 0.41f; expected.g = 0.575f; expected.b = 0.473f, expected.a = 0.93f;
87 D3DXColorAdjustContrast(&got,&color,scale);
88 expect_color(expected,got);
90 /*_______________D3DXColorAdjustSaturation______*/
91 expected.r = 0.486028f; expected.g = 0.651028f; expected.b = 0.549028f, expected.a = 0.93f;
92 D3DXColorAdjustSaturation(&got,&color,scale);
93 expect_color(expected,got);
95 /*_______________D3DXColorLerp________________*/
96 expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
97 D3DXColorLerp(&got,&color,&color1,scale);
98 expect_color(expected,got);
99 /* Test the NULL case */
100 funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
101 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
102 funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
103 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
104 funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
105 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
107 /*_______________D3DXColorModulate________________*/
108 expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
109 D3DXColorModulate(&got,&color1,&color2);
110 expect_color(expected,got);
111 /* Test the NULL case */
112 funcpointer = D3DXColorModulate(&got,NULL,&color2);
113 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
114 funcpointer = D3DXColorModulate(NULL,NULL,&color2);
115 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
116 funcpointer = D3DXColorModulate(NULL,NULL,NULL);
117 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
119 /*_______________D3DXColorNegative________________*/
120 expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
121 D3DXColorNegative(&got,&color);
122 expect_color(got,expected);
123 /* Test the greater than 1 case */
124 color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
125 expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
126 D3DXColorNegative(&got,&color1);
127 expect_color(got,expected);
128 /* Test the negative case */
129 color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
130 expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
131 D3DXColorNegative(&got,&color1);
132 expect_color(got,expected);
133 /* Test the NULL case */
134 funcpointer = D3DXColorNegative(&got,NULL);
135 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
136 funcpointer = D3DXColorNegative(NULL,NULL);
137 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
139 /*_______________D3DXColorScale________________*/
140 expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
141 D3DXColorScale(&got,&color,scale);
142 expect_color(expected,got);
143 /* Test the NULL case */
144 funcpointer = D3DXColorScale(&got,NULL,scale);
145 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
146 funcpointer = D3DXColorScale(NULL,NULL,scale);
147 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
149 /*_______________D3DXColorSubtract_______________*/
150 expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f, expected.a = 0.82f;
151 D3DXColorSubtract(&got,&color,&color2);
152 expect_color(expected,got);
153 /* Test the NULL case */
154 funcpointer = D3DXColorSubtract(&got,NULL,&color2);
155 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
156 funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
157 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
158 funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
159 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
162 static void D3DXMatrixTest(void)
164 D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
165 LPD3DXMATRIX funcpointer;
168 D3DXVECTOR3 at, axis, eye, last, scaling;
171 FLOAT angle, determinant, expectedfloat, gotfloat;
173 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
174 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
175 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
176 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
177 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
178 U(mat).m[3][3] = -40.0f;
180 U(mat2).m[0][0] = 1.0f; U(mat2).m[1][0] = 2.0f; U(mat2).m[2][0] = 3.0f;
181 U(mat2).m[3][0] = 4.0f; U(mat2).m[0][1] = 5.0f; U(mat2).m[1][1] = 6.0f;
182 U(mat2).m[2][1] = 7.0f; U(mat2).m[3][1] = 8.0f; U(mat2).m[0][2] = -8.0f;
183 U(mat2).m[1][2] = -7.0f; U(mat2).m[2][2] = -6.0f; U(mat2).m[3][2] = -5.0f;
184 U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f;
185 U(mat2).m[3][3] = -1.0f;
187 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
189 q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
190 r.x = 0.87f; r.y = 0.65f; r.z =0.43f; r.w= 0.21f;
192 at.x = -2.0f; at.y = 13.0f; at.z = -9.0f;
193 axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f;
194 eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
195 last.x = 9.7f; last.y = -8.6; last.z = 1.3f;
196 scaling.x = 0.03f; scaling.y =0.05f; scaling.z = 0.06f;
198 light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3;
200 angle = D3DX_PI/3.0f;
202 /*____________D3DXMatrixAffineTransformation______*/
203 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;
204 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;
205 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;
206 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;
207 D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis);
208 expect_mat(expectedmat,gotmat);
209 /* Test the NULL case */
210 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;
211 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;
212 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;
213 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;
214 D3DXMatrixAffineTransformation(&gotmat,3.56f,NULL,&q,&axis);
215 expect_mat(expectedmat,gotmat);
217 /*____________D3DXMatrixfDeterminant_____________*/
218 expectedfloat = -147888.0f;
219 gotfloat = D3DXMatrixfDeterminant(&mat);
220 ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
222 /*____________D3DXMatrixInverse______________*/
223 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;
224 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;
225 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;
226 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;
227 expectedfloat = -147888.0f;
228 D3DXMatrixInverse(&gotmat,&determinant,&mat);
229 expect_mat(expectedmat,gotmat);
230 ok(fabs( determinant - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, determinant);
231 funcpointer = D3DXMatrixInverse(&gotmat,NULL,&mat2);
232 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
234 /*____________D3DXMatrixIsIdentity______________*/
236 memset(&mat3, 0, sizeof(mat3));
237 got = D3DXMatrixIsIdentity(&mat3);
238 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
239 D3DXMatrixIdentity(&mat3);
241 got = D3DXMatrixIsIdentity(&mat3);
242 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
243 U(mat3).m[0][0] = 0.000009f;
245 got = D3DXMatrixIsIdentity(&mat3);
246 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
247 /* Test the NULL case */
249 got = D3DXMatrixIsIdentity(NULL);
250 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
252 /*____________D3DXMatrixLookatLH_______________*/
253 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;
254 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;
255 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;
256 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;
257 D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
258 expect_mat(expectedmat,gotmat);
260 /*____________D3DXMatrixLookatRH_______________*/
261 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;
262 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;
263 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;
264 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;
265 D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
266 expect_mat(expectedmat,gotmat);
268 /*____________D3DXMatrixMultiply______________*/
269 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;
270 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;
271 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;
272 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;
273 D3DXMatrixMultiply(&gotmat,&mat,&mat2);
274 expect_mat(expectedmat,gotmat);
276 /*____________D3DXMatrixMultiplyTranspose____*/
277 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;
278 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;
279 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;
280 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;
281 D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
282 expect_mat(expectedmat,gotmat);
284 /*____________D3DXMatrixOrthoLH_______________*/
285 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;
286 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;
287 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;
288 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;
289 D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
290 expect_mat(expectedmat,gotmat);
292 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
293 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;
294 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;
295 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;
296 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;
297 D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
298 expect_mat(expectedmat,gotmat);
300 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
301 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;
302 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;
303 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;
304 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;
305 D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
306 expect_mat(expectedmat,gotmat);
308 /*____________D3DXMatrixOrthoRH_______________*/
309 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;
310 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;
311 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;
312 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;
313 D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
314 expect_mat(expectedmat,gotmat);
316 /*____________D3DXMatrixPerspectiveFovLH_______________*/
317 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;
318 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;
319 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;
320 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;
321 D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
322 expect_mat(expectedmat,gotmat);
324 /*____________D3DXMatrixPerspectiveFovRH_______________*/
325 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;
326 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;
327 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;
328 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;
329 D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
330 expect_mat(expectedmat,gotmat);
332 /*____________D3DXMatrixPerspectiveLH_______________*/
333 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;
334 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;
335 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;
336 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;
337 D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
338 expect_mat(expectedmat,gotmat);
340 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
341 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;
342 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;
343 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;
344 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;
345 D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
346 expect_mat(expectedmat,gotmat);
348 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
349 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;
350 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;
351 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;
352 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;
353 D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
354 expect_mat(expectedmat,gotmat);
356 /*____________D3DXMatrixPerspectiveRH_______________*/
357 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;
358 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;
359 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;
360 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;
361 D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
362 expect_mat(expectedmat,gotmat);
364 /*____________D3DXMatrixReflect______________*/
365 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;
366 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;
367 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;
368 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;
369 D3DXMatrixReflect(&gotmat,&plane);
370 expect_mat(expectedmat,gotmat);
372 /*____________D3DXMatrixRotationAxis_____*/
373 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;
374 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;
375 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;
376 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
377 D3DXMatrixRotationAxis(&gotmat,&axis,angle);
378 expect_mat(expectedmat,gotmat);
380 /*____________D3DXMatrixRotationQuaternion______________*/
381 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;
382 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;
383 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;
384 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;
385 D3DXMatrixRotationQuaternion(&gotmat,&q);
386 expect_mat(expectedmat,gotmat);
388 /*____________D3DXMatrixRotationX______________*/
389 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;
390 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;
391 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;
392 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;
393 D3DXMatrixRotationX(&gotmat,angle);
394 expect_mat(expectedmat,gotmat);
396 /*____________D3DXMatrixRotationY______________*/
397 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;
398 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;
399 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;
400 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;
401 D3DXMatrixRotationY(&gotmat,angle);
402 expect_mat(expectedmat,gotmat);
404 /*____________D3DXMatrixRotationYawPitchRoll____*/
405 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;
406 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;
407 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;
408 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;
409 D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
410 expect_mat(expectedmat,gotmat);
412 /*____________D3DXMatrixRotationZ______________*/
413 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;
414 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;
415 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;
416 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;
417 D3DXMatrixRotationZ(&gotmat,angle);
418 expect_mat(expectedmat,gotmat);
420 /*____________D3DXMatrixScaling______________*/
421 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;
422 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;
423 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;
424 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;
425 D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
426 expect_mat(expectedmat,gotmat);
428 /*____________D3DXMatrixShadow______________*/
429 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;
430 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;
431 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;
432 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;
433 D3DXMatrixShadow(&gotmat,&light,&plane);
434 expect_mat(expectedmat,gotmat);
436 /*____________D3DXMatrixTransformation______________*/
437 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;
438 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;
439 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;
440 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;
441 D3DXMatrixTransformation(&gotmat,&at,&q,NULL,&eye,&r,&last);
442 expect_mat(expectedmat,gotmat);
444 /*____________D3DXMatrixTranslation______________*/
445 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;
446 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;
447 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;
448 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;
449 D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
450 expect_mat(expectedmat,gotmat);
452 /*____________D3DXMatrixTranspose______________*/
453 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;
454 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;
455 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;
456 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;
457 D3DXMatrixTranspose(&gotmat,&mat);
458 expect_mat(expectedmat,gotmat);
461 static void D3DXPlaneTest(void)
464 D3DXPLANE expectedplane, gotplane, nulplane, plane;
465 D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
466 LPD3DXVECTOR3 funcpointer;
470 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
471 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
472 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
473 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
474 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
475 U(mat).m[3][3] = -40.0f;
477 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
479 vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
481 /*_______________D3DXPlaneDot________________*/
483 got = D3DXPlaneDot(&plane,&vec),
484 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
486 got = D3DXPlaneDot(NULL,&vec),
487 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
489 got = D3DXPlaneDot(NULL,NULL),
490 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
492 /*_______________D3DXPlaneDotCoord________________*/
494 got = D3DXPlaneDotCoord(&plane,&vec),
495 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
497 got = D3DXPlaneDotCoord(NULL,&vec),
498 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
500 got = D3DXPlaneDotCoord(NULL,NULL),
501 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
503 /*_______________D3DXPlaneDotNormal______________*/
505 got = D3DXPlaneDotNormal(&plane,&vec),
506 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
508 got = D3DXPlaneDotNormal(NULL,&vec),
509 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
511 got = D3DXPlaneDotNormal(NULL,NULL),
512 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
514 /*_______________D3DXPlaneFromPointNormal_______*/
515 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
516 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
517 expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
518 D3DXPlaneFromPointNormal(&gotplane,&vec1,&vec2);
519 expect_plane(expectedplane, gotplane);
521 /*_______________D3DXPlaneFromPoints_______*/
522 vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
523 vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
524 vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
525 expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
526 D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
527 expect_plane(expectedplane, gotplane);
528 /* Test if 2 vectors are parallels */
529 vec3.x = 1.0f; vec3.y = 1.0f; vec3.z = 2.0f;
530 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
531 D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
532 expect_plane(expectedplane, gotplane);
534 /*_______________D3DXPlaneIntersectLine___________*/
535 vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
536 vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
537 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
538 D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
539 expect_vec3(expectedvec, gotvec);
540 /* Test a parallel line */
541 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
542 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
543 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
544 funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
545 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
547 /*_______________D3DXPlaneNormalize______________*/
548 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);
549 D3DXPlaneNormalize(&gotplane, &plane);
550 expect_plane(expectedplane, gotplane);
551 nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
552 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
553 D3DXPlaneNormalize(&gotplane, &nulplane);
554 expect_plane(expectedplane, gotplane);
555 nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
556 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
557 D3DXPlaneNormalize(&gotplane, &nulplane);
558 expect_plane(expectedplane, gotplane);
560 /*_______________D3DXPlaneTransform____________*/
561 expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
562 D3DXPlaneTransform(&gotplane,&plane,&mat);
563 expect_plane(expectedplane, gotplane);
566 static void D3X8QuaternionTest(void)
569 D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, q, r, s, t, u;
570 LPD3DXQUATERNION funcpointer;
571 D3DXVECTOR3 axis, expectedvec;
572 FLOAT angle, expected, got, scale, scale2;
573 BOOL expectedbool, gotbool;
575 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
576 q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
577 r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
578 t.x = -1111.0f, t.y= 111.0f; t.z = -11.0f; t.w = 1.0f;
579 u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
584 /*_______________D3DXQuaternionBaryCentric________________________*/
585 expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
586 D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
587 expect_vec4(expectedquat,gotquat);
589 /*_______________D3DXQuaternionConjugate________________*/
590 expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
591 D3DXQuaternionConjugate(&gotquat,&q);
592 expect_vec4(expectedquat,gotquat);
593 /* Test the NULL case */
594 funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
595 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
596 funcpointer = D3DXQuaternionConjugate(NULL,NULL);
597 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
599 /*_______________D3DXQuaternionDot______________________*/
601 got = D3DXQuaternionDot(&q,&r);
602 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
603 /* Tests the case NULL */
605 got = D3DXQuaternionDot(NULL,&r);
606 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
608 got = D3DXQuaternionDot(NULL,NULL);
609 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
611 /*_______________D3DXQuaternionExp______________________________*/
612 expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
613 D3DXQuaternionExp(&gotquat,&q);
614 expect_vec4(expectedquat,gotquat);
615 /* Test the null quaternion */
616 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
617 D3DXQuaternionExp(&gotquat,&nul);
618 expect_vec4(expectedquat,gotquat);
619 /* Test the case where the norm of the quaternion is <1 */
620 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
621 expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
622 D3DXQuaternionExp(&gotquat,&Nq1);
623 expect_vec4(expectedquat,gotquat);
625 /*_______________D3DXQuaternionIdentity________________*/
626 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
627 D3DXQuaternionIdentity(&gotquat);
628 expect_vec4(expectedquat,gotquat);
629 /* Test the NULL case */
630 funcpointer = D3DXQuaternionIdentity(NULL);
631 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
633 /*_______________D3DXQuaternionInverse________________________*/
634 expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
635 D3DXQuaternionInverse(&gotquat,&q);
636 expect_vec4(expectedquat,gotquat);
637 /* test the null quaternion */
638 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
639 D3DXQuaternionInverse(&gotquat,&nul);
640 expect_vec4(expectedquat,gotquat);
642 /*_______________D3DXQuaternionIsIdentity________________*/
643 s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
645 gotbool = D3DXQuaternionIsIdentity(&s);
646 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
647 s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
648 expectedbool = FALSE;
649 gotbool = D3DXQuaternionIsIdentity(&q);
650 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
651 /* Test the NULL case */
652 gotbool = D3DXQuaternionIsIdentity(NULL);
653 ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
655 /*_______________D3DXQuaternionLength__________________________*/
657 got = D3DXQuaternionLength(&q);
658 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
659 /* Tests the case NULL */
661 got = D3DXQuaternionLength(NULL);
662 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
664 /*_______________D3DXQuaternionLengthSq________________________*/
666 got = D3DXQuaternionLengthSq(&q);
667 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
668 /* Tests the case NULL */
670 got = D3DXQuaternionLengthSq(NULL);
671 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
673 /*_______________D3DXQuaternionLn______________________________*/
674 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
675 D3DXQuaternionLn(&gotquat,&q);
676 expect_vec4(expectedquat,gotquat);
677 expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
678 D3DXQuaternionLn(&gotquat,&r);
679 expect_vec4(expectedquat,gotquat);
680 Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
681 expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
682 D3DXQuaternionLn(&gotquat,&Nq);
683 expect_vec4(expectedquat,gotquat);
684 /* Test the cas 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.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
687 D3DXQuaternionLn(&gotquat,&Nq1);
688 todo_wine{ expect_vec4(expectedquat,gotquat) };
690 /*_______________D3DXQuaternionMultiply________________________*/
691 expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
692 D3DXQuaternionMultiply(&gotquat,&q,&r);
693 expect_vec4(expectedquat,gotquat);
695 /*_______________D3DXQuaternionNormalize________________________*/
696 expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
697 D3DXQuaternionNormalize(&gotquat,&q);
698 expect_vec4(expectedquat,gotquat);
699 /* Test the nul quaternion */
700 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
701 D3DXQuaternionNormalize(&gotquat,&nul);
702 expect_vec4(expectedquat,gotquat);
704 /*_______________D3DXQuaternionRotationAxis___________________*/
705 axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
706 angle = D3DX_PI/3.0f;
707 expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
708 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
709 expect_vec4(expectedquat,gotquat);
710 /* Test the nul quaternion */
711 axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
712 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
713 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
714 expect_vec4(expectedquat,gotquat);
716 /*_______________D3DXQuaternionRotationMatrix___________________*/
717 /* test when the trace is >0 */
718 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
719 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
720 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
721 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
722 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
723 U(mat).m[3][3] = 48.0f;
724 expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
725 D3DXQuaternionRotationMatrix(&gotquat,&mat);
726 expect_vec4(expectedquat,gotquat);
727 /* test the case when the greater element is (2,2) */
728 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
729 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
730 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
731 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
732 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
733 U(mat).m[3][3] = 48.0f;
734 expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
735 D3DXQuaternionRotationMatrix(&gotquat,&mat);
736 expect_vec4(expectedquat,gotquat);
737 /* test the case when the greater element is (1,1) */
738 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
739 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
740 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
741 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
742 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
743 U(mat).m[3][3] = 48.0f;
744 expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
745 D3DXQuaternionRotationMatrix(&gotquat,&mat);
746 expect_vec4(expectedquat,gotquat);
748 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
749 expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
750 D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
751 expect_vec4(expectedquat,gotquat);
753 /*_______________D3DXQuaternionSlerp________________________*/
754 expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
755 D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
756 expect_vec4(expectedquat,gotquat);
757 expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
758 D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
759 expect_vec4(expectedquat,gotquat);
761 /*_______________D3DXQuaternionSquad________________________*/
762 expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
763 D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
764 expect_vec4(expectedquat,gotquat);
766 /*_______________D3DXQuaternionToAxisAngle__________________*/
767 Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
768 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
769 expected = 2.197869f;
770 D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
771 expect_vec3(expectedvec,axis);
772 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
773 /* Test if |w|>1.0f */
774 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
776 D3DXQuaternionToAxisAngle(&q,&axis,&angle);
777 expect_vec3(expectedvec,axis);
778 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
779 /* Test the null quaternion */
780 expectedvec.x = 1.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
782 D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
783 expect_vec3(expectedvec,axis);
784 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
787 static void D3X8Vector2Test(void)
789 D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
790 LPD3DXVECTOR2 funcpointer;
791 D3DXVECTOR4 expectedtrans, gottrans;
793 FLOAT coeff1, coeff2, expected, got, scale;
795 nul.x = 0.0f; nul.y = 0.0f;
796 u.x = 3.0f; u.y = 4.0f;
797 v.x = -7.0f; v.y = 9.0f;
798 w.x = 4.0f; w.y = -3.0f;
799 x.x = 2.0f; x.y = -11.0f;
801 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;
802 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;
803 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;
804 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;
806 coeff1 = 2.0f; coeff2 = 5.0f;
809 /*_______________D3DXVec2Add__________________________*/
810 expectedvec.x = -4.0f; expectedvec.y = 13.0f;
811 D3DXVec2Add(&gotvec,&u,&v);
812 expect_vec(expectedvec,gotvec);
813 /* Tests the case NULL */
814 funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
815 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
816 funcpointer = D3DXVec2Add(NULL,NULL,NULL);
817 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
819 /*_______________D3DXVec2BaryCentric___________________*/
820 expectedvec.x = -12.0f; expectedvec.y = -21.0f;
821 D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
822 expect_vec(expectedvec,gotvec);
824 /*_______________D3DXVec2CatmullRom____________________*/
825 expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
826 D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
827 expect_vec(expectedvec,gotvec);
829 /*_______________D3DXVec2CCW__________________________*/
831 got = D3DXVec2CCW(&u,&v);
832 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
833 /* Tests the case NULL */
835 got = D3DXVec2CCW(NULL,&v);
836 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
838 got = D3DXVec2CCW(NULL,NULL);
839 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
841 /*_______________D3DXVec2Dot__________________________*/
843 got = D3DXVec2Dot(&u,&v);
844 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
845 /* Tests the case NULL */
847 got = D3DXVec2Dot(NULL,&v);
848 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
850 got = D3DXVec2Dot(NULL,NULL);
851 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
853 /*_______________D3DXVec2Hermite__________________________*/
854 expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
855 D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
856 expect_vec(expectedvec,gotvec);
858 /*_______________D3DXVec2Length__________________________*/
860 got = D3DXVec2Length(&u);
861 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
862 /* Tests the case NULL */
864 got = D3DXVec2Length(NULL);
865 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
867 /*_______________D3DXVec2LengthSq________________________*/
869 got = D3DXVec2LengthSq(&u);
870 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
871 /* Tests the case NULL */
873 got = D3DXVec2LengthSq(NULL);
874 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
876 /*_______________D3DXVec2Lerp__________________________*/
877 expectedvec.x = 68.0f; expectedvec.y = -28.5f;
878 D3DXVec2Lerp(&gotvec,&u,&v,scale);
879 expect_vec(expectedvec,gotvec);
880 /* Tests the case NULL */
881 funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
882 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
883 funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
884 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
886 /*_______________D3DXVec2Maximize__________________________*/
887 expectedvec.x = 3.0f; expectedvec.y = 9.0f;
888 D3DXVec2Maximize(&gotvec,&u,&v);
889 expect_vec(expectedvec,gotvec);
890 /* Tests the case NULL */
891 funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
892 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
893 funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
894 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
896 /*_______________D3DXVec2Minimize__________________________*/
897 expectedvec.x = -7.0f; expectedvec.y = 4.0f;
898 D3DXVec2Minimize(&gotvec,&u,&v);
899 expect_vec(expectedvec,gotvec);
900 /* Tests the case NULL */
901 funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
902 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
903 funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
904 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
906 /*_______________D3DXVec2Normalize_________________________*/
907 expectedvec.x = 0.6f; expectedvec.y = 0.8f;
908 D3DXVec2Normalize(&gotvec,&u);
909 expect_vec(expectedvec,gotvec);
910 /* Test the nul vector */
911 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
912 D3DXVec2Normalize(&gotvec,&nul);
913 expect_vec(expectedvec,gotvec);
915 /*_______________D3DXVec2Scale____________________________*/
916 expectedvec.x = -19.5f; expectedvec.y = -26.0f;
917 D3DXVec2Scale(&gotvec,&u,scale);
918 expect_vec(expectedvec,gotvec);
919 /* Tests the case NULL */
920 funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
921 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
922 funcpointer = D3DXVec2Scale(NULL,NULL,scale);
923 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
925 /*_______________D3DXVec2Subtract__________________________*/
926 expectedvec.x = 10.0f; expectedvec.y = -5.0f;
927 D3DXVec2Subtract(&gotvec,&u,&v);
928 expect_vec(expectedvec,gotvec);
929 /* Tests the case NULL */
930 funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
931 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
932 funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
933 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
935 /*_______________D3DXVec2Transform_______________________*/
936 expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
937 D3DXVec2Transform(&gottrans,&u,&mat);
938 expect_vec4(expectedtrans,gottrans);
940 /*_______________D3DXVec2TransformCoord_______________________*/
941 expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
942 D3DXVec2TransformCoord(&gotvec,&u,&mat);
943 expect_vec(expectedvec,gotvec);
944 /* Test the nul projected vector */
945 nulproj.x = -2.0f; nulproj.y = -1.0f;
946 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
947 D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
948 expect_vec(expectedvec,gotvec);
950 /*_______________D3DXVec2TransformNormal______________________*/
951 expectedvec.x = 23.0f; expectedvec.y = 30.0f;
952 D3DXVec2TransformNormal(&gotvec,&u,&mat);
953 expect_vec(expectedvec,gotvec);
956 static void D3X8Vector3Test(void)
958 D3DVIEWPORT8 viewport;
959 D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
960 LPD3DXVECTOR3 funcpointer;
961 D3DXVECTOR4 expectedtrans, gottrans;
962 D3DXMATRIX mat, projection, view, world;
963 FLOAT coeff1, coeff2, expected, got, scale;
965 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
966 u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
967 v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
968 w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
969 x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
971 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
972 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
974 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;
975 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;
976 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;
977 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;
979 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
980 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
981 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
982 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
983 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
984 U(view).m[3][3] = -40.0f;
986 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;
987 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;
988 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;
989 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;
991 coeff1 = 2.0f; coeff2 = 5.0f;
994 /*_______________D3DXVec3Add__________________________*/
995 expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
996 D3DXVec3Add(&gotvec,&u,&v);
997 expect_vec3(expectedvec,gotvec);
998 /* Tests the case NULL */
999 funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
1000 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1001 funcpointer = D3DXVec3Add(NULL,NULL,NULL);
1002 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1004 /*_______________D3DXVec3BaryCentric___________________*/
1005 expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
1006 D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1008 expect_vec3(expectedvec,gotvec);
1010 /*_______________D3DXVec3CatmullRom____________________*/
1011 expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
1012 D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1013 expect_vec3(expectedvec,gotvec);
1015 /*_______________D3DXVec3Cross________________________*/
1016 expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
1017 D3DXVec3Cross(&gotvec,&u,&v);
1018 expect_vec3(expectedvec,gotvec);
1019 /* Tests the case NULL */
1020 funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
1021 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1022 funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
1023 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1025 /*_______________D3DXVec3Dot__________________________*/
1027 got = D3DXVec3Dot(&u,&v);
1028 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1029 /* Tests the case NULL */
1031 got = D3DXVec3Dot(NULL,&v);
1032 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1034 got = D3DXVec3Dot(NULL,NULL);
1035 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1037 /*_______________D3DXVec3Hermite__________________________*/
1038 expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
1039 D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
1040 expect_vec3(expectedvec,gotvec);
1042 /*_______________D3DXVec3Length__________________________*/
1044 got = D3DXVec3Length(&u);
1045 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1046 /* Tests the case NULL */
1048 got = D3DXVec3Length(NULL);
1049 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1051 /*_______________D3DXVec3LengthSq________________________*/
1053 got = D3DXVec3LengthSq(&u);
1054 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1055 /* Tests the case NULL */
1057 got = D3DXVec3LengthSq(NULL);
1058 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1060 /*_______________D3DXVec3Lerp__________________________*/
1061 expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
1062 D3DXVec3Lerp(&gotvec,&u,&v,scale);
1063 expect_vec3(expectedvec,gotvec);
1064 /* Tests the case NULL */
1065 funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
1066 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1067 funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
1068 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1070 /*_______________D3DXVec3Maximize__________________________*/
1071 expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
1072 D3DXVec3Maximize(&gotvec,&u,&v);
1073 expect_vec3(expectedvec,gotvec);
1074 /* Tests the case NULL */
1075 funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
1076 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1077 funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
1078 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1080 /*_______________D3DXVec3Minimize__________________________*/
1081 expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
1082 D3DXVec3Minimize(&gotvec,&u,&v);
1083 expect_vec3(expectedvec,gotvec);
1084 /* Tests the case NULL */
1085 funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
1086 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1087 funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
1088 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1090 /*_______________D3DXVec3Normalize_________________________*/
1091 expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
1092 D3DXVec3Normalize(&gotvec,&u);
1093 expect_vec3(expectedvec,gotvec);
1094 /* Test the nul vector */
1095 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1096 D3DXVec3Normalize(&gotvec,&nul);
1097 expect_vec3(expectedvec,gotvec);
1099 /*_______________D3DXVec3Project_________________________*/
1100 expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
1101 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1102 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
1103 expect_vec3(expectedvec,gotvec);
1105 /*_______________D3DXVec3Scale____________________________*/
1106 expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
1107 D3DXVec3Scale(&gotvec,&u,scale);
1108 expect_vec3(expectedvec,gotvec);
1109 /* Tests the case NULL */
1110 funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
1111 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1112 funcpointer = D3DXVec3Scale(NULL,NULL,scale);
1113 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1115 /*_______________D3DXVec3Subtract_______________________*/
1116 expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
1117 D3DXVec3Subtract(&gotvec,&u,&v);
1118 expect_vec3(expectedvec,gotvec);
1119 /* Tests the case NULL */
1120 funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
1121 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1122 funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
1123 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1125 /*_______________D3DXVec3Transform_______________________*/
1126 expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
1127 D3DXVec3Transform(&gottrans,&u,&mat);
1128 expect_vec4(expectedtrans,gottrans);
1130 /*_______________D3DXVec3TransformCoord_______________________*/
1131 expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
1132 D3DXVec3TransformCoord(&gotvec,&u,&mat);
1133 expect_vec3(expectedvec,gotvec);
1134 /* Test the nul projected vector */
1135 nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
1136 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1137 D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
1138 expect_vec3(expectedvec,gotvec);
1140 /*_______________D3DXVec3TransformNormal______________________*/
1141 expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
1142 D3DXVec3TransformNormal(&gotvec,&u,&mat);
1143 expect_vec3(expectedvec,gotvec);
1145 /*_______________D3DXVec3Unproject_________________________*/
1146 expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
1147 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1148 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
1149 expect_vec3(expectedvec,gotvec);
1152 static void D3X8Vector4Test(void)
1154 D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
1155 LPD3DXVECTOR4 funcpointer;
1156 D3DXVECTOR4 expectedtrans, gottrans;
1158 FLOAT coeff1, coeff2, expected, got, scale;
1160 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
1161 u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
1162 v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
1163 w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
1164 x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
1166 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;
1167 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;
1168 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;
1169 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;
1171 coeff1 = 2.0f; coeff2 = 5.0;
1174 /*_______________D3DXVec4Add__________________________*/
1175 expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
1176 D3DXVec4Add(&gotvec,&u,&v);
1177 expect_vec4(expectedvec,gotvec);
1178 /* Tests the case NULL */
1179 funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
1180 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1181 funcpointer = D3DXVec4Add(NULL,NULL,NULL);
1182 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1184 /*_______________D3DXVec4BaryCentric____________________*/
1185 expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
1186 D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1187 expect_vec4(expectedvec,gotvec);
1189 /*_______________D3DXVec4CatmullRom____________________*/
1190 expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
1191 D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1192 expect_vec4(expectedvec,gotvec);
1194 /*_______________D3DXVec4Cross_________________________*/
1195 expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
1196 D3DXVec4Cross(&gotvec,&u,&v,&w);
1197 expect_vec4(expectedvec,gotvec);
1199 /*_______________D3DXVec4Dot__________________________*/
1201 got = D3DXVec4Dot(&u,&v);
1202 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1203 /* Tests the case NULL */
1205 got = D3DXVec4Dot(NULL,&v);
1206 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1208 got = D3DXVec4Dot(NULL,NULL);
1209 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1211 /*_______________D3DXVec4Hermite_________________________*/
1212 expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
1213 D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
1214 expect_vec4(expectedvec,gotvec);
1216 /*_______________D3DXVec4Length__________________________*/
1218 got = D3DXVec4Length(&u);
1219 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1220 /* Tests the case NULL */
1222 got = D3DXVec4Length(NULL);
1223 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1225 /*_______________D3DXVec4LengthSq________________________*/
1227 got = D3DXVec4LengthSq(&u);
1228 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1229 /* Tests the case NULL */
1231 got = D3DXVec4LengthSq(NULL);
1232 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1234 /*_______________D3DXVec4Lerp__________________________*/
1235 expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
1236 D3DXVec4Lerp(&gotvec,&u,&v,scale);
1237 expect_vec4(expectedvec,gotvec);
1238 /* Tests the case NULL */
1239 funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
1240 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1241 funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
1242 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1244 /*_______________D3DXVec4Maximize__________________________*/
1245 expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
1246 D3DXVec4Maximize(&gotvec,&u,&v);
1247 expect_vec4(expectedvec,gotvec);
1248 /* Tests the case NULL */
1249 funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
1250 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1251 funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
1252 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1254 /*_______________D3DXVec4Minimize__________________________*/
1255 expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
1256 D3DXVec4Minimize(&gotvec,&u,&v);
1257 expect_vec4(expectedvec,gotvec);
1258 /* Tests the case NULL */
1259 funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
1260 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1261 funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
1262 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1264 /*_______________D3DXVec4Normalize_________________________*/
1265 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
1266 D3DXVec4Normalize(&gotvec,&u);
1267 expect_vec4(expectedvec,gotvec);
1268 /* Test the nul vector */
1269 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
1270 D3DXVec4Normalize(&gotvec,&nul);
1271 expect_vec4(expectedvec,gotvec);
1273 /*_______________D3DXVec4Scale____________________________*/
1274 expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
1275 D3DXVec4Scale(&gotvec,&u,scale);
1276 expect_vec4(expectedvec,gotvec);
1277 /* Tests the case NULL */
1278 funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
1279 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1280 funcpointer = D3DXVec4Scale(NULL,NULL,scale);
1281 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1283 /*_______________D3DXVec4Subtract__________________________*/
1284 expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
1285 D3DXVec4Subtract(&gotvec,&u,&v);
1286 expect_vec4(expectedvec,gotvec);
1287 /* Tests the case NULL */
1288 funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
1289 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1290 funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
1291 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1293 /*_______________D3DXVec4Transform_______________________*/
1294 expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
1295 D3DXVec4Transform(&gottrans,&u,&mat);
1296 expect_vec4(expectedtrans,gottrans);
1304 D3X8QuaternionTest();