use crate::{BVec2, I16Vec2, I64Vec3, I8Vec2, IVec2, U16Vec2, U64Vec2, U8Vec2, UVec2};
use core::fmt;
use core::iter::{Product, Sum};
use core::{f32, ops::*};
#[inline(always)]
#[must_use]
pub const fn i64vec2(x: i64, y: i64) -> I64Vec2 {
I64Vec2::new(x, y)
}
#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
#[derive(Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "cuda", repr(align(16)))]
#[cfg_attr(not(target_arch = "spirv"), repr(C))]
#[cfg_attr(target_arch = "spirv", repr(simd))]
pub struct I64Vec2 {
pub x: i64,
pub y: i64,
}
impl I64Vec2 {
pub const ZERO: Self = Self::splat(0);
pub const ONE: Self = Self::splat(1);
pub const NEG_ONE: Self = Self::splat(-1);
pub const MIN: Self = Self::splat(i64::MIN);
pub const MAX: Self = Self::splat(i64::MAX);
pub const X: Self = Self::new(1, 0);
pub const Y: Self = Self::new(0, 1);
pub const NEG_X: Self = Self::new(-1, 0);
pub const NEG_Y: Self = Self::new(0, -1);
pub const AXES: [Self; 2] = [Self::X, Self::Y];
#[inline(always)]
#[must_use]
pub const fn new(x: i64, y: i64) -> Self {
Self { x, y }
}
#[inline]
#[must_use]
pub const fn splat(v: i64) -> Self {
Self { x: v, y: v }
}
#[inline]
#[must_use]
pub fn map<F>(self, f: F) -> Self
where
F: Fn(i64) -> i64,
{
Self::new(f(self.x), f(self.y))
}
#[inline]
#[must_use]
pub fn select(mask: BVec2, if_true: Self, if_false: Self) -> Self {
Self {
x: if mask.test(0) { if_true.x } else { if_false.x },
y: if mask.test(1) { if_true.y } else { if_false.y },
}
}
#[inline]
#[must_use]
pub const fn from_array(a: [i64; 2]) -> Self {
Self::new(a[0], a[1])
}
#[inline]
#[must_use]
pub const fn to_array(&self) -> [i64; 2] {
[self.x, self.y]
}
#[inline]
#[must_use]
pub const fn from_slice(slice: &[i64]) -> Self {
assert!(slice.len() >= 2);
Self::new(slice[0], slice[1])
}
#[inline]
pub fn write_to_slice(self, slice: &mut [i64]) {
slice[..2].copy_from_slice(&self.to_array());
}
#[inline]
#[must_use]
pub const fn extend(self, z: i64) -> I64Vec3 {
I64Vec3::new(self.x, self.y, z)
}
#[inline]
#[must_use]
pub fn with_x(mut self, x: i64) -> Self {
self.x = x;
self
}
#[inline]
#[must_use]
pub fn with_y(mut self, y: i64) -> Self {
self.y = y;
self
}
#[inline]
#[must_use]
pub fn dot(self, rhs: Self) -> i64 {
(self.x * rhs.x) + (self.y * rhs.y)
}
#[inline]
#[must_use]
pub fn dot_into_vec(self, rhs: Self) -> Self {
Self::splat(self.dot(rhs))
}
#[inline]
#[must_use]
pub fn min(self, rhs: Self) -> Self {
Self {
x: self.x.min(rhs.x),
y: self.y.min(rhs.y),
}
}
#[inline]
#[must_use]
pub fn max(self, rhs: Self) -> Self {
Self {
x: self.x.max(rhs.x),
y: self.y.max(rhs.y),
}
}
#[inline]
#[must_use]
pub fn clamp(self, min: Self, max: Self) -> Self {
glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
self.max(min).min(max)
}
#[inline]
#[must_use]
pub fn min_element(self) -> i64 {
self.x.min(self.y)
}
#[inline]
#[must_use]
pub fn max_element(self) -> i64 {
self.x.max(self.y)
}
#[inline]
#[must_use]
pub fn element_sum(self) -> i64 {
self.x + self.y
}
#[inline]
#[must_use]
pub fn element_product(self) -> i64 {
self.x * self.y
}
#[inline]
#[must_use]
pub fn cmpeq(self, rhs: Self) -> BVec2 {
BVec2::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y))
}
#[inline]
#[must_use]
pub fn cmpne(self, rhs: Self) -> BVec2 {
BVec2::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y))
}
#[inline]
#[must_use]
pub fn cmpge(self, rhs: Self) -> BVec2 {
BVec2::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y))
}
#[inline]
#[must_use]
pub fn cmpgt(self, rhs: Self) -> BVec2 {
BVec2::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y))
}
#[inline]
#[must_use]
pub fn cmple(self, rhs: Self) -> BVec2 {
BVec2::new(self.x.le(&rhs.x), self.y.le(&rhs.y))
}
#[inline]
#[must_use]
pub fn cmplt(self, rhs: Self) -> BVec2 {
BVec2::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y))
}
#[inline]
#[must_use]
pub fn abs(self) -> Self {
Self {
x: self.x.abs(),
y: self.y.abs(),
}
}
#[inline]
#[must_use]
pub fn signum(self) -> Self {
Self {
x: self.x.signum(),
y: self.y.signum(),
}
}
#[inline]
#[must_use]
pub fn is_negative_bitmask(self) -> u32 {
(self.x.is_negative() as u32) | (self.y.is_negative() as u32) << 1
}
#[doc(alias = "magnitude2")]
#[inline]
#[must_use]
pub fn length_squared(self) -> i64 {
self.dot(self)
}
#[inline]
#[must_use]
pub fn distance_squared(self, rhs: Self) -> i64 {
(self - rhs).length_squared()
}
#[inline]
#[must_use]
pub fn div_euclid(self, rhs: Self) -> Self {
Self::new(self.x.div_euclid(rhs.x), self.y.div_euclid(rhs.y))
}
#[inline]
#[must_use]
pub fn rem_euclid(self, rhs: Self) -> Self {
Self::new(self.x.rem_euclid(rhs.x), self.y.rem_euclid(rhs.y))
}
#[inline]
#[must_use]
pub fn perp(self) -> Self {
Self {
x: -self.y,
y: self.x,
}
}
#[doc(alias = "wedge")]
#[doc(alias = "cross")]
#[doc(alias = "determinant")]
#[inline]
#[must_use]
pub fn perp_dot(self, rhs: Self) -> i64 {
(self.x * rhs.y) - (self.y * rhs.x)
}
#[inline]
#[must_use]
pub fn rotate(self, rhs: Self) -> Self {
Self {
x: self.x * rhs.x - self.y * rhs.y,
y: self.y * rhs.x + self.x * rhs.y,
}
}
#[inline]
#[must_use]
pub fn as_vec2(&self) -> crate::Vec2 {
crate::Vec2::new(self.x as f32, self.y as f32)
}
#[inline]
#[must_use]
pub fn as_dvec2(&self) -> crate::DVec2 {
crate::DVec2::new(self.x as f64, self.y as f64)
}
#[inline]
#[must_use]
pub fn as_i8vec2(&self) -> crate::I8Vec2 {
crate::I8Vec2::new(self.x as i8, self.y as i8)
}
#[inline]
#[must_use]
pub fn as_u8vec2(&self) -> crate::U8Vec2 {
crate::U8Vec2::new(self.x as u8, self.y as u8)
}
#[inline]
#[must_use]
pub fn as_i16vec2(&self) -> crate::I16Vec2 {
crate::I16Vec2::new(self.x as i16, self.y as i16)
}
#[inline]
#[must_use]
pub fn as_u16vec2(&self) -> crate::U16Vec2 {
crate::U16Vec2::new(self.x as u16, self.y as u16)
}
#[inline]
#[must_use]
pub fn as_ivec2(&self) -> crate::IVec2 {
crate::IVec2::new(self.x as i32, self.y as i32)
}
#[inline]
#[must_use]
pub fn as_uvec2(&self) -> crate::UVec2 {
crate::UVec2::new(self.x as u32, self.y as u32)
}
#[inline]
#[must_use]
pub fn as_u64vec2(&self) -> crate::U64Vec2 {
crate::U64Vec2::new(self.x as u64, self.y as u64)
}
#[inline]
#[must_use]
pub const fn wrapping_add(self, rhs: Self) -> Self {
Self {
x: self.x.wrapping_add(rhs.x),
y: self.y.wrapping_add(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn wrapping_sub(self, rhs: Self) -> Self {
Self {
x: self.x.wrapping_sub(rhs.x),
y: self.y.wrapping_sub(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn wrapping_mul(self, rhs: Self) -> Self {
Self {
x: self.x.wrapping_mul(rhs.x),
y: self.y.wrapping_mul(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn wrapping_div(self, rhs: Self) -> Self {
Self {
x: self.x.wrapping_div(rhs.x),
y: self.y.wrapping_div(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn saturating_add(self, rhs: Self) -> Self {
Self {
x: self.x.saturating_add(rhs.x),
y: self.y.saturating_add(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn saturating_sub(self, rhs: Self) -> Self {
Self {
x: self.x.saturating_sub(rhs.x),
y: self.y.saturating_sub(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn saturating_mul(self, rhs: Self) -> Self {
Self {
x: self.x.saturating_mul(rhs.x),
y: self.y.saturating_mul(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn saturating_div(self, rhs: Self) -> Self {
Self {
x: self.x.saturating_div(rhs.x),
y: self.y.saturating_div(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn wrapping_add_unsigned(self, rhs: U64Vec2) -> Self {
Self {
x: self.x.wrapping_add_unsigned(rhs.x),
y: self.y.wrapping_add_unsigned(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn wrapping_sub_unsigned(self, rhs: U64Vec2) -> Self {
Self {
x: self.x.wrapping_sub_unsigned(rhs.x),
y: self.y.wrapping_sub_unsigned(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn saturating_add_unsigned(self, rhs: U64Vec2) -> Self {
Self {
x: self.x.saturating_add_unsigned(rhs.x),
y: self.y.saturating_add_unsigned(rhs.y),
}
}
#[inline]
#[must_use]
pub const fn saturating_sub_unsigned(self, rhs: U64Vec2) -> Self {
Self {
x: self.x.saturating_sub_unsigned(rhs.x),
y: self.y.saturating_sub_unsigned(rhs.y),
}
}
}
impl Default for I64Vec2 {
#[inline(always)]
fn default() -> Self {
Self::ZERO
}
}
impl Div<I64Vec2> for I64Vec2 {
type Output = Self;
#[inline]
fn div(self, rhs: Self) -> Self {
Self {
x: self.x.div(rhs.x),
y: self.y.div(rhs.y),
}
}
}
impl Div<&I64Vec2> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: &I64Vec2) -> I64Vec2 {
self.div(*rhs)
}
}
impl Div<&I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).div(*rhs)
}
}
impl Div<I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: I64Vec2) -> I64Vec2 {
(*self).div(rhs)
}
}
impl DivAssign<I64Vec2> for I64Vec2 {
#[inline]
fn div_assign(&mut self, rhs: Self) {
self.x.div_assign(rhs.x);
self.y.div_assign(rhs.y);
}
}
impl DivAssign<&Self> for I64Vec2 {
#[inline]
fn div_assign(&mut self, rhs: &Self) {
self.div_assign(*rhs)
}
}
impl Div<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn div(self, rhs: i64) -> Self {
Self {
x: self.x.div(rhs),
y: self.y.div(rhs),
}
}
}
impl Div<&i64> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: &i64) -> I64Vec2 {
self.div(*rhs)
}
}
impl Div<&i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: &i64) -> I64Vec2 {
(*self).div(*rhs)
}
}
impl Div<i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: i64) -> I64Vec2 {
(*self).div(rhs)
}
}
impl DivAssign<i64> for I64Vec2 {
#[inline]
fn div_assign(&mut self, rhs: i64) {
self.x.div_assign(rhs);
self.y.div_assign(rhs);
}
}
impl DivAssign<&i64> for I64Vec2 {
#[inline]
fn div_assign(&mut self, rhs: &i64) {
self.div_assign(*rhs)
}
}
impl Div<I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: I64Vec2) -> I64Vec2 {
I64Vec2 {
x: self.div(rhs.x),
y: self.div(rhs.y),
}
}
}
impl Div<&I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: &I64Vec2) -> I64Vec2 {
self.div(*rhs)
}
}
impl Div<&I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).div(*rhs)
}
}
impl Div<I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn div(self, rhs: I64Vec2) -> I64Vec2 {
(*self).div(rhs)
}
}
impl Mul<I64Vec2> for I64Vec2 {
type Output = Self;
#[inline]
fn mul(self, rhs: Self) -> Self {
Self {
x: self.x.mul(rhs.x),
y: self.y.mul(rhs.y),
}
}
}
impl Mul<&I64Vec2> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
self.mul(*rhs)
}
}
impl Mul<&I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).mul(*rhs)
}
}
impl Mul<I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: I64Vec2) -> I64Vec2 {
(*self).mul(rhs)
}
}
impl MulAssign<I64Vec2> for I64Vec2 {
#[inline]
fn mul_assign(&mut self, rhs: Self) {
self.x.mul_assign(rhs.x);
self.y.mul_assign(rhs.y);
}
}
impl MulAssign<&Self> for I64Vec2 {
#[inline]
fn mul_assign(&mut self, rhs: &Self) {
self.mul_assign(*rhs)
}
}
impl Mul<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn mul(self, rhs: i64) -> Self {
Self {
x: self.x.mul(rhs),
y: self.y.mul(rhs),
}
}
}
impl Mul<&i64> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: &i64) -> I64Vec2 {
self.mul(*rhs)
}
}
impl Mul<&i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: &i64) -> I64Vec2 {
(*self).mul(*rhs)
}
}
impl Mul<i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: i64) -> I64Vec2 {
(*self).mul(rhs)
}
}
impl MulAssign<i64> for I64Vec2 {
#[inline]
fn mul_assign(&mut self, rhs: i64) {
self.x.mul_assign(rhs);
self.y.mul_assign(rhs);
}
}
impl MulAssign<&i64> for I64Vec2 {
#[inline]
fn mul_assign(&mut self, rhs: &i64) {
self.mul_assign(*rhs)
}
}
impl Mul<I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: I64Vec2) -> I64Vec2 {
I64Vec2 {
x: self.mul(rhs.x),
y: self.mul(rhs.y),
}
}
}
impl Mul<&I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
self.mul(*rhs)
}
}
impl Mul<&I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).mul(*rhs)
}
}
impl Mul<I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn mul(self, rhs: I64Vec2) -> I64Vec2 {
(*self).mul(rhs)
}
}
impl Add<I64Vec2> for I64Vec2 {
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self {
Self {
x: self.x.add(rhs.x),
y: self.y.add(rhs.y),
}
}
}
impl Add<&I64Vec2> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: &I64Vec2) -> I64Vec2 {
self.add(*rhs)
}
}
impl Add<&I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).add(*rhs)
}
}
impl Add<I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: I64Vec2) -> I64Vec2 {
(*self).add(rhs)
}
}
impl AddAssign<I64Vec2> for I64Vec2 {
#[inline]
fn add_assign(&mut self, rhs: Self) {
self.x.add_assign(rhs.x);
self.y.add_assign(rhs.y);
}
}
impl AddAssign<&Self> for I64Vec2 {
#[inline]
fn add_assign(&mut self, rhs: &Self) {
self.add_assign(*rhs)
}
}
impl Add<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn add(self, rhs: i64) -> Self {
Self {
x: self.x.add(rhs),
y: self.y.add(rhs),
}
}
}
impl Add<&i64> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: &i64) -> I64Vec2 {
self.add(*rhs)
}
}
impl Add<&i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: &i64) -> I64Vec2 {
(*self).add(*rhs)
}
}
impl Add<i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: i64) -> I64Vec2 {
(*self).add(rhs)
}
}
impl AddAssign<i64> for I64Vec2 {
#[inline]
fn add_assign(&mut self, rhs: i64) {
self.x.add_assign(rhs);
self.y.add_assign(rhs);
}
}
impl AddAssign<&i64> for I64Vec2 {
#[inline]
fn add_assign(&mut self, rhs: &i64) {
self.add_assign(*rhs)
}
}
impl Add<I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: I64Vec2) -> I64Vec2 {
I64Vec2 {
x: self.add(rhs.x),
y: self.add(rhs.y),
}
}
}
impl Add<&I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: &I64Vec2) -> I64Vec2 {
self.add(*rhs)
}
}
impl Add<&I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).add(*rhs)
}
}
impl Add<I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn add(self, rhs: I64Vec2) -> I64Vec2 {
(*self).add(rhs)
}
}
impl Sub<I64Vec2> for I64Vec2 {
type Output = Self;
#[inline]
fn sub(self, rhs: Self) -> Self {
Self {
x: self.x.sub(rhs.x),
y: self.y.sub(rhs.y),
}
}
}
impl Sub<&I64Vec2> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
self.sub(*rhs)
}
}
impl Sub<&I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).sub(*rhs)
}
}
impl Sub<I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: I64Vec2) -> I64Vec2 {
(*self).sub(rhs)
}
}
impl SubAssign<I64Vec2> for I64Vec2 {
#[inline]
fn sub_assign(&mut self, rhs: I64Vec2) {
self.x.sub_assign(rhs.x);
self.y.sub_assign(rhs.y);
}
}
impl SubAssign<&Self> for I64Vec2 {
#[inline]
fn sub_assign(&mut self, rhs: &Self) {
self.sub_assign(*rhs)
}
}
impl Sub<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn sub(self, rhs: i64) -> Self {
Self {
x: self.x.sub(rhs),
y: self.y.sub(rhs),
}
}
}
impl Sub<&i64> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: &i64) -> I64Vec2 {
self.sub(*rhs)
}
}
impl Sub<&i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: &i64) -> I64Vec2 {
(*self).sub(*rhs)
}
}
impl Sub<i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: i64) -> I64Vec2 {
(*self).sub(rhs)
}
}
impl SubAssign<i64> for I64Vec2 {
#[inline]
fn sub_assign(&mut self, rhs: i64) {
self.x.sub_assign(rhs);
self.y.sub_assign(rhs);
}
}
impl SubAssign<&i64> for I64Vec2 {
#[inline]
fn sub_assign(&mut self, rhs: &i64) {
self.sub_assign(*rhs)
}
}
impl Sub<I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: I64Vec2) -> I64Vec2 {
I64Vec2 {
x: self.sub(rhs.x),
y: self.sub(rhs.y),
}
}
}
impl Sub<&I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
self.sub(*rhs)
}
}
impl Sub<&I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).sub(*rhs)
}
}
impl Sub<I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn sub(self, rhs: I64Vec2) -> I64Vec2 {
(*self).sub(rhs)
}
}
impl Rem<I64Vec2> for I64Vec2 {
type Output = Self;
#[inline]
fn rem(self, rhs: Self) -> Self {
Self {
x: self.x.rem(rhs.x),
y: self.y.rem(rhs.y),
}
}
}
impl Rem<&I64Vec2> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
self.rem(*rhs)
}
}
impl Rem<&I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).rem(*rhs)
}
}
impl Rem<I64Vec2> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: I64Vec2) -> I64Vec2 {
(*self).rem(rhs)
}
}
impl RemAssign<I64Vec2> for I64Vec2 {
#[inline]
fn rem_assign(&mut self, rhs: Self) {
self.x.rem_assign(rhs.x);
self.y.rem_assign(rhs.y);
}
}
impl RemAssign<&Self> for I64Vec2 {
#[inline]
fn rem_assign(&mut self, rhs: &Self) {
self.rem_assign(*rhs)
}
}
impl Rem<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn rem(self, rhs: i64) -> Self {
Self {
x: self.x.rem(rhs),
y: self.y.rem(rhs),
}
}
}
impl Rem<&i64> for I64Vec2 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: &i64) -> I64Vec2 {
self.rem(*rhs)
}
}
impl Rem<&i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: &i64) -> I64Vec2 {
(*self).rem(*rhs)
}
}
impl Rem<i64> for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: i64) -> I64Vec2 {
(*self).rem(rhs)
}
}
impl RemAssign<i64> for I64Vec2 {
#[inline]
fn rem_assign(&mut self, rhs: i64) {
self.x.rem_assign(rhs);
self.y.rem_assign(rhs);
}
}
impl RemAssign<&i64> for I64Vec2 {
#[inline]
fn rem_assign(&mut self, rhs: &i64) {
self.rem_assign(*rhs)
}
}
impl Rem<I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: I64Vec2) -> I64Vec2 {
I64Vec2 {
x: self.rem(rhs.x),
y: self.rem(rhs.y),
}
}
}
impl Rem<&I64Vec2> for i64 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
self.rem(*rhs)
}
}
impl Rem<&I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
(*self).rem(*rhs)
}
}
impl Rem<I64Vec2> for &i64 {
type Output = I64Vec2;
#[inline]
fn rem(self, rhs: I64Vec2) -> I64Vec2 {
(*self).rem(rhs)
}
}
#[cfg(not(target_arch = "spirv"))]
impl AsRef<[i64; 2]> for I64Vec2 {
#[inline]
fn as_ref(&self) -> &[i64; 2] {
unsafe { &*(self as *const I64Vec2 as *const [i64; 2]) }
}
}
#[cfg(not(target_arch = "spirv"))]
impl AsMut<[i64; 2]> for I64Vec2 {
#[inline]
fn as_mut(&mut self) -> &mut [i64; 2] {
unsafe { &mut *(self as *mut I64Vec2 as *mut [i64; 2]) }
}
}
impl Sum for I64Vec2 {
#[inline]
fn sum<I>(iter: I) -> Self
where
I: Iterator<Item = Self>,
{
iter.fold(Self::ZERO, Self::add)
}
}
impl<'a> Sum<&'a Self> for I64Vec2 {
#[inline]
fn sum<I>(iter: I) -> Self
where
I: Iterator<Item = &'a Self>,
{
iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
}
}
impl Product for I64Vec2 {
#[inline]
fn product<I>(iter: I) -> Self
where
I: Iterator<Item = Self>,
{
iter.fold(Self::ONE, Self::mul)
}
}
impl<'a> Product<&'a Self> for I64Vec2 {
#[inline]
fn product<I>(iter: I) -> Self
where
I: Iterator<Item = &'a Self>,
{
iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
}
}
impl Neg for I64Vec2 {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self {
x: self.x.neg(),
y: self.y.neg(),
}
}
}
impl Neg for &I64Vec2 {
type Output = I64Vec2;
#[inline]
fn neg(self) -> I64Vec2 {
(*self).neg()
}
}
impl Not for I64Vec2 {
type Output = Self;
#[inline]
fn not(self) -> Self::Output {
Self {
x: self.x.not(),
y: self.y.not(),
}
}
}
impl BitAnd for I64Vec2 {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self::Output {
Self {
x: self.x.bitand(rhs.x),
y: self.y.bitand(rhs.y),
}
}
}
impl BitOr for I64Vec2 {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self::Output {
Self {
x: self.x.bitor(rhs.x),
y: self.y.bitor(rhs.y),
}
}
}
impl BitXor for I64Vec2 {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self::Output {
Self {
x: self.x.bitxor(rhs.x),
y: self.y.bitxor(rhs.y),
}
}
}
impl BitAnd<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn bitand(self, rhs: i64) -> Self::Output {
Self {
x: self.x.bitand(rhs),
y: self.y.bitand(rhs),
}
}
}
impl BitOr<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn bitor(self, rhs: i64) -> Self::Output {
Self {
x: self.x.bitor(rhs),
y: self.y.bitor(rhs),
}
}
}
impl BitXor<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn bitxor(self, rhs: i64) -> Self::Output {
Self {
x: self.x.bitxor(rhs),
y: self.y.bitxor(rhs),
}
}
}
impl Shl<i8> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: i8) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<i8> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: i8) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<i16> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: i16) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<i16> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: i16) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<i32> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: i32) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<i32> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: i32) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: i64) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<i64> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: i64) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<u8> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: u8) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<u8> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: u8) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<u16> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: u16) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<u16> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: u16) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<u32> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: u32) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<u32> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: u32) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<u64> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: u64) -> Self::Output {
Self {
x: self.x.shl(rhs),
y: self.y.shl(rhs),
}
}
}
impl Shr<u64> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: u64) -> Self::Output {
Self {
x: self.x.shr(rhs),
y: self.y.shr(rhs),
}
}
}
impl Shl<crate::IVec2> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: crate::IVec2) -> Self::Output {
Self {
x: self.x.shl(rhs.x),
y: self.y.shl(rhs.y),
}
}
}
impl Shr<crate::IVec2> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: crate::IVec2) -> Self::Output {
Self {
x: self.x.shr(rhs.x),
y: self.y.shr(rhs.y),
}
}
}
impl Shl<crate::UVec2> for I64Vec2 {
type Output = Self;
#[inline]
fn shl(self, rhs: crate::UVec2) -> Self::Output {
Self {
x: self.x.shl(rhs.x),
y: self.y.shl(rhs.y),
}
}
}
impl Shr<crate::UVec2> for I64Vec2 {
type Output = Self;
#[inline]
fn shr(self, rhs: crate::UVec2) -> Self::Output {
Self {
x: self.x.shr(rhs.x),
y: self.y.shr(rhs.y),
}
}
}
impl Index<usize> for I64Vec2 {
type Output = i64;
#[inline]
fn index(&self, index: usize) -> &Self::Output {
match index {
0 => &self.x,
1 => &self.y,
_ => panic!("index out of bounds"),
}
}
}
impl IndexMut<usize> for I64Vec2 {
#[inline]
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
match index {
0 => &mut self.x,
1 => &mut self.y,
_ => panic!("index out of bounds"),
}
}
}
impl fmt::Display for I64Vec2 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[{}, {}]", self.x, self.y)
}
}
impl fmt::Debug for I64Vec2 {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple(stringify!(I64Vec2))
.field(&self.x)
.field(&self.y)
.finish()
}
}
impl From<[i64; 2]> for I64Vec2 {
#[inline]
fn from(a: [i64; 2]) -> Self {
Self::new(a[0], a[1])
}
}
impl From<I64Vec2> for [i64; 2] {
#[inline]
fn from(v: I64Vec2) -> Self {
[v.x, v.y]
}
}
impl From<(i64, i64)> for I64Vec2 {
#[inline]
fn from(t: (i64, i64)) -> Self {
Self::new(t.0, t.1)
}
}
impl From<I64Vec2> for (i64, i64) {
#[inline]
fn from(v: I64Vec2) -> Self {
(v.x, v.y)
}
}
impl From<I8Vec2> for I64Vec2 {
#[inline]
fn from(v: I8Vec2) -> Self {
Self::new(i64::from(v.x), i64::from(v.y))
}
}
impl From<U8Vec2> for I64Vec2 {
#[inline]
fn from(v: U8Vec2) -> Self {
Self::new(i64::from(v.x), i64::from(v.y))
}
}
impl From<I16Vec2> for I64Vec2 {
#[inline]
fn from(v: I16Vec2) -> Self {
Self::new(i64::from(v.x), i64::from(v.y))
}
}
impl From<U16Vec2> for I64Vec2 {
#[inline]
fn from(v: U16Vec2) -> Self {
Self::new(i64::from(v.x), i64::from(v.y))
}
}
impl From<IVec2> for I64Vec2 {
#[inline]
fn from(v: IVec2) -> Self {
Self::new(i64::from(v.x), i64::from(v.y))
}
}
impl From<UVec2> for I64Vec2 {
#[inline]
fn from(v: UVec2) -> Self {
Self::new(i64::from(v.x), i64::from(v.y))
}
}
impl TryFrom<U64Vec2> for I64Vec2 {
type Error = core::num::TryFromIntError;
#[inline]
fn try_from(v: U64Vec2) -> Result<Self, Self::Error> {
Ok(Self::new(i64::try_from(v.x)?, i64::try_from(v.y)?))
}
}
impl From<BVec2> for I64Vec2 {
#[inline]
fn from(v: BVec2) -> Self {
Self::new(i64::from(v.x), i64::from(v.y))
}
}