#include "../Tests.hpp" #include "core/Plane.hpp" #include "core/Test.hpp" static const float eps = 0.0001f; using V3 = Core::Vector3; static void testToString() { Core::Plane p(V3(3, 6, 8), V3(7, 6, 2), V3(4, 4, 4)); TEST_STRING("(-0.684 x + 0.570 y + -0.456 z + 2.279)", p); TEST_STRING("(0.000 x + 0.000 y + 0.000 z + 0.000)", Core::Plane()); } static void testSignedDistance() { V3 a(3, 6, 8); V3 b(7, 6, 2); V3 c(4, 4, 4); Core::Plane p(a, b, c); TEST_FLOAT(0.0f, p.signedDistance(a), eps); TEST_FLOAT(0.0f, p.signedDistance(b), eps); TEST_FLOAT(0.0f, p.signedDistance(c), eps); TEST_FLOAT(-1.13960576f, p.signedDistance(V3(5, 8, 10)), eps); TEST_FLOAT(0.911684612f, p.signedDistance(V3(3, 2, 1)), eps); } void testPlane() { testToString(); testSignedDistance(); }