示例#1
0
 public LineSegment[] getSidesOfRectangle(Rectangle r)
 {
     LineSegment[] result = new LineSegment[4];
     result[0] = new LineSegment(new Vector2(r.Left, r.Top), new Vector2(r.Right, r.Top));
     result[1] = new LineSegment(new Vector2(r.Right, r.Top), new Vector2(r.Right, r.Bottom));
     result[2] = new LineSegment(new Vector2(r.Left, r.Bottom), new Vector2(r.Right, r.Bottom));
     result[3] = new LineSegment(new Vector2(r.Left, r.Top), new Vector2(r.Left, r.Bottom));
     return result;
 }
示例#2
0
        public LineSegment[] getDeltaVectors(Rectangle a, Rectangle b)
        {
            LineSegment[] result = new LineSegment[4];

            //top left corner
            result[0] = new LineSegment(new Vector2(a.Left, a.Top), new Vector2(b.Left, b.Top));
            //top right corner
            result[1] = new LineSegment(new Vector2(a.Right, a.Top), new Vector2(b.Right, b.Top));
            //bottom left corner
            result[2] = new LineSegment(new Vector2(a.Left, a.Bottom), new Vector2(b.Left, b.Bottom));
            //bottom right corner
            result[3] = new LineSegment(new Vector2(a.Right, a.Bottom), new Vector2(b.Right, b.Bottom));

            return result;
        }