pub struct Vec3<T = f64> {
pub x: T,
pub y: T,
pub z: T,
}Expand description
A struct representing a three-dimensional mathematical vector. These are used to represent particle information, such as position or velocity, in three-dimensional space.
Fields§
§x: T§y: T§z: TImplementations§
Source§impl<T> Vec3<T>
impl<T> Vec3<T>
Sourcepub fn new(x: T, y: T, z: T) -> Self
pub fn new(x: T, y: T, z: T) -> Self
Creates a new Vec3 instance with the given x, y, and z components.
§Example
use moldyn_core::Vec3;
let v: Vec3<f64> = Vec3::new(1.0, 2.0, 3.0);
let w: Vec3<i32> = Vec3::new(1, 2, 3);
assert_eq!(v.x, 1.0);
assert_eq!(v.y, 2.0);
assert_eq!(v.z, 3.0);
assert_eq!(w.x, 1);
assert_eq!(w.y, 2);
assert_eq!(w.z, 3);Source§impl Vec3<u8>
impl Vec3<u8>
Sourcepub fn length2(&self) -> u8
pub fn length2(&self) -> u8
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<u16>
impl Vec3<u16>
Sourcepub fn length2(&self) -> u16
pub fn length2(&self) -> u16
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<u32>
impl Vec3<u32>
Sourcepub fn length2(&self) -> u32
pub fn length2(&self) -> u32
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<u64>
impl Vec3<u64>
Sourcepub fn length2(&self) -> u64
pub fn length2(&self) -> u64
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<u128>
impl Vec3<u128>
Sourcepub fn length2(&self) -> u128
pub fn length2(&self) -> u128
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<usize>
impl Vec3<usize>
Sourcepub fn length2(&self) -> usize
pub fn length2(&self) -> usize
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<i8>
impl Vec3<i8>
Sourcepub fn length2(&self) -> i8
pub fn length2(&self) -> i8
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<i16>
impl Vec3<i16>
Sourcepub fn length2(&self) -> i16
pub fn length2(&self) -> i16
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<i32>
impl Vec3<i32>
Sourcepub fn length2(&self) -> i32
pub fn length2(&self) -> i32
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<i64>
impl Vec3<i64>
Sourcepub fn length2(&self) -> i64
pub fn length2(&self) -> i64
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<i128>
impl Vec3<i128>
Sourcepub fn length2(&self) -> i128
pub fn length2(&self) -> i128
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<isize>
impl Vec3<isize>
Sourcepub fn length2(&self) -> isize
pub fn length2(&self) -> isize
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<f32>
impl Vec3<f32>
Sourcepub fn length2(&self) -> f32
pub fn length2(&self) -> f32
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Source§impl Vec3<f64>
impl Vec3<f64>
Sourcepub fn length2(&self) -> f64
pub fn length2(&self) -> f64
TODO: rethink: old codebase became buggy because we used the wrong method.
Sourcepub fn normal(&self) -> Option<Self>
pub fn normal(&self) -> Option<Self>
Normalizes the Vec3 instance to have a length of 1, returning an option containing a new Vec3 instance. If the original vector is zero-length, returns None to avoid division by zero.
Note: I’ve made this decision with the intention of propagating divisions by zero upwards the stack. I do not know if this will turn out to be useful.
Trait Implementations§
Source§impl<T: AddAssign> AddAssign for Vec3<T>
impl<T: AddAssign> AddAssign for Vec3<T>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Implements the addition-assign operation += for the Vec3 class.
Source§impl<'de, T> Deserialize<'de> for Vec3<T>where
T: Deserialize<'de> + Default,
impl<'de, T> Deserialize<'de> for Vec3<T>where
T: Deserialize<'de> + Default,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T: Div<Output = T> + Copy> Div<T> for Vec3<T>
impl<T: Div<Output = T> + Copy> Div<T> for Vec3<T>
Source§impl<T: DivAssign + Copy> DivAssign<T> for Vec3<T>
impl<T: DivAssign + Copy> DivAssign<T> for Vec3<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Implements the division-assign operation /= for the Vec3 class.
Source§impl<T: Mul<Output = T> + Copy> Mul<T> for Vec3<T>
impl<T: Mul<Output = T> + Copy> Mul<T> for Vec3<T>
Source§impl<T: MulAssign + Copy> MulAssign<T> for Vec3<T>
impl<T: MulAssign + Copy> MulAssign<T> for Vec3<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Implements the multiplication-assign operation *= for the Vec3 class.
Source§impl<T: SubAssign> SubAssign for Vec3<T>
impl<T: SubAssign> SubAssign for Vec3<T>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Implements the subtraction-assign operation -= for the Vec3 class.