wintrust: Use helper function for setting confidence in SoftpubCheckCert.
[wine] / dlls / d3dx8 / tests / math.c
1 /*
2  * Copyright 2007 David Adam
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <assert.h>
20 #include "d3dx8.h"
21
22 #include "wine/test.h"
23
24 #define admitted_error 0.0001f
25
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);
27
28 #define expect_mat(expectedmat,gotmat)\
29 { \
30     int i,j,equal=1; \
31     for (i=0; i<4; i++)\
32         {\
33          for (j=0; j<4; j++)\
34              {\
35                  if (fabs(U(expectedmat).m[i][j]-U(gotmat).m[i][j])>admitted_error) \
36                  {\
37                   equal=0;\
38                  }\
39              }\
40         }\
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]); \
51 }
52
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);
54
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);
56
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);
58
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);
60
61 static void D3DXColorTest(void)
62 {
63     D3DXCOLOR color, color1, color2, expected, got;
64     LPD3DXCOLOR funcpointer;
65     FLOAT scale;
66
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;
70
71     scale = 0.3f;
72
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);
84
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);
89
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);
94
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);
106
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);
118
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);
138
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);
148
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);
160 }
161
162 static void D3DXMatrixTest(void)
163 {
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;
172
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;
179
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;
186
187     plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
188
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;
191
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;
197
198     light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3;
199
200     angle = D3DX_PI/3.0f;
201
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);
216
217 /*____________D3DXMatrixfDeterminant_____________*/
218     expectedfloat = -147888.0f;
219     gotfloat = D3DXMatrixfDeterminant(&mat);
220     ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
221
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);
233
234 /*____________D3DXMatrixIsIdentity______________*/
235     expected = FALSE;
236     memset(&mat3, 0, sizeof(mat3));
237     got = D3DXMatrixIsIdentity(&mat3);
238     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
239     D3DXMatrixIdentity(&mat3);
240     expected = TRUE;
241     got = D3DXMatrixIsIdentity(&mat3);
242     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
243     U(mat3).m[0][0] = 0.000009f;
244     expected = FALSE;
245     got = D3DXMatrixIsIdentity(&mat3);
246     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
247     /* Test the NULL case */
248     expected = FALSE;
249     got = D3DXMatrixIsIdentity(NULL);
250     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
251
252 /*____________D3DXMatrixLookatLH_______________*/
253     U(expectedmat).m[0][0] = -0.822465f; U(expectedmat).m[0][1] = -0.409489f; U(expectedmat).m[0][2] = -0.394803f; U(expectedmat).m[0][3] = 0.0f;
254     U(expectedmat).m[1][0] = -0.555856f; U(expectedmat).m[1][1] = 0.431286f; U(expectedmat).m[1][2] = 0.710645f; U(expectedmat).m[1][3] = 0.0f;
255     U(expectedmat).m[2][0] = -0.120729f; U(expectedmat).m[2][1] = 0.803935f; U(expectedmat).m[2][2] = -0.582335f; U(expectedmat).m[2][3] = 0.0f;
256     U(expectedmat).m[3][0] = 4.494634f; U(expectedmat).m[3][1] = 0.809719f; U(expectedmat).m[3][2] = 10.060076f; U(expectedmat).m[3][3] = 1.0f;
257     D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
258     expect_mat(expectedmat,gotmat);
259
260 /*____________D3DXMatrixLookatRH_______________*/
261     U(expectedmat).m[0][0] = 0.822465f; U(expectedmat).m[0][1] = -0.409489f; U(expectedmat).m[0][2] = 0.394803f; U(expectedmat).m[0][3] = 0.0f;
262     U(expectedmat).m[1][0] = 0.555856f; U(expectedmat).m[1][1] = 0.431286f; U(expectedmat).m[1][2] = -0.710645f; U(expectedmat).m[1][3] = 0.0f;
263     U(expectedmat).m[2][0] = 0.120729f; U(expectedmat).m[2][1] = 0.803935f; U(expectedmat).m[2][2] = 0.582335f; U(expectedmat).m[2][3] = 0.0f;
264     U(expectedmat).m[3][0] = -4.494634f; U(expectedmat).m[3][1] = 0.809719f; U(expectedmat).m[3][2] = -10.060076f; U(expectedmat).m[3][3] = 1.0f;
265     D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
266     expect_mat(expectedmat,gotmat);
267
268 /*____________D3DXMatrixMultiply______________*/
269     U(expectedmat).m[0][0] = 73.0f; U(expectedmat).m[0][1] = 193.0f; U(expectedmat).m[0][2] = -197.0f; U(expectedmat).m[0][3] = -77.0f;
270     U(expectedmat).m[1][0] = 231.0f; U(expectedmat).m[1][1] = 551.0f; U(expectedmat).m[1][2] = -489.0f; U(expectedmat).m[1][3] = -169.0;
271     U(expectedmat).m[2][0] = 239.0f; U(expectedmat).m[2][1] = 523.0f; U(expectedmat).m[2][2] = -400.0f; U(expectedmat).m[2][3] = -116.0f;
272     U(expectedmat).m[3][0] = -164.0f; U(expectedmat).m[3][1] = -320.0f; U(expectedmat).m[3][2] = 187.0f; U(expectedmat).m[3][3] = 31.0f;
273     D3DXMatrixMultiply(&gotmat,&mat,&mat2);
274     expect_mat(expectedmat,gotmat);
275
276 /*____________D3DXMatrixMultiplyTranspose____*/
277     U(expectedmat).m[0][0] = 73.0f; U(expectedmat).m[0][1] = 231.0f; U(expectedmat).m[0][2] = 239.0f; U(expectedmat).m[0][3] = -164.0f;
278     U(expectedmat).m[1][0] = 193.0f; U(expectedmat).m[1][1] = 551.0f; U(expectedmat).m[1][2] = 523.0f; U(expectedmat).m[1][3] = -320.0;
279     U(expectedmat).m[2][0] = -197.0f; U(expectedmat).m[2][1] = -489.0f; U(expectedmat).m[2][2] = -400.0f; U(expectedmat).m[2][3] = 187.0f;
280     U(expectedmat).m[3][0] = -77.0f; U(expectedmat).m[3][1] = -169.0f; U(expectedmat).m[3][2] = -116.0f; U(expectedmat).m[3][3] = 31.0f;
281     D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
282     expect_mat(expectedmat,gotmat);
283
284 /*____________D3DXMatrixOrthoLH_______________*/
285     U(expectedmat).m[0][0] = 0.8f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
286     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.270270f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
287     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.151515f; U(expectedmat).m[2][3] = 0.0f;
288     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -0.484848f; U(expectedmat).m[3][3] = 1.0f;
289     D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
290     expect_mat(expectedmat,gotmat);
291
292 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
293     U(expectedmat).m[0][0] = 3.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
294     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.180180f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
295     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.045662f; U(expectedmat).m[2][3] = 0.0f;
296     U(expectedmat).m[3][0] = -1.727272f; U(expectedmat).m[3][1] = -0.567568f; U(expectedmat).m[3][2] = 0.424658f; U(expectedmat).m[3][3] = 1.0f;
297     D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
298     expect_mat(expectedmat,gotmat);
299
300 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
301     U(expectedmat).m[0][0] = 3.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
302     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.180180f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
303     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.045662f; U(expectedmat).m[2][3] = 0.0f;
304     U(expectedmat).m[3][0] = -1.727272f; U(expectedmat).m[3][1] = -0.567568f; U(expectedmat).m[3][2] = 0.424658f; U(expectedmat).m[3][3] = 1.0f;
305     D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
306     expect_mat(expectedmat,gotmat);
307
308 /*____________D3DXMatrixOrthoRH_______________*/
309     U(expectedmat).m[0][0] = 0.8f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
310     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.270270f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
311     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.151515f; U(expectedmat).m[2][3] = 0.0f;
312     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -0.484848f; U(expectedmat).m[3][3] = 1.0f;
313     D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
314     expect_mat(expectedmat,gotmat);
315
316 /*____________D3DXMatrixPerspectiveFovLH_______________*/
317     U(expectedmat).m[0][0] = 13.288858f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
318     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 9.966644f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
319     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.783784f; U(expectedmat).m[2][3] = 1.0f;
320     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
321     D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
322     expect_mat(expectedmat,gotmat);
323
324 /*____________D3DXMatrixPerspectiveFovRH_______________*/
325     U(expectedmat).m[0][0] = 13.288858f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
326     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 9.966644f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
327     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.783784f; U(expectedmat).m[2][3] = -1.0f;
328     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
329     D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
330     expect_mat(expectedmat,gotmat);
331
332 /*____________D3DXMatrixPerspectiveLH_______________*/
333     U(expectedmat).m[0][0] = -24.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
334     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = -6.4f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
335     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.783784f; U(expectedmat).m[2][3] = 1.0f;
336     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
337     D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
338     expect_mat(expectedmat,gotmat);
339
340 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
341     U(expectedmat).m[0][0] = 11.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
342     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.576577f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
343     U(expectedmat).m[2][0] = -1.727273f; U(expectedmat).m[2][1] = -0.567568f; U(expectedmat).m[2][2] = 0.840796f; U(expectedmat).m[2][3] = 1.0f;
344     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -2.690547f; U(expectedmat).m[3][3] = 0.0f;
345     D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
346     expect_mat(expectedmat,gotmat);
347
348 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
349     U(expectedmat).m[0][0] = 11.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
350     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.576577f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
351     U(expectedmat).m[2][0] = 1.727273f; U(expectedmat).m[2][1] = 0.567568f; U(expectedmat).m[2][2] = -0.840796f; U(expectedmat).m[2][3] = -1.0f;
352     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -2.690547f; U(expectedmat).m[3][3] = 0.0f;
353     D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
354     expect_mat(expectedmat,gotmat);
355
356 /*____________D3DXMatrixPerspectiveRH_______________*/
357     U(expectedmat).m[0][0] = -24.0f; U(expectedmat).m[0][1] = -0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
358     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = -6.4f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
359     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.783784f; U(expectedmat).m[2][3] = -1.0f;
360     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
361     D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
362     expect_mat(expectedmat,gotmat);
363
364 /*____________D3DXMatrixReflect______________*/
365     U(expectedmat).m[0][0] = 0.307692f; U(expectedmat).m[0][1] = -0.230769f; U(expectedmat).m[0][2] = 0.923077f; U(expectedmat).m[0][3] = 0.0f;
366     U(expectedmat).m[1][0] = -0.230769; U(expectedmat).m[1][1] = 0.923077f; U(expectedmat).m[1][2] = 0.307693f; U(expectedmat).m[1][3] = 0.0f;
367     U(expectedmat).m[2][0] = 0.923077f; U(expectedmat).m[2][1] = 0.307693f; U(expectedmat).m[2][2] = -0.230769f; U(expectedmat).m[2][3] = 0.0f;
368     U(expectedmat).m[3][0] = 1.615385f; U(expectedmat).m[3][1] = 0.538462f; U(expectedmat).m[3][2] = -2.153846f; U(expectedmat).m[3][3] = 1.0f;
369     D3DXMatrixReflect(&gotmat,&plane);
370     expect_mat(expectedmat,gotmat);
371
372 /*____________D3DXMatrixRotationAxis_____*/
373     U(expectedmat).m[0][0] = 0.508475f; U(expectedmat).m[0][1] = 0.763805f; U(expectedmat).m[0][2] = 0.397563f; U(expectedmat).m[0][3] = 0.0f;
374     U(expectedmat).m[1][0] = -0.814652f; U(expectedmat).m[1][1] = 0.576271f; U(expectedmat).m[1][2] = -0.065219f; U(expectedmat).m[1][3] = 0.0f;
375     U(expectedmat).m[2][0] = -0.278919f; U(expectedmat).m[2][1] = -0.290713f; U(expectedmat).m[2][2] = 0.915254f; U(expectedmat).m[2][3] = 0.0f;
376     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
377     D3DXMatrixRotationAxis(&gotmat,&axis,angle);
378     expect_mat(expectedmat,gotmat);
379
380 /*____________D3DXMatrixRotationQuaternion______________*/
381     U(expectedmat).m[0][0] = -129.0f; U(expectedmat).m[0][1] = -162.0f; U(expectedmat).m[0][2] = -74.0f; U(expectedmat).m[0][3] = 0.0f;
382     U(expectedmat).m[1][0] = 146.0f; U(expectedmat).m[1][1] = -99.0f; U(expectedmat).m[1][2] = -78.0f; U(expectedmat).m[1][3] = 0.0f;
383     U(expectedmat).m[2][0] = 102.0f; U(expectedmat).m[2][1] = -34.0f; U(expectedmat).m[2][2] = -33.0f; U(expectedmat).m[2][3] = 0.0f;
384     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
385     D3DXMatrixRotationQuaternion(&gotmat,&q);
386     expect_mat(expectedmat,gotmat);
387
388 /*____________D3DXMatrixRotationX______________*/
389     U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
390     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 0.5f; U(expectedmat).m[1][2] = sqrt(3.0f)/2.0f; U(expectedmat).m[1][3] = 0.0f;
391     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = -sqrt(3.0f)/2.0f; U(expectedmat).m[2][2] = 0.5f; U(expectedmat).m[2][3] = 0.0f;
392     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
393     D3DXMatrixRotationX(&gotmat,angle);
394     expect_mat(expectedmat,gotmat);
395
396 /*____________D3DXMatrixRotationY______________*/
397     U(expectedmat).m[0][0] = 0.5f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = -sqrt(3.0f)/2.0f; U(expectedmat).m[0][3] = 0.0f;
398     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
399     U(expectedmat).m[2][0] = sqrt(3.0f)/2.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.5f; U(expectedmat).m[2][3] = 0.0f;
400     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
401     D3DXMatrixRotationY(&gotmat,angle);
402     expect_mat(expectedmat,gotmat);
403
404 /*____________D3DXMatrixRotationYawPitchRoll____*/
405     U(expectedmat).m[0][0] = 0.888777f; U(expectedmat).m[0][1] = 0.091875f; U(expectedmat).m[0][2] = -0.449037f; U(expectedmat).m[0][3] = 0.0f;
406     U(expectedmat).m[1][0] = 0.351713f; U(expectedmat).m[1][1] = 0.491487f; U(expectedmat).m[1][2] = 0.796705f; U(expectedmat).m[1][3] = 0.0f;
407     U(expectedmat).m[2][0] = 0.293893f; U(expectedmat).m[2][1] = -0.866025f; U(expectedmat).m[2][2] = 0.404509f; U(expectedmat).m[2][3] = 0.0f;
408     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
409     D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
410     expect_mat(expectedmat,gotmat);
411
412 /*____________D3DXMatrixRotationZ______________*/
413     U(expectedmat).m[0][0] = 0.5f; U(expectedmat).m[0][1] = sqrt(3.0f)/2.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
414     U(expectedmat).m[1][0] = -sqrt(3.0f)/2.0f; U(expectedmat).m[1][1] = 0.5f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
415     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 1.0f; U(expectedmat).m[2][3] = 0.0f;
416     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
417     D3DXMatrixRotationZ(&gotmat,angle);
418     expect_mat(expectedmat,gotmat);
419
420 /*____________D3DXMatrixScaling______________*/
421     U(expectedmat).m[0][0] = 0.69f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
422     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 0.53f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
423     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 4.11f; U(expectedmat).m[2][3] = 0.0f;
424     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
425     D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
426     expect_mat(expectedmat,gotmat);
427
428 /*____________D3DXMatrixShadow______________*/
429     U(expectedmat).m[0][0] = 12.786773f; U(expectedmat).m[0][1] = 5.000961f; U(expectedmat).m[0][2] = 4.353778f; U(expectedmat).m[0][3] = 3.706595f;
430     U(expectedmat).m[1][0] = 1.882715; U(expectedmat).m[1][1] = 8.805615f; U(expectedmat).m[1][2] = 1.451259f; U(expectedmat).m[1][3] = 1.235532f;
431     U(expectedmat).m[2][0] = -7.530860f; U(expectedmat).m[2][1] = -6.667949f; U(expectedmat).m[2][2] = 1.333590f; U(expectedmat).m[2][3] = -4.942127f;
432     U(expectedmat).m[3][0] = -13.179006f; U(expectedmat).m[3][1] = -11.668910f; U(expectedmat).m[3][2] = -10.158816f; U(expectedmat).m[3][3] = -1.510094f;
433     D3DXMatrixShadow(&gotmat,&light,&plane);
434     expect_mat(expectedmat,gotmat);
435
436 /*____________D3DXMatrixTransformation______________*/
437     U(expectedmat).m[0][0] = -0.2148f; U(expectedmat).m[0][1] = 1.3116f; U(expectedmat).m[0][2] = 0.4752f; U(expectedmat).m[0][3] = 0.0f;
438     U(expectedmat).m[1][0] = 0.9504f; U(expectedmat).m[1][1] = -0.8836f; U(expectedmat).m[1][2] = 0.9244f; U(expectedmat).m[1][3] = 0.0f;
439     U(expectedmat).m[2][0] = 1.0212f; U(expectedmat).m[2][1] = 0.1936f; U(expectedmat).m[2][2] = -1.3588f; U(expectedmat).m[2][3] = 0.0f;
440     U(expectedmat).m[3][0] = 18.2985f; U(expectedmat).m[3][1] = -29.624001f; U(expectedmat).m[3][2] = 15.683499f; U(expectedmat).m[3][3] = 1.0f;
441     D3DXMatrixTransformation(&gotmat,&at,&q,NULL,&eye,&r,&last);
442     expect_mat(expectedmat,gotmat);
443
444 /*____________D3DXMatrixTranslation______________*/
445     U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
446     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
447     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 1.0f; U(expectedmat).m[2][3] = 0.0f;
448     U(expectedmat).m[3][0] = 0.69f; U(expectedmat).m[3][1] = 0.53f; U(expectedmat).m[3][2] = 4.11f; U(expectedmat).m[3][3] = 1.0f;
449     D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
450     expect_mat(expectedmat,gotmat);
451
452 /*____________D3DXMatrixTranspose______________*/
453     U(expectedmat).m[0][0] = 10.0f; U(expectedmat).m[0][1] = 11.0f; U(expectedmat).m[0][2] = 19.0f; U(expectedmat).m[0][3] = 2.0f;
454     U(expectedmat).m[1][0] = 5.0; U(expectedmat).m[1][1] = 20.0f; U(expectedmat).m[1][2] = -21.0f; U(expectedmat).m[1][3] = 3.0f;
455     U(expectedmat).m[2][0] = 7.0f; U(expectedmat).m[2][1] = 16.0f; U(expectedmat).m[2][2] = 30.f; U(expectedmat).m[2][3] = -4.0f;
456     U(expectedmat).m[3][0] = 8.0f; U(expectedmat).m[3][1] = 33.0f; U(expectedmat).m[3][2] = 43.0f; U(expectedmat).m[3][3] = -40.0f;
457     D3DXMatrixTranspose(&gotmat,&mat);
458     expect_mat(expectedmat,gotmat);
459 }
460
461 static void D3DXPlaneTest(void)
462 {
463     D3DXMATRIX mat;
464     D3DXPLANE expectedplane, gotplane, nulplane, plane;
465     D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
466     LPD3DXVECTOR3 funcpointer;
467     D3DXVECTOR4 vec;
468     FLOAT expected, got;
469
470     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
471     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
472     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
473     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
474     U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
475     U(mat).m[3][3] = -40.0f;
476
477     plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
478
479     vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
480
481 /*_______________D3DXPlaneDot________________*/
482     expected = 42.0f;
483     got = D3DXPlaneDot(&plane,&vec),
484     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
485     expected = 0.0f;
486     got = D3DXPlaneDot(NULL,&vec),
487     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
488     expected = 0.0f;
489     got = D3DXPlaneDot(NULL,NULL),
490     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
491
492 /*_______________D3DXPlaneDotCoord________________*/
493     expected = -28.0f;
494     got = D3DXPlaneDotCoord(&plane,&vec),
495     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
496     expected = 0.0f;
497     got = D3DXPlaneDotCoord(NULL,&vec),
498     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
499     expected = 0.0f;
500     got = D3DXPlaneDotCoord(NULL,NULL),
501     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
502
503 /*_______________D3DXPlaneDotNormal______________*/
504     expected = -35.0f;
505     got = D3DXPlaneDotNormal(&plane,&vec),
506     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
507     expected = 0.0f;
508     got = D3DXPlaneDotNormal(NULL,&vec),
509     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
510     expected = 0.0f;
511     got = D3DXPlaneDotNormal(NULL,NULL),
512     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
513
514 /*_______________D3DXPlaneFromPointNormal_______*/
515     vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
516     vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
517     expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
518     D3DXPlaneFromPointNormal(&gotplane,&vec1,&vec2);
519     expect_plane(expectedplane, gotplane);
520
521 /*_______________D3DXPlaneFromPoints_______*/
522     vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
523     vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
524     vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
525     expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
526     D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
527     expect_plane(expectedplane, gotplane);
528     /* Test if 2 vectors are parallels */
529     vec3.x = 1.0f; vec3.y = 1.0f; vec3.z = 2.0f;
530     expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
531     D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
532     expect_plane(expectedplane, gotplane);
533
534 /*_______________D3DXPlaneIntersectLine___________*/
535     vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
536     vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
537     expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
538     D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
539     expect_vec3(expectedvec, gotvec);
540     /* Test a parallel line */
541     vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
542     vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
543     expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
544     funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
545     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
546
547 /*_______________D3DXPlaneNormalize______________*/
548     expectedplane.a = -3.0f/sqrt(26.0f); expectedplane.b = -1.0f/sqrt(26.0f); expectedplane.c = 4.0f/sqrt(26.0f); expectedplane.d = 7.0/sqrt(26.0f);
549     D3DXPlaneNormalize(&gotplane, &plane);
550     expect_plane(expectedplane, gotplane);
551     nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
552     expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
553     D3DXPlaneNormalize(&gotplane, &nulplane);
554     expect_plane(expectedplane, gotplane);
555     nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
556     expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
557     D3DXPlaneNormalize(&gotplane, &nulplane);
558     expect_plane(expectedplane, gotplane);
559
560 /*_______________D3DXPlaneTransform____________*/
561     expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
562     D3DXPlaneTransform(&gotplane,&plane,&mat);
563     expect_plane(expectedplane, gotplane);
564 }
565
566 static void D3X8QuaternionTest(void)
567 {
568     D3DXMATRIX mat;
569     D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, q, r, s, t, u;
570     LPD3DXQUATERNION funcpointer;
571     D3DXVECTOR3 axis, expectedvec;
572     FLOAT angle, expected, got, scale, scale2;
573     BOOL expectedbool, gotbool;
574
575     nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
576     q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
577     r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
578     t.x = -1111.0f, t.y= 111.0f; t.z = -11.0f; t.w = 1.0f;
579     u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
580
581     scale = 0.3f;
582     scale2 = 0.78f;
583
584 /*_______________D3DXQuaternionBaryCentric________________________*/
585     expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
586     D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
587     expect_vec4(expectedquat,gotquat);
588
589 /*_______________D3DXQuaternionConjugate________________*/
590     expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
591     D3DXQuaternionConjugate(&gotquat,&q);
592     expect_vec4(expectedquat,gotquat);
593     /* Test the NULL case */
594     funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
595     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
596     funcpointer = D3DXQuaternionConjugate(NULL,NULL);
597     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
598
599 /*_______________D3DXQuaternionDot______________________*/
600     expected = 55.0f;
601     got = D3DXQuaternionDot(&q,&r);
602     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
603     /* Tests the case NULL */
604     expected=0.0f;
605     got = D3DXQuaternionDot(NULL,&r);
606     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
607     expected=0.0f;
608     got = D3DXQuaternionDot(NULL,NULL);
609     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
610
611 /*_______________D3DXQuaternionExp______________________________*/
612     expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
613     D3DXQuaternionExp(&gotquat,&q);
614     expect_vec4(expectedquat,gotquat);
615     /* Test the null quaternion */
616     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
617     D3DXQuaternionExp(&gotquat,&nul);
618     expect_vec4(expectedquat,gotquat);
619     /* Test the case where the norm of the quaternion is <1 */
620     Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
621     expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
622     D3DXQuaternionExp(&gotquat,&Nq1);
623     expect_vec4(expectedquat,gotquat);
624
625 /*_______________D3DXQuaternionIdentity________________*/
626     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
627     D3DXQuaternionIdentity(&gotquat);
628     expect_vec4(expectedquat,gotquat);
629     /* Test the NULL case */
630     funcpointer = D3DXQuaternionIdentity(NULL);
631     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
632
633 /*_______________D3DXQuaternionInverse________________________*/
634     expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
635     D3DXQuaternionInverse(&gotquat,&q);
636     expect_vec4(expectedquat,gotquat);
637     /* test the null quaternion */
638     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
639     D3DXQuaternionInverse(&gotquat,&nul);
640     expect_vec4(expectedquat,gotquat);
641
642 /*_______________D3DXQuaternionIsIdentity________________*/
643     s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
644     expectedbool = TRUE;
645     gotbool = D3DXQuaternionIsIdentity(&s);
646     ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
647     s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
648     expectedbool = FALSE;
649     gotbool = D3DXQuaternionIsIdentity(&q);
650     ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
651     /* Test the NULL case */
652     gotbool = D3DXQuaternionIsIdentity(NULL);
653     ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
654
655 /*_______________D3DXQuaternionLength__________________________*/
656    expected = 11.0f;
657    got = D3DXQuaternionLength(&q);
658    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
659    /* Tests the case NULL */
660     expected=0.0f;
661     got = D3DXQuaternionLength(NULL);
662     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
663
664 /*_______________D3DXQuaternionLengthSq________________________*/
665     expected = 121.0f;
666     got = D3DXQuaternionLengthSq(&q);
667     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
668     /* Tests the case NULL */
669     expected=0.0f;
670     got = D3DXQuaternionLengthSq(NULL);
671     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
672
673 /*_______________D3DXQuaternionLn______________________________*/
674     expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
675     D3DXQuaternionLn(&gotquat,&q);
676     expect_vec4(expectedquat,gotquat);
677     expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
678     D3DXQuaternionLn(&gotquat,&r);
679     expect_vec4(expectedquat,gotquat);
680     Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
681     expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
682     D3DXQuaternionLn(&gotquat,&Nq);
683     expect_vec4(expectedquat,gotquat);
684     /* Test the cas where the norm of the quaternion is <1 */
685     Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
686     expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
687     D3DXQuaternionLn(&gotquat,&Nq1);
688     todo_wine{ expect_vec4(expectedquat,gotquat) };
689
690 /*_______________D3DXQuaternionMultiply________________________*/
691     expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
692     D3DXQuaternionMultiply(&gotquat,&q,&r);
693     expect_vec4(expectedquat,gotquat);
694
695 /*_______________D3DXQuaternionNormalize________________________*/
696     expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
697     D3DXQuaternionNormalize(&gotquat,&q);
698     expect_vec4(expectedquat,gotquat);
699     /* Test the nul quaternion */
700     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
701     D3DXQuaternionNormalize(&gotquat,&nul);
702     expect_vec4(expectedquat,gotquat);
703
704 /*_______________D3DXQuaternionRotationAxis___________________*/
705     axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
706     angle = D3DX_PI/3.0f;
707     expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
708     D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
709     expect_vec4(expectedquat,gotquat);
710  /* Test the nul quaternion */
711     axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
712     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
713     D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
714     expect_vec4(expectedquat,gotquat);
715
716 /*_______________D3DXQuaternionRotationMatrix___________________*/
717     /* test when the trace is >0 */
718     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
719     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
720     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
721     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
722     U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
723     U(mat).m[3][3] = 48.0f;
724     expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
725     D3DXQuaternionRotationMatrix(&gotquat,&mat);
726     expect_vec4(expectedquat,gotquat);
727     /* test the case when the greater element is (2,2) */
728     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
729     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
730     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
731     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
732     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
733     U(mat).m[3][3] = 48.0f;
734     expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
735     D3DXQuaternionRotationMatrix(&gotquat,&mat);
736     expect_vec4(expectedquat,gotquat);
737     /* test the case when the greater element is (1,1) */
738     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
739     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
740     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
741     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
742     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
743     U(mat).m[3][3] = 48.0f;
744     expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
745     D3DXQuaternionRotationMatrix(&gotquat,&mat);
746     expect_vec4(expectedquat,gotquat);
747     /* test the case when the trace is near 0 in a matrix which is not a rotation */
748     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
749     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
750     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
751     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
752     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.9f;
753     U(mat).m[3][3] = 48.0f;
754     expectedquat.x = 1.709495f; expectedquat.y = 2.339872f; expectedquat.z = -0.534217f; expectedquat.w = 1.282122f;
755     D3DXQuaternionRotationMatrix(&gotquat,&mat);
756     expect_vec4(expectedquat,gotquat);
757     /* test the case when the trace is 0.49 in a matrix which is not a rotation */
758     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
759     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
760     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
761     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
762     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.51f;
763     U(mat).m[3][3] = 48.0f;
764     expectedquat.x = 1.724923f; expectedquat.y = 2.318944f; expectedquat.z = -0.539039f; expectedquat.w = 1.293692f;
765     D3DXQuaternionRotationMatrix(&gotquat,&mat);
766     expect_vec4(expectedquat,gotquat);
767     /* test the case when the trace is 0.51 in a matrix which is not a rotation */
768     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
769     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
770     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
771     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
772     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.49f;
773     U(mat).m[3][3] = 48.0f;
774     expectedquat.x = 1.725726f; expectedquat.y = 2.317865f; expectedquat.z = -0.539289f; expectedquat.w = 1.294294f;
775     D3DXQuaternionRotationMatrix(&gotquat,&mat);
776     expect_vec4(expectedquat,gotquat);
777     /* test the case when the trace is 0.99 in a matrix which is not a rotation */
778     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
779     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
780     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
781     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
782     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.01f;
783     U(mat).m[3][3] = 48.0f;
784     expectedquat.x = 1.745328f; expectedquat.y = 2.291833f; expectedquat.z = -0.545415f; expectedquat.w = 1.308996f;
785     D3DXQuaternionRotationMatrix(&gotquat,&mat);
786     expect_vec4(expectedquat,gotquat);
787     /* test the case when the trace is 1.0 in a matrix which is not a rotation */
788     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
789     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
790     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
791     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
792     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.0f;
793     U(mat).m[3][3] = 48.0f;
794     expectedquat.x = 1.745743f; expectedquat.y = 2.291288f; expectedquat.z = -0.545545f; expectedquat.w = 1.309307f;
795     D3DXQuaternionRotationMatrix(&gotquat,&mat);
796     expect_vec4(expectedquat,gotquat);
797     /* test the case when the trace is 1.01 in a matrix which is not a rotation */
798     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
799     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
800     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
801     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
802     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.01f;
803     U(mat).m[3][3] = 48.0f;
804     expectedquat.x = 18.408188f; expectedquat.y = 5.970223f; expectedquat.z = -2.985111f; expectedquat.w = 0.502494f;
805     D3DXQuaternionRotationMatrix(&gotquat,&mat);
806     expect_vec4(expectedquat,gotquat);
807     /* test the case when the trace is 1.5 in a matrix which is not a rotation */
808     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
809     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
810     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
811     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
812     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.5f;
813     U(mat).m[3][3] = 48.0f;
814     expectedquat.x = 15.105186f; expectedquat.y = 4.898980f; expectedquat.z = -2.449490f; expectedquat.w = 0.612372f;
815     D3DXQuaternionRotationMatrix(&gotquat,&mat);
816     expect_vec4(expectedquat,gotquat);
817     /* test the case when the trace is 1.7 in a matrix which is not a rotation */
818     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
819     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
820     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
821     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
822     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.70f;
823     U(mat).m[3][3] = 48.0f;
824     expectedquat.x = 14.188852f; expectedquat.y = 4.601790f; expectedquat.z = -2.300895f; expectedquat.w = 0.651920f;
825     D3DXQuaternionRotationMatrix(&gotquat,&mat);
826     expect_vec4(expectedquat,gotquat);
827     /* test the case when the trace is 1.99 in a matrix which is not a rotation */
828     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
829     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
830     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
831     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
832     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.99f;
833     U(mat).m[3][3] = 48.0f;
834     expectedquat.x = 13.114303f; expectedquat.y = 4.253287f; expectedquat.z = -2.126644f; expectedquat.w = 0.705337f;
835     D3DXQuaternionRotationMatrix(&gotquat,&mat);
836     expect_vec4(expectedquat,gotquat);
837     /* test the case when the trace is 2.0 in a matrix which is not a rotation */
838     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
839     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
840     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
841     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
842     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 2.0f;
843     U(mat).m[3][3] = 48.0f;
844     expectedquat.x = 10.680980f; expectedquat.y = 3.464102f; expectedquat.z = -1.732051f; expectedquat.w = 0.866025f;
845     D3DXQuaternionRotationMatrix(&gotquat,&mat);
846     expect_vec4(expectedquat,gotquat);
847
848 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
849     expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
850     D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
851     expect_vec4(expectedquat,gotquat);
852
853 /*_______________D3DXQuaternionSlerp________________________*/
854     expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
855     D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
856     expect_vec4(expectedquat,gotquat);
857     expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
858     D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
859     expect_vec4(expectedquat,gotquat);
860
861 /*_______________D3DXQuaternionSquad________________________*/
862     expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
863     D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
864     expect_vec4(expectedquat,gotquat);
865
866 /*_______________D3DXQuaternionToAxisAngle__________________*/
867     Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
868     expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
869     expected = 2.197869f;
870     D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
871     expect_vec3(expectedvec,axis);
872     ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
873     /* Test if |w|>1.0f */
874     expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
875     expected = 0.0f;
876     D3DXQuaternionToAxisAngle(&q,&axis,&angle);
877     expect_vec3(expectedvec,axis);
878     ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
879     /* Test the null quaternion */
880     expectedvec.x = 1.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
881     expected = 0.0f;
882     D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
883     expect_vec3(expectedvec,axis);
884     ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
885 }
886
887 static void D3X8Vector2Test(void)
888 {
889     D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
890     LPD3DXVECTOR2 funcpointer;
891     D3DXVECTOR4 expectedtrans, gottrans;
892     D3DXMATRIX mat;
893     FLOAT coeff1, coeff2, expected, got, scale;
894
895     nul.x = 0.0f; nul.y = 0.0f;
896     u.x = 3.0f; u.y = 4.0f;
897     v.x = -7.0f; v.y = 9.0f;
898     w.x = 4.0f; w.y = -3.0f;
899     x.x = 2.0f; x.y = -11.0f;
900
901     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;
902     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;
903     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;
904     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;
905
906     coeff1 = 2.0f; coeff2 = 5.0f;
907     scale = -6.5f;
908
909 /*_______________D3DXVec2Add__________________________*/
910     expectedvec.x = -4.0f; expectedvec.y = 13.0f;
911     D3DXVec2Add(&gotvec,&u,&v);
912     expect_vec(expectedvec,gotvec);
913     /* Tests the case NULL */
914     funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
915     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
916     funcpointer = D3DXVec2Add(NULL,NULL,NULL);
917     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
918
919 /*_______________D3DXVec2BaryCentric___________________*/
920     expectedvec.x = -12.0f; expectedvec.y = -21.0f;
921     D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
922     expect_vec(expectedvec,gotvec);
923
924 /*_______________D3DXVec2CatmullRom____________________*/
925     expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
926     D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
927     expect_vec(expectedvec,gotvec);
928
929 /*_______________D3DXVec2CCW__________________________*/
930    expected = 55.0f;
931    got = D3DXVec2CCW(&u,&v);
932    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
933    /* Tests the case NULL */
934     expected=0.0f;
935     got = D3DXVec2CCW(NULL,&v);
936     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
937     expected=0.0f;
938     got = D3DXVec2CCW(NULL,NULL);
939     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
940
941 /*_______________D3DXVec2Dot__________________________*/
942     expected = 15.0f;
943     got = D3DXVec2Dot(&u,&v);
944     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
945     /* Tests the case NULL */
946     expected=0.0f;
947     got = D3DXVec2Dot(NULL,&v);
948     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
949     expected=0.0f;
950     got = D3DXVec2Dot(NULL,NULL);
951     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
952
953 /*_______________D3DXVec2Hermite__________________________*/
954     expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
955     D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
956     expect_vec(expectedvec,gotvec);
957
958 /*_______________D3DXVec2Length__________________________*/
959    expected = 5.0f;
960    got = D3DXVec2Length(&u);
961    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
962    /* Tests the case NULL */
963     expected=0.0f;
964     got = D3DXVec2Length(NULL);
965     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
966
967 /*_______________D3DXVec2LengthSq________________________*/
968    expected = 25.0f;
969    got = D3DXVec2LengthSq(&u);
970    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
971    /* Tests the case NULL */
972     expected=0.0f;
973     got = D3DXVec2LengthSq(NULL);
974     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
975
976 /*_______________D3DXVec2Lerp__________________________*/
977    expectedvec.x = 68.0f; expectedvec.y = -28.5f;
978    D3DXVec2Lerp(&gotvec,&u,&v,scale);
979    expect_vec(expectedvec,gotvec);
980    /* Tests the case NULL */
981     funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
982     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
983     funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
984     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
985
986 /*_______________D3DXVec2Maximize__________________________*/
987    expectedvec.x = 3.0f; expectedvec.y = 9.0f;
988    D3DXVec2Maximize(&gotvec,&u,&v);
989    expect_vec(expectedvec,gotvec);
990    /* Tests the case NULL */
991     funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
992     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
993     funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
994     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
995
996 /*_______________D3DXVec2Minimize__________________________*/
997     expectedvec.x = -7.0f; expectedvec.y = 4.0f;
998     D3DXVec2Minimize(&gotvec,&u,&v);
999     expect_vec(expectedvec,gotvec);
1000     /* Tests the case NULL */
1001     funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
1002     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1003     funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
1004     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1005
1006 /*_______________D3DXVec2Normalize_________________________*/
1007     expectedvec.x = 0.6f; expectedvec.y = 0.8f;
1008     D3DXVec2Normalize(&gotvec,&u);
1009     expect_vec(expectedvec,gotvec);
1010     /* Test the nul vector */
1011     expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1012     D3DXVec2Normalize(&gotvec,&nul);
1013     expect_vec(expectedvec,gotvec);
1014
1015 /*_______________D3DXVec2Scale____________________________*/
1016     expectedvec.x = -19.5f; expectedvec.y = -26.0f;
1017     D3DXVec2Scale(&gotvec,&u,scale);
1018     expect_vec(expectedvec,gotvec);
1019     /* Tests the case NULL */
1020     funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
1021     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1022     funcpointer = D3DXVec2Scale(NULL,NULL,scale);
1023     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1024
1025 /*_______________D3DXVec2Subtract__________________________*/
1026    expectedvec.x = 10.0f; expectedvec.y = -5.0f;
1027    D3DXVec2Subtract(&gotvec,&u,&v);
1028    expect_vec(expectedvec,gotvec);
1029    /* Tests the case NULL */
1030     funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
1031     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1032     funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
1033     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1034
1035 /*_______________D3DXVec2Transform_______________________*/
1036     expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
1037     D3DXVec2Transform(&gottrans,&u,&mat);
1038     expect_vec4(expectedtrans,gottrans);
1039
1040 /*_______________D3DXVec2TransformCoord_______________________*/
1041     expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
1042     D3DXVec2TransformCoord(&gotvec,&u,&mat);
1043     expect_vec(expectedvec,gotvec);
1044     /* Test the nul projected vector */
1045     nulproj.x = -2.0f; nulproj.y = -1.0f;
1046     expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1047     D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
1048     expect_vec(expectedvec,gotvec);
1049
1050  /*_______________D3DXVec2TransformNormal______________________*/
1051     expectedvec.x = 23.0f; expectedvec.y = 30.0f;
1052     D3DXVec2TransformNormal(&gotvec,&u,&mat);
1053     expect_vec(expectedvec,gotvec);
1054 }
1055
1056 static void D3X8Vector3Test(void)
1057 {
1058     D3DVIEWPORT8 viewport;
1059     D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
1060     LPD3DXVECTOR3 funcpointer;
1061     D3DXVECTOR4 expectedtrans, gottrans;
1062     D3DXMATRIX mat, projection, view, world;
1063     FLOAT coeff1, coeff2, expected, got, scale;
1064
1065     nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
1066     u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
1067     v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
1068     w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
1069     x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
1070
1071     viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
1072     viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
1073
1074     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;
1075     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;
1076     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;
1077     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;
1078
1079     U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
1080     U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
1081     U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
1082     U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
1083     U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
1084     U(view).m[3][3] = -40.0f;
1085
1086     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;
1087     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;
1088     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;
1089     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;
1090
1091     coeff1 = 2.0f; coeff2 = 5.0f;
1092     scale = -6.5f;
1093
1094 /*_______________D3DXVec3Add__________________________*/
1095     expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
1096     D3DXVec3Add(&gotvec,&u,&v);
1097     expect_vec3(expectedvec,gotvec);
1098     /* Tests the case NULL */
1099     funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
1100     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1101     funcpointer = D3DXVec3Add(NULL,NULL,NULL);
1102     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1103
1104 /*_______________D3DXVec3BaryCentric___________________*/
1105     expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
1106     D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1107
1108     expect_vec3(expectedvec,gotvec);
1109
1110 /*_______________D3DXVec3CatmullRom____________________*/
1111     expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
1112     D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1113     expect_vec3(expectedvec,gotvec);
1114
1115 /*_______________D3DXVec3Cross________________________*/
1116     expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
1117     D3DXVec3Cross(&gotvec,&u,&v);
1118     expect_vec3(expectedvec,gotvec);
1119     /* Tests the case NULL */
1120     funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
1121     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1122     funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
1123     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1124
1125 /*_______________D3DXVec3Dot__________________________*/
1126     expected = -8.0f;
1127     got = D3DXVec3Dot(&u,&v);
1128     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1129     /* Tests the case NULL */
1130     expected=0.0f;
1131     got = D3DXVec3Dot(NULL,&v);
1132     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1133     expected=0.0f;
1134     got = D3DXVec3Dot(NULL,NULL);
1135     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1136
1137 /*_______________D3DXVec3Hermite__________________________*/
1138     expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
1139     D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
1140     expect_vec3(expectedvec,gotvec);
1141
1142 /*_______________D3DXVec3Length__________________________*/
1143    expected = 11.0f;
1144    got = D3DXVec3Length(&u);
1145    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1146    /* Tests the case NULL */
1147     expected=0.0f;
1148     got = D3DXVec3Length(NULL);
1149     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1150
1151 /*_______________D3DXVec3LengthSq________________________*/
1152     expected = 121.0f;
1153     got = D3DXVec3LengthSq(&u);
1154     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1155    /* Tests the case NULL */
1156     expected=0.0f;
1157     got = D3DXVec3LengthSq(NULL);
1158     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1159
1160 /*_______________D3DXVec3Lerp__________________________*/
1161     expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
1162     D3DXVec3Lerp(&gotvec,&u,&v,scale);
1163     expect_vec3(expectedvec,gotvec);
1164     /* Tests the case NULL */
1165     funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
1166     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1167     funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
1168     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1169
1170 /*_______________D3DXVec3Maximize__________________________*/
1171     expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
1172     D3DXVec3Maximize(&gotvec,&u,&v);
1173     expect_vec3(expectedvec,gotvec);
1174     /* Tests the case NULL */
1175     funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
1176     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1177     funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
1178     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1179
1180 /*_______________D3DXVec3Minimize__________________________*/
1181     expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
1182     D3DXVec3Minimize(&gotvec,&u,&v);
1183     expect_vec3(expectedvec,gotvec);
1184     /* Tests the case NULL */
1185     funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
1186     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1187     funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
1188     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1189
1190 /*_______________D3DXVec3Normalize_________________________*/
1191     expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
1192     D3DXVec3Normalize(&gotvec,&u);
1193     expect_vec3(expectedvec,gotvec);
1194     /* Test the nul vector */
1195     expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1196     D3DXVec3Normalize(&gotvec,&nul);
1197     expect_vec3(expectedvec,gotvec);
1198
1199 /*_______________D3DXVec3Project_________________________*/
1200     expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
1201     D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1202     D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
1203     expect_vec3(expectedvec,gotvec);
1204
1205 /*_______________D3DXVec3Scale____________________________*/
1206     expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
1207     D3DXVec3Scale(&gotvec,&u,scale);
1208     expect_vec3(expectedvec,gotvec);
1209     /* Tests the case NULL */
1210     funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
1211     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1212     funcpointer = D3DXVec3Scale(NULL,NULL,scale);
1213     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1214
1215 /*_______________D3DXVec3Subtract_______________________*/
1216     expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
1217     D3DXVec3Subtract(&gotvec,&u,&v);
1218     expect_vec3(expectedvec,gotvec);
1219     /* Tests the case NULL */
1220     funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
1221     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1222     funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
1223     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1224
1225 /*_______________D3DXVec3Transform_______________________*/
1226     expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
1227     D3DXVec3Transform(&gottrans,&u,&mat);
1228     expect_vec4(expectedtrans,gottrans);
1229
1230 /*_______________D3DXVec3TransformCoord_______________________*/
1231     expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
1232     D3DXVec3TransformCoord(&gotvec,&u,&mat);
1233     expect_vec3(expectedvec,gotvec);
1234     /* Test the nul projected vector */
1235     nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
1236     expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1237     D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
1238     expect_vec3(expectedvec,gotvec);
1239
1240 /*_______________D3DXVec3TransformNormal______________________*/
1241     expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
1242     D3DXVec3TransformNormal(&gotvec,&u,&mat);
1243     expect_vec3(expectedvec,gotvec);
1244
1245 /*_______________D3DXVec3Unproject_________________________*/
1246     expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
1247     D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1248     D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
1249     expect_vec3(expectedvec,gotvec);
1250 }
1251
1252 static void D3X8Vector4Test(void)
1253 {
1254     D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
1255     LPD3DXVECTOR4 funcpointer;
1256     D3DXVECTOR4 expectedtrans, gottrans;
1257     D3DXMATRIX mat;
1258     FLOAT coeff1, coeff2, expected, got, scale;
1259
1260     nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
1261     u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
1262     v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
1263     w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
1264     x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
1265
1266     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;
1267     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;
1268     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;
1269     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;
1270
1271     coeff1 = 2.0f; coeff2 = 5.0;
1272     scale = -6.5f;
1273
1274 /*_______________D3DXVec4Add__________________________*/
1275     expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
1276     D3DXVec4Add(&gotvec,&u,&v);
1277     expect_vec4(expectedvec,gotvec);
1278     /* Tests the case NULL */
1279     funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
1280     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1281     funcpointer = D3DXVec4Add(NULL,NULL,NULL);
1282     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1283
1284 /*_______________D3DXVec4BaryCentric____________________*/
1285     expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z =  -44.0f; expectedvec.w = -41.0f;
1286     D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1287     expect_vec4(expectedvec,gotvec);
1288
1289 /*_______________D3DXVec4CatmullRom____________________*/
1290     expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
1291     D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1292     expect_vec4(expectedvec,gotvec);
1293
1294 /*_______________D3DXVec4Cross_________________________*/
1295     expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
1296     D3DXVec4Cross(&gotvec,&u,&v,&w);
1297     expect_vec4(expectedvec,gotvec);
1298
1299 /*_______________D3DXVec4Dot__________________________*/
1300     expected = 55.0f;
1301     got = D3DXVec4Dot(&u,&v);
1302     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1303     /* Tests the case NULL */
1304     expected=0.0f;
1305     got = D3DXVec4Dot(NULL,&v);
1306     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1307     expected=0.0f;
1308     got = D3DXVec4Dot(NULL,NULL);
1309     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1310
1311 /*_______________D3DXVec4Hermite_________________________*/
1312     expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
1313     D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
1314     expect_vec4(expectedvec,gotvec);
1315
1316 /*_______________D3DXVec4Length__________________________*/
1317    expected = 11.0f;
1318    got = D3DXVec4Length(&u);
1319    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1320    /* Tests the case NULL */
1321     expected=0.0f;
1322     got = D3DXVec4Length(NULL);
1323     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1324
1325 /*_______________D3DXVec4LengthSq________________________*/
1326     expected = 121.0f;
1327     got = D3DXVec4LengthSq(&u);
1328     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1329     /* Tests the case NULL */
1330     expected=0.0f;
1331     got = D3DXVec4LengthSq(NULL);
1332     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1333
1334 /*_______________D3DXVec4Lerp__________________________*/
1335     expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5;  expectedvec.w = 29.5;
1336     D3DXVec4Lerp(&gotvec,&u,&v,scale);
1337     expect_vec4(expectedvec,gotvec);
1338     /* Tests the case NULL */
1339     funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
1340     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1341     funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
1342     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1343
1344 /*_______________D3DXVec4Maximize__________________________*/
1345     expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
1346     D3DXVec4Maximize(&gotvec,&u,&v);
1347     expect_vec4(expectedvec,gotvec);
1348     /* Tests the case NULL */
1349     funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
1350     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1351     funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
1352     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1353
1354 /*_______________D3DXVec4Minimize__________________________*/
1355     expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
1356     D3DXVec4Minimize(&gotvec,&u,&v);
1357     expect_vec4(expectedvec,gotvec);
1358     /* Tests the case NULL */
1359     funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
1360     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1361     funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
1362     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1363
1364 /*_______________D3DXVec4Normalize_________________________*/
1365     expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
1366     D3DXVec4Normalize(&gotvec,&u);
1367     expect_vec4(expectedvec,gotvec);
1368     /* Test the nul vector */
1369     expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
1370     D3DXVec4Normalize(&gotvec,&nul);
1371     expect_vec4(expectedvec,gotvec);
1372
1373 /*_______________D3DXVec4Scale____________________________*/
1374     expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
1375     D3DXVec4Scale(&gotvec,&u,scale);
1376     expect_vec4(expectedvec,gotvec);
1377     /* Tests the case NULL */
1378     funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
1379     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1380     funcpointer = D3DXVec4Scale(NULL,NULL,scale);
1381     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1382
1383 /*_______________D3DXVec4Subtract__________________________*/
1384     expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
1385     D3DXVec4Subtract(&gotvec,&u,&v);
1386     expect_vec4(expectedvec,gotvec);
1387     /* Tests the case NULL */
1388     funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
1389     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1390     funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
1391     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1392
1393 /*_______________D3DXVec4Transform_______________________*/
1394     expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
1395     D3DXVec4Transform(&gottrans,&u,&mat);
1396     expect_vec4(expectedtrans,gottrans);
1397 }
1398
1399 START_TEST(math)
1400 {
1401     D3DXColorTest();
1402     D3DXMatrixTest();
1403     D3DXPlaneTest();
1404     D3X8QuaternionTest();
1405     D3X8Vector2Test();
1406     D3X8Vector3Test();
1407     D3X8Vector4Test();
1408 }