#include "../Tests.h" #include "core/Plane.h" static const float eps = 0.0001f; static void testToString() { Plane p; initPlane(&p, &V(3, 6, 8), &V(7, 6, 2), &V(4, 4, 4)); char buffer[128]; toStringPlane(&p, buffer, sizeof(buffer)); TEST_STRING("(-0.684 x + 0.570 y + -0.456 z + 2.279)", buffer); } static void testSignedDistance() { Vector3 a = V(3, 6, 8); Vector3 b = V(7, 6, 2); Vector3 c = V(4, 4, 4); Plane p; initPlane(&p, &a, &b, &c); TEST_FLOAT(0.0f, signedDistance(&p, &a), eps); TEST_FLOAT(0.0f, signedDistance(&p, &b), eps); TEST_FLOAT(0.0f, signedDistance(&p, &c), eps); TEST_FLOAT(-1.13960576f, signedDistance(&p, &V(5, 8, 10)), eps); TEST_FLOAT(0.911684612f, signedDistance(&p, &V(3, 2, 1)), eps); } void testPlane() { testToString(); testSignedDistance(); }