push 0f15bbd80d260bbd8adf052e820484a405c49375
[wine/hacks.git] / dlls / d3dx8 / tests / math.c
bloba8471b3a9edb2b96804129d09cfa3feeb4c6be73
1 /*
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
19 #include <assert.h>
20 #include "d3dx8.h"
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)\
29 { \
30 int i,j,equal=1; \
31 for (i=0; i<4; i++)\
33 for (j=0; j<4; j++)\
35 if (fabs(U(expectedmat).m[i][j]-U(gotmat).m[i][j])>admitted_error) \
37 equal=0;\
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;
65 FLOAT scale;
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;
71 scale = 0.3f;
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;
166 D3DXPLANE plane;
167 D3DXQUATERNION q, r;
168 D3DXVECTOR3 at, axis, eye, last, scaling;
169 D3DXVECTOR4 light;
170 BOOL expected, got;
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______________*/
235 expected = FALSE;
236 got = D3DXMatrixIsIdentity(&mat3);
237 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
238 D3DXMatrixIdentity(&mat3);
239 expected = TRUE;
240 got = D3DXMatrixIsIdentity(&mat3);
241 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
242 U(mat3).m[0][0] = 0.000009f;
243 expected = FALSE;
244 got = D3DXMatrixIsIdentity(&mat3);
245 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
246 /* Test the NULL case */
247 expected = FALSE;
248 got = D3DXMatrixIsIdentity(NULL);
249 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
251 /*____________D3DXMatrixLookatLH_______________*/
252 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;
253 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;
254 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;
255 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;
256 D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
257 expect_mat(expectedmat,gotmat);
259 /*____________D3DXMatrixLookatRH_______________*/
260 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;
261 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;
262 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;
263 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;
264 D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
265 expect_mat(expectedmat,gotmat);
267 /*____________D3DXMatrixMultiply______________*/
268 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;
269 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;
270 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;
271 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;
272 D3DXMatrixMultiply(&gotmat,&mat,&mat2);
273 expect_mat(expectedmat,gotmat);
275 /*____________D3DXMatrixMultiplyTranspose____*/
276 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;
277 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;
278 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;
279 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;
280 D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
281 expect_mat(expectedmat,gotmat);
283 /*____________D3DXMatrixOrthoLH_______________*/
284 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;
285 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;
286 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;
287 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;
288 D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
289 expect_mat(expectedmat,gotmat);
291 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
292 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;
293 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;
294 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;
295 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;
296 D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
297 expect_mat(expectedmat,gotmat);
299 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
300 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;
301 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;
302 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;
303 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;
304 D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
305 expect_mat(expectedmat,gotmat);
307 /*____________D3DXMatrixOrthoRH_______________*/
308 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;
309 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;
310 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;
311 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;
312 D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
313 expect_mat(expectedmat,gotmat);
315 /*____________D3DXMatrixPerspectiveFovLH_______________*/
316 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;
317 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;
318 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;
319 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;
320 D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
321 expect_mat(expectedmat,gotmat);
323 /*____________D3DXMatrixPerspectiveFovRH_______________*/
324 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;
325 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;
326 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;
327 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;
328 D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
329 expect_mat(expectedmat,gotmat);
331 /*____________D3DXMatrixPerspectiveLH_______________*/
332 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;
333 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;
334 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;
335 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;
336 D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
337 expect_mat(expectedmat,gotmat);
339 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
340 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;
341 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;
342 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;
343 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;
344 D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
345 expect_mat(expectedmat,gotmat);
347 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
348 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;
349 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;
350 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;
351 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;
352 D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
353 expect_mat(expectedmat,gotmat);
355 /*____________D3DXMatrixPerspectiveRH_______________*/
356 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;
357 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;
358 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;
359 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;
360 D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
361 expect_mat(expectedmat,gotmat);
363 /*____________D3DXMatrixReflect______________*/
364 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;
365 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;
366 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;
367 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;
368 D3DXMatrixReflect(&gotmat,&plane);
369 expect_mat(expectedmat,gotmat);
371 /*____________D3DXMatrixRotationAxis_____*/
372 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;
373 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;
374 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;
375 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;
376 D3DXMatrixRotationAxis(&gotmat,&axis,angle);
377 expect_mat(expectedmat,gotmat);
379 /*____________D3DXMatrixRotationQuaternion______________*/
380 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;
381 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;
382 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;
383 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;
384 D3DXMatrixRotationQuaternion(&gotmat,&q);
385 expect_mat(expectedmat,gotmat);
387 /*____________D3DXMatrixRotationX______________*/
388 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;
389 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;
390 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;
391 U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
392 D3DXMatrixRotationX(&gotmat,angle);
393 expect_mat(expectedmat,gotmat);
395 /*____________D3DXMatrixRotationY______________*/
396 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;
397 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;
398 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;
399 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;
400 D3DXMatrixRotationY(&gotmat,angle);
401 expect_mat(expectedmat,gotmat);
403 /*____________D3DXMatrixRotationYawPitchRoll____*/
404 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;
405 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;
406 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;
407 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;
408 D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
409 expect_mat(expectedmat,gotmat);
411 /*____________D3DXMatrixRotationZ______________*/
412 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;
413 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;
414 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;
415 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;
416 D3DXMatrixRotationZ(&gotmat,angle);
417 expect_mat(expectedmat,gotmat);
419 /*____________D3DXMatrixScaling______________*/
420 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;
421 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;
422 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;
423 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;
424 D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
425 expect_mat(expectedmat,gotmat);
427 /*____________D3DXMatrixShadow______________*/
428 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;
429 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;
430 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;
431 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;
432 D3DXMatrixShadow(&gotmat,&light,&plane);
433 expect_mat(expectedmat,gotmat);
435 /*____________D3DXMatrixTransformation______________*/
436 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;
437 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;
438 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;
439 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;
440 D3DXMatrixTransformation(&gotmat,&at,&q,NULL,&eye,&r,&last);
441 expect_mat(expectedmat,gotmat);
443 /*____________D3DXMatrixTranslation______________*/
444 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;
445 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;
446 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;
447 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;
448 D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
449 expect_mat(expectedmat,gotmat);
451 /*____________D3DXMatrixTranspose______________*/
452 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;
453 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;
454 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;
455 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;
456 D3DXMatrixTranspose(&gotmat,&mat);
457 expect_mat(expectedmat,gotmat);
460 static void D3DXPlaneTest(void)
462 D3DXMATRIX mat;
463 D3DXPLANE expectedplane, gotplane, nulplane, plane;
464 D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
465 LPD3DXVECTOR3 funcpointer;
466 D3DXVECTOR4 vec;
467 FLOAT expected, got;
469 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
470 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
471 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
472 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
473 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
474 U(mat).m[3][3] = -40.0f;
476 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
478 vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
480 /*_______________D3DXPlaneDot________________*/
481 expected = 42.0f;
482 got = D3DXPlaneDot(&plane,&vec),
483 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
484 expected = 0.0f;
485 got = D3DXPlaneDot(NULL,&vec),
486 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
487 expected = 0.0f;
488 got = D3DXPlaneDot(NULL,NULL),
489 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
491 /*_______________D3DXPlaneDotCoord________________*/
492 expected = -28.0f;
493 got = D3DXPlaneDotCoord(&plane,&vec),
494 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
495 expected = 0.0f;
496 got = D3DXPlaneDotCoord(NULL,&vec),
497 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
498 expected = 0.0f;
499 got = D3DXPlaneDotCoord(NULL,NULL),
500 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
502 /*_______________D3DXPlaneDotNormal______________*/
503 expected = -35.0f;
504 got = D3DXPlaneDotNormal(&plane,&vec),
505 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
506 expected = 0.0f;
507 got = D3DXPlaneDotNormal(NULL,&vec),
508 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
509 expected = 0.0f;
510 got = D3DXPlaneDotNormal(NULL,NULL),
511 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
513 /*_______________D3DXPlaneFromPointNormal_______*/
514 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
515 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
516 expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
517 D3DXPlaneFromPointNormal(&gotplane,&vec1,&vec2);
518 expect_plane(expectedplane, gotplane);
520 /*_______________D3DXPlaneFromPoints_______*/
521 vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
522 vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
523 vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
524 expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
525 D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
526 expect_plane(expectedplane, gotplane);
527 /* Test if 2 vectors are parallels */
528 vec3.x = 1.0f; vec3.y = 1.0f; vec3.z = 2.0f;
529 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
530 D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
531 expect_plane(expectedplane, gotplane);
533 /*_______________D3DXPlaneIntersectLine___________*/
534 vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
535 vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
536 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
537 D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
538 expect_vec3(expectedvec, gotvec);
539 /* Test a parallele line */
540 vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
541 vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
542 expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
543 funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
544 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
546 /*_______________D3DXPlaneNormalize______________*/
547 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);
548 D3DXPlaneNormalize(&gotplane, &plane);
549 expect_plane(expectedplane, gotplane);
550 nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
551 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
552 D3DXPlaneNormalize(&gotplane, &nulplane);
553 expect_plane(expectedplane, gotplane);
554 nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
555 expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
556 D3DXPlaneNormalize(&gotplane, &nulplane);
557 expect_plane(expectedplane, gotplane);
559 /*_______________D3DXPlaneTransform____________*/
560 expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
561 D3DXPlaneTransform(&gotplane,&plane,&mat);
562 expect_plane(expectedplane, gotplane);
565 static void D3X8QuaternionTest(void)
567 D3DXMATRIX mat;
568 D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, q, r, s, t, u;
569 LPD3DXQUATERNION funcpointer;
570 D3DXVECTOR3 axis, expectedvec;
571 FLOAT angle, expected, got, scale, scale2;
572 BOOL expectedbool, gotbool;
574 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
575 q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
576 r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
577 t.x = -1111.0f, t.y= 111.0f; t.z = -11.0f; t.w = 1.0f;
578 u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
580 scale = 0.3f;
581 scale2 = 0.78f;
583 /*_______________D3DXQuaternionBaryCentric________________________*/
584 expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
585 D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
586 expect_vec4(expectedquat,gotquat);
588 /*_______________D3DXQuaternionConjugate________________*/
589 expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
590 D3DXQuaternionConjugate(&gotquat,&q);
591 expect_vec4(expectedquat,gotquat);
592 /* Test the NULL case */
593 funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
594 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
595 funcpointer = D3DXQuaternionConjugate(NULL,NULL);
596 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
598 /*_______________D3DXQuaternionDot______________________*/
599 expected = 55.0f;
600 got = D3DXQuaternionDot(&q,&r);
601 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
602 /* Tests the case NULL */
603 expected=0.0f;
604 got = D3DXQuaternionDot(NULL,&r);
605 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
606 expected=0.0f;
607 got = D3DXQuaternionDot(NULL,NULL);
608 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
610 /*_______________D3DXQuaternionExp______________________________*/
611 expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
612 D3DXQuaternionExp(&gotquat,&q);
613 expect_vec4(expectedquat,gotquat);
614 /* Test the null quaternion */
615 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
616 D3DXQuaternionExp(&gotquat,&nul);
617 expect_vec4(expectedquat,gotquat);
618 /* Test the case where the norm of the quaternion is <1 */
619 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
620 expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
621 D3DXQuaternionExp(&gotquat,&Nq1);
622 expect_vec4(expectedquat,gotquat);
624 /*_______________D3DXQuaternionIdentity________________*/
625 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
626 D3DXQuaternionIdentity(&gotquat);
627 expect_vec4(expectedquat,gotquat);
628 /* Test the NULL case */
629 funcpointer = D3DXQuaternionIdentity(NULL);
630 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
632 /*_______________D3DXQuaternionInverse________________________*/
633 expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
634 D3DXQuaternionInverse(&gotquat,&q);
635 expect_vec4(expectedquat,gotquat);
636 /* test the null quaternion */
637 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
638 D3DXQuaternionInverse(&gotquat,&nul);
639 expect_vec4(expectedquat,gotquat);
641 /*_______________D3DXQuaternionIsIdentity________________*/
642 s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
643 expectedbool = TRUE;
644 gotbool = D3DXQuaternionIsIdentity(&s);
645 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
646 s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
647 expectedbool = FALSE;
648 gotbool = D3DXQuaternionIsIdentity(&q);
649 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
650 /* Test the NULL case */
651 gotbool = D3DXQuaternionIsIdentity(NULL);
652 ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
654 /*_______________D3DXQuaternionLength__________________________*/
655 expected = 11.0f;
656 got = D3DXQuaternionLength(&q);
657 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
658 /* Tests the case NULL */
659 expected=0.0f;
660 got = D3DXQuaternionLength(NULL);
661 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
663 /*_______________D3DXQuaternionLengthSq________________________*/
664 expected = 121.0f;
665 got = D3DXQuaternionLengthSq(&q);
666 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
667 /* Tests the case NULL */
668 expected=0.0f;
669 got = D3DXQuaternionLengthSq(NULL);
670 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
672 /*_______________D3DXQuaternionLn______________________________*/
673 expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
674 D3DXQuaternionLn(&gotquat,&q);
675 expect_vec4(expectedquat,gotquat);
676 expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
677 D3DXQuaternionLn(&gotquat,&r);
678 expect_vec4(expectedquat,gotquat);
679 Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
680 expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
681 D3DXQuaternionLn(&gotquat,&Nq);
682 expect_vec4(expectedquat,gotquat);
683 /* Test the cas where the norm of the quaternion is <1 */
684 Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
685 expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
686 D3DXQuaternionLn(&gotquat,&Nq1);
687 todo_wine{ expect_vec4(expectedquat,gotquat) };
689 /*_______________D3DXQuaternionMultiply________________________*/
690 expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
691 D3DXQuaternionMultiply(&gotquat,&q,&r);
692 expect_vec4(expectedquat,gotquat);
694 /*_______________D3DXQuaternionNormalize________________________*/
695 expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
696 D3DXQuaternionNormalize(&gotquat,&q);
697 expect_vec4(expectedquat,gotquat);
698 /* Test the nul quaternion */
699 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
700 D3DXQuaternionNormalize(&gotquat,&nul);
701 expect_vec4(expectedquat,gotquat);
703 /*_______________D3DXQuaternionRotationAxis___________________*/
704 axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
705 angle = D3DX_PI/3.0f;
706 expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
707 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
708 expect_vec4(expectedquat,gotquat);
709 /* Test the nul quaternion */
710 axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
711 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
712 D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
713 expect_vec4(expectedquat,gotquat);
715 /*_______________D3DXQuaternionRotationMatrix___________________*/
716 /* test when the trace is >0 */
717 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
718 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
719 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
720 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
721 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
722 U(mat).m[3][3] = 48.0f;
723 expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
724 D3DXQuaternionRotationMatrix(&gotquat,&mat);
725 expect_vec4(expectedquat,gotquat);
726 /* test the case when the greater element is (2,2) */
727 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
728 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
729 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
730 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
731 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
732 U(mat).m[3][3] = 48.0f;
733 expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
734 D3DXQuaternionRotationMatrix(&gotquat,&mat);
735 expect_vec4(expectedquat,gotquat);
736 /* test the case when the greater element is (1,1) */
737 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
738 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
739 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
740 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
741 U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
742 U(mat).m[3][3] = 48.0f;
743 expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
744 D3DXQuaternionRotationMatrix(&gotquat,&mat);
745 expect_vec4(expectedquat,gotquat);
747 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
748 expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
749 D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
750 expect_vec4(expectedquat,gotquat);
752 /*_______________D3DXQuaternionSlerp________________________*/
753 expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
754 D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
755 expect_vec4(expectedquat,gotquat);
756 expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
757 D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
758 expect_vec4(expectedquat,gotquat);
760 /*_______________D3DXQuaternionSquad________________________*/
761 expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
762 D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
763 expect_vec4(expectedquat,gotquat);
765 /*_______________D3DXQuaternionToAxisAngle__________________*/
766 Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
767 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
768 expected = 2.197869f;
769 D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
770 expect_vec3(expectedvec,axis);
771 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
772 /* Test if |w|>1.0f */
773 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
774 expected = 0.0f;
775 D3DXQuaternionToAxisAngle(&q,&axis,&angle);
776 expect_vec3(expectedvec,axis);
777 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
778 /* Test the null quaternion */
779 expectedvec.x = 1.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
780 expected = 0.0f;
781 D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
782 expect_vec3(expectedvec,axis);
783 ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
786 static void D3X8Vector2Test(void)
788 D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
789 LPD3DXVECTOR2 funcpointer;
790 D3DXVECTOR4 expectedtrans, gottrans;
791 D3DXMATRIX mat;
792 FLOAT coeff1, coeff2, expected, got, scale;
794 nul.x = 0.0f; nul.y = 0.0f;
795 u.x = 3.0f; u.y = 4.0f;
796 v.x = -7.0f; v.y = 9.0f;
797 w.x = 4.0f; w.y = -3.0f;
798 x.x = 2.0f; x.y = -11.0f;
800 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;
801 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;
802 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;
803 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;
805 coeff1 = 2.0f; coeff2 = 5.0f;
806 scale = -6.5f;
808 /*_______________D3DXVec2Add__________________________*/
809 expectedvec.x = -4.0f; expectedvec.y = 13.0f;
810 D3DXVec2Add(&gotvec,&u,&v);
811 expect_vec(expectedvec,gotvec);
812 /* Tests the case NULL */
813 funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
814 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
815 funcpointer = D3DXVec2Add(NULL,NULL,NULL);
816 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
818 /*_______________D3DXVec2BaryCentric___________________*/
819 expectedvec.x = -12.0f; expectedvec.y = -21.0f;
820 D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
821 expect_vec(expectedvec,gotvec);
823 /*_______________D3DXVec2CatmullRom____________________*/
824 expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
825 D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
826 expect_vec(expectedvec,gotvec);
828 /*_______________D3DXVec2CCW__________________________*/
829 expected = 55.0f;
830 got = D3DXVec2CCW(&u,&v);
831 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
832 /* Tests the case NULL */
833 expected=0.0f;
834 got = D3DXVec2CCW(NULL,&v);
835 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
836 expected=0.0f;
837 got = D3DXVec2CCW(NULL,NULL);
838 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
840 /*_______________D3DXVec2Dot__________________________*/
841 expected = 15.0f;
842 got = D3DXVec2Dot(&u,&v);
843 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
844 /* Tests the case NULL */
845 expected=0.0f;
846 got = D3DXVec2Dot(NULL,&v);
847 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
848 expected=0.0f;
849 got = D3DXVec2Dot(NULL,NULL);
850 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
852 /*_______________D3DXVec2Hermite__________________________*/
853 expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
854 D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
855 expect_vec(expectedvec,gotvec);
857 /*_______________D3DXVec2Length__________________________*/
858 expected = 5.0f;
859 got = D3DXVec2Length(&u);
860 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
861 /* Tests the case NULL */
862 expected=0.0f;
863 got = D3DXVec2Length(NULL);
864 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
866 /*_______________D3DXVec2LengthSq________________________*/
867 expected = 25.0f;
868 got = D3DXVec2LengthSq(&u);
869 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
870 /* Tests the case NULL */
871 expected=0.0f;
872 got = D3DXVec2LengthSq(NULL);
873 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
875 /*_______________D3DXVec2Lerp__________________________*/
876 expectedvec.x = 68.0f; expectedvec.y = -28.5f;
877 D3DXVec2Lerp(&gotvec,&u,&v,scale);
878 expect_vec(expectedvec,gotvec);
879 /* Tests the case NULL */
880 funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
881 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
882 funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
883 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
885 /*_______________D3DXVec2Maximize__________________________*/
886 expectedvec.x = 3.0f; expectedvec.y = 9.0f;
887 D3DXVec2Maximize(&gotvec,&u,&v);
888 expect_vec(expectedvec,gotvec);
889 /* Tests the case NULL */
890 funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
891 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
892 funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
893 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
895 /*_______________D3DXVec2Minimize__________________________*/
896 expectedvec.x = -7.0f; expectedvec.y = 4.0f;
897 D3DXVec2Minimize(&gotvec,&u,&v);
898 expect_vec(expectedvec,gotvec);
899 /* Tests the case NULL */
900 funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
901 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
902 funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
903 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
905 /*_______________D3DXVec2Normalize_________________________*/
906 expectedvec.x = 0.6f; expectedvec.y = 0.8f;
907 D3DXVec2Normalize(&gotvec,&u);
908 expect_vec(expectedvec,gotvec);
909 /* Test the nul vector */
910 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
911 D3DXVec2Normalize(&gotvec,&nul);
912 expect_vec(expectedvec,gotvec);
914 /*_______________D3DXVec2Scale____________________________*/
915 expectedvec.x = -19.5f; expectedvec.y = -26.0f;
916 D3DXVec2Scale(&gotvec,&u,scale);
917 expect_vec(expectedvec,gotvec);
918 /* Tests the case NULL */
919 funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
920 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
921 funcpointer = D3DXVec2Scale(NULL,NULL,scale);
922 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
924 /*_______________D3DXVec2Subtract__________________________*/
925 expectedvec.x = 10.0f; expectedvec.y = -5.0f;
926 D3DXVec2Subtract(&gotvec,&u,&v);
927 expect_vec(expectedvec,gotvec);
928 /* Tests the case NULL */
929 funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
930 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
931 funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
932 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
934 /*_______________D3DXVec2Transform_______________________*/
935 expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
936 D3DXVec2Transform(&gottrans,&u,&mat);
937 expect_vec4(expectedtrans,gottrans);
939 /*_______________D3DXVec2TransformCoord_______________________*/
940 expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
941 D3DXVec2TransformCoord(&gotvec,&u,&mat);
942 expect_vec(expectedvec,gotvec);
943 /* Test the nul projected vector */
944 nulproj.x = -2.0f; nulproj.y = -1.0f;
945 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
946 D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
947 expect_vec(expectedvec,gotvec);
949 /*_______________D3DXVec2TransformNormal______________________*/
950 expectedvec.x = 23.0f; expectedvec.y = 30.0f;
951 D3DXVec2TransformNormal(&gotvec,&u,&mat);
952 expect_vec(expectedvec,gotvec);
955 static void D3X8Vector3Test(void)
957 D3DVIEWPORT8 viewport;
958 D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
959 LPD3DXVECTOR3 funcpointer;
960 D3DXVECTOR4 expectedtrans, gottrans;
961 D3DXMATRIX mat, projection, view, world;
962 FLOAT coeff1, coeff2, expected, got, scale;
964 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
965 u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
966 v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
967 w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
968 x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
970 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
971 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
973 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;
974 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;
975 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;
976 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;
978 U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
979 U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
980 U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
981 U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
982 U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
983 U(view).m[3][3] = -40.0f;
985 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;
986 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;
987 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;
988 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;
990 coeff1 = 2.0f; coeff2 = 5.0f;
991 scale = -6.5f;
993 /*_______________D3DXVec3Add__________________________*/
994 expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
995 D3DXVec3Add(&gotvec,&u,&v);
996 expect_vec3(expectedvec,gotvec);
997 /* Tests the case NULL */
998 funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
999 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1000 funcpointer = D3DXVec3Add(NULL,NULL,NULL);
1001 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1003 /*_______________D3DXVec3BaryCentric___________________*/
1004 expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
1005 D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1007 expect_vec3(expectedvec,gotvec);
1009 /*_______________D3DXVec3CatmullRom____________________*/
1010 expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
1011 D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1012 expect_vec3(expectedvec,gotvec);
1014 /*_______________D3DXVec3Cross________________________*/
1015 expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
1016 D3DXVec3Cross(&gotvec,&u,&v);
1017 expect_vec3(expectedvec,gotvec);
1018 /* Tests the case NULL */
1019 funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
1020 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1021 funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
1022 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1024 /*_______________D3DXVec3Dot__________________________*/
1025 expected = -8.0f;
1026 got = D3DXVec3Dot(&u,&v);
1027 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1028 /* Tests the case NULL */
1029 expected=0.0f;
1030 got = D3DXVec3Dot(NULL,&v);
1031 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1032 expected=0.0f;
1033 got = D3DXVec3Dot(NULL,NULL);
1034 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1036 /*_______________D3DXVec3Hermite__________________________*/
1037 expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
1038 D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
1039 expect_vec3(expectedvec,gotvec);
1041 /*_______________D3DXVec3Length__________________________*/
1042 expected = 11.0f;
1043 got = D3DXVec3Length(&u);
1044 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1045 /* Tests the case NULL */
1046 expected=0.0f;
1047 got = D3DXVec3Length(NULL);
1048 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1050 /*_______________D3DXVec3LengthSq________________________*/
1051 expected = 121.0f;
1052 got = D3DXVec3LengthSq(&u);
1053 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1054 /* Tests the case NULL */
1055 expected=0.0f;
1056 got = D3DXVec3LengthSq(NULL);
1057 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1059 /*_______________D3DXVec3Lerp__________________________*/
1060 expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
1061 D3DXVec3Lerp(&gotvec,&u,&v,scale);
1062 expect_vec3(expectedvec,gotvec);
1063 /* Tests the case NULL */
1064 funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
1065 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1066 funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
1067 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1069 /*_______________D3DXVec3Maximize__________________________*/
1070 expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
1071 D3DXVec3Maximize(&gotvec,&u,&v);
1072 expect_vec3(expectedvec,gotvec);
1073 /* Tests the case NULL */
1074 funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
1075 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1076 funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
1077 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1079 /*_______________D3DXVec3Minimize__________________________*/
1080 expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
1081 D3DXVec3Minimize(&gotvec,&u,&v);
1082 expect_vec3(expectedvec,gotvec);
1083 /* Tests the case NULL */
1084 funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
1085 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1086 funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
1087 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1089 /*_______________D3DXVec3Normalize_________________________*/
1090 expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
1091 D3DXVec3Normalize(&gotvec,&u);
1092 expect_vec3(expectedvec,gotvec);
1093 /* Test the nul vector */
1094 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1095 D3DXVec3Normalize(&gotvec,&nul);
1096 expect_vec3(expectedvec,gotvec);
1098 /*_______________D3DXVec3Project_________________________*/
1099 expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
1100 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1101 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
1102 expect_vec3(expectedvec,gotvec);
1104 /*_______________D3DXVec3Scale____________________________*/
1105 expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
1106 D3DXVec3Scale(&gotvec,&u,scale);
1107 expect_vec3(expectedvec,gotvec);
1108 /* Tests the case NULL */
1109 funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
1110 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1111 funcpointer = D3DXVec3Scale(NULL,NULL,scale);
1112 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1114 /*_______________D3DXVec3Subtract_______________________*/
1115 expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
1116 D3DXVec3Subtract(&gotvec,&u,&v);
1117 expect_vec3(expectedvec,gotvec);
1118 /* Tests the case NULL */
1119 funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
1120 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1121 funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
1122 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1124 /*_______________D3DXVec3Transform_______________________*/
1125 expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
1126 D3DXVec3Transform(&gottrans,&u,&mat);
1127 expect_vec4(expectedtrans,gottrans);
1129 /*_______________D3DXVec3TransformCoord_______________________*/
1130 expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
1131 D3DXVec3TransformCoord(&gotvec,&u,&mat);
1132 expect_vec3(expectedvec,gotvec);
1133 /* Test the nul projected vector */
1134 nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
1135 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1136 D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
1137 expect_vec3(expectedvec,gotvec);
1139 /*_______________D3DXVec3TransformNormal______________________*/
1140 expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
1141 D3DXVec3TransformNormal(&gotvec,&u,&mat);
1142 expect_vec3(expectedvec,gotvec);
1144 /*_______________D3DXVec3Unproject_________________________*/
1145 expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
1146 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1147 D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
1148 expect_vec3(expectedvec,gotvec);
1151 static void D3X8Vector4Test(void)
1153 D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
1154 LPD3DXVECTOR4 funcpointer;
1155 D3DXVECTOR4 expectedtrans, gottrans;
1156 D3DXMATRIX mat;
1157 FLOAT coeff1, coeff2, expected, got, scale;
1159 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
1160 u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
1161 v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
1162 w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
1163 x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
1165 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;
1166 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;
1167 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;
1168 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;
1170 coeff1 = 2.0f; coeff2 = 5.0;
1171 scale = -6.5f;
1173 /*_______________D3DXVec4Add__________________________*/
1174 expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
1175 D3DXVec4Add(&gotvec,&u,&v);
1176 expect_vec4(expectedvec,gotvec);
1177 /* Tests the case NULL */
1178 funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
1179 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1180 funcpointer = D3DXVec4Add(NULL,NULL,NULL);
1181 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1183 /*_______________D3DXVec4BaryCentric____________________*/
1184 expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
1185 D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1186 expect_vec4(expectedvec,gotvec);
1188 /*_______________D3DXVec4CatmullRom____________________*/
1189 expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
1190 D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1191 expect_vec4(expectedvec,gotvec);
1193 /*_______________D3DXVec4Cross_________________________*/
1194 expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
1195 D3DXVec4Cross(&gotvec,&u,&v,&w);
1196 expect_vec4(expectedvec,gotvec);
1198 /*_______________D3DXVec4Dot__________________________*/
1199 expected = 55.0f;
1200 got = D3DXVec4Dot(&u,&v);
1201 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1202 /* Tests the case NULL */
1203 expected=0.0f;
1204 got = D3DXVec4Dot(NULL,&v);
1205 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1206 expected=0.0f;
1207 got = D3DXVec4Dot(NULL,NULL);
1208 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1210 /*_______________D3DXVec4Hermite_________________________*/
1211 expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
1212 D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
1213 expect_vec4(expectedvec,gotvec);
1215 /*_______________D3DXVec4Length__________________________*/
1216 expected = 11.0f;
1217 got = D3DXVec4Length(&u);
1218 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1219 /* Tests the case NULL */
1220 expected=0.0f;
1221 got = D3DXVec4Length(NULL);
1222 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1224 /*_______________D3DXVec4LengthSq________________________*/
1225 expected = 121.0f;
1226 got = D3DXVec4LengthSq(&u);
1227 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1228 /* Tests the case NULL */
1229 expected=0.0f;
1230 got = D3DXVec4LengthSq(NULL);
1231 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1233 /*_______________D3DXVec4Lerp__________________________*/
1234 expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
1235 D3DXVec4Lerp(&gotvec,&u,&v,scale);
1236 expect_vec4(expectedvec,gotvec);
1237 /* Tests the case NULL */
1238 funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
1239 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1240 funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
1241 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1243 /*_______________D3DXVec4Maximize__________________________*/
1244 expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
1245 D3DXVec4Maximize(&gotvec,&u,&v);
1246 expect_vec4(expectedvec,gotvec);
1247 /* Tests the case NULL */
1248 funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
1249 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1250 funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
1251 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1253 /*_______________D3DXVec4Minimize__________________________*/
1254 expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
1255 D3DXVec4Minimize(&gotvec,&u,&v);
1256 expect_vec4(expectedvec,gotvec);
1257 /* Tests the case NULL */
1258 funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
1259 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1260 funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
1261 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1263 /*_______________D3DXVec4Normalize_________________________*/
1264 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
1265 D3DXVec4Normalize(&gotvec,&u);
1266 expect_vec4(expectedvec,gotvec);
1267 /* Test the nul vector */
1268 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
1269 D3DXVec4Normalize(&gotvec,&nul);
1270 expect_vec4(expectedvec,gotvec);
1272 /*_______________D3DXVec4Scale____________________________*/
1273 expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
1274 D3DXVec4Scale(&gotvec,&u,scale);
1275 expect_vec4(expectedvec,gotvec);
1276 /* Tests the case NULL */
1277 funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
1278 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1279 funcpointer = D3DXVec4Scale(NULL,NULL,scale);
1280 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1282 /*_______________D3DXVec4Subtract__________________________*/
1283 expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
1284 D3DXVec4Subtract(&gotvec,&u,&v);
1285 expect_vec4(expectedvec,gotvec);
1286 /* Tests the case NULL */
1287 funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
1288 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1289 funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
1290 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1292 /*_______________D3DXVec4Transform_______________________*/
1293 expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
1294 D3DXVec4Transform(&gottrans,&u,&mat);
1295 expect_vec4(expectedtrans,gottrans);
1298 START_TEST(math)
1300 D3DXColorTest();
1301 D3DXMatrixTest();
1302 D3DXPlaneTest();
1303 D3X8QuaternionTest();
1304 D3X8Vector2Test();
1305 D3X8Vector3Test();
1306 D3X8Vector4Test();