Aller au contenu principal

raygeo.geo.shape.ellipse

Ellipse geometry queries.

Provides parametric point evaluation, uniform sampling over a full turn, circumference membership and containment tests, and the enclosed area, for an ellipse given by center, semi-axis lengths and rotation.

Functions​

get_ellipse_area()​

get_ellipse_area(rx: float, ry: float) -> float

Area enclosed by the ellipse.

ParameterTypeDescription
rxfloatSemi-axis length along x.
ryfloatSemi-axis length along y.
ReturnsfloatEnclosed area (pi * rx * ry).
ComplexityO(1) time, O(1) space

get_ellipse_point_at()​

get_ellipse_point_at(
center: types.Point,
rx: float,
ry: float,
rotation: float,
t: float,
) -> types.Point

Point on the ellipse at parameter t.

Evaluates center + R(rotation) * (rx * cos(t), ry * sin(t)).

ParameterTypeDescription
centertypes.PointEllipse center (x, y).
rxfloatSemi-axis length along the rotated x direction.
ryfloatSemi-axis length along the rotated y direction.
rotationfloatRotation of the x axis in radians.
tfloatCurve parameter in radians.
Returnstypes.PointPoint (x, y) on the ellipse.
ComplexityO(1) time, O(1) space

get_ellipse_samples()​

get_ellipse_samples(
center: types.Point,
rx: float,
ry: float,
rotation: float,
segments: int,
) -> list[types.Point]

Sample the ellipse uniformly over a full turn.

Returns segments + 1 points from t = 0 through the closing point at t = 2*pi.

ParameterTypeDescription
centertypes.PointEllipse center (x, y).
rxfloatSemi-axis length along the rotated x direction.
ryfloatSemi-axis length along the rotated y direction.
rotationfloatRotation of the x axis in radians.
segmentsintNumber of segments (sample count - 1).
Returnslist[types.Point]List of points (x, y).
ComplexityO(n) time, O(n) space for n samples

is_point_inside_ellipse()​

is_point_inside_ellipse(
point: types.Point,
center: types.Point,
rx: float,
ry: float,
rotation: float,
) -> bool

Check whether a point lies inside or on the ellipse.

ParameterTypeDescription
pointtypes.PointQuery point (x, y).
centertypes.PointEllipse center (x, y).
rxfloatSemi-axis length along the rotated x direction.
ryfloatSemi-axis length along the rotated y direction.
rotationfloatRotation of the x axis in radians.
ReturnsboolTrue if the point is inside or on the ellipse.
ComplexityO(1) time, O(1) space

is_point_on_ellipse()​

is_point_on_ellipse(
point: types.Point,
center: types.Point,
rx: float,
ry: float,
rotation: float,
tolerance: float,
) -> bool

Check whether a point lies on the ellipse circumference.

The tolerance is interpreted in world units along the radial direction, scaled by the smaller semi-axis.

ParameterTypeDescription
pointtypes.PointQuery point (x, y).
centertypes.PointEllipse center (x, y).
rxfloatSemi-axis length along the rotated x direction.
ryfloatSemi-axis length along the rotated y direction.
rotationfloatRotation of the x axis in radians.
tolerancefloatWorld-unit distance tolerance.
ReturnsboolTrue if the point lies on the circumference within tolerance.
ComplexityO(1) time, O(1) space