Skip to content

line_in_rectangle_rotated_any

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

line_in_rectangle_rotated_any

Returns random point where the given line intersects the given rectangle

Syntax:

line_in_rectangle_rotated_any(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 a random 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_any(new Vector2(0, 0), new Vector2(64, 64), r);

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

This function will randomly set point to 8, 8 or to 24, 24.

Back to Raycasting

Clone this wiki locally