Struct geo_nd::QArray

source ·
pub struct QArray<F, V3, V4>where
    F: Float,
    V3: Vector<F, 3>,
    V4: Vector<F, 4>,{ /* private fields */ }
Expand description

The QArray is a wrapper around a D sized array of Floats.

It provides implementations of the traits required for a Vector trait, hence it can be used for a Vector of any size D.

Implementations§

source§

impl<F, V3, V4> QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source

pub fn of_vector(data: V4) -> Self

Create a quaternion directly from a 4-element vecto

Trait Implementations§

source§

impl<F, V3, V4> Add<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<F, V3, V4> Add<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<F, V3, V4> AddAssign<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

source§

fn add_assign(&mut self, other: F)

Performs the += operation. Read more
source§

impl<F, V3, V4> AddAssign<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<F, V3, V4> AsMut<[F]> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn as_mut(&mut self) -> &mut [F]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<F, V3, V4> AsMut<[F; 4]> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn as_mut(&mut self) -> &mut [F; 4]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<F, V3, V4> AsRef<[F]> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn as_ref(&self) -> &[F]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<F, V3, V4> AsRef<[F; 4]> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn as_ref(&self) -> &[F; 4]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<F, V3, V4> Clone for QArray<F, V3, V4>where F: Float + Clone, V3: Vector<F, 3> + Clone, V4: Vector<F, 4> + Clone,

source§

fn clone(&self) -> QArray<F, V3, V4>

Returns a copy 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<F, V3, V4> Debug for QArray<F, V3, V4>where F: Float + Debug, V3: Vector<F, 3> + Debug, V4: Vector<F, 4> + Debug,

source§

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

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

impl<F, V3, V4> Default for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn default() -> Self

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

impl<'de, F, V3, V4> Deserialize<'de> for QArray<F, V3, V4>where F: Float + Deserialize<'de>, V3: Vector<F, 3>, V4: Vector<F, 4> + Deserialize<'de>,

source§

fn deserialize<DE>(deserializer: DE) -> Result<Self, DE::Error>where DE: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<F, V3, V4> Display for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

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

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

impl<F, V3, V4> Div<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the / operator.
source§

fn div(self, other: F) -> Self

Performs the / operation. Read more
source§

impl<F, V3, V4> Div<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the / operator.
source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
source§

impl<F, V3, V4> DivAssign<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

source§

fn div_assign(&mut self, other: F)

Performs the /= operation. Read more
source§

impl<F, V3, V4> DivAssign<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
source§

impl<F, V3, V4> From<[F; 4]> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn from(data: [F; 4]) -> Self

Converts to this type from the input type.
source§

impl<F, V3, V4> From<QArray<F, V3, V4>> for [F; 4]where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn from(q: QArray<F, V3, V4>) -> [F; 4]

Converts to this type from the input type.
source§

impl<F, V3, V4> Index<usize> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

§

type Output = F

The returned type after indexing.
source§

fn index(&self, index: usize) -> &F

Performs the indexing (container[index]) operation. Read more
source§

impl<F, V3, V4> IndexMut<usize> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn index_mut(&mut self, index: usize) -> &mut F

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<F, V3, V4> Mul<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the * operator.
source§

fn mul(self, other: F) -> Self

Performs the * operation. Read more
source§

impl<F, V3, V4> Mul<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
source§

impl<F, V3, V4> MulAssign<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

source§

fn mul_assign(&mut self, other: F)

Performs the *= operation. Read more
source§

impl<F, V3, V4> MulAssign<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
source§

impl<F, V3, V4> Neg for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<F, V3, V4> Quaternion<F, V3, V4> for QArray<F, V3, V4>where F: Float, V3: Vector<F, 3>, V4: Vector<F, 4>,

source§

fn of_rotation3<M>(rotation: &M) -> Selfwhere M: SqMatrix<V3, F, 3, 9>,

Find the quaternion of a Matrix3 assuming it is purely a rotation

source§

fn from_array(data: [F; 4]) -> Self

Create a quaternion from an array of Float Read more
source§

fn into_array(self) -> [F; 4]

Create an array Float for the fquaternion in order i, j, k, r
source§

fn as_rijk(&self) -> (F, F, F, F)

Break out into r, i, j, k
source§

fn of_rijk(r: F, i: F, j: F, k: F) -> Self

Create from r, i, j, k
source§

fn unit() -> Self

Create a quaternion whose elements are all zero
source§

fn set_zero(&mut self)

Set the quaternion to be all zeros
source§

fn mix(self, other: &Self, t: F) -> Self

Create a linear combination of this Quaternion and another using parameter t from zero to one
source§

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

Return the dot product of two quaternions; basically used for length
source§

fn set_rotation3<M>(&self, matrix: &mut M)where M: SqMatrix<V3, F, 3, 9>,

