Piccolo.NET

PUtil.RectIntersectsPerpLine Method 

Return true if the given rectangle intersects the given line, which must have either a slope of 0 or 90 degrees.

public static bool RectIntersectsPerpLine(
   RectangleF rect,
   float x1,
   float y1,
   float x2,
   float y2
);

Parameters

rect
The rectangle to compare for intersection.
x1
The x-coordinate of the first end point of the line to check for intersection.
y1
The y-coordinate of the first end point of the line to check for intersection.
x2
The x-coordinate of the second end point of the line to check for intersection.
y2
The y-coordinate of the second end point of the line to check for intersection.

Return Value

True if the rectangle intersects the line; otherwise, false.

Remarks

This is a quick method to check if a vertical or horizontal line intersects a rectangle. If the line is not perpendicular or horizontal, the result will be unpredictable.

See Also

PUtil Class | UMD.HCIL.Piccolo.Util Namespace


Web Accessibility