|
|
|
@ -13,41 +13,41 @@ |
|
|
|
GNU Lesser General Public License version 3 for more details. |
|
|
|
GNU Lesser General Public License version 3 for more details. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include "GeometryUtilsTest.h" |
|
|
|
#include "IntersectionTest.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <limits> |
|
|
|
#include <limits> |
|
|
|
#include <QtTest/QTest> |
|
|
|
#include <QtTest/QTest> |
|
|
|
|
|
|
|
|
|
|
|
#include "GeometryUtils.h" |
|
|
|
#include "Intersection.h" |
|
|
|
|
|
|
|
|
|
|
|
QTEST_APPLESS_MAIN(Magnum::Math::Test::GeometryUtilsTest) |
|
|
|
QTEST_APPLESS_MAIN(Magnum::Math::Geometry::Test::IntersectionTest) |
|
|
|
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
|
|
namespace Magnum { namespace Math { namespace Test { |
|
|
|
namespace Magnum { namespace Math { namespace Geometry { namespace Test { |
|
|
|
|
|
|
|
|
|
|
|
typedef Magnum::Math::Vector3<float> Vector3; |
|
|
|
typedef Magnum::Math::Vector3<float> Vector3; |
|
|
|
|
|
|
|
|
|
|
|
void GeometryUtilsTest::intersection() { |
|
|
|
void IntersectionTest::planeLine() { |
|
|
|
Vector3 planePosition; |
|
|
|
Vector3 planePosition; |
|
|
|
Vector3 planeNormal(0.0f, 0.0f, 1.0f); |
|
|
|
Vector3 planeNormal(0.0f, 0.0f, 1.0f); |
|
|
|
|
|
|
|
|
|
|
|
/* Inside line segment */ |
|
|
|
/* Inside line segment */ |
|
|
|
QCOMPARE((GeometryUtils::intersection(planePosition, planeNormal, |
|
|
|
QCOMPARE((Intersection::planeLine(planePosition, planeNormal, |
|
|
|
Vector3(0, 0, -1), Vector3(0, 0, 1))), 0.5f); |
|
|
|
Vector3(0, 0, -1), Vector3(0, 0, 1))), 0.5f); |
|
|
|
|
|
|
|
|
|
|
|
/* Outside line segment */ |
|
|
|
/* Outside line segment */ |
|
|
|
QCOMPARE((GeometryUtils::intersection(planePosition, planeNormal, |
|
|
|
QCOMPARE((Intersection::planeLine(planePosition, planeNormal, |
|
|
|
Vector3(0, 0, 1), Vector3(0, 0, 2))), -1.0f); |
|
|
|
Vector3(0, 0, 1), Vector3(0, 0, 2))), -1.0f); |
|
|
|
|
|
|
|
|
|
|
|
/* Line lies on the plane */ |
|
|
|
/* Line lies on the plane */ |
|
|
|
float nan = GeometryUtils::intersection(planePosition, planeNormal, |
|
|
|
float nan = Intersection::planeLine(planePosition, planeNormal, |
|
|
|
Vector3(1, 0, 0), Vector3(0, 1, 0)); |
|
|
|
Vector3(1, 0, 0), Vector3(0, 1, 0)); |
|
|
|
QVERIFY(nan != nan); |
|
|
|
QVERIFY(nan != nan); |
|
|
|
|
|
|
|
|
|
|
|
/* Line is parallell to the plane */ |
|
|
|
/* Line is parallell to the plane */ |
|
|
|
QCOMPARE((GeometryUtils::intersection(planePosition, planeNormal, |
|
|
|
QCOMPARE((Intersection::planeLine(planePosition, planeNormal, |
|
|
|
Vector3(1, 0, 1), Vector3(0, 0, 1))), numeric_limits<float>::infinity()); |
|
|
|
Vector3(1, 0, 1), Vector3(0, 0, 1))), numeric_limits<float>::infinity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}}} |
|
|
|
}}}} |