chore: renamed the structs Vec2, Vec3, Vec4, Mat2, Mat3, Mat4, Point2, Point3 to v2, v3, v4, m2, m3, m4, p2, p3

This commit is contained in:
lisk77 2025-04-17 00:54:09 +02:00
parent 982323f671
commit fd8cf1f278
22 changed files with 430 additions and 430 deletions

View file

@ -1,4 +1,4 @@
use crate::point::{Point2, Point3};
use crate::point::{p2, p3};
use crate::quaternion::Quat;
use std::ops::*;
@ -31,21 +31,21 @@ pub trait InnerSpace:
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Vec2 {
pub struct v2 {
x: f32,
y: f32,
}
impl Vec2 {
pub const X: Vec2 = Vec2 { x: 1.0, y: 0.0 };
pub const Y: Vec2 = Vec2 { x: 0.0, y: 1.0 };
pub const ZERO: Vec2 = Vec2 { x: 0.0, y: 0.0 };
impl v2 {
pub const X: v2 = v2 { x: 1.0, y: 0.0 };
pub const Y: v2 = v2 { x: 0.0, y: 1.0 };
pub const ZERO: v2 = v2 { x: 0.0, y: 0.0 };
pub const fn new(x: f32, y: f32) -> Self {
Vec2 { x, y }
v2 { x, y }
}
pub fn from_point(p: Point2) -> Self {
pub fn from_point(p: p2) -> Self {
Self { x: p.x(), y: p.y() }
}
@ -66,43 +66,43 @@ impl Vec2 {
}
}
impl Add<Vec2> for Vec2 {
type Output = Vec2;
impl Add<v2> for v2 {
type Output = v2;
fn add(self, other: Vec2) -> Vec2 {
Vec2 {
fn add(self, other: v2) -> v2 {
v2 {
x: self.x + other.x,
y: self.y + other.y,
}
}
}
impl AddAssign for Vec2 {
fn add_assign(&mut self, other: Vec2) {
impl AddAssign for v2 {
fn add_assign(&mut self, other: v2) {
self.x += other.x;
self.y += other.y;
}
}
impl Sub<Vec2> for Vec2 {
type Output = Vec2;
impl Sub<v2> for v2 {
type Output = v2;
fn sub(self, other: Vec2) -> Vec2 {
Vec2 {
fn sub(self, other: v2) -> v2 {
v2 {
x: self.x - other.x,
y: self.y - other.y,
}
}
}
impl SubAssign for Vec2 {
fn sub_assign(&mut self, other: Vec2) {
impl SubAssign for v2 {
fn sub_assign(&mut self, other: v2) {
self.x -= other.x;
self.y -= other.y;
}
}
impl Neg for Vec2 {
impl Neg for v2 {
type Output = Self;
fn neg(self) -> Self::Output {
@ -113,48 +113,48 @@ impl Neg for Vec2 {
}
}
impl Mul<f32> for Vec2 {
type Output = Vec2;
impl Mul<f32> for v2 {
type Output = v2;
fn mul(self, other: f32) -> Vec2 {
Vec2 {
fn mul(self, other: f32) -> v2 {
v2 {
x: self.x * other,
y: self.y * other,
}
}
}
impl Mul<Vec2> for f32 {
type Output = Vec2;
impl Mul<v2> for f32 {
type Output = v2;
fn mul(self, other: Vec2) -> Vec2 {
Vec2 {
fn mul(self, other: v2) -> v2 {
v2 {
x: self * other.x,
y: self * other.y,
}
}
}
impl Div<f32> for Vec2 {
type Output = Vec2;
impl Div<f32> for v2 {
type Output = v2;
fn div(self, other: f32) -> Vec2 {
Vec2 {
fn div(self, other: f32) -> v2 {
v2 {
x: self.x / other,
y: self.y / other,
}
}
}
impl Into<[f32;2]> for Vec2 {
impl Into<[f32;2]> for v2 {
fn into(self) -> [f32;2] {
[self.x, self.y]
}
}
impl Into<Vec2> for [f32;2] {
fn into(self) -> Vec2 {
Vec2 {
impl Into<v2> for [f32;2] {
fn into(self) -> v2 {
v2 {
x: self[0],
y: self[1],
}
@ -165,26 +165,26 @@ impl Into<Vec2> for [f32;2] {
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct IVec2 {
pub struct v2i {
x: i64,
y: i64,
}
impl IVec2 {
pub const X: IVec2 = IVec2 { x: 1, y: 0 };
pub const Y: IVec2 = IVec2 { x: 0, y: 1 };
pub const ZERO: IVec2 = IVec2 { x: 0, y: 0 };
impl v2i {
pub const X: v2i = v2i { x: 1, y: 0 };
pub const Y: v2i = v2i { x: 0, y: 1 };
pub const ZERO: v2i = v2i { x: 0, y: 0 };
pub const fn new(x: i64, y: i64) -> Self {
IVec2 { x, y }
v2i { x, y }
}
pub fn from_point(p: Point2) -> Self {
pub fn from_point(p: p2) -> Self {
Self { x: p.x() as i64, y: p.y() as i64 }
}
pub fn as_vec2(&self) -> Vec2 {
Vec2 {
pub fn as_vec2(&self) -> v2 {
v2 {
x: self.x as f32,
y: self.y as f32,
}
@ -212,7 +212,7 @@ impl IVec2 {
pub fn normalize(&self) -> Self {
let factor = 1.0 / self.length() as f32;
IVec2 {
v2i {
x: (factor * self.x as f32) as i64,
y: (factor * self.y as f32) as i64,
}
@ -247,122 +247,122 @@ impl IVec2 {
}
}
impl Add<IVec2> for IVec2 {
type Output = IVec2;
impl Add<v2i> for v2i {
type Output = v2i;
fn add(self, other: IVec2) -> IVec2 {
IVec2 {
fn add(self, other: v2i) -> v2i {
v2i {
x: self.x + other.x,
y: self.y + other.y,
}
}
}
impl Add<IVec2> for Vec2 {
type Output = Vec2;
impl Add<v2i> for v2 {
type Output = v2;
fn add(self, other: IVec2) -> Vec2 {
Vec2 {
fn add(self, other: v2i) -> v2 {
v2 {
x: self.x + other.x as f32,
y: self.y + other.y as f32,
}
}
}
impl Add<Vec2> for IVec2 {
type Output = Vec2;
impl Add<v2> for v2i {
type Output = v2;
fn add(self, other: Vec2) -> Vec2 {
Vec2 {
fn add(self, other: v2) -> v2 {
v2 {
x: self.x as f32 + other.x,
y: self.y as f32 + other.y,
}
}
}
impl AddAssign for IVec2 {
fn add_assign(&mut self, other: IVec2) {
impl AddAssign for v2i {
fn add_assign(&mut self, other: v2i) {
self.x += other.x;
self.y += other.y;
}
}
impl Sub<IVec2> for IVec2 {
type Output = IVec2;
impl Sub<v2i> for v2i {
type Output = v2i;
fn sub(self, other: IVec2) -> IVec2 {
IVec2 {
fn sub(self, other: v2i) -> v2i {
v2i {
x: self.x - other.x,
y: self.y - other.y,
}
}
}
impl Sub<IVec2> for Vec2 {
type Output = Vec2;
impl Sub<v2i> for v2 {
type Output = v2;
fn sub(self, other: IVec2) -> Vec2 {
Vec2 {
fn sub(self, other: v2i) -> v2 {
v2 {
x: self.x - other.x as f32,
y: self.y - other.y as f32,
}
}
}
impl Sub<Vec2> for IVec2 {
type Output = Vec2;
impl Sub<v2> for v2i {
type Output = v2;
fn sub(self, other: Vec2) -> Vec2 {
Vec2 {
fn sub(self, other: v2) -> v2 {
v2 {
x: self.x as f32 - other.x,
y: self.y as f32 - other.y,
}
}
}
impl SubAssign for IVec2 {
fn sub_assign(&mut self, other: IVec2) {
impl SubAssign for v2i {
fn sub_assign(&mut self, other: v2i) {
self.x -= other.x;
self.y -= other.y;
}
}
impl Mul<f32> for IVec2 {
type Output = IVec2;
impl Mul<f32> for v2i {
type Output = v2i;
fn mul(self, other: f32) -> IVec2 {
IVec2 {
fn mul(self, other: f32) -> v2i {
v2i {
x: self.x * other as i64,
y: self.y * other as i64,
}
}
}
impl From<IVec2> for Vec2 {
fn from(v: IVec2) -> Vec2 {
Vec2 {
impl From<v2i> for v2 {
fn from(v: v2i) -> v2 {
v2 {
x: v.x as f32,
y: v.y as f32,
}
}
}
impl From<Vec2> for IVec2 {
fn from(v: Vec2) -> IVec2 {
IVec2 {
impl From<v2> for v2i {
fn from(v: v2) -> v2i {
v2i {
x: v.x as i64,
y: v.y as i64,
}
}
}
impl Into<[i64;2]> for IVec2 {
impl Into<[i64;2]> for v2i {
fn into(self) -> [i64;2] {
[self.x, self.y]
}
}
impl Into<[f32;2]> for IVec2 {
impl Into<[f32;2]> for v2i {
fn into(self) -> [f32;2] {
[self.x as f32, self.y as f32]
}
@ -376,23 +376,23 @@ impl Into<[f32;2]> for IVec2 {
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Vec3 {
pub struct v3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl Vec3 {
pub const X: Vec3 = Vec3 { x: 1.0, y: 0.0, z: 0.0 };
pub const Y: Vec3 = Vec3 { x: 0.0, y: 1.0, z: 0.0 };
pub const Z: Vec3 = Vec3 { x: 0.0, y: 0.0, z: 1.0 };
pub const ZERO: Vec3 = Vec3 { x: 0.0, y: 0.0, z: 0.0 };
impl v3 {
pub const X: v3 = v3 { x: 1.0, y: 0.0, z: 0.0 };
pub const Y: v3 = v3 { x: 0.0, y: 1.0, z: 0.0 };
pub const Z: v3 = v3 { x: 0.0, y: 0.0, z: 1.0 };
pub const ZERO: v3 = v3 { x: 0.0, y: 0.0, z: 0.0 };
pub const fn new(x: f32, y: f32, z: f32) -> Self {
Vec3 { x, y, z }
v3 { x, y, z }
}
pub fn from_point(p: Point3) -> Self {
pub fn from_point(p: p3) -> Self {
Self {
x: p.x(),
y: p.y(),
@ -425,11 +425,11 @@ impl Vec3 {
}
}
impl Add<Vec3> for Vec3 {
type Output = Vec3;
impl Add<v3> for v3 {
type Output = v3;
fn add(self, other: Vec3) -> Vec3 {
Vec3 {
fn add(self, other: v3) -> v3 {
v3 {
x: self.x + other.x,
y: self.y + other.y,
z: self.z + other.z,
@ -437,19 +437,19 @@ impl Add<Vec3> for Vec3 {
}
}
impl AddAssign for Vec3 {
fn add_assign(&mut self, other: Vec3) {
impl AddAssign for v3 {
fn add_assign(&mut self, other: v3) {
self.x += other.x;
self.y += other.y;
self.z += other.z;
}
}
impl Sub<Vec3> for Vec3 {
type Output = Vec3;
impl Sub<v3> for v3 {
type Output = v3;
fn sub(self, other: Vec3) -> Vec3 {
Vec3 {
fn sub(self, other: v3) -> v3 {
v3 {
x: self.x - other.x,
y: self.y - other.y,
z: self.z - other.z,
@ -457,19 +457,19 @@ impl Sub<Vec3> for Vec3 {
}
}
impl SubAssign for Vec3 {
fn sub_assign(&mut self, other: Vec3) {
impl SubAssign for v3 {
fn sub_assign(&mut self, other: v3) {
self.x -= other.x;
self.y -= other.y;
self.z -= other.z;
}
}
impl Neg for Vec3 {
type Output = Vec3;
impl Neg for v3 {
type Output = v3;
fn neg(self) -> Vec3 {
Vec3 {
fn neg(self) -> v3 {
v3 {
x: -self.x,
y: -self.y,
z: -self.z,
@ -477,11 +477,11 @@ impl Neg for Vec3 {
}
}
impl Mul<f32> for Vec3 {
type Output = Vec3;
impl Mul<f32> for v3 {
type Output = v3;
fn mul(self, other: f32) -> Vec3 {
Vec3 {
fn mul(self, other: f32) -> v3 {
v3 {
x: self.x * other,
y: self.y * other,
z: self.z * other,
@ -489,11 +489,11 @@ impl Mul<f32> for Vec3 {
}
}
impl Mul<Vec3> for f32 {
type Output = Vec3;
impl Mul<v3> for f32 {
type Output = v3;
fn mul(self, other: Vec3) -> Vec3 {
Vec3 {
fn mul(self, other: v3) -> v3 {
v3 {
x: self * other.x,
y: self * other.y,
z: self * other.z,
@ -501,11 +501,11 @@ impl Mul<Vec3> for f32 {
}
}
impl Div<f32> for Vec3 {
type Output = Vec3;
impl Div<f32> for v3 {
type Output = v3;
fn div(self, other: f32) -> Vec3 {
Vec3 {
fn div(self, other: f32) -> v3 {
v3 {
x: self.x / other,
y: self.y / other,
z: self.z / other,
@ -513,21 +513,21 @@ impl Div<f32> for Vec3 {
}
}
impl Into<Quat> for Vec3 {
impl Into<Quat> for v3 {
fn into(self) -> Quat {
Quat::new(0.0, self)
}
}
impl Into<[f32;3]> for Vec3 {
impl Into<[f32;3]> for v3 {
fn into(self) -> [f32;3] {
[self.x, self.y, self.z]
}
}
impl Into<Vec3> for [f32;3] {
fn into(self) -> Vec3 {
Vec3 {
impl Into<v3> for [f32;3] {
fn into(self) -> v3 {
v3 {
x: self[0],
y: self[1],
z: self[2],
@ -539,23 +539,23 @@ impl Into<Vec3> for [f32;3] {
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct IVec3 {
pub struct v3i {
pub x: i64,
pub y: i64,
pub z: i64,
}
impl IVec3 {
pub const X: IVec3 = IVec3 { x: 1, y: 0, z: 0 };
pub const Y: IVec3 = IVec3 { x: 0, y: 1, z: 0 };
pub const Z: IVec3 = IVec3 { x: 0, y: 0, z: 1 };
pub const ZERO: IVec3 = IVec3 { x: 0, y: 0, z: 0 };
impl v3i {
pub const X: v3i = v3i { x: 1, y: 0, z: 0 };
pub const Y: v3i = v3i { x: 0, y: 1, z: 0 };
pub const Z: v3i = v3i { x: 0, y: 0, z: 1 };
pub const ZERO: v3i = v3i { x: 0, y: 0, z: 0 };
pub const fn new(x: i64, y: i64, z: i64) -> Self {
IVec3 { x, y, z }
v3i { x, y, z }
}
pub fn from_point(p: Point3) -> Self {
pub fn from_point(p: p3) -> Self {
Self {
x: p.x() as i64,
y: p.y() as i64,
@ -593,7 +593,7 @@ impl IVec3 {
pub fn normalize(&self) -> Self {
let factor = 1 / self.length();
IVec3 {
v3i {
x: factor * self.x,
y: factor * self.y,
z: factor * self.z,
@ -601,11 +601,11 @@ impl IVec3 {
}
}
impl Add<IVec3> for IVec3 {
type Output = IVec3;
impl Add<v3i> for v3i {
type Output = v3i;
fn add(self, other: IVec3) -> IVec3 {
IVec3 {
fn add(self, other: v3i) -> v3i {
v3i {
x: self.x + other.x,
y: self.y + other.y,
z: self.z + other.z,
@ -613,11 +613,11 @@ impl Add<IVec3> for IVec3 {
}
}
impl Add<IVec3> for Vec3 {
type Output = Vec3;
impl Add<v3i> for v3 {
type Output = v3;
fn add(self, other: IVec3) -> Vec3 {
Vec3 {
fn add(self, other: v3i) -> v3 {
v3 {
x: self.x + other.x as f32,
y: self.y + other.y as f32,
z: self.z + other.z as f32,
@ -625,11 +625,11 @@ impl Add<IVec3> for Vec3 {
}
}
impl Add<Vec3> for IVec3 {
type Output = Vec3;
impl Add<v3> for v3i {
type Output = v3;
fn add(self, other: Vec3) -> Vec3 {
Vec3 {
fn add(self, other: v3) -> v3 {
v3 {
x: self.x as f32 + other.x,
y: self.y as f32 + other.y,
z: self.z as f32 + other.z,
@ -637,19 +637,19 @@ impl Add<Vec3> for IVec3 {
}
}
impl AddAssign for IVec3 {
fn add_assign(&mut self, other: IVec3) {
impl AddAssign for v3i {
fn add_assign(&mut self, other: v3i) {
self.x += other.x;
self.y += other.y;
self.z += other.z;
}
}
impl Sub<IVec3> for IVec3 {
type Output = IVec3;
impl Sub<v3i> for v3i {
type Output = v3i;
fn sub(self, other: IVec3) -> IVec3 {
IVec3 {
fn sub(self, other: v3i) -> v3i {
v3i {
x: self.x - other.x,
y: self.y - other.y,
z: self.z - other.z,
@ -657,11 +657,11 @@ impl Sub<IVec3> for IVec3 {
}
}
impl Sub<IVec3> for Vec3 {
type Output = Vec3;
impl Sub<v3i> for v3 {
type Output = v3;
fn sub(self, other: IVec3) -> Vec3 {
Vec3 {
fn sub(self, other: v3i) -> v3 {
v3 {
x: self.x - other.x as f32,
y: self.y - other.y as f32,
z: self.z - other.z as f32,
@ -669,11 +669,11 @@ impl Sub<IVec3> for Vec3 {
}
}
impl Sub<Vec3> for IVec3 {
type Output = Vec3;
impl Sub<v3> for v3i {
type Output = v3;
fn sub(self, other: Vec3) -> Vec3 {
Vec3 {
fn sub(self, other: v3) -> v3 {
v3 {
x: self.x as f32 - other.x,
y: self.y as f32 - other.y,
z: self.z as f32 - other.z,
@ -681,18 +681,18 @@ impl Sub<Vec3> for IVec3 {
}
}
impl SubAssign for IVec3 {
fn sub_assign(&mut self, other: IVec3) {
impl SubAssign for v3i {
fn sub_assign(&mut self, other: v3i) {
self.x -= other.x;
self.y -= other.y;
}
}
impl Mul<f32> for IVec3 {
type Output = IVec3;
impl Mul<f32> for v3i {
type Output = v3i;
fn mul(self, other: f32) -> IVec3 {
IVec3 {
fn mul(self, other: f32) -> v3i {
v3i {
x: self.x * other as i64,
y: self.y * other as i64,
z: self.z * other as i64,
@ -700,9 +700,9 @@ impl Mul<f32> for IVec3 {
}
}
impl From<IVec3> for Vec3 {
fn from(v: IVec3) -> Vec3 {
Vec3 {
impl From<v3i> for v3 {
fn from(v: v3i) -> v3 {
v3 {
x: v.x as f32,
y: v.y as f32,
z: v.z as f32,
@ -710,9 +710,9 @@ impl From<IVec3> for Vec3 {
}
}
impl From<Vec3> for IVec3 {
fn from(v: Vec3) -> IVec3 {
IVec3 {
impl From<v3> for v3i {
fn from(v: v3) -> v3i {
v3i {
x: v.x as i64,
y: v.y as i64,
z: v.z as i64,
@ -728,23 +728,23 @@ impl From<Vec3> for IVec3 {
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Vec4 {
pub struct v4 {
x: f32,
y: f32,
z: f32,
w: f32,
}
impl Vec4 {
pub const X: Vec4 = Vec4 { x: 1.0, y: 0.0, z: 0.0, w: 0.0 };
pub const Y: Vec4 = Vec4 { x: 0.0, y: 1.0, z: 0.0, w: 0.0 };
pub const Z: Vec4 = Vec4 { x: 0.0, y: 0.0, z: 1.0, w: 0.0 };
pub const W: Vec4 = Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 1.0 };
impl v4 {
pub const X: v4 = v4 { x: 1.0, y: 0.0, z: 0.0, w: 0.0 };
pub const Y: v4 = v4 { x: 0.0, y: 1.0, z: 0.0, w: 0.0 };
pub const Z: v4 = v4 { x: 0.0, y: 0.0, z: 1.0, w: 0.0 };
pub const W: v4 = v4 { x: 0.0, y: 0.0, z: 0.0, w: 1.0 };
pub const ZERO: Vec4 = Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 };
pub const ZERO: v4 = v4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 };
pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self {
Vec4 { x, y, z, w }
v4 { x, y, z, w }
}
pub fn x(&self) -> f32 {
@ -780,11 +780,11 @@ impl Vec4 {
}
}
impl Add<Vec4> for Vec4 {
type Output = Vec4;
impl Add<v4> for v4 {
type Output = v4;
fn add(self, other: Vec4) -> Vec4 {
Vec4 {
fn add(self, other: v4) -> v4 {
v4 {
x: self.x + other.x,
y: self.y + other.y,
z: self.z + other.z,
@ -793,8 +793,8 @@ impl Add<Vec4> for Vec4 {
}
}
impl AddAssign for Vec4 {
fn add_assign(&mut self, other: Vec4) {
impl AddAssign for v4 {
fn add_assign(&mut self, other: v4) {
self.x += other.x;
self.y += other.y;
self.z += other.z;
@ -802,11 +802,11 @@ impl AddAssign for Vec4 {
}
}
impl Sub<Vec4> for Vec4 {
type Output = Vec4;
impl Sub<v4> for v4 {
type Output = v4;
fn sub(self, other: Vec4) -> Vec4 {
Vec4 {
fn sub(self, other: v4) -> v4 {
v4 {
x: self.x - other.x,
y: self.y - other.y,
z: self.z - other.z,
@ -815,8 +815,8 @@ impl Sub<Vec4> for Vec4 {
}
}
impl SubAssign for Vec4 {
fn sub_assign(&mut self, other: Vec4) {
impl SubAssign for v4 {
fn sub_assign(&mut self, other: v4) {
self.x -= other.x;
self.y -= other.y;
self.z -= other.z;
@ -824,7 +824,7 @@ impl SubAssign for Vec4 {
}
}
impl Neg for Vec4 {
impl Neg for v4 {
type Output = Self;
fn neg(self) -> Self::Output {
@ -837,11 +837,11 @@ impl Neg for Vec4 {
}
}
impl Mul<f32> for Vec4 {
type Output = Vec4;
impl Mul<f32> for v4 {
type Output = v4;
fn mul(self, other: f32) -> Vec4 {
Vec4 {
fn mul(self, other: f32) -> v4 {
v4 {
x: self.x * other,
y: self.y * other,
z: self.z * other,
@ -850,11 +850,11 @@ impl Mul<f32> for Vec4 {
}
}
impl Mul<Vec4> for f32 {
type Output = Vec4;
impl Mul<v4> for f32 {
type Output = v4;
fn mul(self, other: Vec4) -> Vec4 {
Vec4 {
fn mul(self, other: v4) -> v4 {
v4 {
x: self * other.x,
y: self * other.y,
z: self * other.z,
@ -863,7 +863,7 @@ impl Mul<Vec4> for f32 {
}
}
impl MulAssign<f32> for Vec4 {
impl MulAssign<f32> for v4 {
fn mul_assign(&mut self, other: f32) {
self.x *= other;
self.y *= other;
@ -872,11 +872,11 @@ impl MulAssign<f32> for Vec4 {
}
}
impl Div<f32> for Vec4 {
type Output = Vec4;
impl Div<f32> for v4 {
type Output = v4;
fn div(self, other: f32) -> Vec4 {
Vec4 {
fn div(self, other: f32) -> v4 {
v4 {
x: self.x / other,
y: self.y / other,
z: self.z / other,
@ -885,19 +885,19 @@ impl Div<f32> for Vec4 {
}
}
impl Into<[f32;4]> for Vec4 {
impl Into<[f32;4]> for v4 {
fn into(self) -> [f32;4] {
[self.x, self.y, self.z, self.w]
}
}
impl InnerSpace for Vec2 {
impl InnerSpace for v2 {
fn dot(&self, other: &Self) -> f32 {
self.x * other.x + self.y * other.y
}
fn dist(&self, other: &Self) -> f32 {
Vec2 {
v2 {
x: other.x - self.x,
y: other.y - self.y,
}
@ -914,7 +914,7 @@ impl InnerSpace for Vec2 {
fn normalize(&self) -> Self {
let factor = 1.0 / self.length();
Vec2 {
v2 {
x: factor * self.x,
y: factor * self.y,
}
@ -940,13 +940,13 @@ impl InnerSpace for Vec2 {
}
}
impl InnerSpace for Vec3 {
impl InnerSpace for v3 {
fn dot(&self, other: &Self) -> f32 {
self.x * other.x + self.y * other.y + self.z * other.z
}
fn dist(&self, other: &Self) -> f32 {
Vec3 {
v3 {
x: other.x - self.x,
y: other.y - self.y,
z: other.z - self.z,
@ -964,7 +964,7 @@ impl InnerSpace for Vec3 {
fn normalize(&self) -> Self {
let factor = 1.0 / self.length();
Vec3 {
v3 {
x: factor * self.x,
y: factor * self.y,
z: factor * self.z,
@ -992,13 +992,13 @@ impl InnerSpace for Vec3 {
}
}
impl InnerSpace for Vec4 {
impl InnerSpace for v4 {
fn dot(&self, other: &Self) -> f32 {
self.x * other.x + self.y * other.y + self.z * other.z + self.w * other.w
}
fn dist(&self, other: &Self) -> f32 {
Vec4 {
v4 {
x: other.x - self.x,
y: other.y - self.y,
z: other.z - self.z,
@ -1017,7 +1017,7 @@ impl InnerSpace for Vec4 {
fn normalize(&self) -> Self {
let factor = 1.0 / self.length();
Vec4 {
v4 {
x: factor * self.x,
y: factor * self.y,
z: factor * self.z,
@ -1095,12 +1095,12 @@ macro_rules! generate_swizzles4 {
};
}
generate_swizzles2!(Vec2,
generate_swizzles2!(v2,
xx => (x, x), xy => (x, y),
yx => (y, x), yy => (y, y)
);
generate_swizzles3!(Vec3,
generate_swizzles3!(v3,
xxx => (x, x, x), xxy => (x, x, y), xxz => (x, x, z),
xyx => (x, y, x), xyy => (x, y, y), xyz => (x, y, z),
xzx => (x, z, x), xzy => (x, z, y), xzz => (x, z, z),
@ -1112,7 +1112,7 @@ generate_swizzles3!(Vec3,
zzx => (z, z, x), zzy => (z, z, y), zzz => (z, z, z)
);
generate_swizzles4!(Vec4,
generate_swizzles4!(v4,
xxxx => (x, x, x, x), xxxy => (x, x, x, y), xxxz => (x, x, x, z), xxxw => (x, x, x, w),
xxyx => (x, x, y, x), xxyy => (x, x, y, y), xxyz => (x, x, y, z), xxyw => (x, x, y, w),
xxzx => (x, x, z, x), xxzy => (x, x, z, y), xxzz => (x, x, z, z), xxzw => (x, x, z, w),