2 * Copyright 2007 David Adam
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
24 #define admitted_error 0.0001f
26 #define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(expectedcolor.a-gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
28 static inline BOOL
compare_matrix(const D3DXMATRIX
*m1
, const D3DXMATRIX
*m2
)
32 for (i
= 0; i
< 4; ++i
)
34 for (j
= 0; j
< 4; ++j
)
36 if (fabs(U(*m1
).m
[i
][j
] - U(*m2
).m
[i
][j
]) > admitted_error
)
44 #define expect_mat(expectedmat, gotmat) \
46 const D3DXMATRIX *__m1 = (expectedmat); \
47 const D3DXMATRIX *__m2 = (gotmat); \
48 ok(compare_matrix(__m1, __m2), "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \
49 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
50 U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
51 U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
52 U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
53 U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
54 U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
55 U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
56 U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
57 U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
60 #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);
62 #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);
64 #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);
66 #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);
68 static void D3DXColorTest(void)
70 D3DXCOLOR color
, color1
, color2
, expected
, got
;
71 LPD3DXCOLOR funcpointer
;
74 color
.r
= 0.2f
; color
.g
= 0.75f
; color
.b
= 0.41f
; color
.a
= 0.93f
;
75 color1
.r
= 0.6f
; color1
.g
= 0.55f
; color1
.b
= 0.23f
; color1
.a
= 0.82f
;
76 color2
.r
= 0.3f
; color2
.g
= 0.5f
; color2
.b
= 0.76f
; color2
.a
= 0.11f
;
80 /*_______________D3DXColorAdd________________*/
81 expected
.r
= 0.9f
; expected
.g
= 1.05f
; expected
.b
= 0.99f
, expected
.a
= 0.93f
;
82 D3DXColorAdd(&got
,&color1
,&color2
);
83 expect_color(expected
,got
);
84 /* Test the NULL case */
85 funcpointer
= D3DXColorAdd(&got
,NULL
,&color2
);
86 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
87 funcpointer
= D3DXColorAdd(NULL
,NULL
,&color2
);
88 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
89 funcpointer
= D3DXColorAdd(NULL
,NULL
,NULL
);
90 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
92 /*_______________D3DXColorAdjustContrast______*/
93 expected
.r
= 0.41f
; expected
.g
= 0.575f
; expected
.b
= 0.473f
, expected
.a
= 0.93f
;
94 D3DXColorAdjustContrast(&got
,&color
,scale
);
95 expect_color(expected
,got
);
97 /*_______________D3DXColorAdjustSaturation______*/
98 expected
.r
= 0.486028f
; expected
.g
= 0.651028f
; expected
.b
= 0.549028f
, expected
.a
= 0.93f
;
99 D3DXColorAdjustSaturation(&got
,&color
,scale
);
100 expect_color(expected
,got
);
102 /*_______________D3DXColorLerp________________*/
103 expected
.r
= 0.32f
; expected
.g
= 0.69f
; expected
.b
= 0.356f
; expected
.a
= 0.897f
;
104 D3DXColorLerp(&got
,&color
,&color1
,scale
);
105 expect_color(expected
,got
);
106 /* Test the NULL case */
107 funcpointer
= D3DXColorLerp(&got
,NULL
,&color1
,scale
);
108 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
109 funcpointer
= D3DXColorLerp(NULL
,NULL
,&color1
,scale
);
110 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
111 funcpointer
= D3DXColorLerp(NULL
,NULL
,NULL
,scale
);
112 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
114 /*_______________D3DXColorModulate________________*/
115 expected
.r
= 0.18f
; expected
.g
= 0.275f
; expected
.b
= 0.1748f
; expected
.a
= 0.0902f
;
116 D3DXColorModulate(&got
,&color1
,&color2
);
117 expect_color(expected
,got
);
118 /* Test the NULL case */
119 funcpointer
= D3DXColorModulate(&got
,NULL
,&color2
);
120 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
121 funcpointer
= D3DXColorModulate(NULL
,NULL
,&color2
);
122 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
123 funcpointer
= D3DXColorModulate(NULL
,NULL
,NULL
);
124 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
126 /*_______________D3DXColorNegative________________*/
127 expected
.r
= 0.8f
; expected
.g
= 0.25f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
128 D3DXColorNegative(&got
,&color
);
129 expect_color(got
,expected
);
130 /* Test the greater than 1 case */
131 color1
.r
= 0.2f
; color1
.g
= 1.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
132 expected
.r
= 0.8f
; expected
.g
= -0.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
133 D3DXColorNegative(&got
,&color1
);
134 expect_color(got
,expected
);
135 /* Test the negative case */
136 color1
.r
= 0.2f
; color1
.g
= -0.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
137 expected
.r
= 0.8f
; expected
.g
= 1.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
138 D3DXColorNegative(&got
,&color1
);
139 expect_color(got
,expected
);
140 /* Test the NULL case */
141 funcpointer
= D3DXColorNegative(&got
,NULL
);
142 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
143 funcpointer
= D3DXColorNegative(NULL
,NULL
);
144 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
146 /*_______________D3DXColorScale________________*/
147 expected
.r
= 0.06f
; expected
.g
= 0.225f
; expected
.b
= 0.123f
; expected
.a
= 0.279f
;
148 D3DXColorScale(&got
,&color
,scale
);
149 expect_color(expected
,got
);
150 /* Test the NULL case */
151 funcpointer
= D3DXColorScale(&got
,NULL
,scale
);
152 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
153 funcpointer
= D3DXColorScale(NULL
,NULL
,scale
);
154 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
156 /*_______________D3DXColorSubtract_______________*/
157 expected
.r
= -0.1f
; expected
.g
= 0.25f
; expected
.b
= -0.35f
, expected
.a
= 0.82f
;
158 D3DXColorSubtract(&got
,&color
,&color2
);
159 expect_color(expected
,got
);
160 /* Test the NULL case */
161 funcpointer
= D3DXColorSubtract(&got
,NULL
,&color2
);
162 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
163 funcpointer
= D3DXColorSubtract(NULL
,NULL
,&color2
);
164 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
165 funcpointer
= D3DXColorSubtract(NULL
,NULL
,NULL
);
166 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
169 static void D3DXMatrixTest(void)
171 D3DXMATRIX expectedmat
, gotmat
, mat
, mat2
, mat3
;
172 LPD3DXMATRIX funcpointer
;
175 D3DXVECTOR3 at
, axis
, eye
, last
, scaling
;
178 FLOAT angle
, determinant
, expectedfloat
, gotfloat
;
180 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
181 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
182 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
183 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
184 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
185 U(mat
).m
[3][3] = -40.0f
;
187 U(mat2
).m
[0][0] = 1.0f
; U(mat2
).m
[1][0] = 2.0f
; U(mat2
).m
[2][0] = 3.0f
;
188 U(mat2
).m
[3][0] = 4.0f
; U(mat2
).m
[0][1] = 5.0f
; U(mat2
).m
[1][1] = 6.0f
;
189 U(mat2
).m
[2][1] = 7.0f
; U(mat2
).m
[3][1] = 8.0f
; U(mat2
).m
[0][2] = -8.0f
;
190 U(mat2
).m
[1][2] = -7.0f
; U(mat2
).m
[2][2] = -6.0f
; U(mat2
).m
[3][2] = -5.0f
;
191 U(mat2
).m
[0][3] = -4.0f
; U(mat2
).m
[1][3] = -3.0f
; U(mat2
).m
[2][3] = -2.0f
;
192 U(mat2
).m
[3][3] = -1.0f
;
194 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
196 q
.x
= 1.0f
; q
.y
= -4.0f
; q
.z
=7.0f
; q
.w
= -11.0f
;
197 r
.x
= 0.87f
; r
.y
= 0.65f
; r
.z
=0.43f
; r
.w
= 0.21f
;
199 at
.x
= -2.0f
; at
.y
= 13.0f
; at
.z
= -9.0f
;
200 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
201 eye
.x
= 8.0f
; eye
.y
= -5.0f
; eye
.z
= 5.75f
;
202 last
.x
= 9.7f
; last
.y
= -8.6; last
.z
= 1.3f
;
203 scaling
.x
= 0.03f
; scaling
.y
=0.05f
; scaling
.z
= 0.06f
;
205 light
.x
= 9.6f
; light
.y
= 8.5f
; light
.z
= 7.4; light
.w
= 6.3;
207 angle
= D3DX_PI
/3.0f
;
209 /*____________D3DXMatrixAffineTransformation______*/
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] = -1239.0f
; U(expectedmat
).m
[3][1] = 667.0f
; U(expectedmat
).m
[3][2] = 567.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
214 D3DXMatrixAffineTransformation(&gotmat
,3.56f
,&at
,&q
,&axis
);
215 expect_mat(&expectedmat
, &gotmat
);
216 /* Test the NULL case */
217 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
;
218 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
;
219 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
;
220 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
;
221 D3DXMatrixAffineTransformation(&gotmat
,3.56f
,NULL
,&q
,&axis
);
222 expect_mat(&expectedmat
, &gotmat
);
224 /*____________D3DXMatrixfDeterminant_____________*/
225 expectedfloat
= -147888.0f
;
226 gotfloat
= D3DXMatrixfDeterminant(&mat
);
227 ok(fabs( gotfloat
- expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, gotfloat
);
229 /*____________D3DXMatrixInverse______________*/
230 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
;
231 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
;
232 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
;
233 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
;
234 expectedfloat
= -147888.0f
;
235 D3DXMatrixInverse(&gotmat
,&determinant
,&mat
);
236 expect_mat(&expectedmat
, &gotmat
);
237 ok(fabs( determinant
- expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, determinant
);
238 funcpointer
= D3DXMatrixInverse(&gotmat
,NULL
,&mat2
);
239 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
241 /*____________D3DXMatrixIsIdentity______________*/
243 memset(&mat3
, 0, sizeof(mat3
));
244 got
= D3DXMatrixIsIdentity(&mat3
);
245 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
246 D3DXMatrixIdentity(&mat3
);
248 got
= D3DXMatrixIsIdentity(&mat3
);
249 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
250 U(mat3
).m
[0][0] = 0.000009f
;
252 got
= D3DXMatrixIsIdentity(&mat3
);
253 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
254 /* Test the NULL case */
256 got
= D3DXMatrixIsIdentity(NULL
);
257 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
259 /*____________D3DXMatrixLookatLH_______________*/
260 U(expectedmat
).m
[0][0] = -0.822465f
; U(expectedmat
).m
[0][1] = -0.409489f
; U(expectedmat
).m
[0][2] = -0.394803f
; U(expectedmat
).m
[0][3] = 0.0f
;
261 U(expectedmat
).m
[1][0] = -0.555856f
; U(expectedmat
).m
[1][1] = 0.431286f
; U(expectedmat
).m
[1][2] = 0.710645f
; U(expectedmat
).m
[1][3] = 0.0f
;
262 U(expectedmat
).m
[2][0] = -0.120729f
; U(expectedmat
).m
[2][1] = 0.803935f
; U(expectedmat
).m
[2][2] = -0.582335f
; U(expectedmat
).m
[2][3] = 0.0f
;
263 U(expectedmat
).m
[3][0] = 4.494634f
; U(expectedmat
).m
[3][1] = 0.809719f
; U(expectedmat
).m
[3][2] = 10.060076f
; U(expectedmat
).m
[3][3] = 1.0f
;
264 D3DXMatrixLookAtLH(&gotmat
,&eye
,&at
,&axis
);
265 expect_mat(&expectedmat
, &gotmat
);
267 /*____________D3DXMatrixLookatRH_______________*/
268 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
;
269 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
;
270 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
;
271 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
;
272 D3DXMatrixLookAtRH(&gotmat
,&eye
,&at
,&axis
);
273 expect_mat(&expectedmat
, &gotmat
);
275 /*____________D3DXMatrixMultiply______________*/
276 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
;
277 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;
278 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
;
279 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
;
280 D3DXMatrixMultiply(&gotmat
,&mat
,&mat2
);
281 expect_mat(&expectedmat
, &gotmat
);
283 /*____________D3DXMatrixMultiplyTranspose____*/
284 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
;
285 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;
286 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
;
287 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
;
288 D3DXMatrixMultiplyTranspose(&gotmat
,&mat
,&mat2
);
289 expect_mat(&expectedmat
, &gotmat
);
291 /*____________D3DXMatrixOrthoLH_______________*/
292 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
;
293 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
;
294 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
;
295 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
;
296 D3DXMatrixOrthoLH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
297 expect_mat(&expectedmat
, &gotmat
);
299 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
300 U(expectedmat
).m
[0][0] = 3.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
301 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.180180f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
302 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.045662f
; U(expectedmat
).m
[2][3] = 0.0f
;
303 U(expectedmat
).m
[3][0] = -1.727272f
; U(expectedmat
).m
[3][1] = -0.567568f
; U(expectedmat
).m
[3][2] = 0.424658f
; U(expectedmat
).m
[3][3] = 1.0f
;
304 D3DXMatrixOrthoOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
305 expect_mat(&expectedmat
, &gotmat
);
307 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
308 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
;
309 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
;
310 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
;
311 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
;
312 D3DXMatrixOrthoOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
313 expect_mat(&expectedmat
, &gotmat
);
315 /*____________D3DXMatrixOrthoRH_______________*/
316 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
;
317 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
;
318 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
;
319 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
;
320 D3DXMatrixOrthoRH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
321 expect_mat(&expectedmat
, &gotmat
);
323 /*____________D3DXMatrixPerspectiveFovLH_______________*/
324 U(expectedmat
).m
[0][0] = 13.288858f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
325 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 9.966644f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
326 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.783784f
; U(expectedmat
).m
[2][3] = 1.0f
;
327 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
328 D3DXMatrixPerspectiveFovLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
329 expect_mat(&expectedmat
, &gotmat
);
331 /*____________D3DXMatrixPerspectiveFovRH_______________*/
332 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
;
333 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
;
334 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.783784f
; U(expectedmat
).m
[2][3] = -1.0f
;
335 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
336 D3DXMatrixPerspectiveFovRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
337 expect_mat(&expectedmat
, &gotmat
);
339 /*____________D3DXMatrixPerspectiveLH_______________*/
340 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
;
341 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
;
342 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
;
343 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
;
344 D3DXMatrixPerspectiveLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
345 expect_mat(&expectedmat
, &gotmat
);
347 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
348 U(expectedmat
).m
[0][0] = 11.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
349 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.576577f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
350 U(expectedmat
).m
[2][0] = -1.727273f
; U(expectedmat
).m
[2][1] = -0.567568f
; U(expectedmat
).m
[2][2] = 0.840796f
; U(expectedmat
).m
[2][3] = 1.0f
;
351 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -2.690547f
; U(expectedmat
).m
[3][3] = 0.0f
;
352 D3DXMatrixPerspectiveOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
353 expect_mat(&expectedmat
, &gotmat
);
355 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
356 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
;
357 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
;
358 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
;
359 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
;
360 D3DXMatrixPerspectiveOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
361 expect_mat(&expectedmat
, &gotmat
);
363 /*____________D3DXMatrixPerspectiveRH_______________*/
364 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
;
365 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
;
366 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
;
367 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
;
368 D3DXMatrixPerspectiveRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
369 expect_mat(&expectedmat
, &gotmat
);
371 /*____________D3DXMatrixReflect______________*/
372 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
;
373 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
;
374 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
;
375 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
;
376 D3DXMatrixReflect(&gotmat
,&plane
);
377 expect_mat(&expectedmat
, &gotmat
);
379 /*____________D3DXMatrixRotationAxis_____*/
380 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
;
381 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
;
382 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
;
383 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
384 D3DXMatrixRotationAxis(&gotmat
,&axis
,angle
);
385 expect_mat(&expectedmat
, &gotmat
);
387 /*____________D3DXMatrixRotationQuaternion______________*/
388 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
;
389 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
;
390 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
;
391 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
392 D3DXMatrixRotationQuaternion(&gotmat
,&q
);
393 expect_mat(&expectedmat
, &gotmat
);
395 /*____________D3DXMatrixRotationX______________*/
396 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
;
397 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
;
398 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
;
399 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
400 D3DXMatrixRotationX(&gotmat
,angle
);
401 expect_mat(&expectedmat
, &gotmat
);
403 /*____________D3DXMatrixRotationY______________*/
404 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
;
405 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
;
406 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
;
407 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
408 D3DXMatrixRotationY(&gotmat
,angle
);
409 expect_mat(&expectedmat
, &gotmat
);
411 /*____________D3DXMatrixRotationYawPitchRoll____*/
412 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
;
413 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
;
414 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
;
415 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
416 D3DXMatrixRotationYawPitchRoll(&gotmat
, 3.0f
*angle
/5.0f
, angle
, 3.0f
*angle
/17.0f
);
417 expect_mat(&expectedmat
, &gotmat
);
419 /*____________D3DXMatrixRotationZ______________*/
420 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
;
421 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
;
422 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
;
423 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
424 D3DXMatrixRotationZ(&gotmat
,angle
);
425 expect_mat(&expectedmat
, &gotmat
);
427 /*____________D3DXMatrixScaling______________*/
428 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
;
429 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
;
430 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
;
431 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
;
432 D3DXMatrixScaling(&gotmat
,0.69f
,0.53f
,4.11f
);
433 expect_mat(&expectedmat
, &gotmat
);
435 /*____________D3DXMatrixShadow______________*/
436 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
;
437 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
;
438 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
;
439 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
;
440 D3DXMatrixShadow(&gotmat
,&light
,&plane
);
441 expect_mat(&expectedmat
, &gotmat
);
443 /*____________D3DXMatrixTransformation______________*/
444 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
;
445 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
;
446 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
;
447 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
;
448 D3DXMatrixTransformation(&gotmat
,&at
,&q
,NULL
,&eye
,&r
,&last
);
449 expect_mat(&expectedmat
, &gotmat
);
451 /*____________D3DXMatrixTranslation______________*/
452 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
;
453 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
;
454 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
;
455 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
;
456 D3DXMatrixTranslation(&gotmat
,0.69f
,0.53f
,4.11f
);
457 expect_mat(&expectedmat
, &gotmat
);
459 /*____________D3DXMatrixTranspose______________*/
460 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
;
461 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
;
462 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
;
463 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
;
464 D3DXMatrixTranspose(&gotmat
,&mat
);
465 expect_mat(&expectedmat
, &gotmat
);
468 static void D3DXPlaneTest(void)
471 D3DXPLANE expectedplane
, gotplane
, nulplane
, plane
;
472 D3DXVECTOR3 expectedvec
, gotvec
, vec1
, vec2
, vec3
;
473 LPD3DXVECTOR3 funcpointer
;
477 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
478 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
479 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
480 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
481 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
482 U(mat
).m
[3][3] = -40.0f
;
484 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
486 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
488 /*_______________D3DXPlaneDot________________*/
490 got
= D3DXPlaneDot(&plane
,&vec
),
491 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
493 got
= D3DXPlaneDot(NULL
,&vec
),
494 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
496 got
= D3DXPlaneDot(NULL
,NULL
),
497 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
499 /*_______________D3DXPlaneDotCoord________________*/
501 got
= D3DXPlaneDotCoord(&plane
,&vec
),
502 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
504 got
= D3DXPlaneDotCoord(NULL
,&vec
),
505 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
507 got
= D3DXPlaneDotCoord(NULL
,NULL
),
508 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
510 /*_______________D3DXPlaneDotNormal______________*/
512 got
= D3DXPlaneDotNormal(&plane
,&vec
),
513 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
515 got
= D3DXPlaneDotNormal(NULL
,&vec
),
516 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
518 got
= D3DXPlaneDotNormal(NULL
,NULL
),
519 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
521 /*_______________D3DXPlaneFromPointNormal_______*/
522 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
523 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
524 expectedplane
.a
= 17.0f
; expectedplane
.b
= 31.0f
; expectedplane
.c
= 24.0f
; expectedplane
.d
= -950.0f
;
525 D3DXPlaneFromPointNormal(&gotplane
,&vec1
,&vec2
);
526 expect_plane(expectedplane
, gotplane
);
528 /*_______________D3DXPlaneFromPoints_______*/
529 vec1
.x
= 1.0f
; vec1
.y
= 2.0f
; vec1
.z
= 3.0f
;
530 vec2
.x
= 1.0f
; vec2
.y
= -6.0f
; vec2
.z
= -5.0f
;
531 vec3
.x
= 83.0f
; vec3
.y
= 74.0f
; vec3
.z
= 65.0f
;
532 expectedplane
.a
= 0.085914f
; expectedplane
.b
= -0.704492f
; expectedplane
.c
= 0.704492f
; expectedplane
.d
= -0.790406f
;
533 D3DXPlaneFromPoints(&gotplane
,&vec1
,&vec2
,&vec3
);
534 expect_plane(expectedplane
, gotplane
);
535 /* Test if 2 vectors are parallels */
536 vec3
.x
= 1.0f
; vec3
.y
= 1.0f
; vec3
.z
= 2.0f
;
537 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
538 D3DXPlaneFromPoints(&gotplane
,&vec1
,&vec2
,&vec3
);
539 expect_plane(expectedplane
, gotplane
);
541 /*_______________D3DXPlaneIntersectLine___________*/
542 vec1
.x
= 9.0f
; vec1
.y
= 6.0f
; vec1
.z
= 3.0f
;
543 vec2
.x
= 2.0f
; vec2
.y
= 5.0f
; vec2
.z
= 8.0f
;
544 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
545 D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
546 expect_vec3(expectedvec
, gotvec
);
547 /* Test a parallel line */
548 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
549 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
550 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
551 funcpointer
= D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
552 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
554 /*_______________D3DXPlaneNormalize______________*/
555 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
);
556 D3DXPlaneNormalize(&gotplane
, &plane
);
557 expect_plane(expectedplane
, gotplane
);
558 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
, nulplane
.c
= 0.0f
; nulplane
.d
= 0.0f
;
559 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
560 D3DXPlaneNormalize(&gotplane
, &nulplane
);
561 expect_plane(expectedplane
, gotplane
);
562 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
, nulplane
.c
= 0.0f
; nulplane
.d
= 4.3f
;
563 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
564 D3DXPlaneNormalize(&gotplane
, &nulplane
);
565 expect_plane(expectedplane
, gotplane
);
567 /*_______________D3DXPlaneTransform____________*/
568 expectedplane
.a
= 49.0f
; expectedplane
.b
= -98.0f
; expectedplane
.c
= 55.0f
; expectedplane
.d
= -165.0f
;
569 D3DXPlaneTransform(&gotplane
,&plane
,&mat
);
570 expect_plane(expectedplane
, gotplane
);
573 static void D3X8QuaternionTest(void)
576 D3DXQUATERNION expectedquat
, gotquat
, Nq
, Nq1
, nul
, q
, r
, s
, t
, u
;
577 LPD3DXQUATERNION funcpointer
;
578 D3DXVECTOR3 axis
, expectedvec
;
579 FLOAT angle
, expected
, got
, scale
, scale2
;
580 BOOL expectedbool
, gotbool
;
582 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
583 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
584 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
585 t
.x
= -1111.0f
, t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
586 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
591 /*_______________D3DXQuaternionBaryCentric________________________*/
592 expectedquat
.x
= -867.444458; expectedquat
.y
= 87.851111f
; expectedquat
.z
= -9.937778f
; expectedquat
.w
= 3.235555f
;
593 D3DXQuaternionBaryCentric(&gotquat
,&q
,&r
,&t
,scale
,scale2
);
594 expect_vec4(expectedquat
,gotquat
);
596 /*_______________D3DXQuaternionConjugate________________*/
597 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
598 D3DXQuaternionConjugate(&gotquat
,&q
);
599 expect_vec4(expectedquat
,gotquat
);
600 /* Test the NULL case */
601 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
602 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
603 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
604 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
606 /*_______________D3DXQuaternionDot______________________*/
608 got
= D3DXQuaternionDot(&q
,&r
);
609 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
610 /* Tests the case NULL */
612 got
= D3DXQuaternionDot(NULL
,&r
);
613 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
615 got
= D3DXQuaternionDot(NULL
,NULL
);
616 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
618 /*_______________D3DXQuaternionExp______________________________*/
619 expectedquat
.x
= -0.216382f
; expectedquat
.y
= -0.432764f
; expectedquat
.z
= -0.8655270f
; expectedquat
.w
= -0.129449f
;
620 D3DXQuaternionExp(&gotquat
,&q
);
621 expect_vec4(expectedquat
,gotquat
);
622 /* Test the null quaternion */
623 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
624 D3DXQuaternionExp(&gotquat
,&nul
);
625 expect_vec4(expectedquat
,gotquat
);
626 /* Test the case where the norm of the quaternion is <1 */
627 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
628 expectedquat
.x
= 0.195366; expectedquat
.y
= 0.097683f
; expectedquat
.z
= 0.293049f
; expectedquat
.w
= 0.930813f
;
629 D3DXQuaternionExp(&gotquat
,&Nq1
);
630 expect_vec4(expectedquat
,gotquat
);
632 /*_______________D3DXQuaternionIdentity________________*/
633 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
634 D3DXQuaternionIdentity(&gotquat
);
635 expect_vec4(expectedquat
,gotquat
);
636 /* Test the NULL case */
637 funcpointer
= D3DXQuaternionIdentity(NULL
);
638 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
640 /*_______________D3DXQuaternionInverse________________________*/
641 expectedquat
.x
= -1.0f
/121.0f
; expectedquat
.y
= -2.0f
/121.0f
; expectedquat
.z
= -4.0f
/121.0f
; expectedquat
.w
= 10.0f
/121.0f
;
642 D3DXQuaternionInverse(&gotquat
,&q
);
643 expect_vec4(expectedquat
,gotquat
);
644 /* test the null quaternion */
645 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
646 D3DXQuaternionInverse(&gotquat
,&nul
);
647 expect_vec4(expectedquat
,gotquat
);
649 /*_______________D3DXQuaternionIsIdentity________________*/
650 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
652 gotbool
= D3DXQuaternionIsIdentity(&s
);
653 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
654 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
655 expectedbool
= FALSE
;
656 gotbool
= D3DXQuaternionIsIdentity(&q
);
657 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
658 /* Test the NULL case */
659 gotbool
= D3DXQuaternionIsIdentity(NULL
);
660 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
662 /*_______________D3DXQuaternionLength__________________________*/
664 got
= D3DXQuaternionLength(&q
);
665 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
666 /* Tests the case NULL */
668 got
= D3DXQuaternionLength(NULL
);
669 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
671 /*_______________D3DXQuaternionLengthSq________________________*/
673 got
= D3DXQuaternionLengthSq(&q
);
674 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
675 /* Tests the case NULL */
677 got
= D3DXQuaternionLengthSq(NULL
);
678 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
680 /*_______________D3DXQuaternionLn______________________________*/
681 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 0.0f
;
682 D3DXQuaternionLn(&gotquat
,&q
);
683 expect_vec4(expectedquat
,gotquat
);
684 expectedquat
.x
= -3.0f
; expectedquat
.y
= 4.0f
; expectedquat
.z
= -5.0f
; expectedquat
.w
= 0.0f
;
685 D3DXQuaternionLn(&gotquat
,&r
);
686 expect_vec4(expectedquat
,gotquat
);
687 Nq
.x
= 1.0f
/11.0f
; Nq
.y
= 2.0f
/11.0f
; Nq
.z
= 4.0f
/11.0f
; Nq
.w
=10.0f
/11.0f
;
688 expectedquat
.x
= 0.093768f
; expectedquat
.y
= 0.187536f
; expectedquat
.z
= 0.375073f
; expectedquat
.w
= 0.0f
;
689 D3DXQuaternionLn(&gotquat
,&Nq
);
690 expect_vec4(expectedquat
,gotquat
);
691 /* Test the cas where the norm of the quaternion is <1 */
692 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
693 expectedquat
.x
= 0.206945f
; expectedquat
.y
= 0.103473f
; expectedquat
.z
= 0.310418f
; expectedquat
.w
= 0.0f
;
694 D3DXQuaternionLn(&gotquat
,&Nq1
);
695 todo_wine
{ expect_vec4(expectedquat
,gotquat
) };
697 /*_______________D3DXQuaternionMultiply________________________*/
698 expectedquat
.x
= 3.0f
; expectedquat
.y
= 61.0f
; expectedquat
.z
= -32.0f
; expectedquat
.w
= 85.0f
;
699 D3DXQuaternionMultiply(&gotquat
,&q
,&r
);
700 expect_vec4(expectedquat
,gotquat
);
702 /*_______________D3DXQuaternionNormalize________________________*/
703 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
704 D3DXQuaternionNormalize(&gotquat
,&q
);
705 expect_vec4(expectedquat
,gotquat
);
706 /* Test the nul quaternion */
707 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
708 D3DXQuaternionNormalize(&gotquat
,&nul
);
709 expect_vec4(expectedquat
,gotquat
);
711 /*_______________D3DXQuaternionRotationAxis___________________*/
712 axis
.x
= 2.0f
; axis
.y
= 7.0; axis
.z
= 13.0f
;
713 angle
= D3DX_PI
/3.0f
;
714 expectedquat
.x
= 0.067116; expectedquat
.y
= 0.234905f
; expectedquat
.z
= 0.436251f
; expectedquat
.w
= 0.866025f
;
715 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
716 expect_vec4(expectedquat
,gotquat
);
717 /* Test the nul quaternion */
718 axis
.x
= 0.0f
; axis
.y
= 0.0; axis
.z
= 0.0f
;
719 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.866025f
;
720 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
721 expect_vec4(expectedquat
,gotquat
);
723 /*_______________D3DXQuaternionRotationMatrix___________________*/
724 /* test when the trace is >0 */
725 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
726 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
727 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
728 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
729 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
730 U(mat
).m
[3][3] = 48.0f
;
731 expectedquat
.x
= 2.368682f
; expectedquat
.y
= 0.768221f
; expectedquat
.z
= -0.384111f
; expectedquat
.w
= 3.905125f
;
732 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
733 expect_vec4(expectedquat
,gotquat
);
734 /* test the case when the greater element is (2,2) */
735 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
736 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
737 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
738 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
739 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = -60.0f
; U(mat
).m
[2][2] = 40.0f
;
740 U(mat
).m
[3][3] = 48.0f
;
741 expectedquat
.x
= 1.233905f
; expectedquat
.y
= -0.237290f
; expectedquat
.z
= 5.267827f
; expectedquat
.w
= -0.284747f
;
742 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
743 expect_vec4(expectedquat
,gotquat
);
744 /* test the case when the greater element is (1,1) */
745 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
746 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
747 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
748 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
749 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 60.0f
; U(mat
).m
[2][2] = -80.0f
;
750 U(mat
).m
[3][3] = 48.0f
;
751 expectedquat
.x
= 0.651031f
; expectedquat
.y
= 6.144103f
; expectedquat
.z
= -0.203447f
; expectedquat
.w
= 0.488273f
;
752 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
753 expect_vec4(expectedquat
,gotquat
);
754 /* test the case when the trace is near 0 in a matrix which is not a rotation */
755 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
756 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
757 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
758 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
759 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.9f
;
760 U(mat
).m
[3][3] = 48.0f
;
761 expectedquat
.x
= 1.709495f
; expectedquat
.y
= 2.339872f
; expectedquat
.z
= -0.534217f
; expectedquat
.w
= 1.282122f
;
762 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
763 expect_vec4(expectedquat
,gotquat
);
764 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
765 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
766 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
767 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
768 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
769 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.51f
;
770 U(mat
).m
[3][3] = 48.0f
;
771 expectedquat
.x
= 1.724923f
; expectedquat
.y
= 2.318944f
; expectedquat
.z
= -0.539039f
; expectedquat
.w
= 1.293692f
;
772 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
773 expect_vec4(expectedquat
,gotquat
);
774 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
775 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
776 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
777 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
778 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
779 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.49f
;
780 U(mat
).m
[3][3] = 48.0f
;
781 expectedquat
.x
= 1.725726f
; expectedquat
.y
= 2.317865f
; expectedquat
.z
= -0.539289f
; expectedquat
.w
= 1.294294f
;
782 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
783 expect_vec4(expectedquat
,gotquat
);
784 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
785 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
786 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
787 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
788 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
789 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.01f
;
790 U(mat
).m
[3][3] = 48.0f
;
791 expectedquat
.x
= 1.745328f
; expectedquat
.y
= 2.291833f
; expectedquat
.z
= -0.545415f
; expectedquat
.w
= 1.308996f
;
792 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
793 expect_vec4(expectedquat
,gotquat
);
794 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
795 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
796 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
797 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
798 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
799 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.0f
;
800 U(mat
).m
[3][3] = 48.0f
;
801 expectedquat
.x
= 1.745743f
; expectedquat
.y
= 2.291288f
; expectedquat
.z
= -0.545545f
; expectedquat
.w
= 1.309307f
;
802 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
803 expect_vec4(expectedquat
,gotquat
);
804 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
805 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
806 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
807 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
808 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
809 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.01f
;
810 U(mat
).m
[3][3] = 48.0f
;
811 expectedquat
.x
= 18.408188f
; expectedquat
.y
= 5.970223f
; expectedquat
.z
= -2.985111f
; expectedquat
.w
= 0.502494f
;
812 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
813 expect_vec4(expectedquat
,gotquat
);
814 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
815 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
816 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
817 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
818 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
819 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.5f
;
820 U(mat
).m
[3][3] = 48.0f
;
821 expectedquat
.x
= 15.105186f
; expectedquat
.y
= 4.898980f
; expectedquat
.z
= -2.449490f
; expectedquat
.w
= 0.612372f
;
822 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
823 expect_vec4(expectedquat
,gotquat
);
824 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
825 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
826 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
827 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
828 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
829 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.70f
;
830 U(mat
).m
[3][3] = 48.0f
;
831 expectedquat
.x
= 14.188852f
; expectedquat
.y
= 4.601790f
; expectedquat
.z
= -2.300895f
; expectedquat
.w
= 0.651920f
;
832 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
833 expect_vec4(expectedquat
,gotquat
);
834 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
835 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
836 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
837 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
838 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
839 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.99f
;
840 U(mat
).m
[3][3] = 48.0f
;
841 expectedquat
.x
= 13.114303f
; expectedquat
.y
= 4.253287f
; expectedquat
.z
= -2.126644f
; expectedquat
.w
= 0.705337f
;
842 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
843 expect_vec4(expectedquat
,gotquat
);
844 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
845 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
846 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
847 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
848 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
849 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 2.0f
;
850 U(mat
).m
[3][3] = 48.0f
;
851 expectedquat
.x
= 10.680980f
; expectedquat
.y
= 3.464102f
; expectedquat
.z
= -1.732051f
; expectedquat
.w
= 0.866025f
;
852 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
853 expect_vec4(expectedquat
,gotquat
);
855 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
856 expectedquat
.x
= 0.303261f
; expectedquat
.y
= 0.262299f
; expectedquat
.z
= 0.410073f
; expectedquat
.w
= 0.819190f
;
857 D3DXQuaternionRotationYawPitchRoll(&gotquat
,D3DX_PI
/4.0f
,D3DX_PI
/11.0f
,D3DX_PI
/3.0f
);
858 expect_vec4(expectedquat
,gotquat
);
860 /*_______________D3DXQuaternionSlerp________________________*/
861 expectedquat
.x
= -0.2f
; expectedquat
.y
= 2.6f
; expectedquat
.z
= 1.3f
; expectedquat
.w
= 9.1f
;
862 D3DXQuaternionSlerp(&gotquat
,&q
,&r
,scale
);
863 expect_vec4(expectedquat
,gotquat
);
864 expectedquat
.x
= 334.0f
; expectedquat
.y
= -31.9f
; expectedquat
.z
= 6.1f
; expectedquat
.w
= 6.7f
;
865 D3DXQuaternionSlerp(&gotquat
,&q
,&t
,scale
);
866 expect_vec4(expectedquat
,gotquat
);
868 /*_______________D3DXQuaternionSquad________________________*/
869 expectedquat
.x
= -156.296f
; expectedquat
.y
= 30.242f
; expectedquat
.z
= -2.5022f
; expectedquat
.w
= 7.3576f
;
870 D3DXQuaternionSquad(&gotquat
,&q
,&r
,&t
,&u
,scale
);
871 expect_vec4(expectedquat
,gotquat
);
873 /*_______________D3DXQuaternionToAxisAngle__________________*/
874 Nq
.x
= 1.0f
/22.0f
; Nq
.y
= 2.0f
/22.0f
; Nq
.z
= 4.0f
/22.0f
; Nq
.w
= 10.0f
/22.0f
;
875 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
;
876 expected
= 2.197869f
;
877 D3DXQuaternionToAxisAngle(&Nq
,&axis
,&angle
);
878 expect_vec3(expectedvec
,axis
);
879 ok(fabs( angle
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
880 /* Test if |w|>1.0f */
881 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
;
883 D3DXQuaternionToAxisAngle(&q
,&axis
,&angle
);
884 expect_vec3(expectedvec
,axis
);
885 ok(fabs( angle
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
886 /* Test the null quaternion */
887 expectedvec
.x
= 1.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
889 D3DXQuaternionToAxisAngle(&nul
,&axis
,&angle
);
890 expect_vec3(expectedvec
,axis
);
891 ok(fabs( angle
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
894 static void D3X8Vector2Test(void)
896 D3DXVECTOR2 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
897 LPD3DXVECTOR2 funcpointer
;
898 D3DXVECTOR4 expectedtrans
, gottrans
;
900 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
902 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
903 u
.x
= 3.0f
; u
.y
= 4.0f
;
904 v
.x
= -7.0f
; v
.y
= 9.0f
;
905 w
.x
= 4.0f
; w
.y
= -3.0f
;
906 x
.x
= 2.0f
; x
.y
= -11.0f
;
908 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
;
909 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
;
910 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
;
911 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
;
913 coeff1
= 2.0f
; coeff2
= 5.0f
;
916 /*_______________D3DXVec2Add__________________________*/
917 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
918 D3DXVec2Add(&gotvec
,&u
,&v
);
919 expect_vec(expectedvec
,gotvec
);
920 /* Tests the case NULL */
921 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
922 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
923 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
924 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
926 /*_______________D3DXVec2BaryCentric___________________*/
927 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
928 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
929 expect_vec(expectedvec
,gotvec
);
931 /*_______________D3DXVec2CatmullRom____________________*/
932 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
933 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
934 expect_vec(expectedvec
,gotvec
);
936 /*_______________D3DXVec2CCW__________________________*/
938 got
= D3DXVec2CCW(&u
,&v
);
939 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
940 /* Tests the case NULL */
942 got
= D3DXVec2CCW(NULL
,&v
);
943 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
945 got
= D3DXVec2CCW(NULL
,NULL
);
946 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
948 /*_______________D3DXVec2Dot__________________________*/
950 got
= D3DXVec2Dot(&u
,&v
);
951 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
952 /* Tests the case NULL */
954 got
= D3DXVec2Dot(NULL
,&v
);
955 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
957 got
= D3DXVec2Dot(NULL
,NULL
);
958 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
960 /*_______________D3DXVec2Hermite__________________________*/
961 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
962 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
963 expect_vec(expectedvec
,gotvec
);
965 /*_______________D3DXVec2Length__________________________*/
967 got
= D3DXVec2Length(&u
);
968 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
969 /* Tests the case NULL */
971 got
= D3DXVec2Length(NULL
);
972 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
974 /*_______________D3DXVec2LengthSq________________________*/
976 got
= D3DXVec2LengthSq(&u
);
977 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
978 /* Tests the case NULL */
980 got
= D3DXVec2LengthSq(NULL
);
981 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
983 /*_______________D3DXVec2Lerp__________________________*/
984 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
985 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
986 expect_vec(expectedvec
,gotvec
);
987 /* Tests the case NULL */
988 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
989 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
990 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
991 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
993 /*_______________D3DXVec2Maximize__________________________*/
994 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
995 D3DXVec2Maximize(&gotvec
,&u
,&v
);
996 expect_vec(expectedvec
,gotvec
);
997 /* Tests the case NULL */
998 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
999 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1000 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
1001 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1003 /*_______________D3DXVec2Minimize__________________________*/
1004 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
1005 D3DXVec2Minimize(&gotvec
,&u
,&v
);
1006 expect_vec(expectedvec
,gotvec
);
1007 /* Tests the case NULL */
1008 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
1009 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1010 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
1011 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1013 /*_______________D3DXVec2Normalize_________________________*/
1014 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
1015 D3DXVec2Normalize(&gotvec
,&u
);
1016 expect_vec(expectedvec
,gotvec
);
1017 /* Test the nul vector */
1018 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
1019 D3DXVec2Normalize(&gotvec
,&nul
);
1020 expect_vec(expectedvec
,gotvec
);
1022 /*_______________D3DXVec2Scale____________________________*/
1023 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
1024 D3DXVec2Scale(&gotvec
,&u
,scale
);
1025 expect_vec(expectedvec
,gotvec
);
1026 /* Tests the case NULL */
1027 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
1028 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1029 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
1030 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1032 /*_______________D3DXVec2Subtract__________________________*/
1033 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
1034 D3DXVec2Subtract(&gotvec
,&u
,&v
);
1035 expect_vec(expectedvec
,gotvec
);
1036 /* Tests the case NULL */
1037 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
1038 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1039 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
1040 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1042 /*_______________D3DXVec2Transform_______________________*/
1043 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
1044 D3DXVec2Transform(&gottrans
,&u
,&mat
);
1045 expect_vec4(expectedtrans
,gottrans
);
1047 /*_______________D3DXVec2TransformCoord_______________________*/
1048 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
1049 D3DXVec2TransformCoord(&gotvec
,&u
,&mat
);
1050 expect_vec(expectedvec
,gotvec
);
1051 /* Test the nul projected vector */
1052 nulproj
.x
= -2.0f
; nulproj
.y
= -1.0f
;
1053 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
1054 D3DXVec2TransformCoord(&gotvec
,&nulproj
,&mat
);
1055 expect_vec(expectedvec
,gotvec
);
1057 /*_______________D3DXVec2TransformNormal______________________*/
1058 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
1059 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
1060 expect_vec(expectedvec
,gotvec
);
1063 static void D3X8Vector3Test(void)
1065 D3DVIEWPORT8 viewport
;
1066 D3DXVECTOR3 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
1067 LPD3DXVECTOR3 funcpointer
;
1068 D3DXVECTOR4 expectedtrans
, gottrans
;
1069 D3DXMATRIX mat
, projection
, view
, world
;
1070 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1072 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
1073 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
1074 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
1075 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
1076 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
1078 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
1079 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
1081 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
;
1082 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
;
1083 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
;
1084 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
;
1086 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
1087 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
1088 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
1089 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
1090 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
1091 U(view
).m
[3][3] = -40.0f
;
1093 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;
1094 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
;
1095 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
;
1096 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
;
1098 coeff1
= 2.0f
; coeff2
= 5.0f
;
1101 /*_______________D3DXVec3Add__________________________*/
1102 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
1103 D3DXVec3Add(&gotvec
,&u
,&v
);
1104 expect_vec3(expectedvec
,gotvec
);
1105 /* Tests the case NULL */
1106 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
1107 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1108 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
1109 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1111 /*_______________D3DXVec3BaryCentric___________________*/
1112 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
1113 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1115 expect_vec3(expectedvec
,gotvec
);
1117 /*_______________D3DXVec3CatmullRom____________________*/
1118 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
1119 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1120 expect_vec3(expectedvec
,gotvec
);
1122 /*_______________D3DXVec3Cross________________________*/
1123 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
1124 D3DXVec3Cross(&gotvec
,&u
,&v
);
1125 expect_vec3(expectedvec
,gotvec
);
1126 /* Tests the case NULL */
1127 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
1128 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1129 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
1130 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1132 /*_______________D3DXVec3Dot__________________________*/
1134 got
= D3DXVec3Dot(&u
,&v
);
1135 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1136 /* Tests the case NULL */
1138 got
= D3DXVec3Dot(NULL
,&v
);
1139 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1141 got
= D3DXVec3Dot(NULL
,NULL
);
1142 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1144 /*_______________D3DXVec3Hermite__________________________*/
1145 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
1146 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1147 expect_vec3(expectedvec
,gotvec
);
1149 /*_______________D3DXVec3Length__________________________*/
1151 got
= D3DXVec3Length(&u
);
1152 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1153 /* Tests the case NULL */
1155 got
= D3DXVec3Length(NULL
);
1156 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1158 /*_______________D3DXVec3LengthSq________________________*/
1160 got
= D3DXVec3LengthSq(&u
);
1161 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1162 /* Tests the case NULL */
1164 got
= D3DXVec3LengthSq(NULL
);
1165 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1167 /*_______________D3DXVec3Lerp__________________________*/
1168 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
1169 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
1170 expect_vec3(expectedvec
,gotvec
);
1171 /* Tests the case NULL */
1172 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
1173 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1174 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
1175 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1177 /*_______________D3DXVec3Maximize__________________________*/
1178 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
1179 D3DXVec3Maximize(&gotvec
,&u
,&v
);
1180 expect_vec3(expectedvec
,gotvec
);
1181 /* Tests the case NULL */
1182 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
1183 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1184 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
1185 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1187 /*_______________D3DXVec3Minimize__________________________*/
1188 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
1189 D3DXVec3Minimize(&gotvec
,&u
,&v
);
1190 expect_vec3(expectedvec
,gotvec
);
1191 /* Tests the case NULL */
1192 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
1193 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1194 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
1195 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1197 /*_______________D3DXVec3Normalize_________________________*/
1198 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
1199 D3DXVec3Normalize(&gotvec
,&u
);
1200 expect_vec3(expectedvec
,gotvec
);
1201 /* Test the nul vector */
1202 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1203 D3DXVec3Normalize(&gotvec
,&nul
);
1204 expect_vec3(expectedvec
,gotvec
);
1206 /*_______________D3DXVec3Project_________________________*/
1207 expectedvec
.x
= 1135.721924f
; expectedvec
.y
= 147.086914f
; expectedvec
.z
= 0.153412f
;
1208 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1209 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1210 expect_vec3(expectedvec
,gotvec
);
1212 /*_______________D3DXVec3Scale____________________________*/
1213 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
1214 D3DXVec3Scale(&gotvec
,&u
,scale
);
1215 expect_vec3(expectedvec
,gotvec
);
1216 /* Tests the case NULL */
1217 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
1218 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1219 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
1220 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1222 /*_______________D3DXVec3Subtract_______________________*/
1223 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
1224 D3DXVec3Subtract(&gotvec
,&u
,&v
);
1225 expect_vec3(expectedvec
,gotvec
);
1226 /* Tests the case NULL */
1227 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
1228 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1229 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
1230 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1232 /*_______________D3DXVec3Transform_______________________*/
1233 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
1234 D3DXVec3Transform(&gottrans
,&u
,&mat
);
1235 expect_vec4(expectedtrans
,gottrans
);
1237 /*_______________D3DXVec3TransformCoord_______________________*/
1238 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
1239 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
1240 expect_vec3(expectedvec
,gotvec
);
1241 /* Test the nul projected vector */
1242 nulproj
.x
= 1.0f
; nulproj
.y
= -1.0f
, nulproj
.z
= -1.0f
;
1243 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1244 D3DXVec3TransformCoord(&gotvec
,&nulproj
,&mat
);
1245 expect_vec3(expectedvec
,gotvec
);
1247 /*_______________D3DXVec3TransformNormal______________________*/
1248 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
1249 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
1250 expect_vec3(expectedvec
,gotvec
);
1252 /*_______________D3DXVec3Unproject_________________________*/
1253 expectedvec
.x
= -2.913411f
; expectedvec
.y
= 1.593215f
; expectedvec
.z
= 0.380724f
;
1254 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1255 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1256 expect_vec3(expectedvec
,gotvec
);
1259 static void D3X8Vector4Test(void)
1261 D3DXVECTOR4 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1262 LPD3DXVECTOR4 funcpointer
;
1263 D3DXVECTOR4 expectedtrans
, gottrans
;
1265 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1267 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
1268 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
1269 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
1270 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
1271 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
1273 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
;
1274 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
;
1275 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
;
1276 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
;
1278 coeff1
= 2.0f
; coeff2
= 5.0;
1281 /*_______________D3DXVec4Add__________________________*/
1282 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
1283 D3DXVec4Add(&gotvec
,&u
,&v
);
1284 expect_vec4(expectedvec
,gotvec
);
1285 /* Tests the case NULL */
1286 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
1287 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1288 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
1289 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1291 /*_______________D3DXVec4BaryCentric____________________*/
1292 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
1293 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1294 expect_vec4(expectedvec
,gotvec
);
1296 /*_______________D3DXVec4CatmullRom____________________*/
1297 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
1298 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1299 expect_vec4(expectedvec
,gotvec
);
1301 /*_______________D3DXVec4Cross_________________________*/
1302 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
1303 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
1304 expect_vec4(expectedvec
,gotvec
);
1306 /*_______________D3DXVec4Dot__________________________*/
1308 got
= D3DXVec4Dot(&u
,&v
);
1309 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1310 /* Tests the case NULL */
1312 got
= D3DXVec4Dot(NULL
,&v
);
1313 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1315 got
= D3DXVec4Dot(NULL
,NULL
);
1316 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1318 /*_______________D3DXVec4Hermite_________________________*/
1319 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
1320 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1321 expect_vec4(expectedvec
,gotvec
);
1323 /*_______________D3DXVec4Length__________________________*/
1325 got
= D3DXVec4Length(&u
);
1326 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1327 /* Tests the case NULL */
1329 got
= D3DXVec4Length(NULL
);
1330 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1332 /*_______________D3DXVec4LengthSq________________________*/
1334 got
= D3DXVec4LengthSq(&u
);
1335 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1336 /* Tests the case NULL */
1338 got
= D3DXVec4LengthSq(NULL
);
1339 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1341 /*_______________D3DXVec4Lerp__________________________*/
1342 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
1343 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
1344 expect_vec4(expectedvec
,gotvec
);
1345 /* Tests the case NULL */
1346 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
1347 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1348 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
1349 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1351 /*_______________D3DXVec4Maximize__________________________*/
1352 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
1353 D3DXVec4Maximize(&gotvec
,&u
,&v
);
1354 expect_vec4(expectedvec
,gotvec
);
1355 /* Tests the case NULL */
1356 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
1357 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1358 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
1359 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1361 /*_______________D3DXVec4Minimize__________________________*/
1362 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
1363 D3DXVec4Minimize(&gotvec
,&u
,&v
);
1364 expect_vec4(expectedvec
,gotvec
);
1365 /* Tests the case NULL */
1366 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
1367 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1368 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
1369 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1371 /*_______________D3DXVec4Normalize_________________________*/
1372 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
1373 D3DXVec4Normalize(&gotvec
,&u
);
1374 expect_vec4(expectedvec
,gotvec
);
1375 /* Test the nul vector */
1376 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
; expectedvec
.w
= 0.0f
;
1377 D3DXVec4Normalize(&gotvec
,&nul
);
1378 expect_vec4(expectedvec
,gotvec
);
1380 /*_______________D3DXVec4Scale____________________________*/
1381 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
1382 D3DXVec4Scale(&gotvec
,&u
,scale
);
1383 expect_vec4(expectedvec
,gotvec
);
1384 /* Tests the case NULL */
1385 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
1386 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1387 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
1388 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1390 /*_______________D3DXVec4Subtract__________________________*/
1391 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
1392 D3DXVec4Subtract(&gotvec
,&u
,&v
);
1393 expect_vec4(expectedvec
,gotvec
);
1394 /* Tests the case NULL */
1395 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
1396 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1397 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
1398 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1400 /*_______________D3DXVec4Transform_______________________*/
1401 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
1402 D3DXVec4Transform(&gottrans
,&u
,&mat
);
1403 expect_vec4(expectedtrans
,gottrans
);
1406 static void test_matrix_stack(void)
1408 ID3DXMatrixStack
*stack
;
1412 const D3DXMATRIX mat1
= {{{
1413 1.0f
, 2.0f
, 3.0f
, 4.0f
,
1414 5.0f
, 6.0f
, 7.0f
, 8.0f
,
1415 9.0f
, 10.0f
, 11.0f
, 12.0f
,
1416 13.0f
, 14.0f
, 15.0f
, 16.0f
1419 const D3DXMATRIX mat2
= {{{
1420 17.0f
, 18.0f
, 19.0f
, 20.0f
,
1421 21.0f
, 22.0f
, 23.0f
, 24.0f
,
1422 25.0f
, 26.0f
, 27.0f
, 28.0f
,
1423 29.0f
, 30.0f
, 31.0f
, 32.0f
1426 hr
= D3DXCreateMatrixStack(0, &stack
);
1427 ok(SUCCEEDED(hr
), "Failed to create a matrix stack, hr %#x\n", hr
);
1428 if (FAILED(hr
)) return;
1430 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)),
1431 "The top of an empty matrix stack should be an identity matrix\n");
1433 hr
= ID3DXMatrixStack_Pop(stack
);
1434 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1436 hr
= ID3DXMatrixStack_Push(stack
);
1437 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1438 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1440 hr
= ID3DXMatrixStack_Push(stack
);
1441 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1443 hr
= ID3DXMatrixStack_LoadMatrix(stack
, NULL
);
1444 ok(hr
== D3DERR_INVALIDCALL
, "LoadMatrix returned %#x, expected D3DERR_INVALIDCALL\n", hr
);
1446 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat1
);
1447 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1448 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1450 hr
= ID3DXMatrixStack_Push(stack
);
1451 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1452 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1454 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat2
);
1455 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1456 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1458 hr
= ID3DXMatrixStack_Push(stack
);
1459 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1460 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1462 hr
= ID3DXMatrixStack_LoadIdentity(stack
);
1463 ok(SUCCEEDED(hr
), "LoadIdentity failed, hr %#x\n", hr
);
1464 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1466 hr
= ID3DXMatrixStack_Pop(stack
);
1467 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1468 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1470 hr
= ID3DXMatrixStack_Pop(stack
);
1471 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1472 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1474 hr
= ID3DXMatrixStack_Pop(stack
);
1475 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1476 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1478 hr
= ID3DXMatrixStack_Pop(stack
);
1479 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1480 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1482 refcount
= ID3DXMatrixStack_Release(stack
);
1483 ok(!refcount
, "Matrix stack has %u references left.\n", refcount
);
1491 D3X8QuaternionTest();
1495 test_matrix_stack();