1use crate::{Vector3, Vector3Coordinate};
2use core::ops::{Div, DivAssign, Mul, MulAssign, Neg};
3
4impl<T: Vector3Coordinate + Neg<Output = T>> Neg for Vector3<T> {
5 type Output = Self;
6 fn neg(self) -> Self::Output {
7 Self {
8 x: -self.x,
9 y: -self.y,
10 z: -self.z,
11 }
12 }
13}
14
15impl<T: Vector3Coordinate + Neg<Output = T> + Copy> Neg for &Vector3<T> {
16 type Output = Vector3<T>;
17 fn neg(self) -> Self::Output {
18 Vector3 {
19 x: -self.x,
20 y: -self.y,
21 z: -self.z,
22 }
23 }
24}
25
26impl<T: Vector3Coordinate> Mul<T> for Vector3<T> {
27 type Output = Self;
28 fn mul(self, rhs: T) -> Self::Output {
29 Self {
30 x: self.x * rhs.clone(),
31 y: self.y * rhs.clone(),
32 z: self.z * rhs,
33 }
34 }
35}
36
37impl<T: Vector3Coordinate> Div<T> for Vector3<T> {
38 type Output = Self;
39 fn div(self, rhs: T) -> Self::Output {
40 Self {
41 x: self.x / rhs.clone(),
42 y: self.y / rhs.clone(),
43 z: self.z / rhs,
44 }
45 }
46}
47
48impl<T: Vector3Coordinate> MulAssign<T> for Vector3<T> {
49 fn mul_assign(&mut self, rhs: T) {
50 self.x *= rhs.clone();
51 self.y *= rhs.clone();
52 self.z *= rhs;
53 }
54}
55
56impl<T: Vector3Coordinate> DivAssign<T> for Vector3<T> {
57 fn div_assign(&mut self, rhs: T) {
58 self.x /= rhs.clone();
59 self.y /= rhs.clone();
60 self.z /= rhs;
61 }
62}