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