raygeo.geo.shape.line
Line segment geometry queries.
Provides line-line intersection (infinite lines), line-segment intersection, closest point on a line or segment to a given point, line-segment-vs-polygon intersections, point-on-segment tests, point-in-rectangle tests, rectangle containment checks, and angle-at-vertex computation.
Functions
does_line_segment_intersect_circle()
does_line_segment_intersect_circle(p1: Point, p2: Point, circle_center: Point, circle_radius: float) -> bool
Check if a line segment intersects a circle.
Returns: True if the segment intersects the circle.
| Parameter | Type | Description |
|---|---|---|
p1 | Point | Start of the line segment. |
p2 | Point | End of the line segment. |
circle_center | Point | Circle center (x, y). |
circle_radius | float | Circle radius. |
| Returns | bool |
does_line_segment_intersect_rect()
does_line_segment_intersect_rect(p1: Point, p2: Point, rect: Rect) -> bool
Check if a line segment intersects a rectangle.
Returns: True if the segment intersects the rectangle.
| Parameter | Type | Description |
|---|---|---|
p1 | Point | Start of the line segment. |
p2 | Point | End of the line segment. |
rect | Rect | Rectangle (x_min, y_min, x_max, y_max). |
| Returns | bool |
get_angle_at_vertex()
get_angle_at_vertex(p0: Point, p1: Point, p2: Point) -> float
Get the angle at a vertex between three points.
Returns: Angle in radians.
| Parameter | Type | Description |
|---|---|---|
p0 | Point | First point. |
p1 | Point | Vertex point. |
p2 | Point | Third point. |
| Returns | float |
get_line_closest_point()
get_line_closest_point(line_p1: Point, line_p2: Point, x: float, y: float) -> Point
Get the closest point on a line to a given point.
Returns: Closest point (x, y) on the line.
| Parameter | Type | Description |
|---|---|---|
line_p1 | Point | First point on the line. |
line_p2 | Point | Second point on the line. |
x | float | X coordinate of target point. |
y | float | Y coordinate of target point. |
| Returns | Point |
get_line_line_intersection()
get_line_line_intersection(p1: Point, p2: Point, p3: Point, p4: Point) -> Optional[Point]
Get the intersection of two infinite lines.
Returns: Intersection point (x, y) or None.
| Parameter | Type | Description |
|---|---|---|
p1 | Point | First point on line 1. |
p2 | Point | Second point on line 1. |
p3 | Point | First point on line 2. |
p4 | Point | Second point on line 2. |
| Returns | Optional[Point] |
get_line_segment_closest_point()
get_line_segment_closest_point(seg_p1: Point, seg_p2: Point, x: float, y: float) -> tuple[float, Point, float]
Get closest point on a line segment to a point.
Returns: Tuple of (parameter, closest_point, distance).
| Parameter | Type | Description |
|---|---|---|
seg_p1 | Point | Start of the line segment. |
seg_p2 | Point | End of the line segment. |
x | float | X coordinate of target point. |
y | float | Y coordinate of target point. |
| Returns | tuple[float, Point, float] |
get_line_segment_intersection()
get_line_segment_intersection(p1: Point, p2: Point, p3: Point, p4: Point) -> Optional[Point]
Get the intersection of two line segments.
Returns: Intersection point (x, y) or None.
| Parameter | Type | Description |
|---|---|---|
p1 | Point | Start of segment 1. |
p2 | Point | End of segment 1. |
p3 | Point | Start of segment 2. |
p4 | Point | End of segment 2. |
| Returns | Optional[Point] |
get_line_segment_polygon_intersections()
get_line_segment_polygon_intersections(p1: Point, p2: Point, polygon: list[Polygon]) -> list[float]
Get t-values of line segment-polygon intersections.
Returns: List of t-values where the segment intersects.
| Parameter | Type | Description |
|---|---|---|
p1 | Point | Start of the line segment. |
p2 | Point | End of the line segment. |
polygon | list[Polygon] | Polygon(s) to test against. |
| Returns | list[float] |
get_point_line_distance()
get_point_line_distance(point: Point, line_p1: Point, line_p2: Point) -> float
Get the distance from a point to a line.
Returns: Perpendicular distance.
| Parameter | Type | Description |
|---|---|---|
point | Point | Point (x, y). |
line_p1 | Point | First point on the line. |
line_p2 | Point | Second point on the line. |
| Returns | float |
is_point_on_line_segment()
is_point_on_line_segment(point: Point, seg_p1: Point, seg_p2: Point) -> bool
Check if a point is on a line segment.
Returns: True if the point lies on the segment.
| Parameter | Type | Description |
|---|---|---|
point | Point | Point (x, y) to test. |
seg_p1 | Point | Start of the line segment. |
seg_p2 | Point | End of the line segment. |
| Returns | bool |