मुख्य सामग्री पर जाएँ

raygeo.geo.shape.arc

Arc geometry queries and conversions.

Provides bounding rectangle computation, intersection tests (arc-rect, arc-circle, arc-polygons), arc linearization into line segments for rendering or further processing, angle utilities (normalize, direction, containment), and arc midpoint / closest-point lookups.

Functions​

does_arc_intersect_circle()​

does_arc_intersect_circle(
arc_start: types.Point,
arc_end: types.Point,
arc_center: types.Point,
clockwise: bool,
circle_center: types.Point,
circle_radius: float,
) -> bool

Check if an arc intersects a circle.

ParameterTypeDescription
arc_starttypes.PointArc start point (x, y).
arc_endtypes.PointArc end point (x, y).
arc_centertypes.PointArc center point (x, y).
clockwiseboolWhether the arc is clockwise.
circle_centertypes.PointCircle center (x, y).
circle_radiusfloatCircle radius.
ReturnsboolTrue if the arc intersects the circle.
ComplexityO(n) time, O(1) space

does_arc_intersect_rect()​

does_arc_intersect_rect(
arc_start: types.Point,
arc_end: types.Point,
arc_center: types.Point,
clockwise: bool,
rect: types.Rect,
) -> bool

Check if an arc intersects a rectangle.

ParameterTypeDescription
arc_starttypes.PointArc start point (x, y).
arc_endtypes.PointArc end point (x, y).
arc_centertypes.PointArc center point (x, y).
clockwiseboolWhether the arc is clockwise.
recttypes.RectRectangle (x_min, y_min, x_max, y_max).
ReturnsboolTrue if the arc intersects the rectangle.
ComplexityO(n) time, O(1) space

get_arc_angles()​

get_arc_angles(
start: types.Point,
end: types.Point,
center: types.Point,
clockwise: bool,
) -> types.Point3D

Get the start, end, and sweep angles of an arc.

ParameterTypeDescription
starttypes.PointArc start point (x, y).
endtypes.PointArc end point (x, y).
centertypes.PointArc center point (x, y).
clockwiseboolWhether the arc is clockwise.
Returnstypes.Point3DTuple of (start_angle, end_angle, sweep_angle) in radians.
ComplexityO(1) time, O(1) space

get_arc_bounds()​

get_arc_bounds(
start: types.Point,
end: types.Point,
center: types.Point,
clockwise: bool,
) -> types.Rect

Get the bounding rectangle of an arc.

ParameterTypeDescription
starttypes.PointArc start point (x, y).
endtypes.PointArc end point (x, y).
centertypes.PointArc center point (x, y).
clockwiseboolWhether the arc is clockwise.
Returnstypes.RectBounding rectangle as (x_min, y_min, x_max, y_max).
ComplexityO(1) time, O(1) space

get_arc_closest_point()​

get_arc_closest_point(
arc_cmd: Any,
start_pos: types.Point3D,
x: float,
y: float,
) -> Optional[tuple[float, types.Point, float]]

Get the closest point on an arc to a given point.

ParameterTypeDescription
arc_cmdAnyArc command row or MockArc-like object.
start_postypes.Point3DStart position (x, y, z).
xfloatX coordinate of target point.
yfloatY coordinate of target point.
ReturnsOptional[tuple[float, types.Point, float]]Tuple of (parameter, closest_point, distance) or None.
ComplexityO(n) time, O(1) space

get_arc_direction()​

get_arc_direction(
center: types.Point,
start: types.Point,
mouse: types.Point,
) -> bool

Get the direction (CW/CCW) of an arc at a mouse point.

ParameterTypeDescription
centertypes.PointArc center (x, y).
starttypes.PointArc start point (x, y).
mousetypes.PointMouse point (x, y).
ReturnsboolTrue if clockwise, False if counter-clockwise.
ComplexityO(1) time, O(1) space

get_arc_length()​

get_arc_length(
start_pos: types.Point,
end_pos: types.Point,
center_offset: types.Point,
clockwise: bool,
) -> float

Compute the arc length of a circular arc.

ParameterTypeDescription
start_postypes.PointStart point (x, y).
end_postypes.PointEnd point (x, y).
center_offsettypes.PointCenter offset (i, j) from start.
clockwiseboolTrue for clockwise, False for counter-clockwise.
ReturnsfloatArc length.
ComplexityO(1) time, O(1) space

get_arc_midpoint()​

get_arc_midpoint(
start: types.Point,
end: types.Point,
center: types.Point,
clockwise: bool,
) -> types.Point

Get the midpoint of an arc.

ParameterTypeDescription
starttypes.PointArc start point (x, y).
endtypes.PointArc end point (x, y).
centertypes.PointArc center point (x, y).
clockwiseboolWhether the arc is clockwise.
Returnstypes.PointMidpoint (x, y).
ComplexityO(1) time, O(1) space

