euclidean

Crates.ioeuclidean
lib.rseuclidean
version0.1.0
created_at2025-04-21 21:37:24.880733+00
updated_at2025-04-21 21:37:24.880733+00
descriptionA collection of operations for euclidean geometry in three dimensions.
homepage
repository
max_upload_size
id1643243
size31,536
Makogan (Makogan)

documentation

README

Euclidean

This crate contains a collection of type agnostic euclidean algorithms..

These include, but are not limited to:

  • Triangle box intersection.
  • Segment-segment intersection.
  • Projecting a point onto a line.
  • Projecting a point onto a plane.
  • Find the closest points on two lines.
  • And more.

The crate relies on linear_isomoprhic to abstract over the underlying type, meaning that it can be used with a wide variety of underlying vector types.

Some functions are dimension agnostic. However, many assume $\mathbb{R}^3$.

Example use:

use crate::segment_segment_intersection;

use ::core::f32::consts::PI;
type Vec2 = nalgebra::Vector2<f32>;
type Vec3 = nalgebra::Vector3<f32>;

fn project_onto_polyline() {
    let curve: Vec<_> = (0..50)
        .map(|i| {
            let t = i as f32 / 49.;
            let t = t * PI;

            Vec2::new(t.cos(), t.sin())
        })
        .collect();

    let point = Vec2::new(0., 10.);
    let (proj, param, interval) = project_onto_open_poly_line(&point, &curve);

    assert!((proj - Vec2::new(0., 1.0)).norm() < 0.001,);
    assert!((param - 0.5).abs() < 0.001);
    assert!(interval == 24);
}

The library is tested directly against the Nalgebra crate. If you find that it doesn't work with your own vector type, please open an issue.

Commit count: 0

cargo fmt