Struct nalgebra::base::Unit

source ·
#[repr(transparent)]
pub struct Unit<T> { /* private fields */ }
Expand description

A wrapper that ensures the underlying algebraic entity has a unit norm.

Use .as_ref() or .unwrap() to obtain the underlying value by-reference or by-move.

Implementations§

Computes the spherical linear interpolation between two unit vectors.

Computes the spherical linear interpolation between two unit vectors.

Returns None if the two vectors are almost collinear and with opposite direction (in this case, there is an infinity of possible results).

Normalize the given value and return it wrapped on a Unit structure.

Attempts to normalize the given value and return it wrapped on a Unit structure.

Returns None if the norm was smaller or equal to min_norm.

Normalize the given value and return it wrapped on a Unit structure and its norm.

Normalize the given value and return it wrapped on a Unit structure and its norm.

Returns None if the norm was smaller or equal to min_norm.

Normalizes this value again. This is useful when repeated computations might cause a drift in the norm because of float inaccuracies.

Returns the norm before re-normalization (should be close to 1.0).

Wraps the given value, assuming it is already normalized.

Wraps the given reference, assuming it is already normalized.

Retrieves the underlying value.

Returns a mutable reference to the underlying value. This is _unchecked because modifying the underlying value in such a way that it no longer has unit length may lead to unexpected results.

👎Deprecated: This method is a no-op and will be removed in a future release.

Moves this unit quaternion into one that owns its data.

👎Deprecated: This method is a no-op and will be removed in a future release.

Clones this unit quaternion into one that owns its data.

The rotation angle in [0; pi] of this unit quaternion.

The underlying quaternion.

Same as self.as_ref().

Compute the conjugate of this unit quaternion.

Inverts this quaternion if it is not zero.

The rotation angle needed to make self and other coincide.

The unit quaternion needed to make self and other coincide.

The result is such that: self.rotation_to(other) * self == other.

Linear interpolation between two unit quaternions.

The result is not normalized.

Normalized linear interpolation between two unit quaternions.

Spherical linear interpolation between two unit quaternions.

Panics if the angle between both quaternion is 180 degrees (in which case the interpolation is not well-defined).

Computes the spherical linear interpolation between two unit quaternions or returns None if both quaternions are approximately 180 degrees apart (in which case the interpolation is not well-defined).

Arguments
  • self: the first quaternion to interpolate from.
  • other: the second quaternion to interpolate toward.
  • t: the interpolation parameter. Should be between 0 and 1.
  • epsilon: the value below which the sinus of the angle separating both quaternion must be to return None.

Compute the conjugate of this unit quaternion in-place.

Inverts this quaternion if it is not zero.

The rotation axis of this unit quaternion or None if the rotation is zero.

The rotation axis of this unit quaternion multiplied by the rotation angle.

The rotation axis and angle in ]0, pi] of this unit quaternion.

Returns None if the angle is zero.

Compute the exponential of a quaternion.

Note that this function yields a Quaternion<N> because it looses the unit property.

Compute the natural logarithm of a quaternion.

Note that this function yields a Quaternion<N> because it looses the unit property. The vector part of the return value corresponds to the axis-angle representation (divided by 2.0) of this unit quaternion.

Raise the quaternion to a given floating power.

This returns the unit quaternion that identifies a rotation with axis self.axis() and angle self.angle() × n.

Builds a rotation matrix from this unit quaternion.

Converts this unit quaternion into its equivalent Euler angles.

The angles are produced in the form (roll, yaw, pitch).

Converts this unit quaternion into its equivalent homogeneous transformation matrix.

The quaternion multiplicative identity.

Creates a new quaternion from a unit vector (the rotation axis) and an angle (the rotation angle).

Creates a new unit quaternion from a quaternion.

The input quaternion will be normalized.

Creates a new unit quaternion from Euler angles.

The primitive rotations are applied in order: 1 roll − 2 pitch − 3 yaw.

Builds an unit quaternion from a rotation matrix.

The unit quaternion needed to make a and b be collinear and point toward the same direction.

The smallest rotation needed to make a and b collinear and point toward the same direction, raised to the power s.

The unit quaternion needed to make a and b be collinear and point toward the same direction.

The smallest rotation needed to make a and b collinear and point toward the same direction, raised to the power s.

Creates an unit quaternion that corresponds to the local frame of an observer standing at the origin and looking toward dir.

It maps the view direction dir to the positive z axis.

