From 8a2055abfcdf955c1ef6d358dd95736a07638e37 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 17 Apr 2018 17:11:41 +1000 Subject: [PATCH] WIP ellipse area --- test/geom/ellipse.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/test/geom/ellipse.cpp b/test/geom/ellipse.cpp index a3d36ef2..1e947eca 100644 --- a/test/geom/ellipse.cpp +++ b/test/geom/ellipse.cpp @@ -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 (); }