poly - line intersect and tests
This commit is contained in:
+15
-3
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user