|
|
|
|
@ -51,19 +51,19 @@ void IntersectionTest::planeLine() {
|
|
|
|
|
|
|
|
|
|
/* Inside line segment */ |
|
|
|
|
CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal, |
|
|
|
|
{0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, 2.0f}), 0.75f); |
|
|
|
|
Vector3{0.0f, 0.0f, -1.0f}, Vector3{0.0f, 0.0f, 2.0f}), 0.75f); |
|
|
|
|
|
|
|
|
|
/* Outside line segment */ |
|
|
|
|
CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal, |
|
|
|
|
{0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f}), -0.5f); |
|
|
|
|
Vector3{0.0f, 0.0f, 1.0f}, Vector3{0.0f, 0.0f, 1.0f}), -0.5f); |
|
|
|
|
|
|
|
|
|
/* Line lies on the plane */ |
|
|
|
|
CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal, |
|
|
|
|
{1.0f, 0.5f, 0.5f}, {-1.0f, 0.5f, 0.0f}), std::numeric_limits<Float>::quiet_NaN()); |
|
|
|
|
Vector3{1.0f, 0.5f, 0.5f}, Vector3{-1.0f, 0.5f, 0.0f}), std::numeric_limits<Float>::quiet_NaN()); |
|
|
|
|
|
|
|
|
|
/* Line is parallel to the plane */ |
|
|
|
|
CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal, |
|
|
|
|
{1.0f, 0.0f, 1.0f}, {-1.0f, 0.0f, 0.0f}), -std::numeric_limits<Float>::infinity()); |
|
|
|
|
Vector3{1.0f, 0.0f, 1.0f}, Vector3{-1.0f, 0.0f, 0.0f}), -std::numeric_limits<Float>::infinity()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void IntersectionTest::lineLine() { |
|
|
|
|
@ -72,30 +72,30 @@ void IntersectionTest::lineLine() {
|
|
|
|
|
|
|
|
|
|
/* Inside both line segments */ |
|
|
|
|
CORRADE_COMPARE(Intersection::lineSegmentLineSegment(p, r, |
|
|
|
|
{0.0f, 0.0f}, {-1.0f, 0.0f}), std::make_pair(0.5f, 0.5f)); |
|
|
|
|
Vector2{0.0f, 0.0f}, Vector2{-1.0f, 0.0f}), std::make_pair(0.5f, 0.5f)); |
|
|
|
|
CORRADE_COMPARE(Intersection::lineSegmentLine(p, r, |
|
|
|
|
{0.0f, 0.0f}, {-1.0f, 0.0f}), 0.5); |
|
|
|
|
Vector2{0.0f, 0.0f}, Vector2{-1.0f, 0.0f}), 0.5); |
|
|
|
|
|
|
|
|
|
/* Outside both line segments */ |
|
|
|
|
CORRADE_COMPARE(Intersection::lineSegmentLineSegment(p, r, |
|
|
|
|
{0.0f, -2.0f}, {-1.0f, 0.0f}), std::make_pair(-0.5f, 1.5f)); |
|
|
|
|
Vector2{0.0f, -2.0f}, Vector2{-1.0f, 0.0f}), std::make_pair(-0.5f, 1.5f)); |
|
|
|
|
CORRADE_COMPARE(Intersection::lineSegmentLine(p, r, |
|
|
|
|
{0.0f, -2.0f}, {-1.0f, 0.0f}), -0.5f); |
|
|
|
|
Vector2{0.0f, -2.0f}, Vector2{-1.0f, 0.0f}), -0.5f); |
|
|
|
|
|
|
|
|
|
/* Collinear lines */ |
|
|
|
|
const auto tu = Intersection::lineSegmentLineSegment(p, r, |
|
|
|
|
{0.0f, 1.0f}, {-1.0f, -2.0f}); |
|
|
|
|
Vector2{0.0f, 1.0f}, Vector2{-1.0f, -2.0f}); |
|
|
|
|
CORRADE_COMPARE(tu.first, -std::numeric_limits<Float>::quiet_NaN()); |
|
|
|
|
CORRADE_COMPARE(tu.second, -std::numeric_limits<Float>::quiet_NaN()); |
|
|
|
|
CORRADE_COMPARE(Intersection::lineSegmentLine(p, r, |
|
|
|
|
{0.0f, 1.0f}, {-1.0f, -2.0f}), -std::numeric_limits<Float>::quiet_NaN()); |
|
|
|
|
Vector2{0.0f, 1.0f}, Vector2{-1.0f, -2.0f}), -std::numeric_limits<Float>::quiet_NaN()); |
|
|
|
|
|
|
|
|
|
/* Parallel lines */ |
|
|
|
|
CORRADE_COMPARE(Intersection::lineSegmentLineSegment(p, r, |
|
|
|
|
{0.0f, 0.0f}, {1.0f, 2.0f}), std::make_pair(std::numeric_limits<Float>::infinity(), |
|
|
|
|
std::numeric_limits<Float>::infinity())); |
|
|
|
|
Vector2{0.0f, 0.0f}, Vector2{1.0f, 2.0f}), std::make_pair(std::numeric_limits<Float>::infinity(), |
|
|
|
|
std::numeric_limits<Float>::infinity())); |
|
|
|
|
CORRADE_COMPARE(Intersection::lineSegmentLine(p, r, |
|
|
|
|
{0.0f, 0.0f}, {1.0f, 2.0f}), std::numeric_limits<Float>::infinity()); |
|
|
|
|
Vector2{0.0f, 0.0f}, Vector2{1.0f, 2.0f}), std::numeric_limits<Float>::infinity()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}}}} |
|
|
|
|
|