src/cube.rs

changeset 12
3b05a8b45b95
parent 11
933242e0f3b8
child 13
f67949050a32
equal deleted inserted replaced
11:933242e0f3b8 12:3b05a8b45b95
1 1
2 use core::f64; 2 use serde_repr::*;
3 3 use serde::Serialize;
4 use alg_tools::loc::Loc; 4 use alg_tools::loc::Loc;
5 use alg_tools::norms::{Norm, L2}; 5 use alg_tools::norms::{Norm, L2};
6 use crate::manifold::{ManifoldPoint, EmbeddedManifoldPoint}; 6 use crate::manifold::{ManifoldPoint, EmbeddedManifoldPoint};
7 7
8 #[derive(Copy, Clone, Debug, Eq, PartialEq)] 8 #[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
9 pub enum Face {F1, F2, F3, F4, F5, F6} 9 #[repr(u8)]
10 pub enum Face {F1 = 1, F2 = 2, F3 = 3, F4 = 4, F5 = 5, F6 = 6}
10 use Face::*; 11 use Face::*;
11 12
12 pub type Point = Loc<f64, 2>; 13 pub type Point = Loc<f64, 2>;
13 14
14 pub type AdjacentFaces = [Face; 4]; 15 pub type AdjacentFaces = [Face; 4];
15 16
16 #[derive(Clone, Debug)] 17 #[derive(Clone, Debug, Serialize)]
17 pub enum Path { 18 pub enum Path {
18 Direct { destination : Face }, 19 Direct { destination : Face },
19 Indirect { destination : Face, intermediate : Face }, 20 Indirect { destination : Face, intermediate : Face },
20 } 21 }
21 22
214 F6 => [x, y, 1.0], 215 F6 => [x, y, 1.0],
215 }) 216 })
216 } 217 }
217 } 218 }
218 219
219 #[derive(Clone, Debug, PartialEq)] 220 #[derive(Clone, Debug, PartialEq, Serialize)]
220 pub struct OnCube { 221 pub struct OnCube {
221 face : Face, 222 face : Face,
222 point : Point, 223 point : Point,
223 } 224 }
224 225
241 best_tan = tan; 242 best_tan = tan;
242 best_len = len; 243 best_len = len;
243 } 244 }
244 } 245 }
245 (best_tan, best_len) 246 (best_tan, best_len)
247 }
248
249 pub fn face(&self) -> Face {
250 self.face
246 } 251 }
247 } 252 }
248 253
249 254
250 impl EmbeddedManifoldPoint for OnCube { 255 impl EmbeddedManifoldPoint for OnCube {

mercurial