#linear-algebra #geometry #graphics

euclidean

A collection of operations for euclidean geometry in three dimensions

1 unstable release

Uses new Rust 2024

new 0.1.0 Apr 21, 2025

#971 in Math

Download history 77/week @ 2025-04-16

77 downloads per month
Used in mesh_rasterization

MIT license

25KB
544 lines

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.

Dependencies

~470KB