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