MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / testRayBoxIntersection

Function testRayBoxIntersection

src/ImathTest/testBoxAlgo.cpp:412–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412void
413testRayBoxIntersection (const Box3f& box)
414{
415 Rand48 random (2007);
416
417 float e = 50 * std::numeric_limits<float>::epsilon ();
418
419 if (box.isEmpty ())
420 {
421 cout << " empty box, no rays intersect" << endl;
422
423 for (int i = 0; i < 100000; ++i)
424 {
425 V3f p1 (
426 float(random.nextf (box.max.x, box.min.x)),
427 float(random.nextf (box.max.y, box.min.y)),
428 float(random.nextf (box.max.z, box.min.z)));
429
430 V3f p2 (p1 + hollowSphereRand<V3f> (random));
431
432 V3f ip;
433 assert (!intersects (box, Line3f (p1, p2), ip));
434 }
435
436 return;
437 }
438
439 cout << " box = (" << box.min << " " << box.max << ")" << endl;
440
441 if (box.max == box.min)
442 {
443 cout << " single-point box, ray intersects" << endl;
444
445 static const float off[6][3] = {
446 {-1, 0, 0},
447 {1, 0, 0},
448 {0, -1, 0},
449 {0, 1, 0},
450 {0, 0, -1},
451 {0, 0, 1}};
452
453 for (int i = 0; i < 6; ++i)
454 {
455 V3f p1 (
456 box.min.x + off[i][0],
457 box.min.y + off[i][1],
458 box.min.z + off[i][2]);
459
460 V3f ip;
461 assert (intersects (box, Line3f (p1, box.min), ip));
462 assert (ip == box.min);
463 }
464
465 cout << " single-point box, ray does not intersect" << endl;
466
467 for (int i = 0; i < 100000; ++i)
468 {
469 //

Callers 1

rayBoxIntersection1Function · 0.85

Calls 5

approximatelyEqualFunction · 0.85
normalizedMethod · 0.80
equalWithAbsErrorMethod · 0.80
nextfMethod · 0.60
absFunction · 0.50

Tested by

no test coverage detected