Set a Matrix3 to be the rotation matrix corresponding to the unit quaternion
source§

fn set_rotation4<M>(&self, matrix: &mut M)where M: SqMatrix<V4, F, 4, 16>,

Set a Matrix4 to be the rotation matrix corresponding to the unit quaternion
source§

fn conjugate(self) -> Self

Create the conjugate of a quaternion
source§

fn of_axis_angle(axis: &V3, angle: F) -> Self

Create a unit quaternion for a rotation of an angle about an axis
source§

fn rotate_x(self, angle: F) -> Self

Apply a rotation about the X-axis to this quaternion
source§

fn rotate_y(self, angle: F) -> Self

Apply a rotation about the Y-axis to this quaternion
source§

fn rotate_z(self, angle: F) -> Self

Apply a rotation about the Z-axis to this quaternion
source§

fn look_at(dirn: &V3, up: &V3) -> Self

Create a quaternion that maps a unit V3 of dirn to (0,0,-1) and a unit V3 of up (if perpendicular to dirn) to (0,1,0)
source§

fn rotation_of_vec_to_vec(a: &V3, b: &V3) -> Self

Get a quaternion that is a rotation of one vector to another Read more
source§

fn weighted_average_pair(&self, w_a: F, qb: &Self, w_b: F) -> Self

Calculate the weighted average of two unit quaternions Read more
source§

fn weighted_average_many<I: Iterator<Item = (F, Self)>>(value_iter: I) -> Self

Calculate the weighted average of many unit quaternions Read more
source§

fn as_axis_angle(&self) -> (V3, F)

Find the axis and angle of rotation for a (non-unit) quaternion
source§

fn length_sq(&self) -> F

Return the square of the length of the quaternion
source§

fn length(&self) -> F

Return the length of the quaternion
source§

fn distance_sq(&self, other: &Self) -> F

Return the square of the distance between this quaternion and another
source§

fn distance(&self, other: &Self) -> F

Return the distance between this quaternion and another
source§

fn normalize(self) -> Self

Normalize the quaternion; if its length is close to zero, then set it to be zero
source§

fn apply3(self, other: &V3) -> V3

Apply the quaternion to a V3
source§

fn apply4(self, other: &V4) -> V4

Apply the quaternion to a V4
source§

impl<F, V3, V4> Serialize for QArray<F, V3, V4>where F: Float + Serialize, V3: Vector<F, 3>, V4: Vector<F, 4> + Serialize,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<F, V3, V4> Sub<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<F, V3, V4> Sub<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

§

type Output = QArray<F, V3, V4>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<F, V3, V4> SubAssign<F> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

source§

fn sub_assign(&mut self, other: F)

Performs the -= operation. Read more
source§

impl<F, V3, V4> SubAssign<QArray<F, V3, V4>> for QArray<F, V3, V4>where F: Float, V3: Vector<F, { _ }>, V4: Vector<F, { _ }>,

source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
source§

impl<F: Float + Serialize> Transform<F, FArray<F, 3>, FArray<F, 4>, FArray2<F, 4, 16>, QArray<F, FArray<F, 3>, FArray<F, 4>>> for FQArrayTrans<F>

source§

fn of_trs(t: FArray<F, 3>, r: QArray<F, FArray<F, 3>, FArray<F, 4>>, s: F) -> Self

Create an FQArrayTrans from a Vector3 translation, Quat rotation and Float scaling

source§

fn scale(&self) -> F

Get the scaling of the transformation

source§

fn translation(&self) -> FArray<F, 3>

Get the translation of the transformation

source§

fn rotation(&self) -> QArray<F, FArray<F, 3>, FArray<F, 4>>

Get the rotation of the transformation

source§

fn inverse(&self) -> Self

Get a transformation that is the inverse of this

source§

fn invert(&mut self)

Invert this transformation

source§

fn as_mat(&self) -> FArray2<F, 4, 16>

Return the matrix

source§

impl<F, V3, V4> Copy for QArray<F, V3, V4>where F: Float + Copy, V3: Vector<F, 3> + Copy, V4: Vector<F, 4> + Copy,

Auto Trait Implementations§

§

impl<F, V3, V4> RefUnwindSafe for QArray<F, V3, V4>where F: RefUnwindSafe, V3: RefUnwindSafe, V4: RefUnwindSafe,

§

impl<F, V3, V4> Send for QArray<F, V3, V4>where F: Send, V3: Send, V4: Send,

§

impl<F, V3, V4> Sync for QArray<F, V3, V4>where F: Sync, V3: Sync, V4: Sync,

§

impl<F, V3, V4> Unpin for QArray<F, V3, V4>where F: Unpin, V3: Unpin, V4: Unpin,

§

impl<F, V3, V4> UnwindSafe for QArray<F, V3, V4>where F: UnwindSafe, V3: UnwindSafe, V4: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,