41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#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 ();
|
|
}
|