2018-04-20 15:04:54 +10:00
|
|
|
#include "tap.hpp"
|
|
|
|
|
|
|
|
#include "geom/line.hpp"
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int, char**)
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::TAP::logger tap;
|
2018-04-20 15:04:54 +10:00
|
|
|
|
|
|
|
static struct {
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::point3f origin;
|
|
|
|
cruft::vector3f direction;
|
|
|
|
cruft::point3f q;
|
2018-04-20 15:04:54 +10:00
|
|
|
float distance;
|
|
|
|
const char *message;
|
|
|
|
} TESTS[] = {
|
|
|
|
{ { 0, 0, 0 }, { 1, 0, 0}, { 0, 0, 0 }, 0, "origin line, origin point" } ,
|
|
|
|
{ { 0, 1, 0 }, { 1, 0, 0}, { 0, 0, 0 }, 1, "+x line, unit distance" },
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto const& t: TESTS) {
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::geom::line3f l { t.origin, t.direction };
|
2018-04-20 15:04:54 +10:00
|
|
|
auto d = distance2 (l, t.q);
|
|
|
|
tap.expect_eq (d, t.distance, "%!", t.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tap.status ();
|
|
|
|
}
|