Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public override bool Touch(Shape2 inShape)
 {
     return(Touch((Polygon2)GeoConverter.Convert(inShape, ShapeType.Polygon, false)));
 }
Esempio n. 4
0
 public bool Touch(Circle inCircle)
 {
     return(Touch((Polygon2)GeoConverter.Convert(inCircle, ShapeType.Polygon)));
 }
Esempio n. 5
0
 public bool Touch(Rectangle inRectangle)
 {
     return(Touch((Polygon2)GeoConverter.Convert(inRectangle, ShapeType.Polygon)));
 }