Skip to content

line_in_rectangle_rotated_furthest

Vašek edited this page Feb 10, 2019 · 2 revisions

line_in_rectangle_rotated_furthest

Returns the furthest intersection point of the given line and the given rectangle

Syntax:

line_in_rectangle_rotated_furthest(p1, p2, r)
Argument Description
Vector2 p1 The first point of the given line
Vector2 p2 The other point of the given line
RotatedRectangle r The given rectangle

Returns: Vector2?

Description:

If a given line intersects a given rectangle, the function returns the furthest intersection point. Otherwise, the function returns null.

Example:

Vector2 p1 = new Vector2(8, 8);
Vector2 p2 = new Vector2(8, 24);
Vector2 p3 = new Vector2(24, 24);
Vector2 p4 = new Vector2(24, 8);
RotatedRectangle r = new RotatedRectangle(p1, p2, p3, p4);

Vector2? pos = line_in_rectangle_rotated_furthest(new Vector2(0, 0), new Vector2(64, 64), r);

if (pos.HasValue)
{
    Vector2 point = pos.Value;
}

This function will set point to 24, 24.

Back to Raycasting

Clone this wiki locally