Пример #1
0
 TEST(HitPointInterval, ShouldComputeIntersectionOfEmptyAndNonEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval2.add(hitPoint);
   HitPointInterval intersectionInterval = interval1 & interval2;
   ASSERT_TRUE(intersectionInterval.min() == HitPoint::undefined());
   ASSERT_TRUE(intersectionInterval.max() == HitPoint::undefined());
 }
Пример #2
0
 TEST(HitPointInterval, ShouldComputeUnionOfEmptyAndNonEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval2.add(hitPoint);
   HitPointInterval unionInterval = interval1 | interval2;
   
   ASSERT_TRUE(unionInterval.min() == hitPoint);
   ASSERT_TRUE(unionInterval.max() == hitPoint);
 }
Пример #3
0
 TEST(HitPointInterval, ShouldComputeCompositeOfIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 3, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 5, Vector3d(), Vector3d());
   interval1.add(hitPoint1, hitPoint2);
   interval2.add(hitPoint3, hitPoint4);
   HitPointInterval compositeInterval = interval1 + interval2;
   
   ASSERT_TRUE(compositeInterval.min() == hitPoint1);
   ASSERT_TRUE(compositeInterval.max() == hitPoint4);
 }
Пример #4
0
 TEST(HitPointInterval, ShouldReturnEmptyIntersectionIfIntervalsDontOverlap) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 3, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 5, Vector3d(), Vector3d());
   interval1.add(hitPoint1, hitPoint2);
   interval2.add(hitPoint3, hitPoint4);
   HitPointInterval intersectionInterval = interval1 & interval2;
   
   ASSERT_TRUE(intersectionInterval.min() == HitPoint::undefined());
   ASSERT_TRUE(intersectionInterval.max() == HitPoint::undefined());
 }
Пример #5
0
 TEST(HitPointInterval, ShouldComputeIntersectionOfTwoNonEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 5, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 7, Vector3d(), Vector3d());
   interval1.add(hitPoint1, hitPoint2);
   interval2.add(hitPoint3, hitPoint4);
   HitPointInterval intersectionInterval = interval1 & interval2;
   
   ASSERT_TRUE(intersectionInterval.min() == hitPoint3);
   ASSERT_TRUE(intersectionInterval.max() == hitPoint2);
 }
Пример #6
0
 TEST(HitPointInterval, ShouldComputeMergedInterval) {
   HitPointInterval interval;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 3, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 5, Vector3d(), Vector3d());
   interval.add(hitPoint1, hitPoint2);
   interval.add(hitPoint3, hitPoint4);
   
   interval = interval.merged();
   ASSERT_EQ(2ul, interval.points().size());
   ASSERT_TRUE(interval.min() == hitPoint1);
   ASSERT_TRUE(interval.max() == hitPoint4);
 }
Пример #7
0
 TEST(HitPointInterval, ShouldComputeIntersectionOfTwoEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPointInterval intersectionInterval = interval1 & interval2;
   ASSERT_TRUE(intersectionInterval.min() == HitPoint::undefined());
   ASSERT_TRUE(intersectionInterval.max() == HitPoint::undefined());
 }
Пример #8
0
 TEST(HitPointInterval, ShouldSetClosestAndFarthestHitPointWhenOnlyOneHitPointIsAdded) {
   HitPointInterval interval;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval.add(hitPoint);
   ASSERT_TRUE(interval.min() == interval.max());
 }
Пример #9
0
 TEST(HitPointInterval, ShouldReturnFarthestHitPoint) {
   HitPointInterval interval;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval.add(hitPoint);
   ASSERT_TRUE(hitPoint == interval.max());
 }
Пример #10
0
 TEST(HitPointInterval, ShouldReturnUndefinedFarthestHitPointOnEmptyInterval) {
   HitPointInterval interval;
   const HitPoint& i = interval.max();
   ASSERT_TRUE(i == HitPoint::undefined());
 }