MCPcopy Create free account
hub / github.com/crownengine/crown / test_aabb

Function test_aabb

src/core/unit_tests.cpp:915–993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

913}
914
915static void test_aabb()
916{
917 {
918 AABB a;
919 aabb::reset(a);
920 ENSURE(a.min == VECTOR3_ZERO);
921 ENSURE(a.max == VECTOR3_ZERO);
922 }
923 {
924 AABB a;
925 a.min = { -2.3f, 1.2f, -4.5f };
926 a.max = { 3.7f, 5.3f, -2.9f };
927 const Vector3 c = aabb::center(a);
928 ENSURE(fequal(c.x, 0.70f, 0.00001f));
929 ENSURE(fequal(c.y, 3.25f, 0.00001f));
930 ENSURE(fequal(c.z, -3.70f, 0.00001f));
931 }
932 {
933 AABB a;
934 a.min = { -2.3f, 1.2f, -4.5f };
935 a.max = { 3.7f, 5.3f, -2.9f };
936 const float c = aabb::volume(a);
937 ENSURE(fequal(c, 39.36f, 0.00001f));
938 }
939 {
940 const Vector3 points[] =
941 {
942 { -1.2f, 3.4f, 5.5f },
943 { 8.2f, -2.4f, -1.5f },
944 { -5.9f, 9.2f, 6.0f }
945 };
946 AABB a;
947 aabb::from_points(a, countof(points), points);
948 ENSURE(fequal(a.min.x, -5.9f, 0.00001f));
949 ENSURE(fequal(a.min.y, -2.4f, 0.00001f));
950 ENSURE(fequal(a.min.z, -1.5f, 0.00001f));
951 ENSURE(fequal(a.max.x, 8.2f, 0.00001f));
952 ENSURE(fequal(a.max.y, 9.2f, 0.00001f));
953 ENSURE(fequal(a.max.z, 6.0f, 0.00001f));
954 }
955 {
956 const Vector3 points[] =
957 {
958 { -1.2f, 3.4f, 5.5f },
959 { 8.2f, -2.4f, -1.5f },
960 { -5.9f, 9.2f, 6.0f },
961
962 { -2.8f, -3.5f, 1.9f },
963 { -8.3f, -3.1f, 1.9f },
964 { 4.0f, -3.9f, -1.4f },
965
966 { -0.4f, -1.8f, -2.2f },
967 { -8.6f, -4.8f, 2.8f },
968 { 4.1f, 4.7f, -0.4f }
969 };
970 AABB boxes[3];
971 aabb::from_points(boxes[0], countof(points)/3, &points[0]);
972 aabb::from_points(boxes[1], countof(points)/3, &points[3]);

Callers

nothing calls this directly

Calls 3

from_pointsFunction · 0.85
from_boxesFunction · 0.85
resetFunction · 0.50

Tested by

no test coverage detected