diff --git a/src/Math/Geometry/Intersection.h b/src/Math/Geometry/Intersection.h index f79eae8dc..b4cee3f72 100644 --- a/src/Math/Geometry/Intersection.h +++ b/src/Math/Geometry/Intersection.h @@ -59,7 +59,7 @@ class Intersection { T f = Vector3::dot(planePosition, planeNormal); /* Compute t */ - return (f-Vector3::dot(planeNormal, a)/Vector3::dot(planeNormal, b-a)); + return (f-Vector3::dot(planeNormal, a))/Vector3::dot(planeNormal, b-a); } }; diff --git a/src/Math/Geometry/Test/IntersectionTest.cpp b/src/Math/Geometry/Test/IntersectionTest.cpp index 51e76ff89..7809fe95c 100644 --- a/src/Math/Geometry/Test/IntersectionTest.cpp +++ b/src/Math/Geometry/Test/IntersectionTest.cpp @@ -29,25 +29,25 @@ namespace Magnum { namespace Math { namespace Geometry { namespace Test { typedef Magnum::Math::Vector3 Vector3; void IntersectionTest::planeLine() { - Vector3 planePosition; + Vector3 planePosition(-1.0f, 1.0f, 0.5f); Vector3 planeNormal(0.0f, 0.0f, 1.0f); /* Inside line segment */ QCOMPARE((Intersection::planeLine(planePosition, planeNormal, - Vector3(0, 0, -1), Vector3(0, 0, 1))), 0.5f); + Vector3(0.0f, 0.0f, -1.0f), Vector3(0.0f, 0.0f, 1.0f))), 0.75f); /* Outside line segment */ QCOMPARE((Intersection::planeLine(planePosition, planeNormal, - Vector3(0, 0, 1), Vector3(0, 0, 2))), -1.0f); + Vector3(0.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 2.0f))), -0.5f); /* Line lies on the plane */ float nan = Intersection::planeLine(planePosition, planeNormal, - Vector3(1, 0, 0), Vector3(0, 1, 0)); + Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)); QVERIFY(nan != nan); /* Line is parallell to the plane */ QCOMPARE((Intersection::planeLine(planePosition, planeNormal, - Vector3(1, 0, 1), Vector3(0, 0, 1))), numeric_limits::infinity()); + Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), numeric_limits::infinity()); } }}}}