No project description provided
Project description
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:
[dependencies]
r3fit = "0.1.1"
Or run
$ cargo add r3fit
Python
$ pip install r3fit
Example (Rust)
Here's a simple example, more can be found in the unit tests.
use r3fit::Circle;
let points = vec![(0.0, 1.0), (1.0, 0.0), (-1.0, 0.0)];
let circle = Circle::fit(&points, 1000, 0.1).unwrap();
println!("{}", circle); // Circle: center=(0.0, 0.0), radius=1.0
assert_eq!(circle.x, 0.0);
assert_eq!(circle.y, 0.0);
assert_eq!(circle.r, 1.0);
As well as the corresponding image.
Example (Python)
Here's a simple example for how to use it in Python.
import numpy as np
import r3fit
xs = np.array([[ 1.04074565, 0.06601208],
[ 0.82567141, 0.62465951],
[ 0.27211257, 1.05536321],
[-0.3230298 , 0.99809331],
[-0.69139874, 0.49374204],
[-1.03243453, -0.08763805],
[-0.86916729, -0.52544072],
[-0.22495387, -0.93536315],
[ 0.25773429, -0.8631605 ],
[ 0.8385662 , -0.52786283]])
circle = r3fit.fit(xs, 1000, 0.25)
print(circle) # Circle(x: -0.010063759065123072, y: 0.0614577470528755, r: 1.033185147957909)
As well as the corresponding image.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file r3fit-0.1.2.tar.gz.
File metadata
- Download URL: r3fit-0.1.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4dde4210df012788651c448b4ffdd8d0e809ca265830a2c056be840fa521946
|
|
| MD5 |
59f318efe50ea5af34d8e74f72d9d6e8
|
|
| BLAKE2b-256 |
f0ffdf92ae0aa57b0d8fd9cec0059f9d7e800ad64be9a3835e861e6f96ed80bd
|
File details
Details for the file r3fit-0.1.2-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: r3fit-0.1.2-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 166.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5259c202c6a0666129e0fda866ba795d4f106c8db3db3077c10b98e88547f41
|
|
| MD5 |
0c921938ac4d361dc10db49fb5a83cb3
|
|
| BLAKE2b-256 |
b69691548ab88a6fad7ca02ca52dd5e9cbda782c7c798716619f89bbde9c106c
|