2018-04-20 15:07:16 +10:00
|
|
|
#include "tap.hpp"
|
|
|
|
|
|
|
|
#include "geom/segment.hpp"
|
|
|
|
|
|
|
|
|
2019-03-21 16:26:00 +11:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
void test_point_distance (cruft::TAP::logger &tap)
|
|
|
|
{
|
2018-04-20 15:07:16 +10:00
|
|
|
static struct {
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::point3f a, b;
|
|
|
|
cruft::point3f q;
|
2018-04-20 15:07:16 +10:00
|
|
|
float distance;
|
|
|
|
const char *message;
|
|
|
|
} const TESTS[] = {
|
|
|
|
{ { 0, 0, 0 }, { 1, 1, 1 }, { 0, 0, 0 }, 0, "origin line, origin point" },
|
|
|
|
{ { 0, 0, 0 }, { 1, 1, 1 }, { 1, 1, 1 }, 0, "origin line, point on line" },
|
|
|
|
{ { 0, 1, 0 }, { 1, 1, 0 }, { 0, 0, 0 }, 1, "+x line, unit distance" },
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto const& t: TESTS) {
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::geom::segment3f s {t.a, t.b};
|
2018-04-20 15:07:16 +10:00
|
|
|
auto d = distance (s, t.q);
|
|
|
|
tap.expect_eq (d, t.distance, "%!", t.message);
|
|
|
|
}
|
2019-03-21 16:26:00 +11:00
|
|
|
}
|
2018-04-20 15:07:16 +10:00
|
|
|
|
2019-03-21 16:26:00 +11:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int
|
|
|
|
main (int, char**)
|
|
|
|
{
|
|
|
|
cruft::TAP::logger tap;
|
|
|
|
test_point_distance (tap);
|
2018-04-20 15:07:16 +10:00
|
|
|
return tap.status ();
|
|
|
|
}
|