Arguments
  • dir - The look direction, that is, direction the matrix z axis will be aligned with.
  • up - The vertical direction. The only requirement of this parameter is to not be collinear to dir. Non-collinearity is not checked.

Builds a right-handed look-at view matrix without translation.

This conforms to the common notion of right handed look-at matrix from the computer graphics community.

Arguments
  • eye - The eye position.
  • target - The target position.
  • up - A vector approximately aligned with required the vertical axis. The only requirement of this parameter is to not be collinear to target - eye.

Builds a left-handed look-at view matrix without translation.

This conforms to the common notion of left handed look-at matrix from the computer graphics community.

Arguments
  • eye - The eye position.
  • target - The target position.
  • up - A vector approximately aligned with required the vertical axis. The only requirement of this parameter is to not be collinear to target - eye.

Creates a new unit quaternion rotation from a rotation axis scaled by the rotation angle.

If axisangle has a magnitude smaller than N::default_epsilon(), this returns the identity rotation.

Creates a new unit quaternion rotation from a rotation axis scaled by the rotation angle.

If axisangle has a magnitude smaller than eps, this returns the identity rotation.

Creates a new unit quaternion rotation from a rotation axis scaled by the rotation angle.

If axisangle has a magnitude smaller than N::default_epsilon(), this returns the identity rotation. Same as Self::new(axisangle).

Creates a new unit quaternion rotation from a rotation axis scaled by the rotation angle.

If axisangle has a magnitude smaller than eps, this returns the identity rotation. Same as Self::new(axisangle).

The rotation angle in ]-pi; pi] of this unit complex number.

The sine of the rotation angle.

The cosine of the rotation angle.

The rotation angle returned as a 1-dimensional vector.

The rotation axis and angle in ]0, pi] of this complex number.

Returns None if the angle is zero.

The underlying complex number.

Same as self.as_ref().

Compute the conjugate of this unit complex number.

Inverts this complex number if it is not zero.

The rotation angle needed to make self and other coincide.

The unit complex number needed to make self and other coincide.

The result is such that: self.rotation_to(other) * self == other.

Compute in-place the conjugate of this unit complex number.

Inverts in-place this unit complex number.

Raise this unit complex number to a given floating power.

This returns the unit complex number that identifies a rotation angle equal to self.angle() × n.

Builds the rotation matrix corresponding to this unit complex number.

Converts this unit complex number into its equivalent homogeneous transformation matrix.

The unit complex number multiplicative identity.

Builds the unit complex number corresponding to the rotation with the angle.

Builds the unit complex number corresponding to the rotation with the angle.

Same as Self::new(angle).

Builds the unit complex number from the sinus and cosinus of the rotation angle.

The input values are not checked.

Builds a unit complex rotation from an angle in radian wrapped in a 1-dimensional vector.

Equivalent to Self::new(axisangle[0]).

Creates a new unit complex number from a complex number.

The input complex number will be normalized.

Creates a new unit complex number from a complex number.

The input complex number will be normalized. Returns the complex number norm as well.

Builds the unit complex number from the corresponding 2D rotation matrix.

The unit complex needed to make a and b be collinear and point toward the same direction.

The smallest rotation needed to make a and b collinear and point toward the same direction, raised to the power s.

The unit complex needed to make a and b be collinear and point toward the same direction.

The smallest rotation needed to make a and b collinear and point toward the same direction, raised to the power s.

Performs the multiplication rhs = self * rhs in-place.

Performs the multiplication lhs = lhs * self in-place.

Trait Implementations§

Used for specifying relative comparisons.
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of ApproxEq::abs_diff_eq.
Used for specifying relative comparisons.
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of ApproxEq::abs_diff_eq.
Used for specifying relative comparisons.
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of ApproxEq::abs_diff_eq.
Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.

Generate a uniformly distributed random UnitComplex.

Create an iterator that generates random values of T, using rng as the source of randomness. Read more

Generate a uniformly distributed random unit vector.

Create an iterator that generates random values of T, using rng as the source of randomness. Read more

Generate a uniformly distributed random rotation quaternion.

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of ApproxEq::relative_eq.
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of ApproxEq::relative_eq.
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of ApproxEq::relative_eq.
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
The inverse of ApproxEq::ulps_eq.
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
The inverse of ApproxEq::ulps_eq.
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
The inverse of ApproxEq::ulps_eq.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

👎Deprecated since 0.5.0: replaced by distributions::Standard
Generates a random instance of this type using the specified source of randomness. Read more
Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.