Skip to main content

XYZ

Struct XYZ 

Source
pub struct XYZ<T>(/* private fields */);
Expand description

Internal shared storage for 3D Cartesian coordinates.

This is a thin wrapper around nalgebra::Vector3<T> that provides centralized implementations of component-wise operations.

§Type Parameter

  • T: The component type (e.g., f64, Quantity<U>)

Implementations§

Source§

impl<T> XYZ<T>

Source

pub const fn new(x: T, y: T, z: T) -> Self

Creates a new XYZ from individual components.

Source

pub const fn from_vec3(vec: Vector3<T>) -> Self

Creates an XYZ from a nalgebra Vector3.

Source

pub const fn as_vec3(&self) -> &Vector3<T>

Returns the underlying nalgebra Vector3.

Source

pub fn into_vec3(self) -> Vector3<T>

Consumes self and returns the underlying Vector3.

Source§

impl<T: Copy> XYZ<T>

Source

pub fn x(&self) -> T

Returns the x-component.

Source

pub fn y(&self) -> T

Returns the y-component.

Source

pub fn z(&self) -> T

Returns the z-component.

Source

pub fn components(&self) -> (T, T, T)

Returns components as a tuple.

Source§

impl XYZ<f64>

Source

pub const ZERO: Self

The zero vector.

Source

pub fn magnitude(&self) -> f64

Computes the Euclidean magnitude (length) of the vector.

Source

pub fn magnitude_squared(&self) -> f64

Computes the squared magnitude (avoids sqrt).

Source

pub fn dot(&self, other: &Self) -> f64

Computes the dot product with another vector.

Source

pub fn cross(&self, other: &Self) -> Self

Computes the cross product with another vector.

Source

pub fn try_normalize(&self) -> Option<Self>

Returns a normalized (unit length) version, or None if magnitude is zero.

Source

pub fn normalize_unchecked(&self) -> Self

Returns a normalized version, assuming non-zero magnitude.

§Safety

Caller must ensure the vector is non-zero.

Source

pub fn scale(&self, factor: f64) -> Self

Scales the vector by a scalar factor.

Source

pub fn add(&self, other: &Self) -> Self

Component-wise addition.

Source

pub fn sub(&self, other: &Self) -> Self

Component-wise subtraction.

Source

pub fn neg(&self) -> Self

Negates all components.

Source§

impl<U: Unit> XYZ<Quantity<U>>

Source

pub const ZERO: Self

The zero vector for this unit type.

Source

pub fn magnitude(&self) -> Quantity<U>

Computes the Euclidean magnitude in the same unit.

Source

pub fn magnitude_squared(&self) -> f64

Computes the squared magnitude.

Source

pub fn to_raw(&self) -> XYZ<f64>

Extracts raw f64 values as an XYZ.

Source

pub fn from_raw(raw: XYZ<f64>) -> Self

Creates from raw f64 values.

Source

pub fn add(&self, other: &Self) -> Self

Component-wise addition.

Source

pub fn sub(&self, other: &Self) -> Self

Component-wise subtraction.

Trait Implementations§

Source§

impl<U: Unit> Add for XYZ<Quantity<U>>

Source§

type Output = XYZ<Quantity<U>>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for XYZ<f64>

Source§

type Output = XYZ<f64>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for XYZ<T>

Source§

fn clone(&self) -> XYZ<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for XYZ<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for XYZ<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Display + Copy> Display for XYZ<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: LowerExp + Copy> LowerExp for XYZ<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<U: Unit> Mul<XYZ<Quantity<U>>> for Isometry3

Source§

type Output = XYZ<Quantity<U>>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: XYZ<Quantity<U>>) -> XYZ<Quantity<U>>

Performs the * operation. Read more
Source§

impl<U: Unit> Mul<XYZ<Quantity<U>>> for Rotation3

Source§

type Output = XYZ<Quantity<U>>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: XYZ<Quantity<U>>) -> XYZ<Quantity<U>>

Performs the * operation. Read more
Source§

impl<U: Unit> Mul<XYZ<Quantity<U>>> for Translation3

Source§

type Output = XYZ<Quantity<U>>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: XYZ<Quantity<U>>) -> XYZ<Quantity<U>>

Performs the * operation. Read more
Source§

impl Mul<XYZ<f64>> for f64

Source§

type Output = XYZ<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, xyz: XYZ<f64>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for XYZ<f64>

Source§

type Output = XYZ<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl<U: Unit> Neg for XYZ<Quantity<U>>

Source§

type Output = XYZ<Quantity<U>>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for XYZ<f64>

Source§

type Output = XYZ<f64>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for XYZ<T>

Source§

fn eq(&self, other: &XYZ<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<U: Unit> Sub for XYZ<Quantity<U>>

Source§

type Output = XYZ<Quantity<U>>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for XYZ<f64>

Source§

type Output = XYZ<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: UpperExp + Copy> UpperExp for XYZ<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy> Copy for XYZ<T>

Source§

impl<T> StructuralPartialEq for XYZ<T>

Auto Trait Implementations§

§

impl<T> Freeze for XYZ<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for XYZ<T>
where T: RefUnwindSafe,

§

impl<T> Send for XYZ<T>
where T: Send,

§

impl<T> Sync for XYZ<T>
where T: Sync,

§

impl<T> Unpin for XYZ<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for XYZ<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for XYZ<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,