public bool Touch(Polygon2 inShape) { bool inside = true; Polygon2 selfPoly = (Polygon2)GeoConverter.Convert(this, ShapeType.Polygon); Vector2 primoPoint = null; Vector2 lastPoint = null; foreach (Vector2 vec in inShape.Points) { if (lastPoint != null) { for (int i = 0; i < 4; i++) { if (Line.LineIntersectsLine(selfPoly.Points[0 + i], selfPoly.Points[(1 + i) % 4], vec, lastPoint)) { return(true); } } } else { primoPoint = new Vector2(vec.X, vec.Y); } //1 point not inside ? it's not inside... if (!Contains(vec)) { inside = false; } lastPoint = new Vector2(vec.X, vec.Y); } //Last chance... last segment for (int i = 0; i < 4; i++) { if (Line.LineIntersectsLine(selfPoly.Points[0 + i], selfPoly.Points[(1 + i) % 4], primoPoint, lastPoint)) { return(true); } } return(inside); }
public bool Touch(Stroke2 inStroke) { Polygon2 selfPoly = (Polygon2)GeoConverter.Convert(this, ShapeType.Polygon); Vector2 lastPoint = null; foreach (Vector2 vec in inStroke.Points) { if (lastPoint != null) { for (int i = 0; i < 4; i++) { if (Line.LineIntersectsLine(selfPoly.Points[0 + i], selfPoly.Points[(1 + i) % 4], vec, lastPoint)) { return(true); } } } lastPoint = new Vector2(vec.X, vec.Y); } return(false); }
public override bool Touch(Shape2 inShape) { return(Touch((Polygon2)GeoConverter.Convert(inShape, ShapeType.Polygon, false))); }
public bool Touch(Circle inCircle) { return(Touch((Polygon2)GeoConverter.Convert(inCircle, ShapeType.Polygon))); }
public bool Touch(Rectangle inRectangle) { return(Touch((Polygon2)GeoConverter.Convert(inRectangle, ShapeType.Polygon))); }