Skip to content

Commit fea8731

Browse files
gregmeessrms80
authored andcommitted
Add Polygon2d.Contains(Segment2d) method
1 parent 838b040 commit fea8731

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Folders
2+
.vs/
3+
14
# Compiled Object files
25
*.slo
36
*.lo

curve/Polygon2d.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,20 @@ public bool Contains(Polygon2d o) {
333333
return true;
334334
}
335335

336+
public bool Contains(Segment2d o)
337+
{
338+
if (Contains(o.P0) == false || Contains(o.P1) == false)
339+
return false;
340+
341+
foreach (Segment2d seg in SegmentItr())
342+
{
343+
if (seg.Intersects(o))
344+
return false;
345+
}
346+
return true;
347+
}
336348

337-
public bool Intersects(Polygon2d o) {
349+
public bool Intersects(Polygon2d o) {
338350
if ( ! this.GetBounds().Intersects( o.GetBounds() ) )
339351
return false;
340352

0 commit comments

Comments
 (0)