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

raygeo.geo.shape.point

Individual point operations.

Provides equality testing within a configurable tolerance, midpoint computation between two points, 2D/3D get_circumcenter of three points, applying a 4x4 affine transformation matrix to a single point, point interpolation along a sequence, and moving-average smoothing of point sequences.

Functions​

are_points_equal_3d()​

are_points_equal_3d(
p1: types.Point3D,
p2: types.Point3D,
tolerance: float,
) -> bool

Check if two 3D points are equal within tolerance.

ParameterTypeDescription
p1types.Point3DFirst point (x, y, z).
p2types.Point3DSecond point (x, y, z).
tolerancefloatMaximum allowed difference.
ReturnsboolTrue if points are equal within tolerance.
ComplexityO(1) time, O(1) space

get_circumcenter()​

get_circumcenter(
a: types.Point,
b: types.Point,
c: types.Point,
) -> tuple[types.Point, float]

Compute the get_circumcenter and radius of three 2D points.

Returns the center of the unique circle passing through all three points along with its radius. Returns ((0.0, 0.0), -1.0) when the points are collinear.

ParameterTypeDescription
atypes.PointFirst point (x, y).
btypes.PointSecond point (x, y).
ctypes.PointThird point (x, y).
Returnstuple[types.Point, float](center, radius) where center is (x, y).
ComplexityO(1) time, O(1) space

get_circumcenter_3d()​

get_circumcenter_3d(
a: types.Point3D,
b: types.Point3D,
c: types.Point3D,
) -> Optional[types.Point3D]

Compute the get_circumcenter of three 3D points.

Returns the center of the unique circle passing through all three points. Returns None when the points are collinear.

ParameterTypeDescription
atypes.Point3DFirst point (x, y, z).
btypes.Point3DSecond point (x, y, z).
ctypes.Point3DThird point (x, y, z).
ReturnsOptional[types.Point3D]Circumcenter (x, y, z) or None if collinear.
ComplexityO(1) time, O(1) space

Circumcenter of three 3D points with circumcircle

Circumcenter of three 3D points with circumcircle

get_midpoint_3d()​

get_midpoint_3d(p1: types.Point3D, p2: types.Point3D) -> types.Point3D

Get the midpoint between two 3D points.

ParameterTypeDescription
p1types.Point3DFirst point (x, y, z).
p2types.Point3DSecond point (x, y, z).
Returnstypes.Point3DMidpoint (x, y, z).
ComplexityO(1) time, O(1) space

Midpoint of a 3D segment

Midpoint of a 3D segment

get_point_at_fraction()​

get_point_at_fraction(
points: list[types.Point],
fraction: float,
) -> types.Point

Get the point at a normalized fraction along a point sequence.

Linear interpolation along the polyline formed by points: fraction 0.0 is the first point, 1.0 is the last point.

ParameterTypeDescription
pointslist[types.Point]Sequence of points (x, y).
fractionfloatNormalized position along the sequence [0, 1].
Returnstypes.PointInterpolated point (x, y).
ComplexityO(1) time, O(1) space

get_points_moving_average()​

get_points_moving_average(
points: list[types.Point],
radius: int,
) -> list[types.Point]

Apply a moving average to a point sequence.

Each output point is the mean of the input points within radius positions on either side; the window shrinks and renormalizes near the sequence ends.

ParameterTypeDescription
pointslist[types.Point]Sequence of points (x, y).
radiusintWindow radius in points.
Returnslist[types.Point]Smoothed sequence of points (x, y).
ComplexityO(n * r) time, O(n) space where n is the point count and r the radius

rotate_point()​

rotate_point(point: types.Point, angle: float) -> types.Point

Rotate a 2D point around the origin.

ParameterTypeDescription
pointtypes.PointPoint (x, y) to rotate.
anglefloatRotation angle in radians (counter-clockwise).
Returnstypes.PointRotated point (x, y).
ComplexityO(1) time, O(1) space

transform_point_3d()​

transform_point_3d(
matrix: Sequence[Sequence[float]],
x: float,
y: float,
z: float,
) -> types.Point3D

Apply an affine transformation matrix to a 3D point.

ParameterTypeDescription
matrixSequence[Sequence[float]]4x4 affine transformation matrix.
xfloatX coordinate.
yfloatY coordinate.
zfloatZ coordinate.
Returnstypes.Point3DTransformed point (x, y, z).
ComplexityO(1) time, O(1) space