--- a/src/cube.rs Mon Oct 21 14:02:52 2024 -0500 +++ b/src/cube.rs Mon Oct 21 15:07:41 2024 -0500 @@ -273,7 +273,48 @@ use super::*; #[test] - fn log_test_adjacent() { + fn convert_adjacent() { + let point = Loc([0.4, 0.6]); + + for f1 in [F1, F2, F3, F4, F5, F6] { + for f2 in [F1, F2, F3, F4, F5, F6] { + println!("{:?}-{:?}", f1, f2); + match f1.convert_adjacent(f2, &point) { + None => assert_eq!(f2.opposing_face(), f1), + Some(q) => { + match f2.convert_adjacent(f1, &q) { + None => assert_eq!(f1.opposing_face(), f2), + Some(p) => assert!((p-&point).norm(L2) < 1e-9), + } + } + } + } + } + } + + // This will fail, as different return path does not guarantee + // that a point outside the face will be returned to its point of origin. + // #[test] + // fn convert_paths() { + // let point = Loc([0.4, 0.6]); + + // for f1 in [F1, F2, F3, F4, F5, F6] { + // for f2 in [F1, F2, F3, F4, F5, F6] { + // for p1 in f2.paths(f1) { + // for p2 in f1.paths(f2) { + // println!("{:?}-{:?}; {:?} {:?}", f1, f2, p1, p2); + // let v = &f2.convert(&p1, &point); + // let q = f1.convert(&p2, v); + // assert!((q-&point).norm(L2) < 1e-9, + // "norm({}-{}) ≥ 1e-9 (dest {})", q, &point, &v); + // } + // } + // } + // } + // } + + #[test] + fn log_adjacent() { let p1 = OnCube{ face : F1, point : Loc([0.5, 0.5])}; let p2 = OnCube{ face : F2, point : Loc([0.5, 0.5])}; @@ -281,7 +322,7 @@ } #[test] - fn log_test_opposing_equal() { + fn log_opposing_equal() { let p1 = OnCube{ face : F1, point : Loc([0.5, 0.5])}; let p2 = OnCube{ face : F6, point : Loc([0.5, 0.5])}; @@ -289,7 +330,7 @@ } #[test] - fn log_test_opposing_unique_shortest() { + fn log_opposing_unique_shortest() { let p1 = OnCube{ face : F1, point : Loc([0.3, 0.25])}; let p2 = OnCube{ face : F6, point : Loc([0.3, 0.25])};