Struct components::foundation::Point3D
[−]#[repr(C)]pub struct Point3D<T> {
pub x: T,
pub y: T,
pub z: T,
}Expand description
A 3d Vector tagged with a unit.
Fields
x: TThe x (traditionally, horizontal) coordinate.
y: TThe y (traditionally, vertical) coordinate.
z: TThe z (traditionally, depth) coordinate.
Implementations
impl<T> Vector3D<T>
impl<T> Vector3D<T>
pub const fn new(x: T, y: T, z: T) -> Vector3D<T>
pub const fn new(x: T, y: T, z: T) -> Vector3D<T>
Constructor, setting all components to zero. Constructor taking scalar values directly.
pub fn splat(v: T) -> Vector3D<T> where
T: Clone,
pub fn splat(v: T) -> Vector3D<T> where
T: Clone,
Constructor setting all components to the same value.
pub fn from_untyped(p: Vector3D<T>) -> Vector3D<T>
pub fn from_untyped(p: Vector3D<T>) -> Vector3D<T>
Tag a unitless value with units.
pub fn abs(self) -> Vector3D<T> where
T: Signed,
pub fn abs(self) -> Vector3D<T> where
T: Signed,
Computes the vector with absolute values of each component.
Example
assert_eq!(Vector3D::new(-1, 0, 2).abs(), Vector3D::new(1, 0, 2));
let vec = Vector3D::new(f32::NAN, 0.0, -f32::MAX).abs();
assert!(vec.x.is_nan());
assert_eq!(vec.y, 0.0);
assert_eq!(vec.z, f32::MAX);Panics
The behavior for each component follows the scalar type’s implementation of
num_traits::Signed::abs.
impl<T> Vector3D<T> where
T: Copy,
impl<T> Vector3D<T> where
T: Copy,
pub fn cross(self, other: Vector3D<T>) -> Vector3D<T> where
T: Sub<T, Output = T> + Mul<T, Output = T>,
pub fn cross(self, other: Vector3D<T>) -> Vector3D<T> where
T: Sub<T, Output = T> + Mul<T, Output = T>,
Cross product.
pub fn component_mul(self, other: Vector3D<T>) -> Vector3D<T> where
T: Mul<T, Output = T>,
pub fn component_mul(self, other: Vector3D<T>) -> Vector3D<T> where
T: Mul<T, Output = T>,
Returns the component-wise multiplication of the two vectors.
pub fn component_div(self, other: Vector3D<T>) -> Vector3D<T> where
T: Div<T, Output = T>,
pub fn component_div(self, other: Vector3D<T>) -> Vector3D<T> where
T: Div<T, Output = T>,
Returns the component-wise division of the two vectors.
pub fn to_untyped(self) -> Vector3D<T>
pub fn to_untyped(self) -> Vector3D<T>
Drop the units, preserving only the numeric value.
impl<T> Vector3D<T> where
T: Mul<T, Output = T> + Add<T, Output = T> + Copy,
impl<T> Vector3D<T> where
T: Mul<T, Output = T> + Add<T, Output = T> + Copy,
pub fn square_length(self) -> T
pub fn square_length(self) -> T
Returns the vector’s length squared.
pub fn project_onto_vector(self, onto: Vector3D<T>) -> Vector3D<T> where
T: Sub<T, Output = T> + Div<T, Output = T>,
pub fn project_onto_vector(self, onto: Vector3D<T>) -> Vector3D<T> where
T: Sub<T, Output = T> + Div<T, Output = T>,
Returns this vector projected onto another one.
Projecting onto a nil vector will cause a division by zero.
impl<T> Vector3D<T> where
T: Float,
impl<T> Vector3D<T> where
T: Float,
pub fn length(self) -> T
pub fn length(self) -> T
Returns the vector length.
pub fn try_normalize(self) -> Option<Vector3D<T>>
pub fn try_normalize(self) -> Option<Vector3D<T>>
Returns the vector with length of one unit.
Unlike Vector2D::normalize, this returns None in the case that the
length of the vector is zero.
pub fn robust_normalize(self) -> Vector3D<T>
pub fn robust_normalize(self) -> Vector3D<T>
Return the normalized vector even if the length is larger than the max value of Float.
pub fn with_max_length(self, max_length: T) -> Vector3D<T>
pub fn with_max_length(self, max_length: T) -> Vector3D<T>
Return this vector capped to a maximum length.
pub fn with_min_length(self, min_length: T) -> Vector3D<T>
pub fn with_min_length(self, min_length: T) -> Vector3D<T>
Return this vector with a minimum length applied.
pub fn clamp_length(self, min: T, max: T) -> Vector3D<T>
pub fn clamp_length(self, min: T, max: T) -> Vector3D<T>
Return this vector with minimum and maximum lengths applied.
impl<T> Vector3D<T> where
T: NumCast + Copy,
impl<T> Vector3D<T> where
T: NumCast + Copy,
pub fn cast<NewT>(self) -> Vector3D<NewT> where
NewT: NumCast,
pub fn cast<NewT>(self) -> Vector3D<NewT> where
NewT: NumCast,
Cast from one numeric representation to another, preserving the units.
When casting from floating vector to integer coordinates, the decimals are truncated
as one would expect from a simple cast, but this behavior does not always make sense
geometrically. Consider using round(), ceil() or floor() before casting.
pub fn try_cast<NewT>(self) -> Option<Vector3D<NewT>> where
NewT: NumCast,
pub fn try_cast<NewT>(self) -> Option<Vector3D<NewT>> where
NewT: NumCast,
Fallible cast from one numeric representation to another, preserving the units.
When casting from floating vector to integer coordinates, the decimals are truncated
as one would expect from a simple cast, but this behavior does not always make sense
geometrically. Consider using round(), ceil() or floor() before casting.
pub fn to_usize(self) -> Vector3D<usize>
pub fn to_usize(self) -> Vector3D<usize>
Cast into an usize vector, truncating decimals if any.
When casting from floating vector vectors, it is worth considering whether
to round(), ceil() or floor() before the cast in order to obtain
the desired conversion behavior.
pub fn to_u32(self) -> Vector3D<u32>
pub fn to_u32(self) -> Vector3D<u32>
Cast into an u32 vector, truncating decimals if any.
When casting from floating vector vectors, it is worth considering whether
to round(), ceil() or floor() before the cast in order to obtain
the desired conversion behavior.
Trait Implementations
impl<T> AddAssign<Vector3D<T>> for Vector3D<T> where
T: Copy + Add<T, Output = T>,
impl<T> AddAssign<Vector3D<T>> for Vector3D<T> where
T: Copy + Add<T, Output = T>,
fn add_assign(&mut self, other: Vector3D<T>)
fn add_assign(&mut self, other: Vector3D<T>)
Performs the += operation. Read more
impl<T> DivAssign<T> for Vector3D<T> where
T: Copy + Div<T, Output = T>,
impl<T> DivAssign<T> for Vector3D<T> where
T: Copy + Div<T, Output = T>,
fn div_assign(&mut self, scale: T)
fn div_assign(&mut self, scale: T)
Performs the /= operation. Read more
impl<T> MulAssign<T> for Vector3D<T> where
T: Copy + Mul<T, Output = T>,
impl<T> MulAssign<T> for Vector3D<T> where
T: Copy + Mul<T, Output = T>,
fn mul_assign(&mut self, scale: T)
fn mul_assign(&mut self, scale: T)
Performs the *= operation. Read more
impl<T> SubAssign<Vector3D<T>> for Vector3D<T> where
T: Copy + Sub<T, Output = T>,
impl<T> SubAssign<Vector3D<T>> for Vector3D<T> where
T: Copy + Sub<T, Output = T>,
fn sub_assign(&mut self, other: Vector3D<T>)
fn sub_assign(&mut self, other: Vector3D<T>)
Performs the -= operation. Read more
impl<T> Copy for Vector3D<T> where
T: Copy,
impl<T> Eq for Vector3D<T> where
T: Eq,
Auto Trait Implementations
impl<T> RefUnwindSafe for Vector3D<T> where
T: RefUnwindSafe,
impl<T> Send for Vector3D<T> where
T: Send,
impl<T> Sync for Vector3D<T> where
T: Sync,
impl<T> Unpin for Vector3D<T> where
T: Unpin,
impl<T> UnwindSafe for Vector3D<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
fn into_color(self) -> To
fn into_color(self) -> To
Convert into color
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
Sets value as a parameter of self.