1234567891011121314151617181920212223242526272829303132 |
- #include "../Tests.h"
- #include "core/Plane.h"
- static const float eps = 0.0001f;
- #define CV3(a, b, c) (&(CoreVector3){{a, b, c}})
- static void testToString() {
- CorePlane p;
- coreInitPlane(&p, CV3(3, 6, 8), CV3(7, 6, 2), CV3(4, 4, 4));
- 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, 6, 8}};
- CoreVector3 b = {{7, 6, 2}};
- CoreVector3 c = {{4, 4, 4}};
- CorePlane p;
- coreInitPlane(&p, &a, &b, &c);
- CORE_TEST_FLOAT(0.0f, coreSignedDistance(&p, &a), eps);
- CORE_TEST_FLOAT(0.0f, coreSignedDistance(&p, &b), eps);
- CORE_TEST_FLOAT(0.0f, coreSignedDistance(&p, &c), eps);
- CORE_TEST_FLOAT(-1.13960576f, coreSignedDistance(&p, CV3(5, 8, 10)), eps);
- CORE_TEST_FLOAT(0.911684612f, coreSignedDistance(&p, CV3(3, 2, 1)), eps);
- }
- void coreTestPlane() {
- testToString();
- testSignedDistance();
- }
|