--- a/src/cube.rs Fri Dec 06 14:27:14 2024 -0500 +++ b/src/cube.rs Fri Dec 06 14:57:11 2024 -0500 @@ -14,26 +14,40 @@ pub enum Face {F1 = 1, F2 = 2, F3 = 3, F4 = 4, F5 = 5, F6 = 6} use Face::*; +/// General point in 2D pub type Point = Loc<f64, 2>; +/// Types for faces adjacent to a given face. pub type AdjacentFaces = [Face; 4]; +/// Types of paths on a cube #[derive(Clone, Debug, Serialize)] pub enum Path { + /// Direct path from an unindicated source face to a `destination` face. Direct { destination : Face }, + /// Indirect path from an unindicated source face to a `destination` face, + /// via an `intermediate` face. Indirect { destination : Face, intermediate : Face }, } /// An iterator over paths on a cube, from a source face to a destination face. #[derive(Clone, Debug)] pub enum PathIter { + /// Direct path to a destination. Same { + /// Deistination face destination : Face, + /// Indicator whether the only possible [`Path::Direct`] has already been returned. exhausted : bool }, + /// Path via several possible intermedite faces. + /// This is used to generate several [`Path::Indirect`]. Indirect { + /// Destination face destination : Face, + /// Possible intermediate faces intermediate : AdjacentFaces, + /// Intermediate face index counter. current : usize } } @@ -197,7 +211,7 @@ } /// Indicates whether an unfolded point `p` is on this face, i.e., - /// has coordinates in [0,1]². + /// has coordinates in $\[0,1\]^2$. pub fn is_in_face(&self, p: &Point) -> bool { p.iter().all(|t| 0.0 <= *t && *t <= 1.0) } @@ -264,6 +278,7 @@ } } +/// Point on a the surface of the unit cube $\[0,1\]^3$. #[derive(Clone, Debug, PartialEq, Serialize)] pub struct OnCube { face : Face, @@ -348,6 +363,7 @@ mod tests { use super::*; + /// Tests that the distancse between the centers of all the faces are correctly calculated. #[test] fn center_distance() { let center = Loc([0.5, 0.5]); @@ -367,6 +383,8 @@ } } + /// Tests that the distances between points on the boundaries of distinct faces are + /// correctly calculated. #[test] fn boundary_distance() { let left = Loc([0.0, 0.5]); @@ -399,6 +417,7 @@ } + /// Tests that the conversions between the coordinate systems of each face is working correctly. #[test] fn convert_adjacent() { let point = Loc([0.4, 0.6]); @@ -440,6 +459,7 @@ // } // } + /// Tests that the logarithmic map is working correctly between adjacent faces. #[test] fn log_adjacent() { let p1 = OnCube{ face : F1, point : Loc([0.5, 0.5])}; @@ -448,6 +468,7 @@ assert_eq!(p1.log(&p2).norm(L2), 1.0); } + /// Tests that the logarithmic map is working correctly between opposing faces. #[test] fn log_opposing_equal() { let p1 = OnCube{ face : F1, point : Loc([0.5, 0.5])}; @@ -456,6 +477,8 @@ assert_eq!(p1.log(&p2).norm(L2), 2.0); } + /// Tests that the logarithmic map is working correctly between opposing faces when there + /// is a unique shortest geodesic. #[test] fn log_opposing_unique_shortest() { let p1 = OnCube{ face : F1, point : Loc([0.3, 0.25])};