Skip to main content

axiolid_linear/
bounded.rs

1//! Bounded and half-bounded linear geometry.
2//!
3//! `Ray3` is deliberately **not** redefined here: `axiolid_core::Ray3` already
4//! owns that value, and a second incompatible `Ray3` would split the vocabulary
5//! for every existing consumer. It is re-exported instead, so this package
6//! still presents a complete linear vocabulary without duplicating a type.
7
8use axiolid_core::{Point2, Point3, Vec2};
9
10pub use axiolid_core::Ray3;
11
12/// A parametric two-dimensional ray: `origin + t * direction` for `t >= 0`.
13///
14/// The 3D counterpart lives in `axiolid-core`; this is the missing planar half
15/// of the pair, added because planar linear queries need a stable value type.
16#[derive(Debug, Clone, Copy, PartialEq)]
17pub struct Ray2 {
18    /// Ray start.
19    pub origin: Point2,
20    /// Ray direction. It need not be normalized at the storage boundary.
21    pub direction: Vec2,
22}
23
24/// A bounded linear span between two endpoints.
25///
26/// A segment is stored by its endpoints rather than an origin/direction pair
27/// with an interval, because endpoint identity is what topology and imported
28/// data actually carry. The natural parameterisation is `start + t * (end -
29/// start)` over `t` in `[0, 1]`; keeping that implicit avoids inventing a
30/// parameter range the source never stated.
31#[derive(Debug, Clone, Copy, PartialEq)]
32pub struct Segment<P> {
33    /// Endpoint at parameter zero.
34    pub start: P,
35    /// Endpoint at parameter one.
36    pub end: P,
37}
38
39/// Two-dimensional segment.
40pub type Segment2 = Segment<Point2>;
41/// Three-dimensional segment.
42pub type Segment3 = Segment<Point3>;