| Crates.io | legasea_line |
| lib.rs | legasea_line |
| version | 0.2.3 |
| created_at | 2020-09-11 15:52:34.176311+00 |
| updated_at | 2025-11-29 05:04:01.346093+00 |
| description | Tools for working with lines |
| homepage | https://git.sr.ht/~halzy/legasea_line |
| repository | https://git.sr.ht/~halzy/legasea_line |
| max_upload_size | |
| id | 287425 |
| size | 10,304 |
A simple utility for working with lines.
Provides a method to get the distance from a point to a Line.
Add this to your Cargo.toml:
[dependencies]
legasea_line = "0.2"
use legasea_line::Line;
use mint::Point2;
// Create a horizontal line from (-3, 1) to (3, 1)
let a = Point2 { x: -3, y: 1 };
let b = Point2 { x: 3, y: 1 };
let line = Line::new(a, b);
// Get a LineDistance calculator for efficient repeated distance calculations
let line_distance = line.distance();
// Calculate the perpendicular distance from a point to the line
let point = Point2 { x: 0, y: 6 };
let distance = line_distance.to(&point).unwrap();
assert_eq!(distance, 5.0);
Line<T> - A line defined by two points. Provides a distance() method that returns a LineDistance.LineDistance - Pre-calculates values for efficient repeated distance calculations. Use to(&point) to get the perpendicular distance from the line to a point. Also exposes the length of the line segment.mint - For the Point2 typenum-traits - For numeric type conversionsMIT