2018-04-16 15:59:39 +10:00
|
|
|
#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",
|
|
|
|
},
|
2018-04-17 14:26:23 +10:00
|
|
|
|
|
|
|
{
|
|
|
|
.shape = { .origin = 1, .radius = 1, .up = { 0, 1, 0 } },
|
|
|
|
.caster = { .origin = {1,1,3}, .direction = {0,0,-1} },
|
|
|
|
.distance = 1.f,
|
|
|
|
.message = "ellipse at 1,1,1, ray along -z",
|
|
|
|
}
|
2018-04-16 15:59:39 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
for (auto const& t: TESTS) {
|
|
|
|
tap.expect_eq (t.distance, distance (t.caster, t.shape), "%s", t.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tap.status ();
|
|
|
|
}
|