WIP ellipse area

This commit is contained in:
Danny Robson 2018-04-17 17:11:41 +10:00
parent 06350b53cf
commit 8a2055abfc

View File

@ -5,11 +5,11 @@
#include "point.hpp"
#include "vector.hpp"
int
main ()
{
util::TAP::logger tap;
///////////////////////////////////////////////////////////////////////////////
void
test_intersection (util::TAP::logger &tap)
{
static struct {
util::geom::ellipse3f shape;
util::geom::ray3f caster;
@ -38,10 +38,39 @@ main ()
}
};
for (auto const& t: TESTS) {
tap.expect_eq (t.distance, distance (t.caster, t.shape), "%s", t.message);
}
}
void
test_area (util::TAP::logger &tap)
{
static struct {
util::geom::ellipse3f shape;
float value;
const char *message;
} const TESTS[] = {
{ .shape = { .origin = {0}, .radius = {1}, .up = {0} }, .value = 12.57f, .message = "unit radius" },
};
for (auto const& t: TESTS) {
auto found = area (t.shape);
tap.expect (util::relatively_equal (found, t.value, 1.08e-2f), "%!", t.message);
}
}
///////////////////////////////////////////////////////////////////////////////
int
main ()
{
util::TAP::logger tap;
test_intersection (tap);
test_area (tap);
return tap.status ();
}