1use crate::Vector2;
2
3pub struct Vector3<T> {
5 one: T,
6 two: T,
7 three: T
8}
9
10impl<T> Vector3<T> {
11 pub fn new(one: T, two: T, three: T) -> Self {
12 return Self {
13 one: one,
14 two: two,
15 three: three
16 };
17 }
18}
19
20impl<T> Vector3<T> {
21 pub fn get_one(&self) -> &T {
22 return &self.one;
23 }
24
25 pub fn get_one_mut(&mut self) -> &mut T {
26 return &mut self.one;
27 }
28
29 pub fn get_two(&self) -> &T {
30 return &self.two;
31 }
32
33 pub fn get_two_mut(&mut self) -> &mut T {
34 return &mut self.two;
35 }
36
37 pub fn get_three(&self) -> &T {
38 return &self.three;
39 }
40
41 pub fn get_three_mut(&mut self) -> &mut T {
42 return &mut self.three;
43 }
44}
45
46impl<T: Default> Default for Vector3<T> {
47 fn default() -> Self {
48 return Self {
49 one: T::default(),
50 two: T::default(),
51 three: T::default()
52 };
53 }
54}
55
56impl<T: Clone> Clone for Vector3<T> {
57 fn clone(&self) -> Self {
58 return Self {
59 one: self.one.clone(),
60 two: self.two.clone(),
61 three: self.three.clone()
62 };
63 }
64}
65
66impl<T: Copy> Copy for Vector3<T> {}
67
68impl<T> Into<(T, T, T)> for Vector3<T> {
69 fn into(self) -> (T, T, T) {
70 return (self.one, self.two, self.three);
71 }
72}
73
74impl<T> Into<Vector3<T>> for (T, T, T) {
75 fn into(self) -> Vector3<T> {
76 return Vector3::new(self.0, self.1, self.2);
77 }
78}
79
80impl<T: PartialEq> PartialEq for Vector3<T> {
81 fn eq(&self, other: &Self) -> bool {
82 return self.one == other.one &&
83 self.two == other.two &&
84 self.three == other.three;
85 }
86
87 fn ne(&self, other: &Self) -> bool {
88 return !self.eq(other);
89 }
90}
91
92impl<T> Into<(Vector2<T>, T)> for Vector3<T> {
93 fn into(self) -> (Vector2<T>, T) {
94 return (Vector2::new(self.one, self.two), self.three);
95 }
96}
97
98impl<T> Into<Vector3<T>> for (Vector2<T>, T) {
99 fn into(self) -> Vector3<T> {
100 let (v1, v2) = self.0.into();
101 return Vector3::new(v1, v2, self.1);
102 }
103}