r3fit
r3fit is a lightweight Rust library for fitting a circle to 2D points using a RANSAC-like method. It's built to handle noisy datasets by finding a circle that best fits the majority of inliers within a threshold.
Features
- Fit a circle using random triplets of points
- Detect and handle collinear cases
- Configurable iterations and radius threshold
- Deterministic mode via user-supplied RNG
- Useful diagnostics (e.g. inlier counting)
- Unit + property-based testing with
proptest
Disclaimer
The Python bindings are not complete, and for that matter neither is the Rust library. This was mostly meant for me to use in a different project where I needed these very specific methods. I will most likely never update this ever again.
Installation
Rust
Add to your Cargo.toml:
[]
= "0.1.1"
Or run
Python
Example (Rust)
Here's a simple example, more can be found in the unit tests.
use Circle;
let points = vec!;
let circle = fit.unwrap;
println!; // Circle: center=(0.0, 0.0), radius=1.0
assert_eq!;
assert_eq!;
assert_eq!;
As well as the corresponding image.

Example (Python)
Here's a simple example for how to use it in Python.
=
=
# Circle(x: -0.010063759065123072, y: 0.0614577470528755, r: 1.033185147957909)
As well as the corresponding image.
