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
use std::ops::{Add, Div, Mul, Sub};
use derive_more::*;
use crate::prelude::*;
#[derive(Clone, Copy, Debug, Display, From, Neg, PartialEq)]
pub struct RelativeVector<T: Scalar>(pub(crate) Vector<T>);
impl<T: Scalar> From<RelativeVector<T>> for Vector<T> {
fn from(from: RelativeVector<T>) -> Self {
from.0
}
}
impl<T: Scalar> Add for RelativeVector<T> {
type Output = Self;
fn add(self, other: Self) -> Self {
Self(self.0 + other.0)
}
}
impl<T: Scalar> Add<PositionVector<T>> for RelativeVector<T> {
type Output = PositionVector<T>;
fn add(self, other: PositionVector<T>) -> Self::Output {
PositionVector(self.0 + other.0)
}
}
impl<T: Scalar> Sub for RelativeVector<T> {
type Output = Self;
fn sub(self, other: Self) -> Self {
Self(self.0 - other.0)
}
}
impl<T: Scalar> Sub<PositionVector<T>> for RelativeVector<T> {
type Output = PositionVector<T>;
fn sub(self, other: PositionVector<T>) -> Self::Output {
PositionVector(self.0 - other.0)
}
}
impl<T: Scalar> Mul<T> for RelativeVector<T> {
type Output = Self;
fn mul(self, other: T) -> Self {
Self(self.0 * other)
}
}
impl<T: Scalar> Div<T> for RelativeVector<T> {
type Output = Self;
fn div(self, other: T) -> Self {
Self(self.0 / other)
}
}