geom/ellipse: add ray distance tests
This commit is contained in:
parent
1889a76e26
commit
f21297cad5
@ -492,8 +492,9 @@ if (TESTS)
|
||||
float
|
||||
format
|
||||
geom/aabb
|
||||
geom/ray
|
||||
geom/ellipse
|
||||
geom/frustum
|
||||
geom/ray
|
||||
geom/sphere
|
||||
hash/checksum
|
||||
hash/crc
|
||||
|
40
test/geom/ellipse.cpp
Normal file
40
test/geom/ellipse.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "tap.hpp"
|
||||
|
||||
#include "geom/ellipse.hpp"
|
||||
#include "geom/ray.hpp"
|
||||
#include "point.hpp"
|
||||
#include "vector.hpp"
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
util::TAP::logger tap;
|
||||
|
||||
static struct {
|
||||
util::geom::ellipse3f shape;
|
||||
util::geom::ray3f caster;
|
||||
float distance;
|
||||
const char *message;
|
||||
} const TESTS[] = {
|
||||
{
|
||||
.shape = { .origin = {0}, .radius = {1}, .up = {0,1,0} },
|
||||
.caster = { .origin = { 0, 0, -2 }, .direction = util::vector3f{ 0, 0, 1 } },
|
||||
.distance = 1,
|
||||
.message = "sphere on origin, ray mostly on origin"
|
||||
},
|
||||
|
||||
{
|
||||
.shape = { .origin = {0}, .radius = {1,1,1.5}, .up = {0,1,0} },
|
||||
.caster = { .origin = {0,0,-2}, .direction = util::vector3f{0,0,1} },
|
||||
.distance = .5f,
|
||||
.message = "ellipse on origin, extended on z, ray along z",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
for (auto const& t: TESTS) {
|
||||
tap.expect_eq (t.distance, distance (t.caster, t.shape), "%s", t.message);
|
||||
}
|
||||
|
||||
return tap.status ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user