SuperMap.WindowsPhone.Core.PolylineElementClip.ClipLineSegment C# (CSharp) Method

ClipLineSegment() private method

private ClipLineSegment ( Point2D p0, Point2D p1, Rectangle2D box ) : Point2D
p0 Point2D
p1 Point2D
box Rectangle2D
return Point2D
        private Point2D ClipLineSegment(Point2D p0, Point2D p1, Rectangle2D box)
        {
            Point2D point = new Point2D(p1.X, p1.Y);
            if (p1.X < box.Left)
            {
                point = EdgeIntersection(p0, p1, box.Left, false);
            }
            else if (p1.X > box.Right)
            {
                point = EdgeIntersection(p0, p1, box.Right, false);
            }
            if (point.Y < box.Bottom)
            {
                return EdgeIntersection(p0, p1, box.Bottom, true);
            }
            if (point.Y > box.Top)
            {
                point = EdgeIntersection(p0, p1, box.Top, true);
            }
            return point;
        }