use std::ops::{self, AddAssign, SubAssign};
use crate::LARGE_EPSILON;
use super::v2::V2;
impl ops::Add<V2> for V2 {
type Output = V2;
fn add(self, _rhs: V2) -> V2 {
V2::new(self.x + _rhs.x, self.y + _rhs.y)
}
}
impl ops::Add<&V2> for V2 {
type Output = V2;
fn add(self, _rhs: &V2) -> V2 {
V2::new(self.x + _rhs.x, self.y + _rhs.y)
}
}
impl ops::Add<V2> for &V2 {
type Output = V2;
fn add(self, _rhs: V2) -> V2 {
V2::new(self.x + _rhs.x, self.y + _rhs.y)
}
}
impl ops::Add<&V2> for &V2 {
type Output = V2;
fn add(self, _rhs: &V2) -> V2 {
V2::new(self.x + _rhs.x, self.y + _rhs.y)
}
}
impl ops::Add<f32> for V2 {
type Output = V2;
fn add(self, _rhs: f32) -> V2 {
V2::new(self.x + _rhs, self.y + _rhs)
}
}
impl ops::Add<f32> for &V2 {
type Output = V2;
fn add(self, _rhs: f32) -> V2 {
V2::new(self.x + _rhs, self.y + _rhs)
}
}
impl AddAssign<V2> for V2 {
fn add_assign(&mut self, _rhs: V2) {
*self = *self + _rhs;
}
}
impl AddAssign<&V2> for V2 {
fn add_assign(&mut self, _rhs: &V2) {
*self = *self + _rhs;
}
}
impl AddAssign<f32> for V2 {
fn add_assign(&mut self, _rhs: f32) {
*self = *self + _rhs;
}
}
impl ops::Sub<V2> for V2 {
type Output = V2;
fn sub(self, _rhs: V2) -> V2 {
V2::new(self.x - _rhs.x, self.y - _rhs.y)
}
}
impl ops::Sub<&V2> for V2 {
type Output = V2;
fn sub(self, _rhs: &V2) -> V2 {
V2::new(self.x - _rhs.x, self.y - _rhs.y)
}
}
impl ops::Sub<V2> for &V2 {
type Output = V2;
fn sub(self, _rhs: V2) -> V2 {
V2::new(self.x - _rhs.x, self.y - _rhs.y)
}
}
impl ops::Sub<&V2> for &V2 {
type Output = V2;
fn sub(self, _rhs: &V2) -> V2 {
V2::new(self.x - _rhs.x, self.y - _rhs.y)
}
}
impl ops::Sub<f32> for V2 {
type Output = V2;
fn sub(self, _rhs: f32) -> V2 {
V2::new(self.x - _rhs, self.y - _rhs)
}
}
impl ops::Sub<f32> for &V2 {
type Output = V2;
fn sub(self, _rhs: f32) -> V2 {
V2::new(self.x - _rhs, self.y - _rhs)
}
}
impl SubAssign<V2> for V2 {
fn sub_assign(&mut self, _rhs: V2) {
*self = *self - _rhs;
}
}
impl SubAssign<&V2> for V2 {
fn sub_assign(&mut self, _rhs: &V2) {
*self = *self - _rhs;
}
}
impl SubAssign<f32> for V2 {
fn sub_assign(&mut self, _rhs: f32) {
*self = *self - _rhs;
}
}
impl ops::Mul<V2> for V2 {
type Output = V2;
fn mul(self, _rhs: V2) -> V2 {
V2::new(self.x * _rhs.x, self.y * _rhs.y)
}
}
impl ops::Mul<&V2> for V2 {
type Output = V2;
fn mul(self, _rhs: &V2) -> V2 {
V2::new(self.x * _rhs.x, self.y * _rhs.y)
}
}
impl ops::Mul<V2> for &V2 {
type Output = V2;
fn mul(self, _rhs: V2) -> V2 {
V2::new(self.x * _rhs.x, self.y * _rhs.y)
}
}
impl ops::Mul<&V2> for &V2 {
type Output = V2;
fn mul(self, _rhs: &V2) -> V2 {
V2::new(self.x * _rhs.x, self.y * _rhs.y)
}
}
impl ops::Mul<f32> for V2 {
type Output = V2;
fn mul(self, _rhs: f32) -> V2 {
V2::new(self.x * _rhs, self.y * _rhs)
}
}
impl ops::Mul<f32> for &V2 {
type Output = V2;
fn mul(self, _rhs: f32) -> V2 {
V2::new(self.x * _rhs, self.y * _rhs)
}
}
impl ops::MulAssign<V2> for V2 {
fn mul_assign(&mut self, _rhs: V2) {
*self = *self * _rhs;
}
}
impl ops::MulAssign<&V2> for V2 {
fn mul_assign(&mut self, _rhs: &V2) {
*self = *self * _rhs;
}
}
impl ops::MulAssign<f32> for V2 {
fn mul_assign(&mut self, _rhs: f32) {
*self = *self * _rhs;
}
}
impl ops::Div<V2> for V2 {
type Output = V2;
fn div(self, _rhs: V2) -> V2 {
V2::new(self.x / _rhs.x, self.y / _rhs.y)
}
}
impl ops::Div<&V2> for V2 {
type Output = V2;
fn div(self, _rhs: &V2) -> V2 {
V2::new(self.x / _rhs.x, self.y / _rhs.y)
}
}
impl ops::Div<V2> for &V2 {
type Output = V2;
fn div(self, _rhs: V2) -> V2 {
V2::new(self.x / _rhs.x, self.y / _rhs.y)
}
}
impl ops::Div<&V2> for &V2 {
type Output = V2;
fn div(self, _rhs: &V2) -> V2 {
V2::new(self.x / _rhs.x, self.y / _rhs.y)
}
}
impl ops::Div<f32> for V2 {
type Output = V2;
fn div(self, _rhs: f32) -> V2 {
V2::new(self.x / _rhs, self.y / _rhs)
}
}
impl ops::Div<f32> for &V2 {
type Output = V2;
fn div(self, _rhs: f32) -> V2 {
V2::new(self.x / _rhs, self.y / _rhs)
}
}
impl ops::DivAssign<V2> for V2 {
fn div_assign(&mut self, _rhs: V2) {
*self = *self / _rhs;
}
}
impl ops::DivAssign<&V2> for V2 {
fn div_assign(&mut self, _rhs: &V2) {
*self = *self / _rhs;
}
}
impl ops::DivAssign<f32> for V2 {
fn div_assign(&mut self, _rhs: f32) {
*self = *self / _rhs;
}
}
impl PartialEq<V2> for V2 {
fn eq(&self, _rhs: &V2) -> bool {
self.dist_manhattan(*_rhs) < LARGE_EPSILON
}
}
impl PartialEq<&V2> for V2 {
fn eq(&self, _rhs: &&V2) -> bool {
self.dist_manhattan(**_rhs) < LARGE_EPSILON
}
}
impl PartialEq<V2> for &V2 {
fn eq(&self, _rhs: &V2) -> bool {
self.dist_manhattan(*_rhs) < LARGE_EPSILON
}
}