2015-04-13 16:45:56 +10:00
|
|
|
#include "region.hpp"
|
|
|
|
|
|
|
|
#include "point.hpp"
|
|
|
|
#include "tap.hpp"
|
2012-05-11 12:21:47 +10:00
|
|
|
|
|
|
|
|
2016-01-19 18:31:49 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-05-11 12:21:47 +10:00
|
|
|
int
|
2016-01-19 18:31:49 +11:00
|
|
|
main (int, char **)
|
|
|
|
{
|
|
|
|
util::TAP::logger tap;
|
|
|
|
|
2012-05-11 12:21:47 +10:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
util::point2d ap { 32.7, -6.09703 };
|
|
|
|
util::extent2d ae { 0.8, 2. };
|
|
|
|
|
|
|
|
util::point2d bp {33.5, -4.5};
|
|
|
|
util::extent2d be { 0.5, 0.5 };
|
|
|
|
|
2016-01-19 18:31:49 +11:00
|
|
|
util::region2d a (ap, ae);
|
|
|
|
util::region2d b (bp, be);
|
2012-05-11 12:21:47 +10:00
|
|
|
|
2016-01-19 18:31:49 +11:00
|
|
|
tap.expect (!a.intersects (b), "simple 2d intersection");
|
2012-05-11 12:21:47 +10:00
|
|
|
}
|
|
|
|
|
2016-12-12 17:07:53 +11:00
|
|
|
tap.expect (util::region2d::max ().intersects (util::region2d::unit ()), "maximal region2d intersection");
|
|
|
|
tap.expect (util::region2f::max ().intersects (util::region2f::unit ()), "maximal region2f intersection");
|
2012-06-15 16:38:57 +10:00
|
|
|
|
2016-12-12 17:07:53 +11:00
|
|
|
tap.expect_eq (util::region2d::unit ().area (), 1.0, "unit region2d area");
|
|
|
|
tap.expect_eq (util::region2f::unit ().area (), 1.0f, "unit region2f area");
|
2012-06-15 16:38:57 +10:00
|
|
|
|
2016-12-12 17:07:53 +11:00
|
|
|
util::point2u p0 { 0 };
|
2015-03-06 01:09:37 +11:00
|
|
|
util::extent2u e0 { 2 };
|
|
|
|
|
2016-01-19 18:31:49 +11:00
|
|
|
tap.expect (util::region2u (p0, e0).includes (util::point2u {1, 1}), "unsigned region centre inclusion");
|
|
|
|
tap.expect (util::region2u (p0, e0).includes (util::point2u {0, 0}), "unsigned region base inclusion");
|
|
|
|
tap.expect (util::region2u (p0, e0).includes (util::point2u {2, 2}), "unsigned region corner inclusion");
|
2012-06-08 16:48:33 +10:00
|
|
|
|
2016-01-19 18:31:49 +11:00
|
|
|
tap.expect ( util::region2u (p0, e0).contains (util::point2u {1, 1}), "unsigned region center contains");
|
|
|
|
tap.expect (!util::region2u (p0, e0).contains (util::point2u {0, 0}), "unsigned region base contains");
|
|
|
|
tap.expect (!util::region2u (p0, e0).contains (util::point2u {2, 2}), "unsigned region corner contains");
|
2012-06-08 16:48:33 +10:00
|
|
|
|
2015-03-03 04:13:29 +11:00
|
|
|
//CHECK (region<2,intmax_t> (0, 0, 10, 10).includes (point2d (0.4, 0.01)));
|
|
|
|
//CHECK (region<2,intmax_t> (0, 0, 10, 10).contains (point2d (0.4, 0.01)));
|
2012-06-08 16:48:33 +10:00
|
|
|
|
2016-01-19 18:31:49 +11:00
|
|
|
return tap.status ();
|
2012-05-11 12:21:47 +10:00
|
|
|
}
|