65 const std::vector<HalfLineContainsPointCase> cases{
73 "Point on the ray start",
79 "Point on the ray end",
85 "Point on the ray, past the end",
91 "Point on the infinite line, but on the wrong side",
104 for(
const auto& c : cases )
106 BOOST_TEST_INFO( c.Description );
108 const bool contains = c.Hl.Contains( c.Point );
117 const std::vector<HalfLineHalfLineIntersectionCase> cases{
125 "Parallel, no intersection",
132 for(
const auto& c : cases )
134 BOOST_TEST_INFO( c.Description );
136 std::optional<VECTOR2I> intersection = c.HlA.Intersect( c.HlB );
138 BOOST_REQUIRE( intersection.has_value() == c.ExpectedIntersection.has_value() );
143 BOOST_TEST( *intersection == *c.ExpectedIntersection );
150 const std::vector<HalfLineBoxClipCase> cases{
152 "Center to right edge",
164 "Ray not in the box",
170 "Ray starts outside but crosses box",
177 for(
const auto& c : cases )
179 BOOST_TEST_INFO( c.Description );
183 BOOST_REQUIRE( clipped.has_value() == c.ExpectedClippedSeg.has_value() );
189 ( *clipped )( *c.ExpectedClippedSeg ) );
bool SegmentsHaveSameEndPoints(const SEG &aSeg1, const SEG &aSeg2)
Check that two SEGs have the same end points, in either order.
std::optional< SEG > ClipHalfLineToBox(const HALF_LINE &aRay, const BOX2I &aBox)
Get the segment of a half-line that is inside a box, if any.
Utility functions for working with shapes.
std::optional< SEG > ExpectedClippedSeg
std::optional< VECTOR2I > ExpectedIntersection
BOOST_TEST(box.ClosestPointTo(VECTOR2D(0, 0))==VECTOR2D(1, 2))
BOOST_AUTO_TEST_CASE(Contains)
BOOST_AUTO_TEST_SUITE_END()
VECTOR2< int32_t > VECTOR2I