Browse Source

MSVC 2013 compatibility: some explicit typing is needed.

Vladimír Vondruš 13 years ago
parent
commit
cb00fdce57
  1. 8
      src/Math/Geometry/Test/DistanceTest.cpp
  2. 26
      src/Math/Geometry/Test/IntersectionTest.cpp

8
src/Math/Geometry/Test/DistanceTest.cpp

@ -84,7 +84,7 @@ void DistanceTest::linePoint3D() {
Constants::sqrt2()/Constants::sqrt3());
/* Check that 3D implementation gives the same result as 2D implementation */
CORRADE_COMPARE(Distance::linePoint(a, {1.0f, 1.0f, 0.0f}, Vector3(1.0f, 0.0f, 0.0f)),
CORRADE_COMPARE(Distance::linePoint(a, Vector3(1.0f, 1.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f)),
1.0f/Constants::sqrt2());
}
@ -110,9 +110,9 @@ void DistanceTest::lineSegmentPoint2D() {
1.0f);
/* Point next to the line segment */
CORRADE_COMPARE(Distance::lineSegmentPoint(a, b, {1.0f, 0.0f}),
CORRADE_COMPARE(Distance::lineSegmentPoint(a, b, Vector2(1.0f, 0.0f)),
1.0f/Constants::sqrt2());
CORRADE_COMPARE(Distance::lineSegmentPointSquared(a, b, {1.0f, 0.0f}),
CORRADE_COMPARE(Distance::lineSegmentPointSquared(a, b, Vector2(1.0f, 0.0f)),
0.5f);
/* Point outside the line segment, closer to A */
@ -145,7 +145,7 @@ void DistanceTest::lineSegmentPoint3D() {
1.0f);
/* Point next to the line segment */
CORRADE_COMPARE(Distance::lineSegmentPoint(a, b, {1.0f, 0.0f, 1.0f}),
CORRADE_COMPARE(Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f)),
Constants::sqrt2()/Constants::sqrt3());
/* Point outside the line segment, closer to A */

26
src/Math/Geometry/Test/IntersectionTest.cpp

@ -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());
}
}}}}

Loading…
Cancel
Save