1use std::{fmt, ops::{Add, Div, Mul, Neg, Rem, Sub}};
7
8use crate::{Construct, F32Fmt, One, SignOps, Two, Zero, axes::Axes, linear_algebra::{matrix3::Matrix3, vector3::Vector3}};
9
10use super::{Rotation, quaternion::Quaternion, rotor::Rotor};
11
12#[derive(Copy, Clone)]
14pub struct Euler<T>(pub T, pub T, pub T);
15
16impl<T> PartialEq for Euler<T>
17where Self: Rem<T, Output = Self>, T: Add<T, Output = T> + One + PartialEq + Copy {
18 fn eq(&self, other: &Self) -> bool {
19 let two = T::ONE + T::ONE;
20 let spa0 = *self % two;
21 let spa1 = *other % two;
22 spa0.0 == spa1.0 && spa0.1 == spa1.1 && spa0.2 == spa1.2
23 }
24}
25
26impl<T> Euler<T>{
27 pub fn new(x_rot: T, y_rot: T, z_rot: T) -> Self {
28 Euler(x_rot, y_rot, z_rot)
29 }
30}
31
32impl<T> Construct<T> for Euler<T> where T: Construct<T> {}
33impl<T> Rotation<T> for Euler<T> where T: Construct<T> {
34 fn look_at_xy(_pos: Vector3<T>, _look_at: Vector3<T>) -> Self {
35 todo!()
36 }
37
38 fn look_at_xz(_pos: Vector3<T>, _look_at: Vector3<T>) -> Self {
39 todo!()
40 }
41
42 fn look_at_yz(_pos: Vector3<T>, _look_at: Vector3<T>) -> Self {
43 todo!()
44 }
45
46 fn look_at_lock(_pos: Vector3<T>, _look_at: Vector3<T>, _locked_axis: Vector3<T>) -> Self {
47 todo!()
48 }
49
50 fn camera_look_at_xy(_pos: Vector3<T>, _look_at: Vector3<T>) -> Self {
51 todo!()
52 }
53
54 fn camera_look_at_xz(_pos: Vector3<T>, _look_at: Vector3<T>) -> Self {
55 todo!()
56 }
57
58 fn camera_look_at_yz(_pos: Vector3<T>, _look_at: Vector3<T>) -> Self {
59 todo!()
60 }
61
62 fn camera_look_at_lock(_pos: Vector3<T>, _look_at: Vector3<T>, _locked_axis: Vector3<T>) -> Self {
63 todo!()
64 }
65}
66
67impl<T> fmt::Debug for Euler<T>
68where T: fmt::Debug + Copy {
69 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
70 write!(f, "Euler({:?}, {:?}, {:?})", self.0, self.1, self.2)
71 }
72}
73
74impl<T> From<Euler<T>> for Matrix3<T> {
75 fn from(_: Euler<T>) -> Matrix3<T> {
76 todo!()
77 }
78}
79
80impl<T> From<Matrix3<T>> for Euler<T> {
81 fn from(_: Matrix3<T>) -> Self {
82 todo!()
83 }
84}
85
86impl<T> From<Axes<T>> for Euler<T>
87where T: Copy {
88 fn from(a: Axes<T>) -> Self {
89 Into::<Matrix3<T>>::into(a).into()
90 }
91}
92
93impl<T> From<Rotor<T>> for Euler<T>
94where T: Construct<T> + Copy {
95 fn from(r: Rotor<T>) -> Self {
96 Into::<Matrix3<T>>::into(r).into()
97 }
98}
99
100impl<T> From<Quaternion<T>> for Euler<T>
101where T: Construct<T> + Copy {
102 fn from(q: Quaternion<T>) -> Self {
103 Into::<Matrix3<T>>::into(q).into()
104 }
105}
106
107impl<T> Add for Euler<T>
108where T: Add<T, Output = T> + Copy {
109 type Output = Self;
110
111 fn add(self, rhs: Euler<T>) -> Self::Output {
112 Euler(self.0 + rhs.0, self.1 + rhs.1, self.2 + rhs.2)
113 }
114}
115
116impl<T> Add<T> for Euler<T>
117where T: Add<T, Output = T> + Copy {
118 type Output = Self;
119
120 fn add(self, rhs: T) -> Self::Output {
121 Euler(self.0 + rhs, self.1 + rhs, self.2 + rhs)
122 }
123}
124
125impl<T> Sub for Euler<T>
126where T: Sub<T, Output = T> + Copy {
127 type Output = Self;
128
129 fn sub(self, rhs: Euler<T>) -> Self::Output {
130 Euler(self.0 - rhs.0, self.1 - rhs.1, self.2 - rhs.2)
131 }
132}
133
134impl<T> Sub<T> for Euler<T>
135where T: Sub<T, Output = T> + Copy {
136 type Output = Self;
137
138 fn sub(self, rhs: T) -> Self::Output {
139 Euler(self.0 - rhs, self.1 - rhs, self.2 - rhs)
140 }
141}
142
143impl<T> Mul for Euler<T>
144where T: Mul<T, Output = T> + Copy {
145 type Output = Self;
146
147 fn mul(self, rhs: Euler<T>) -> Self::Output {
148 Euler(self.0 * rhs.0, self.1 * rhs.1, self.2 * rhs.2)
149 }
150}
151
152impl<T> Mul<T> for Euler<T>
153where T: Mul<T, Output = T> + Copy {
154 type Output = Self;
155
156 fn mul(self, rhs: T) -> Self::Output {
157 Euler(self.0 * rhs, self.1 * rhs, self.2 * rhs)
158 }
159}
160
161impl<T> Div for Euler<T>
162where T: Div<T, Output = T> + Copy {
163 type Output = Self;
164
165 fn div(self, rhs: Euler<T>) -> Self::Output {
166 Euler(self.0 / rhs.0, self.1 / rhs.1, self.2 / rhs.2)
167 }
168}
169
170impl<T> Div<T> for Euler<T>
171where T: Div<T, Output = T> + Copy {
172 type Output = Self;
173
174 fn div(self, rhs: T) -> Self::Output {
175 Euler(self.0 / rhs, self.1 / rhs, self.2 / rhs)
176 }
177}
178
179impl<T> Rem for Euler<T>
180where T: Rem<T, Output = T> + Copy {
181 type Output = Self;
182
183 fn rem(self, rhs: Euler<T>) -> Self::Output {
184 Euler(self.0 % rhs.0, self.1 % rhs.1, self.2 % rhs.2)
185 }
186}
187
188impl<T> Rem<T> for Euler<T>
189where T: Rem<T, Output = T> + Copy {
190 type Output = Self;
191
192 fn rem(self, rhs: T) -> Self::Output {
193 Euler(self.0 % rhs, self.1 % rhs, self.2 % rhs)
194 }
195}
196
197impl<T> Neg for Euler<T>
198where T: Neg<Output = T> + Copy {
199 type Output = Self;
200
201 fn neg(self) -> Self::Output {
202 Euler(-self.0, -self.1, -self.2)
203 }
204}
205
206impl<T> Zero for Euler<T> where T: Zero { const ZERO: Self = Euler(T::ZERO, T::ZERO, T::ZERO); }
207impl<T> One for Euler<T> where T: One { const ONE: Self = Euler(T::ONE, T::ONE, T::ONE); }
208impl<T> Two for Euler<T> where T: Two { const TWO: Self = Euler(T::TWO, T::TWO, T::TWO); }
209
210impl<T: F32Fmt> F32Fmt for Euler<T> {
211 type F32Fmt = Euler<T::F32Fmt>;
212 #[inline]
213 fn intoF32Fmt(self) -> Self::F32Fmt {
214 Euler(self.0.intoF32Fmt(), self.1.intoF32Fmt(), self.2.intoF32Fmt())
215 }
216 #[inline]
217 fn fromF32Fmt(f32_fmt: Self::F32Fmt) -> Self {
218 Euler(T::fromF32Fmt(f32_fmt.0), T::fromF32Fmt(f32_fmt.1), T::fromF32Fmt(f32_fmt.2))
219 }
220
221 fn sqrt(self) -> Self {
222 Euler(self.0.sqrt(), self.1.sqrt(), self.2.sqrt())
223 }
224
225 fn cbrt(self) -> Self {
226 Euler(self.0.cbrt(), self.1.cbrt(), self.2.cbrt())
227 }
228
229 fn f32_const_mul(self, constant: f32) -> Self {
230 Euler(self.0.f32_const_mul(constant), self.1.f32_const_mul(constant), self.2.f32_const_mul(constant))
231 }
232
233 fn sin_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
234 todo!()
235 }
236
237 fn cos_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
238 todo!()
239 }
240
241 fn tan_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
242 todo!()
243 }
244
245 fn asin_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
246 todo!()
247 }
248
249 fn acos_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
250 todo!()
251 }
252
253 fn atan_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
254 todo!()
255 }
256
257 fn atan2_mul(self, _other: Self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
258 todo!()
259 }
260
261 fn sinh_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
262 todo!()
263 }
264
265 fn cosh_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
266 todo!()
267 }
268
269 fn tanh_mul(self, _mul_by: Self) -> Self where Self: Mul<Self, Output = Self> + Sized {
270 todo!()
271 }
272}
273
274impl<T> SignOps for Euler<T> {
275 fn ptcopysign(self, _sign: Self) -> Self {
276 todo!()
277 }
278
279 fn ptsignum(self) -> i8 {
280 todo!()
281 }
282
283 fn abs(self) -> Self {
284 todo!()
285 }
286}