poly - line intersect and tests

This commit is contained in:
Fraser Graham
2013-11-24 21:01:09 -08:00
parent 5b6dac04e0
commit 6170691eb1
3 changed files with 79 additions and 3 deletions
+15 -3
View File
@@ -61,9 +61,21 @@ func ProjectPolygon(axis Vector2d, p Polygon2d) (min float32, max float32) {
return min, max
}
func PolygonIntersection(r Polygon2d, p Point2d, v Vector2d) (bool, bool, Point2d) {
// TBD
return false, false, Point2d{}
func PolygonIntersection(r Polygon2d, p Point2d, v Vector2d) (bool, Point2d) {
for point, _ := range r.Points {
if point == len(r.Points) {
break
}
edgePt, edgeVec := r.Edge(point)
intersection, pt := Intersection(p, edgePt, v, edgeVec)
if intersection {
return intersection, pt
}
}
return false, Point2d{}
}
func PolyPolyIntersection(p1 Polygon2d, v1 Vector2d, p2 Polygon2d, v2 Vector2d) bool {