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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use *;
/// A trait for types that support linear interpolation between two values.
/// A trait abstracting the operations common to `Vector2D` and `Vector3D`.
///
/// Provides a single abstraction surface so that dimension-agnostic algorithms
/// (e.g. `integrate_linear` in physics) can be written once. Method signatures
/// match the inherent implementations on both vectors: taking `&self` and
/// returning new owned values where the inherent methods do, taking `self` by
/// value where they already do.
///
/// The arithmetic operator supertraits (`Add`, `Sub`, `Mul<f64>`, `Neg`, and
/// the `*Assign` variants) are required so generic code can use natural
/// `a + b`, `v * 2.0`, `-v`, `v += other`, `v *= scalar` syntax without
/// importing additional bounds.
///
/// `Vector2D` adds 2D-specific operations (`perp`, `cross -> f64`,
/// `from_angle`) and `Vector3D` adds 3D-specific ones (`cross -> Vector3D`).
/// These are intentionally **not** part of the trait — they have different
/// return types or only exist in one dimension.