|
@@ -0,0 +1,43 @@
|
|
|
+#include "../Tests.h"
|
|
|
+#include "core/Plane.h"
|
|
|
+
|
|
|
+static const float eps = 0.0001f;
|
|
|
+
|
|
|
+#define CV3(a, b, c) (&(CoreVector3){{a, b, c}})
|
|
|
+
|
|
|
+static void testToString1() {
|
|
|
+ CorePlane p = CORE_PLANE;
|
|
|
+ char buffer[128];
|
|
|
+ coreToStringPlane(&p, buffer, sizeof(buffer));
|
|
|
+ CORE_TEST_STRING("(0.000 x + 0.000 y + 0.000 z + 0.000)", buffer);
|
|
|
+}
|
|
|
+
|
|
|
+static void testToString2() {
|
|
|
+ CorePlane p = CORE_PLANE;
|
|
|
+ coreInitPlane(&p, CV3(3.0f, 6.0f, 8.0f), CV3(7.0f, 6.0f, 2.0f),
|
|
|
+ CV3(4.0f, 4.0f, 4.0f));
|
|
|
+ char buffer[128];
|
|
|
+ coreToStringPlane(&p, buffer, sizeof(buffer));
|
|
|
+ CORE_TEST_STRING("(-0.684 x + 0.570 y + -0.456 z + 2.279)", buffer);
|
|
|
+}
|
|
|
+
|
|
|
+static void testSignedDistance() {
|
|
|
+ CoreVector3 a = {{3.0f, 6.0f, 8.0f}};
|
|
|
+ CoreVector3 b = {{7.0f, 6.0f, 2.0f}};
|
|
|
+ CoreVector3 c = {{4.0f, 4.0f, 4.0f}};
|
|
|
+ CorePlane p = CORE_PLANE;
|
|
|
+ coreInitPlane(&p, &a, &b, &c);
|
|
|
+ CORE_TEST_FLOAT(0.0f, coreGetSignedDistance(&p, &a), eps);
|
|
|
+ CORE_TEST_FLOAT(0.0f, coreGetSignedDistance(&p, &b), eps);
|
|
|
+ CORE_TEST_FLOAT(0.0f, coreGetSignedDistance(&p, &c), eps);
|
|
|
+ CORE_TEST_FLOAT(-1.13960576f,
|
|
|
+ coreGetSignedDistance(&p, CV3(5.0f, 8.0f, 10.0f)), eps);
|
|
|
+ CORE_TEST_FLOAT(0.911684612f,
|
|
|
+ coreGetSignedDistance(&p, CV3(3.0f, 2.0f, 1.0f)), eps);
|
|
|
+}
|
|
|
+
|
|
|
+void coreTestPlane() {
|
|
|
+ testToString1();
|
|
|
+ testToString2();
|
|
|
+ testSignedDistance();
|
|
|
+}
|