36 lines
887 B
C++
36 lines
887 B
C++
|
#include "geom/plane.hpp"
|
||
|
#include "point.hpp"
|
||
|
#include "tap.hpp"
|
||
|
|
||
|
|
||
|
void
|
||
|
test_distances (util::TAP::logger &tap)
|
||
|
{
|
||
|
static struct {
|
||
|
util::point3f a, b, c;
|
||
|
util::point3f query;
|
||
|
float distance;
|
||
|
const char *message;
|
||
|
} const TESTS[] = {
|
||
|
{ { 0, 0, 0 }, { 0, 1, 0 }, { 1, 0, 0 }, { 0, 0, 0 }, 0, "colinear with plane about -z" },
|
||
|
{ { 0, 0, 0 }, { 0, 1, 0 }, { 1, 0, 0 }, { 0, 0,-1 }, 1, "in front of plane about -z" },
|
||
|
{ { 0, 0, 0 }, { 0, 1, 0 }, { 1, 0, 0 }, { 0, 0, 1 }, -1, "behind plane about -z" },
|
||
|
};
|
||
|
|
||
|
for (auto const &t: TESTS) {
|
||
|
auto const p = util::geom::make_plane (t.a, t.b, t.c);
|
||
|
const auto d = distance (p, t.query);
|
||
|
tap.expect_eq (d, t.distance, "%!", t.message);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
int
|
||
|
main (int, char**)
|
||
|
{
|
||
|
util::TAP::logger tap;
|
||
|
|
||
|
test_distances (tap);
|
||
|
|
||
|
return tap.status ();
|
||
|
}
|