honeycomb_core/geometry/
mod.rs

1//! geometry representation types & operators
2//!
3//! This module contains all code related to custom spatial representation type implementations.
4//! This include custom vector / vertex types as well as a generic FP trait.
5
6mod dim2;
7mod dim3;
8
9pub use dim2::{vector::Vector2, vertex::Vertex2};
10pub use dim3::{vector::Vector3, vertex::Vertex3};
11
12use std::fmt::Debug;
13use std::ops::{AddAssign, DivAssign, MulAssign, SubAssign};
14use thiserror::Error;
15
16/// # Coordinates-level error enum
17#[derive(Error, Debug, PartialEq)]
18pub enum CoordsError {
19    /// Error returned when trying to compute the unit vector of a null [`Vector2`].
20    #[error("cannot compute unit direction of a null vector")]
21    InvalidUnitDir,
22    /// Error returned when trying to compute the normal to a null [`Vector2`].
23    #[error("cannot compute normal direction to a null vector")]
24    InvalidNormDir,
25}
26
27/// # Generic FP type trait
28///
29/// This trait is used for vertex & vector values. The static lifetime is a requirements induced
30/// by the attribute system implementation.
31pub trait CoordsFloat:
32    num_traits::Float
33    + Default
34    + AddAssign
35    + SubAssign
36    + MulAssign
37    + DivAssign
38    + Debug
39    + Send
40    + Sync
41    + 'static
42{
43}
44
45impl<
46        T: num_traits::Float
47            + Default
48            + AddAssign
49            + SubAssign
50            + MulAssign
51            + DivAssign
52            + Debug
53            + Send
54            + Sync
55            + 'static,
56    > CoordsFloat for T
57{
58}