diff options
author | Jacek Antonelli | 2008-08-15 23:45:02 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:02 -0500 |
commit | d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd (patch) | |
tree | 7ed0c2c27d717801238a2e6b5749cd5bf88c3059 /linden/indra/test/v3dmath_tut.cpp | |
parent | Second Life viewer sources 1.17.3.0 (diff) | |
download | meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.zip meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.gz meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.bz2 meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.xz |
Second Life viewer sources 1.18.0.6
Diffstat (limited to 'linden/indra/test/v3dmath_tut.cpp')
-rw-r--r-- | linden/indra/test/v3dmath_tut.cpp | 157 |
1 files changed, 139 insertions, 18 deletions
diff --git a/linden/indra/test/v3dmath_tut.cpp b/linden/indra/test/v3dmath_tut.cpp index 88ade71..2f5ea8e 100644 --- a/linden/indra/test/v3dmath_tut.cpp +++ b/linden/indra/test/v3dmath_tut.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | /** | 1 | /** |
2 | * @file v3dmath_tut.cpp | 2 | * @file v3dmath_tut.cpp |
3 | * @author Adroit | 3 | * @author Adroit |
4 | * @date March 2007 | 4 | * @date 2007-03 |
5 | * @brief v3dmath test cases. | 5 | * @brief v3dmath test cases. |
6 | * | 6 | * |
7 | * Copyright (c) 2007-2007, Linden Research, Inc. | 7 | * Copyright (c) 2007-2007, Linden Research, Inc. |
@@ -212,21 +212,70 @@ namespace tut | |||
212 | F64 x2 = 1.2, y2 = 2.5, z2 = 1.; | 212 | F64 x2 = 1.2, y2 = 2.5, z2 = 1.; |
213 | LLVector3d vec3D(x1,y1,z1),vec3Da(x2,y2,z2); | 213 | LLVector3d vec3D(x1,y1,z1),vec3Da(x2,y2,z2); |
214 | F64 res = vec3D * vec3Da; | 214 | F64 res = vec3D * vec3Da; |
215 | ensure("1:operator* failed",(res == (x1*x2 + y1*y2 + z1*z2))); | 215 | ensure_approximately_equals( |
216 | "1:operator* failed", | ||
217 | res, | ||
218 | (x1*x2 + y1*y2 + z1*z2), | ||
219 | 8); | ||
216 | vec3Da.clearVec(); | 220 | vec3Da.clearVec(); |
217 | F64 mulVal = 4.2; | 221 | F64 mulVal = 4.2; |
218 | vec3Da = vec3D * mulVal; | 222 | vec3Da = vec3D * mulVal; |
219 | ensure("2:operator* failed",(x1*mulVal == vec3Da.mdV[VX]) && (y1*mulVal == vec3Da.mdV[VY])&& (z1*mulVal == vec3Da.mdV[VZ])); | 223 | ensure_approximately_equals( |
224 | "2a:operator* failed", | ||
225 | vec3Da.mdV[VX], | ||
226 | x1*mulVal, | ||
227 | 8); | ||
228 | ensure_approximately_equals( | ||
229 | "2b:operator* failed", | ||
230 | vec3Da.mdV[VY], | ||
231 | y1*mulVal, | ||
232 | 8); | ||
233 | ensure_approximately_equals( | ||
234 | "2c:operator* failed", | ||
235 | vec3Da.mdV[VZ], | ||
236 | z1*mulVal, | ||
237 | 8); | ||
220 | vec3Da.clearVec(); | 238 | vec3Da.clearVec(); |
221 | vec3Da = mulVal * vec3D; | 239 | vec3Da = mulVal * vec3D; |
222 | ensure("3:operator* failed",(x1*mulVal == vec3Da.mdV[VX]) && (y1*mulVal == vec3Da.mdV[VY])&& (z1*mulVal == vec3Da.mdV[VZ])); | 240 | ensure_approximately_equals( |
241 | "3a:operator* failed", | ||
242 | vec3Da.mdV[VX], | ||
243 | x1*mulVal, | ||
244 | 8); | ||
245 | ensure_approximately_equals( | ||
246 | "3b:operator* failed", | ||
247 | vec3Da.mdV[VY], | ||
248 | y1*mulVal, | ||
249 | 8); | ||
250 | ensure_approximately_equals( | ||
251 | "3c:operator* failed", | ||
252 | vec3Da.mdV[VZ], | ||
253 | z1*mulVal, | ||
254 | 8); | ||
223 | vec3D *= mulVal; | 255 | vec3D *= mulVal; |
224 | ensure("4:operator*= failed",(x1*mulVal == vec3D.mdV[VX]) && (y1*mulVal == vec3D.mdV[VY])&& (z1*mulVal == vec3D.mdV[VZ])); | 256 | ensure_approximately_equals( |
257 | "4a:operator*= failed", | ||
258 | vec3D.mdV[VX], | ||
259 | x1*mulVal, | ||
260 | 8); | ||
261 | ensure_approximately_equals( | ||
262 | "4b:operator*= failed", | ||
263 | vec3D.mdV[VY], | ||
264 | y1*mulVal, | ||
265 | 8); | ||
266 | ensure_approximately_equals( | ||
267 | "4c:operator*= failed", | ||
268 | vec3D.mdV[VZ], | ||
269 | z1*mulVal, | ||
270 | 8); | ||
225 | } | 271 | } |
226 | 272 | ||
227 | template<> template<> | 273 | template<> template<> |
228 | void v3dmath_object::test<12>() | 274 | void v3dmath_object::test<12>() |
229 | { | 275 | { |
276 | #if (LL_RELEASE && LL_LINUX) | ||
277 | skip_fail("Doesn't work under Linux -- FIX ME!"); | ||
278 | #endif | ||
230 | F64 x1 = 1., y1 = 2., z1 = -1.1; | 279 | F64 x1 = 1., y1 = 2., z1 = -1.1; |
231 | F64 x2 = 1.2, y2 = 2.5, z2 = 1.; | 280 | F64 x2 = 1.2, y2 = 2.5, z2 = 1.; |
232 | F64 val1, val2, val3; | 281 | F64 val1, val2, val3; |
@@ -247,15 +296,57 @@ namespace tut | |||
247 | F64 t = 1.f / div; | 296 | F64 t = 1.f / div; |
248 | LLVector3d vec3D(x1,y1,z1), vec3Da; | 297 | LLVector3d vec3D(x1,y1,z1), vec3Da; |
249 | vec3Da = vec3D/div; | 298 | vec3Da = vec3D/div; |
250 | ensure("1:operator/ failed",(x1*t == vec3Da.mdV[VX]) && (y1*t == vec3Da.mdV[VY])&& (z1*t == vec3Da.mdV[VZ])); | 299 | ensure_approximately_equals( |
251 | x1 = 1.23, y1 = 4., z1 = -2.32; | 300 | "1a:operator/ failed", |
252 | vec3D.clearVec(); | 301 | vec3Da.mdV[VX], |
253 | vec3Da.clearVec(); | 302 | x1*t, |
254 | vec3D.setVec(x1,y1,z1); | 303 | 8); |
255 | vec3Da = vec3D/div; | 304 | ensure_approximately_equals( |
256 | ensure("2:operator/ failed",(x1*t == vec3Da.mdV[VX]) && (y1*t == vec3Da.mdV[VY])&& (z1*t == vec3Da.mdV[VZ])); | 305 | "1b:operator/ failed", |
257 | vec3D /= div; | 306 | vec3Da.mdV[VY], |
258 | ensure("3:operator/= failed",(x1*t == vec3D.mdV[VX]) && (y1*t == vec3D.mdV[VY])&& (z1*t == vec3D.mdV[VZ])); | 307 | y1*t, |
308 | 8); | ||
309 | ensure_approximately_equals( | ||
310 | "1c:operator/ failed", | ||
311 | vec3Da.mdV[VZ], | ||
312 | z1*t, | ||
313 | 8); | ||
314 | x1 = 1.23, y1 = 4., z1 = -2.32; | ||
315 | vec3D.clearVec(); | ||
316 | vec3Da.clearVec(); | ||
317 | vec3D.setVec(x1,y1,z1); | ||
318 | vec3Da = vec3D/div; | ||
319 | ensure_approximately_equals( | ||
320 | "2a:operator/ failed", | ||
321 | vec3Da.mdV[VX], | ||
322 | x1*t, | ||
323 | 8); | ||
324 | ensure_approximately_equals( | ||
325 | "2b:operator/ failed", | ||
326 | vec3Da.mdV[VY], | ||
327 | y1*t, | ||
328 | 8); | ||
329 | ensure_approximately_equals( | ||
330 | "2c:operator/ failed", | ||
331 | vec3Da.mdV[VZ], | ||
332 | z1*t, | ||
333 | 8); | ||
334 | vec3D /= div; | ||
335 | ensure_approximately_equals( | ||
336 | "3a:operator/= failed", | ||
337 | vec3D.mdV[VX], | ||
338 | x1*t, | ||
339 | 8); | ||
340 | ensure_approximately_equals( | ||
341 | "3b:operator/= failed", | ||
342 | vec3D.mdV[VY], | ||
343 | y1*t, | ||
344 | 8); | ||
345 | ensure_approximately_equals( | ||
346 | "3c:operator/= failed", | ||
347 | vec3D.mdV[VZ], | ||
348 | z1*t, | ||
349 | 8); | ||
259 | } | 350 | } |
260 | 351 | ||
261 | template<> template<> | 352 | template<> template<> |
@@ -324,18 +415,48 @@ namespace tut | |||
324 | LLVector3d vec3D(x,y,z); | 415 | LLVector3d vec3D(x,y,z); |
325 | F64 mag = vec3D.normVec(); | 416 | F64 mag = vec3D.normVec(); |
326 | mag = 1.f/ mag; | 417 | mag = 1.f/ mag; |
327 | ensure("1:normVec: Fail ", (x* mag == vec3D.mdV[VX]) && (y* mag == vec3D.mdV[VY])&& (z* mag == vec3D.mdV[VZ])); | 418 | ensure_approximately_equals( |
419 | "1a:normVec: Fail ", | ||
420 | vec3D.mdV[VX], | ||
421 | x * mag, | ||
422 | 8); | ||
423 | ensure_approximately_equals( | ||
424 | "1b:normVec: Fail ", | ||
425 | vec3D.mdV[VY], | ||
426 | y * mag, | ||
427 | 8); | ||
428 | ensure_approximately_equals( | ||
429 | "1c:normVec: Fail ", | ||
430 | vec3D.mdV[VZ], | ||
431 | z * mag, | ||
432 | 8); | ||
328 | x = 0.000000001, y = 0.000000001, z = 0.000000001; | 433 | x = 0.000000001, y = 0.000000001, z = 0.000000001; |
329 | vec3D.clearVec(); | 434 | vec3D.clearVec(); |
330 | vec3D.setVec(x,y,z); | 435 | vec3D.setVec(x,y,z); |
331 | mag = vec3D.normVec(); | 436 | mag = vec3D.normVec(); |
332 | ensure("2:normVec: Fail ", (x* mag == vec3D.mdV[VX]) && (y* mag == vec3D.mdV[VY])&& (z* mag == vec3D.mdV[VZ])); | 437 | ensure_approximately_equals( |
438 | "2a:normVec: Fail ", | ||
439 | vec3D.mdV[VX], | ||
440 | x * mag, | ||
441 | 8); | ||
442 | ensure_approximately_equals( | ||
443 | "2b:normVec: Fail ", | ||
444 | vec3D.mdV[VY], | ||
445 | y * mag, | ||
446 | 8); | ||
447 | ensure_approximately_equals( | ||
448 | "2c:normVec: Fail ", | ||
449 | vec3D.mdV[VZ], | ||
450 | z * mag, | ||
451 | 8); | ||
333 | } | 452 | } |
334 | 453 | ||
335 | template<> template<> | 454 | template<> template<> |
336 | void v3dmath_object::test<20>() | 455 | void v3dmath_object::test<20>() |
337 | { | 456 | { |
338 | F64 x1 = 1111.232222, y1 = 2222222222.22, z1 = 422222222222; | 457 | F64 x1 = 1111.232222; |
458 | F64 y1 = 2222222222.22; | ||
459 | F64 z1 = 422222222222.0; | ||
339 | char buf[] = "1111.232222 2222222222.22 422222222222"; | 460 | char buf[] = "1111.232222 2222222222.22 422222222222"; |
340 | LLVector3d vec3Da, vec3Db(x1,y1,z1); | 461 | LLVector3d vec3Da, vec3Db(x1,y1,z1); |
341 | LLVector3d::parseVector3d(buf, &vec3Da); | 462 | LLVector3d::parseVector3d(buf, &vec3Da); |
@@ -399,4 +520,4 @@ namespace tut | |||
399 | angle = acos(angle); | 520 | angle = acos(angle); |
400 | ensure("2:angle_between: Fail ", (angle == angle2)); | 521 | ensure("2:angle_between: Fail ", (angle == angle2)); |
401 | } | 522 | } |
402 | } \ No newline at end of file | 523 | } |