skspatial.objects.Circle.best_fit¶
- classmethod Circle.best_fit(points: Union[ndarray, Sequence]) Circle [source]¶
Return the sphere of best fit for a set of 2D points.
- Parameters
- pointsarray_like
Input 2D points.
- Returns
- Circle
The circle of best fit.
- Raises
- ValueError
If the points are not 2D. If there are fewer than three points. If the points are collinear.
References
https://meshlogic.github.io/posts/jupyter/curve-fitting/fitting-a-circle-to-cluster-of-3d-points/
Examples
>>> import numpy as np
>>> from skspatial.objects import Circle
>>> points = [[1, 1], [2, 2], [3, 1]] >>> circle = Circle.best_fit(points)
>>> circle.point Point([2., 1.])
>>> np.round(circle.radius, 2) 1.0