#include "2d.hpp" #include "test/u.hpp" #include namespace { AddTestCase _(1, "2d.hpp", [](TestCase& t) { t.expectEq([] { return cross({1, 2}, {4, 1}); }, -7); t.expectEq([] { return cross({.5, 2.5}, {4, 1.5}); }, -9.25); t.expectEq([] { return dot({1, 2}, {4, 1}); }, 6); t.expectTrue([] { return Circle({0, 0}, 2).contain({1, 1}); }); t.expectTrue([] { return Circle({0, 0}, 1).contain({0, 1}); }); t.expectFalse([] { return Circle({1, 0}, 1.4).contain({0, -1}); }); t.expectTrue([] { return Circle({1, 1}, 1.42).contain({0, 0}); }); t.expectEq([] { return Polygon<3>{{0, 0}, {1, 0}, {1, 1}}.vertex[0]; }, {0, 0}); t.expectTrue([] { return Polygon<3>{{0, 0}, {1, 0}, {1, 1}}.contain({.1, .05}); }); t.expectFalse([] { return Polygon<3>{{0, 0}, {1, 0}, {1, 1}}.contain({.1, .2}); }); }); }