devela/num/geom/shape/point/
mod.rs

1// devela::num::geom::shape::point
2//
3//! A geometrical point.
4//
5
6#[cfg(feature = "alloc")]
7use crate::Vec;
8
9mod impl_traits;
10mod methods;
11
12/// A coordinate position in `D`-space without extent.
13pub struct Point<T, const D: usize> {
14    /// The D-dimensional coordinates.
15    pub coords: [T; D],
16}
17// /// A shared reference coordinate position in `D`-space without extent.
18// pub struct PointRef<&'p, T, const D: usize> {
19//     pub coords: &'a [T; D],
20// }
21// /// An exclusive reference coordinate position in `D`-space without extent.
22// pub struct PointRef<&mut 'a, T, const D: usize> {
23//     /// The D-dimensional coordinates.
24//     pub coords: &mut [T; D],
25// }
26
27/// A specific position in 2d-space without a size.
28pub type Point2d<T> = Point<T, 2>;
29
30/// A specific position in 3d-space without a size.
31pub type Point3d<T> = Point<T, 3>;
32
33/* lists */
34
35/// A static sequence of `N` `D`-dimensional [`Point`]s.
36#[must_use]
37#[repr(transparent)]
38pub struct Points<T, const D: usize, const N: usize> {
39    /// The array of points.
40    pub array: [Point<T, D>; N],
41}
42
43// /// A shared reference to a static sequence of `N` `D`-dimensional [`Point`]s.
44// /// A shared reference coordinate position in `D`-space without extent.
45// pub struct PointRef<&'p, T, const D: usize> {
46//     pub coords: &'a [T; D],
47// }
48// /// An exclusive reference coordinate position in `D`-space without extent.
49// pub struct PointRef<&mut 'a, T, const D: usize> {
50//     /// The D-dimensional coordinates.
51//     pub coords: &mut [T; D],
52// }
53
54/// A dynamic sequence of `D`-dimensional [`Point`]s.
55#[cfg(feature = "alloc")]
56#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "alloc")))]
57pub struct VecPoints<T, const D: usize> {
58    /// The vec of points.
59    pub vec: Vec<Point<T, D>>,
60}
61// UNDERSTAND What do I gain for that?
62// UNDERSTAND also for NumRef trait…
63// TODO examples that showcase that!
64//
65//
66// /// A shared reference coordinate position in `D`-space without extent.
67// pub struct VecPointsRef<&'p, T, const D: usize> {
68//     pub coords: &'a [T; D],
69// }
70// /// An exclusive reference coordinate position in `D`-space without extent.
71// pub struct VecPointsRef<&mut 'a, T, const D: usize> {
72//     /// The D-dimensional coordinates.
73//     pub coords: &mut [T; D],
74// }