get_arc_sweep()​

get_arc_sweep(start_angle: float, end_angle: float, clockwise: bool) -> float

Compute the signed sweep angle for an arc.

Handles direction (CW/CCW) and full-circle detection.

ParameterTypeDescription
start_anglefloatStart angle in radians.
end_anglefloatEnd angle in radians.
clockwiseboolWhether the arc is clockwise.
ReturnsfloatSigned sweep angle in radians.
ComplexityO(1) time, O(1) space

get_arc_through_point()​

get_arc_through_point(
t_start: types.Point,
t_end: types.Point,
t_mid: types.Point,
center: types.Point,
radius: float,
) -> types.Polygon

Build a circular arc through three points around a centre.

Returns a polyline approximation of the arc from t_start to t_end that passes through t_mid, with the given centre and radius.

ParameterTypeDescription
t_starttypes.PointArc start point (x, y).
t_endtypes.PointArc end point (x, y).
t_midtypes.PointPoint the arc must pass through (x, y).
centertypes.PointArc centre (x, y).
radiusfloatArc radius.
Returnstypes.PolygonPolyline approximation as list of (x, y) points.

Construct a circular arc through a given point

Construct a circular arc through a given point

get_polyline_turn_sign()​

get_polyline_turn_sign(polyline: Sequence[types.Point]) -> float

Determine the turn direction of a polyline at its midpoint.

Computes the cross product of the edge vectors just before and just after the midpoint vertex. Returns +1.0 for a counter-clockwise (left) turn and -1.0 for a clockwise (right) turn.

ParameterTypeDescription
polylineSequence[types.Point]Open polyline as (x, y) points.
Returnsfloat+1.0 (CCW) or -1.0 (CW).
ComplexityO(1) time, O(1) space

Determine turn direction of a polyline at its midpoint vertex

Determine turn direction of a polyline at its midpoint vertex

is_angle_between()​

is_angle_between(
angle: float,
start: float,
end: float,
clockwise: bool,
) -> bool

Check if an angle is between two other angles.

ParameterTypeDescription
anglefloatAngle to test.
startfloatStart angle.
endfloatEnd angle.
clockwiseboolWhether the arc is clockwise.
ReturnsboolTrue if angle is between start and end.
ComplexityO(1) time, O(1) space

is_arc_clockwise()​

is_arc_clockwise(
points: Sequence[types.Point2DOr3D],
center: types.Point2DOr3D,
) -> bool

Check if an arc is clockwise.

ParameterTypeDescription
pointsSequence[types.Point2DOr3D]Sequence of (x, y) points on the arc.
centertypes.Point2DOr3DArc center (x, y).
ReturnsboolTrue if the arc is clockwise.
ComplexityO(n) time, O(1) space

is_arc_inside_polygons()​

is_arc_inside_polygons(
arc_start: types.Point,
arc_end: types.Point,
arc_center: types.Point,
clockwise: bool,
polygons: Any,
) -> bool

Check if an arc is inside a set of polygons.

ParameterTypeDescription
arc_starttypes.PointArc start point (x, y).
arc_endtypes.PointArc end point (x, y).
arc_centertypes.PointArc center point (x, y).
clockwiseboolWhether the arc is clockwise.
polygonsAnyList of polygons to check against.
ReturnsboolTrue if the arc is inside all polygons.
ComplexityO(n * m) time, O(1) space

linearize_arc()​

linearize_arc(
arc_cmd: Any,
start_point: types.Point3D,
resolution: float = 0.1,
) -> list[tuple[types.Point3D, types.Point3D]]

Linearize an arc into line segments.

ParameterTypeDescription
arc_cmdAnyArc command row or MockArc-like object.
start_pointtypes.Point3DStart point (x, y, z).
resolutionfloat = 0.1Maximum segment length.
Returnslist[tuple[types.Point3D, types.Point3D]]List of (p1, p2) segment pairs.
ComplexityO(n) time, O(n) space

Arc linearization: coarse and fine resolution

Arc linearization: coarse and fine resolution

normalize_angle()​

normalize_angle(angle: float) -> float

Normalize an angle to the range [0, 2*pi).

ParameterTypeDescription
anglefloatAngle in radians.
ReturnsfloatNormalized angle in [0, 2*pi).
ComplexityO(1) time, O(1) space

normalize_angle_signed()​

normalize_angle_signed(angle: float) -> float

Normalize an angle to the range [-pi, pi).

ParameterTypeDescription
anglefloatAngle in radians.
ReturnsfloatNormalized angle in [-pi, pi).
ComplexityO(1) time, O(1) space