| Crates.io | polydf |
| lib.rs | polydf |
| version | 0.1.1 |
| created_at | 2025-09-11 04:17:43.47581+00 |
| updated_at | 2025-09-11 04:19:06.650782+00 |
| description | Distance queries for parametric curves in 2D and 3D (nearest point, unsigned distance, early-out with speed bounds). |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1833321 |
| size | 87,767 |
polydf provides fast nearest-point queries from points to differentiable parametric curves:
Highlights
t range.Quick start (2D)
use nalgebra::{Vector2, vector};
use polydf::{NearestOptions, nearest_t};
fn circle(t: f32) -> Vector2<f32> { vector![t.cos(), t.sin()] }
let p = vector![1.5, 0.0];
let res = nearest_t(p, circle, 0.0..=std::f32::consts::TAU, NearestOptions::default());
assert!((res.distance - 0.5).abs() < 1e-3);
Quick start (3D)
use nalgebra::{Vector3, vector};
use polydf::{NearestOptions, nearest_t_3d};
fn helix(t: f32) -> Vector3<f32> { vector![t.cos(), t.sin(), 0.5 * t] }
let p = vector![2.0, 0.0, 0.0];
let res = nearest_t_3d(p, helix, -10.0..=10.0, NearestOptions::default());
println!("t* = {} d = {}", res.t, res.distance);
Early-out (needs speed upper bound)
use polydf::is_definitely_far_3d;
let threshold = 5.0f32;
let speed_ub = Some(1.2f32); // for helix
let far = is_definitely_far_3d(p, helix, -10.0..=10.0, threshold, speed_ub, 64);
Examples
cargo run --example render_curve (2D image)cargo run --example render_curve_with_derivative (2D image with derivative)cargo run --example nearest_helix_3d (3D console demo)