1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::{Scalar, Map, euclidean::Euclidean3};
pub trait Geometry<T: Scalar = f64>: Clone + 'static {
type Pos: Clone;
type Dir: Clone;
type Map: Map<Self::Pos, Self::Dir>;
fn origin() -> Self::Pos;
fn default_dir() -> Self::Dir;
fn length(a: Self::Pos) -> T;
fn distance(a: Self::Pos, b: Self::Pos) -> T;
}
pub trait Geometry3<T: Scalar = f64>: Geometry<T> {
fn dir_to_local(pos: Self::Pos, dir: Self::Dir) -> <Euclidean3<T> as Geometry<T>>::Dir;
fn dir_from_local(pos: Self::Pos, dir: <Euclidean3<T> as Geometry<T>>::Dir) -> Self::Dir;
fn dir_when_moved_at_pos(src_pos: Self::Pos, src_dir: Self::Dir, dst_pos: Self::Pos) -> Self::Dir;
fn shift_x(dist: T) -> Self::Map;
fn shift_y(dist: T) -> Self::Map;
fn shift_z(dist: T) -> Self::Map;
fn rotate_x(angle: T) -> Self::Map;
fn rotate_y(angle: T) -> Self::Map;
fn rotate_z(angle: T) -> Self::Map;
fn look_at_pos(pos: Self::Pos) -> Self::Map;
fn look_at_dir(dir: Self::Dir) -> Self::Map;
fn move_at_pos(pos: Self::Pos) -> Self::Map;
fn move_at_dir(dir: Self::Dir, dist: T) -> Self::Map;
}