d3dx8: Implement D3XMatrixVec3Project.
[wine/wine-kai.git] / dlls / d3dx8 / tests / math.c
blob70e5240afb2854bfde56baf8f21e0d1703e9425c
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.00001f
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_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);
55 #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);
57 #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);
59 static void D3DXColorTest(void)
61 D3DXCOLOR color, color1, color2, expected, got;
62 LPD3DXCOLOR funcpointer;
63 FLOAT scale;
65 color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
66 color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
67 color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
68 scale = 0.3f;
70 /*_______________D3DXColorAdd________________*/
71 expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f, expected.a = 0.93f;
72 D3DXColorAdd(&got,&color1,&color2);
73 expect_color(expected,got);
74 /* Test the NULL case */
75 funcpointer = D3DXColorAdd(&got,NULL,&color2);
76 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
77 funcpointer = D3DXColorAdd(NULL,NULL,&color2);
78 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
79 funcpointer = D3DXColorAdd(NULL,NULL,NULL);
80 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
82 /*_______________D3DXColorLerp________________*/
83 expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
84 D3DXColorLerp(&got,&color,&color1,scale);
85 expect_color(expected,got);
86 /* Test the NULL case */
87 funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
88 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
89 funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
90 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
91 funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
92 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
94 /*_______________D3DXColorModulate________________*/
95 expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
96 D3DXColorModulate(&got,&color1,&color2);
97 expect_color(expected,got);
98 /* Test the NULL case */
99 funcpointer = D3DXColorModulate(&got,NULL,&color2);
100 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
101 funcpointer = D3DXColorModulate(NULL,NULL,&color2);
102 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
103 funcpointer = D3DXColorModulate(NULL,NULL,NULL);
104 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
106 /*_______________D3DXColorNegative________________*/
107 expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
108 D3DXColorNegative(&got,&color);
109 expect_color(got,expected);
110 /* Test the greater than 1 case */
111 color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
112 expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
113 D3DXColorNegative(&got,&color1);
114 expect_color(got,expected);
115 /* Test the negative case */
116 color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
117 expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
118 D3DXColorNegative(&got,&color1);
119 expect_color(got,expected);
120 /* Test the NULL case */
121 funcpointer = D3DXColorNegative(&got,NULL);
122 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
123 funcpointer = D3DXColorNegative(NULL,NULL);
124 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
126 /*_______________D3DXColorScale________________*/
127 expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
128 D3DXColorScale(&got,&color,scale);
129 expect_color(expected,got);
130 /* Test the NULL case */
131 funcpointer = D3DXColorScale(&got,NULL,scale);
132 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
133 funcpointer = D3DXColorScale(NULL,NULL,scale);
134 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
136 /*_______________D3DXColorSubtract_______________*/
137 expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f, expected.a = 0.82f;
138 D3DXColorSubtract(&got,&color,&color2);
139 expect_color(expected,got);
140 /* Test the NULL case */
141 funcpointer = D3DXColorSubtract(&got,NULL,&color2);
142 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
143 funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
144 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
145 funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
146 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
149 static void D3DXMatrixTest(void)
151 D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
152 LPD3DXMATRIX funcpointer;
153 D3DXQUATERNION q;
154 D3DXVECTOR3 at, axis, eye;
155 BOOL expected, got;
156 FLOAT angle, determinant, expectedfloat, gotfloat;
158 U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
159 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
160 U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
161 U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
162 U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
163 U(mat).m[3][3] = -40.0f;
165 U(mat2).m[0][0] = 1.0f; U(mat2).m[1][0] = 2.0f; U(mat2).m[2][0] = 3.0f;
166 U(mat2).m[3][0] = 4.0f; U(mat2).m[0][1] = 5.0f; U(mat2).m[1][1] = 6.0f;
167 U(mat2).m[2][1] = 7.0f; U(mat2).m[3][1] = 8.0f; U(mat2).m[0][2] = -8.0f;
168 U(mat2).m[1][2] = -7.0f; U(mat2).m[2][2] = -6.0f; U(mat2).m[3][2] = -5.0f;
169 U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f;
170 U(mat2).m[3][3] = -1.0f;
172 q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
174 at.x = -2.0f; at.y = 13.0f; at.z = -9.0f;
175 axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f;
176 eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
178 angle = D3DX_PI/3.0f;
180 /*____________D3DXMatrixfDeterminant_____________*/
181 expectedfloat = -147888.0f;
182 gotfloat = D3DXMatrixfDeterminant(&mat);
183 ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
185 /*____________D3DXMatrixInverse______________*/
186 expectedmat.m[0][0] = 16067.0f/73944.0f; expectedmat.m[0][1] = -10165.0f/147888.0f; expectedmat.m[0][2] = -2729.0f/147888.0f; expectedmat.m[0][3] = -1631.0f/49296.0f;
187 expectedmat.m[1][0] = -565.0f/36972.0f; expectedmat.m[1][1] = 2723.0f/73944.0f; expectedmat.m[1][2] = -1073.0f/73944.0f; expectedmat.m[1][3] = 289.0f/24648.0f;
188 expectedmat.m[2][0] = -389.0f/2054.0f; expectedmat.m[2][1] = 337.0f/4108.0f; expectedmat.m[2][2] = 181.0f/4108.0f; expectedmat.m[2][3] = 317.0f/4108.0f;
189 expectedmat.m[3][0] = 163.0f/5688.0f; expectedmat.m[3][1] = -101.0f/11376.0f; expectedmat.m[3][2] = -73.0f/11376.0f; expectedmat.m[3][3] = -127.0f/3792.0f;
190 expectedfloat = -147888.0f;
191 D3DXMatrixInverse(&gotmat,&determinant,&mat);
192 expect_mat(expectedmat,gotmat);
193 ok(fabs( determinant - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, determinant);
194 funcpointer = D3DXMatrixInverse(&gotmat,NULL,&mat2);
195 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
197 /*____________D3DXMatrixIsIdentity______________*/
198 expected = FALSE;
199 got = D3DXMatrixIsIdentity(&mat3);
200 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
201 D3DXMatrixIdentity(&mat3);
202 expected = TRUE;
203 got = D3DXMatrixIsIdentity(&mat3);
204 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
205 U(mat3).m[0][0] = 0.000009f;
206 expected = FALSE;
207 got = D3DXMatrixIsIdentity(&mat3);
208 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
209 /* Test the NULL case */
210 expected = FALSE;
211 got = D3DXMatrixIsIdentity(NULL);
212 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
214 /*____________D3DXMatrixLookatLH_______________*/
215 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;
216 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;
217 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;
218 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;
219 D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
220 expect_mat(expectedmat,gotmat);
222 /*____________D3DXMatrixLookatRH_______________*/
223 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;
224 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;
225 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;
226 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;
227 D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
228 expect_mat(expectedmat,gotmat);
230 /*____________D3DXMatrixMultiply______________*/
231 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;
232 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;
233 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;
234 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;
235 D3DXMatrixMultiply(&gotmat,&mat,&mat2);
236 expect_mat(expectedmat,gotmat);
238 /*____________D3DXMatrixMultiplyTranspose____*/
239 expectedmat.m[0][0] = 73.0f; expectedmat.m[0][1] = 231.0f; expectedmat.m[0][2] = 239.0f; expectedmat.m[0][3] = -164.0f;
240 expectedmat.m[1][0] = 193.0f; expectedmat.m[1][1] = 551.0f; expectedmat.m[1][2] = 523.0f; expectedmat.m[1][3] = -320.0;
241 expectedmat.m[2][0] = -197.0f; expectedmat.m[2][1] = -489.0f; expectedmat.m[2][2] = -400.0f; expectedmat.m[2][3] = 187.0f;
242 expectedmat.m[3][0] = -77.0f; expectedmat.m[3][1] = -169.0f; expectedmat.m[3][2] = -116.0f; expectedmat.m[3][3] = 31.0f;
243 D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
244 expect_mat(expectedmat,gotmat);
246 /*____________D3DXMatrixOrthoLH_______________*/
247 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;
248 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;
249 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;
250 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;
251 D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
252 expect_mat(expectedmat,gotmat);
254 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
255 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;
256 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;
257 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;
258 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;
259 D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
260 expect_mat(expectedmat,gotmat);
262 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
263 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;
264 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;
265 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;
266 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;
267 D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
268 expect_mat(expectedmat,gotmat);
270 /*____________D3DXMatrixOrthoRH_______________*/
271 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;
272 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;
273 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;
274 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;
275 D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
276 expect_mat(expectedmat,gotmat);
278 /*____________D3DXMatrixPerspectiveFovLH_______________*/
279 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;
280 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;
281 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;
282 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;
283 D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
284 expect_mat(expectedmat,gotmat);
286 /*____________D3DXMatrixPerspectiveFovRH_______________*/
287 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;
288 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;
289 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;
290 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;
291 D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
292 expect_mat(expectedmat,gotmat);
294 /*____________D3DXMatrixPerspectiveLH_______________*/
295 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;
296 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;
297 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;
298 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;
299 D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
300 expect_mat(expectedmat,gotmat);
302 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
303 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;
304 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;
305 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;
306 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;
307 D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
308 expect_mat(expectedmat,gotmat);
310 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
311 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;
312 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;
313 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;
314 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;
315 D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
316 expect_mat(expectedmat,gotmat);
318 /*____________D3DXMatrixPerspectiveRH_______________*/
319 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;
320 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;
321 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;
322 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;
323 D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
324 expect_mat(expectedmat,gotmat);
326 /*____________D3DXMatrixRotationAxis_____*/
327 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;
328 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;
329 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;
330 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;
331 D3DXMatrixRotationAxis(&gotmat,&axis,angle);
332 expect_mat(expectedmat,gotmat);
334 /*____________D3DXMatrixRotationQuaternion______________*/
335 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;
336 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;
337 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;
338 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;
339 D3DXMatrixRotationQuaternion(&gotmat,&q);
340 expect_mat(expectedmat,gotmat);
342 /*____________D3DXMatrixRotationX______________*/
343 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;
344 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;
345 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;
346 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;
347 D3DXMatrixRotationX(&gotmat,angle);
348 expect_mat(expectedmat,gotmat);
350 /*____________D3DXMatrixRotationY______________*/
351 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;
352 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;
353 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;
354 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;
355 D3DXMatrixRotationY(&gotmat,angle);
356 expect_mat(expectedmat,gotmat);
358 /*____________D3DXMatrixRotationYawPitchRoll____*/
359 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;
360 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;
361 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;
362 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;
363 D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
364 expect_mat(expectedmat,gotmat);
366 /*____________D3DXMatrixRotationZ______________*/
367 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;
368 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;
369 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;
370 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;
371 D3DXMatrixRotationZ(&gotmat,angle);
372 expect_mat(expectedmat,gotmat);
374 /*____________D3DXMatrixScaling______________*/
375 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;
376 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;
377 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;
378 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;
379 D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
380 expect_mat(expectedmat,gotmat);
382 /*____________D3DXMatrixTranslation______________*/
383 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;
384 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;
385 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;
386 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;
387 D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
388 expect_mat(expectedmat,gotmat);
390 /*____________D3DXMatrixTranspose______________*/
391 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;
392 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;
393 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;
394 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;
395 D3DXMatrixTranspose(&gotmat,&mat);
396 expect_mat(expectedmat,gotmat);
399 static void D3DXPlaneTest(void)
401 D3DXPLANE plane;
402 D3DXVECTOR4 vec;
403 FLOAT expected, got;
405 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
406 vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
408 /*_______________D3DXPlaneDot________________*/
409 expected = 42.0f;
410 got = D3DXPlaneDot(&plane,&vec),
411 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
412 expected = 0.0f;
413 got = D3DXPlaneDot(NULL,&vec),
414 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
415 expected = 0.0f;
416 got = D3DXPlaneDot(NULL,NULL),
417 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
419 /*_______________D3DXPlaneDotCoord________________*/
420 expected = -28.0f;
421 got = D3DXPlaneDotCoord(&plane,&vec),
422 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
423 expected = 0.0f;
424 got = D3DXPlaneDotCoord(NULL,&vec),
425 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
426 expected = 0.0f;
427 got = D3DXPlaneDotCoord(NULL,NULL),
428 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
430 /*_______________D3DXPlaneDotNormal______________*/
431 expected = -35.0f;
432 got = D3DXPlaneDotNormal(&plane,&vec),
433 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
434 expected = 0.0f;
435 got = D3DXPlaneDotNormal(NULL,&vec),
436 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
437 expected = 0.0f;
438 got = D3DXPlaneDotNormal(NULL,NULL),
439 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
442 static void D3X8QuaternionTest(void)
444 D3DXQUATERNION expectedquat, gotquat, nul, q, r, s;
445 LPD3DXQUATERNION funcpointer;
446 FLOAT expected, got;
447 BOOL expectedbool, gotbool;
449 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
450 q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
451 r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
453 /*_______________D3DXQuaternionConjugate________________*/
454 expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
455 D3DXQuaternionConjugate(&gotquat,&q);
456 expect_vec4(expectedquat,gotquat);
457 /* Test the NULL case */
458 funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
459 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
460 funcpointer = D3DXQuaternionConjugate(NULL,NULL);
461 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
463 /*_______________D3DXQuaternionDot______________________*/
464 expected = 55.0f;
465 got = D3DXQuaternionDot(&q,&r);
466 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
467 /* Tests the case NULL */
468 expected=0.0f;
469 got = D3DXQuaternionDot(NULL,&r);
470 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
471 expected=0.0f;
472 got = D3DXQuaternionDot(NULL,NULL);
473 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
475 /*_______________D3DXQuaternionIdentity________________*/
476 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
477 D3DXQuaternionIdentity(&gotquat);
478 expect_vec4(expectedquat,gotquat);
479 /* Test the NULL case */
480 funcpointer = D3DXQuaternionIdentity(NULL);
481 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
483 /*_______________D3DXQuaternionIsIdentity________________*/
484 s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
485 expectedbool = TRUE;
486 gotbool = D3DXQuaternionIsIdentity(&s);
487 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
488 s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
489 expectedbool = FALSE;
490 gotbool = D3DXQuaternionIsIdentity(&q);
491 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
492 /* Test the NULL case */
493 gotbool = D3DXQuaternionIsIdentity(NULL);
494 ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
496 /*_______________D3DXQuaternionLength__________________________*/
497 expected = 11.0f;
498 got = D3DXQuaternionLength(&q);
499 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
500 /* Tests the case NULL */
501 expected=0.0f;
502 got = D3DXQuaternionLength(NULL);
503 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
505 /*_______________D3DXQuaternionLengthSq________________________*/
506 expected = 121.0f;
507 got = D3DXQuaternionLengthSq(&q);
508 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
509 /* Tests the case NULL */
510 expected=0.0f;
511 got = D3DXQuaternionLengthSq(NULL);
512 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
514 /*_______________D3DXQuaternionNormalize________________________*/
515 expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
516 D3DXQuaternionNormalize(&gotquat,&q);
517 expect_vec4(expectedquat,gotquat);
518 /* Test the nul quaternion */
519 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
520 D3DXQuaternionNormalize(&gotquat,&nul);
521 expect_vec4(expectedquat,gotquat);
524 static void D3X8Vector2Test(void)
526 D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
527 LPD3DXVECTOR2 funcpointer;
528 D3DXVECTOR4 expectedtrans, gottrans;
529 D3DXMATRIX mat;
530 FLOAT coeff1, coeff2, expected, got, scale;
532 nul.x = 0.0f; nul.y = 0.0f;
533 u.x = 3.0f; u.y = 4.0f;
534 v.x = -7.0f; v.y = 9.0f;
535 w.x = 4.0f; w.y = -3.0f;
536 x.x = 2.0f; x.y = -11.0f;
538 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;
539 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;
540 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;
541 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;
543 coeff1 = 2.0f; coeff2 = 5.0f;
544 scale = -6.5f;
546 /*_______________D3DXVec2Add__________________________*/
547 expectedvec.x = -4.0f; expectedvec.y = 13.0f;
548 D3DXVec2Add(&gotvec,&u,&v);
549 expect_vec(expectedvec,gotvec);
550 /* Tests the case NULL */
551 funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
552 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
553 funcpointer = D3DXVec2Add(NULL,NULL,NULL);
554 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
556 /*_______________D3DXVec2BaryCentric___________________*/
557 expectedvec.x = -12.0f; expectedvec.y = -21.0f;
558 D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
559 expect_vec(expectedvec,gotvec);
561 /*_______________D3DXVec2CatmullRom____________________*/
562 expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
563 D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
564 expect_vec(expectedvec,gotvec);
566 /*_______________D3DXVec2CCW__________________________*/
567 expected = 55.0f;
568 got = D3DXVec2CCW(&u,&v);
569 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
570 /* Tests the case NULL */
571 expected=0.0f;
572 got = D3DXVec2CCW(NULL,&v);
573 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
574 expected=0.0f;
575 got = D3DXVec2CCW(NULL,NULL);
576 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
578 /*_______________D3DXVec2Dot__________________________*/
579 expected = 15.0f;
580 got = D3DXVec2Dot(&u,&v);
581 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
582 /* Tests the case NULL */
583 expected=0.0f;
584 got = D3DXVec2Dot(NULL,&v);
585 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
586 expected=0.0f;
587 got = D3DXVec2Dot(NULL,NULL);
588 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
590 /*_______________D3DXVec2Hermite__________________________*/
591 expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
592 D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
593 expect_vec(expectedvec,gotvec);
595 /*_______________D3DXVec2Length__________________________*/
596 expected = 5.0f;
597 got = D3DXVec2Length(&u);
598 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
599 /* Tests the case NULL */
600 expected=0.0f;
601 got = D3DXVec2Length(NULL);
602 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
604 /*_______________D3DXVec2LengthSq________________________*/
605 expected = 25.0f;
606 got = D3DXVec2LengthSq(&u);
607 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
608 /* Tests the case NULL */
609 expected=0.0f;
610 got = D3DXVec2LengthSq(NULL);
611 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
613 /*_______________D3DXVec2Lerp__________________________*/
614 expectedvec.x = 68.0f; expectedvec.y = -28.5f;
615 D3DXVec2Lerp(&gotvec,&u,&v,scale);
616 expect_vec(expectedvec,gotvec);
617 /* Tests the case NULL */
618 funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
619 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
620 funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
621 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
623 /*_______________D3DXVec2Maximize__________________________*/
624 expectedvec.x = 3.0f; expectedvec.y = 9.0f;
625 D3DXVec2Maximize(&gotvec,&u,&v);
626 expect_vec(expectedvec,gotvec);
627 /* Tests the case NULL */
628 funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
629 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
630 funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
631 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
633 /*_______________D3DXVec2Minimize__________________________*/
634 expectedvec.x = -7.0f; expectedvec.y = 4.0f;
635 D3DXVec2Minimize(&gotvec,&u,&v);
636 expect_vec(expectedvec,gotvec);
637 /* Tests the case NULL */
638 funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
639 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
640 funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
641 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
643 /*_______________D3DXVec2Normalize_________________________*/
644 expectedvec.x = 0.6f; expectedvec.y = 0.8f;
645 D3DXVec2Normalize(&gotvec,&u);
646 expect_vec(expectedvec,gotvec);
647 /* Test the nul vector */
648 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
649 D3DXVec2Normalize(&gotvec,&nul);
650 expect_vec(expectedvec,gotvec);
652 /*_______________D3DXVec2Scale____________________________*/
653 expectedvec.x = -19.5f; expectedvec.y = -26.0f;
654 D3DXVec2Scale(&gotvec,&u,scale);
655 expect_vec(expectedvec,gotvec);
656 /* Tests the case NULL */
657 funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
658 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
659 funcpointer = D3DXVec2Scale(NULL,NULL,scale);
660 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
662 /*_______________D3DXVec2Subtract__________________________*/
663 expectedvec.x = 10.0f; expectedvec.y = -5.0f;
664 D3DXVec2Subtract(&gotvec,&u,&v);
665 expect_vec(expectedvec,gotvec);
666 /* Tests the case NULL */
667 funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
668 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
669 funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
670 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
672 /*_______________D3DXVec2Transform_______________________*/
673 expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
674 D3DXVec2Transform(&gottrans,&u,&mat);
675 expect_vec4(expectedtrans,gottrans);
677 /*_______________D3DXVec2TransformCoord_______________________*/
678 expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
679 D3DXVec2TransformCoord(&gotvec,&u,&mat);
680 expect_vec(expectedvec,gotvec);
681 /* Test the nul projected vector */
682 nulproj.x = -2.0f; nulproj.y = -1.0f;
683 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
684 D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
685 expect_vec(expectedvec,gotvec);
687 /*_______________D3DXVec2TransformNormal______________________*/
688 expectedvec.x = 23.0f; expectedvec.y = 30.0f;
689 D3DXVec2TransformNormal(&gotvec,&u,&mat);
690 expect_vec(expectedvec,gotvec);
693 static void D3X8Vector3Test(void)
695 D3DVIEWPORT8 viewport;
696 D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
697 LPD3DXVECTOR3 funcpointer;
698 D3DXVECTOR4 expectedtrans, gottrans;
699 D3DXMATRIX mat, projection, view, world;
700 FLOAT coeff1, coeff2, expected, got, scale;
702 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
703 u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
704 v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
705 w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
706 x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
708 viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
709 viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
711 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;
712 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;
713 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;
714 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;
716 view.m[0][1] = 5.0f; view.m[0][2] = 7.0f; view.m[0][3] = 8.0f;
717 view.m[1][0] = 11.0f; view.m[1][2] = 16.0f; view.m[1][3] = 33.0f;
718 view.m[2][0] = 19.0f; view.m[2][1] = -21.0f; view.m[2][3] = 43.0f;
719 view.m[3][0] = 2.0f; view.m[3][1] = 3.0f; view.m[3][2] = -4.0f;
720 view.m[0][0] = 10.0f; view.m[1][1] = 20.0f; view.m[2][2] = 30.0f;
721 view.m[3][3] = -40.0f;
723 world.m[0][0] = 21.0f; world.m[0][1] = 2.0f; world.m[0][2] = 3.0f; world.m[0][3] = 4.0;
724 world.m[1][0] = 5.0f; world.m[1][1] = 23.0f; world.m[1][2] = 7.0f; world.m[1][3] = 8.0f;
725 world.m[2][0] = -8.0f; world.m[2][1] = -7.0f; world.m[2][2] = 25.0f; world.m[2][3] = -5.0f;
726 world.m[3][0] = -4.0f; world.m[3][1] = -3.0f; world.m[3][2] = -2.0f; world.m[3][3] = 27.0f;
728 coeff1 = 2.0f; coeff2 = 5.0f;
729 scale = -6.5f;
731 /*_______________D3DXVec3Add__________________________*/
732 expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
733 D3DXVec3Add(&gotvec,&u,&v);
734 expect_vec3(expectedvec,gotvec);
735 /* Tests the case NULL */
736 funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
737 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
738 funcpointer = D3DXVec3Add(NULL,NULL,NULL);
739 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
741 /*_______________D3DXVec3BaryCentric___________________*/
742 expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
743 D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
745 expect_vec3(expectedvec,gotvec);
747 /*_______________D3DXVec3CatmullRom____________________*/
748 expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
749 D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
750 expect_vec3(expectedvec,gotvec);
752 /*_______________D3DXVec3Cross________________________*/
753 expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
754 D3DXVec3Cross(&gotvec,&u,&v);
755 expect_vec3(expectedvec,gotvec);
756 /* Tests the case NULL */
757 funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
758 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
759 funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
760 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
762 /*_______________D3DXVec3Dot__________________________*/
763 expected = -8.0f;
764 got = D3DXVec3Dot(&u,&v);
765 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
766 /* Tests the case NULL */
767 expected=0.0f;
768 got = D3DXVec3Dot(NULL,&v);
769 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
770 expected=0.0f;
771 got = D3DXVec3Dot(NULL,NULL);
772 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
774 /*_______________D3DXVec3Hermite__________________________*/
775 expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
776 D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
777 expect_vec3(expectedvec,gotvec);
779 /*_______________D3DXVec3Length__________________________*/
780 expected = 11.0f;
781 got = D3DXVec3Length(&u);
782 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
783 /* Tests the case NULL */
784 expected=0.0f;
785 got = D3DXVec3Length(NULL);
786 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
788 /*_______________D3DXVec3LengthSq________________________*/
789 expected = 121.0f;
790 got = D3DXVec3LengthSq(&u);
791 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
792 /* Tests the case NULL */
793 expected=0.0f;
794 got = D3DXVec3LengthSq(NULL);
795 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
797 /*_______________D3DXVec3Lerp__________________________*/
798 expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
799 D3DXVec3Lerp(&gotvec,&u,&v,scale);
800 expect_vec3(expectedvec,gotvec);
801 /* Tests the case NULL */
802 funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
803 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
804 funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
805 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
807 /*_______________D3DXVec3Maximize__________________________*/
808 expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
809 D3DXVec3Maximize(&gotvec,&u,&v);
810 expect_vec3(expectedvec,gotvec);
811 /* Tests the case NULL */
812 funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
813 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
814 funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
815 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
817 /*_______________D3DXVec3Minimize__________________________*/
818 expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
819 D3DXVec3Minimize(&gotvec,&u,&v);
820 expect_vec3(expectedvec,gotvec);
821 /* Tests the case NULL */
822 funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
823 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
824 funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
825 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
827 /*_______________D3DXVec3Normalize_________________________*/
828 expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
829 D3DXVec3Normalize(&gotvec,&u);
830 expect_vec3(expectedvec,gotvec);
831 /* Test the nul vector */
832 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
833 D3DXVec3Normalize(&gotvec,&nul);
834 expect_vec3(expectedvec,gotvec);
836 /*_______________D3DXVec3Project_________________________*/
837 expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
838 D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
839 D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
840 expect_vec3(expectedvec,gotvec);
842 /*_______________D3DXVec3Scale____________________________*/
843 expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
844 D3DXVec3Scale(&gotvec,&u,scale);
845 expect_vec3(expectedvec,gotvec);
846 /* Tests the case NULL */
847 funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
848 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
849 funcpointer = D3DXVec3Scale(NULL,NULL,scale);
850 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
852 /*_______________D3DXVec3Subtract_______________________*/
853 expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
854 D3DXVec3Subtract(&gotvec,&u,&v);
855 expect_vec3(expectedvec,gotvec);
856 /* Tests the case NULL */
857 funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
858 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
859 funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
860 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
862 /*_______________D3DXVec3Transform_______________________*/
863 expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
864 D3DXVec3Transform(&gottrans,&u,&mat);
865 expect_vec4(expectedtrans,gottrans);
867 /*_______________D3DXVec3TransformCoord_______________________*/
868 expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
869 D3DXVec3TransformCoord(&gotvec,&u,&mat);
870 expect_vec3(expectedvec,gotvec);
871 /* Test the nul projected vector */
872 nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
873 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
874 D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
875 expect_vec3(expectedvec,gotvec);
877 /*_______________D3DXVec3TransformNormal______________________*/
878 expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
879 D3DXVec3TransformNormal(&gotvec,&u,&mat);
880 expect_vec3(expectedvec,gotvec);
883 static void D3X8Vector4Test(void)
885 D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
886 LPD3DXVECTOR4 funcpointer;
887 D3DXVECTOR4 expectedtrans, gottrans;
888 D3DXMATRIX mat;
889 FLOAT coeff1, coeff2, expected, got, scale;
891 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
892 u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
893 v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
894 w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
895 x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
897 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;
898 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;
899 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;
900 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;
902 coeff1 = 2.0f; coeff2 = 5.0;
903 scale = -6.5f;
905 /*_______________D3DXVec4Add__________________________*/
906 expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
907 D3DXVec4Add(&gotvec,&u,&v);
908 expect_vec4(expectedvec,gotvec);
909 /* Tests the case NULL */
910 funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
911 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
912 funcpointer = D3DXVec4Add(NULL,NULL,NULL);
913 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
915 /*_______________D3DXVec4BaryCentric____________________*/
916 expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
917 D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
918 expect_vec4(expectedvec,gotvec);
920 /*_______________D3DXVec4CatmullRom____________________*/
921 expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
922 D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
923 expect_vec4(expectedvec,gotvec);
925 /*_______________D3DXVec4Cross_________________________*/
926 expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
927 D3DXVec4Cross(&gotvec,&u,&v,&w);
928 expect_vec4(expectedvec,gotvec);
930 /*_______________D3DXVec4Dot__________________________*/
931 expected = 55.0f;
932 got = D3DXVec4Dot(&u,&v);
933 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
934 /* Tests the case NULL */
935 expected=0.0f;
936 got = D3DXVec4Dot(NULL,&v);
937 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
938 expected=0.0f;
939 got = D3DXVec4Dot(NULL,NULL);
940 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
942 /*_______________D3DXVec4Hermite_________________________*/
943 expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
944 D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
945 expect_vec4(expectedvec,gotvec);
947 /*_______________D3DXVec4Length__________________________*/
948 expected = 11.0f;
949 got = D3DXVec4Length(&u);
950 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
951 /* Tests the case NULL */
952 expected=0.0f;
953 got = D3DXVec4Length(NULL);
954 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
956 /*_______________D3DXVec4LengthSq________________________*/
957 expected = 121.0f;
958 got = D3DXVec4LengthSq(&u);
959 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
960 /* Tests the case NULL */
961 expected=0.0f;
962 got = D3DXVec4LengthSq(NULL);
963 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
965 /*_______________D3DXVec4Lerp__________________________*/
966 expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
967 D3DXVec4Lerp(&gotvec,&u,&v,scale);
968 expect_vec4(expectedvec,gotvec);
969 /* Tests the case NULL */
970 funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
971 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
972 funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
973 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
975 /*_______________D3DXVec4Maximize__________________________*/
976 expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
977 D3DXVec4Maximize(&gotvec,&u,&v);
978 expect_vec4(expectedvec,gotvec);
979 /* Tests the case NULL */
980 funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
981 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
982 funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
983 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
985 /*_______________D3DXVec4Minimize__________________________*/
986 expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
987 D3DXVec4Minimize(&gotvec,&u,&v);
988 expect_vec4(expectedvec,gotvec);
989 /* Tests the case NULL */
990 funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
991 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
992 funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
993 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
995 /*_______________D3DXVec4Normalize_________________________*/
996 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
997 D3DXVec4Normalize(&gotvec,&u);
998 expect_vec4(expectedvec,gotvec);
999 /* Test the nul vector */
1000 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
1001 D3DXVec4Normalize(&gotvec,&nul);
1002 expect_vec4(expectedvec,gotvec);
1004 /*_______________D3DXVec4Scale____________________________*/
1005 expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
1006 D3DXVec4Scale(&gotvec,&u,scale);
1007 expect_vec4(expectedvec,gotvec);
1008 /* Tests the case NULL */
1009 funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
1010 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1011 funcpointer = D3DXVec4Scale(NULL,NULL,scale);
1012 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1014 /*_______________D3DXVec4Subtract__________________________*/
1015 expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
1016 D3DXVec4Subtract(&gotvec,&u,&v);
1017 expect_vec4(expectedvec,gotvec);
1018 /* Tests the case NULL */
1019 funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
1020 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1021 funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
1022 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1024 /*_______________D3DXVec4Transform_______________________*/
1025 expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
1026 D3DXVec4Transform(&gottrans,&u,&mat);
1027 expect_vec4(expectedtrans,gottrans);
1030 START_TEST(math)
1032 D3DXColorTest();
1033 D3DXMatrixTest();
1034 D3DXPlaneTest();
1035 D3X8QuaternionTest();
1036 D3X8Vector2Test();
1037 D3X8Vector3Test();
1038 D3X8Vector4Test();