Skip to main content

Dir3

Struct Dir3 

Source
pub struct Dir3(/* private fields */);
Expand description

A normalized vector pointing in a direction in 3D space

Implementations§

Source§

impl Dir3

Source

pub const X: Self

A unit vector pointing along the positive X axis.

Source

pub const Y: Self

A unit vector pointing along the positive Y axis.

Source

pub const Z: Self

A unit vector pointing along the positive Z axis.

Source

pub const NEG_X: Self

A unit vector pointing along the negative X axis.

Source

pub const NEG_Y: Self

A unit vector pointing along the negative Y axis.

Source

pub const NEG_Z: Self

A unit vector pointing along the negative Z axis.

Source

pub const AXES: [Self; 3]

The directional axes.

Source

pub const CARDINALS: [Self; 6]

The cardinal directions.

Source

pub const ALL_VERTICES: [Self; 8]

The directions pointing towards the vertices of a cube centered at the origin.

Source

pub const ALL_EDGES: [Self; 12]

The directions towards centers of each edge of a cube

Source

pub const ALL_NEIGHBORS: [Self; 26]

All neighbors of a tile on a cube grid a 3x3x3 neighborhood. A combination of Self::CARDINALS, Self::ALL_EDGES and Self::ALL_VERTICES

Source

pub fn new(value: Vec3) -> Result<Self, InvalidDirectionError>

Create a direction from a finite, nonzero Vec3, normalizing it.

Returns Err(InvalidDirectionError) if the length of the given vector is zero (or very close to zero), infinite, or NaN.

Source

pub fn new_unchecked(value: Vec3) -> Self

Create a Dir3 from a Vec3 that is already normalized.

§Warning

value must be normalized, i.e its length must be 1.0.

Source

pub fn new_and_length(value: Vec3) -> Result<(Self, f32), InvalidDirectionError>

Create a direction from a finite, nonzero Vec3, normalizing it and also returning its original length.

Returns Err(InvalidDirectionError) if the length of the given vector is zero (or very close to zero), infinite, or NaN.

Source

pub fn from_xyz(x: f32, y: f32, z: f32) -> Result<Self, InvalidDirectionError>

Create a direction from its x, y, and z components.

Returns Err(InvalidDirectionError) if the length of the vector formed by the components is zero (or very close to zero), infinite, or NaN.

Source

pub fn from_xyz_unchecked(x: f32, y: f32, z: f32) -> Self

Create a direction from its x, y, and z components, assuming the resulting vector is normalized.

§Warning

The vector produced from x, y, and z must be normalized, i.e its length must be 1.0.

Source

pub const fn as_vec3(&self) -> Vec3

Returns the inner Vec3

Source

pub fn slerp(self, rhs: Self, s: f32) -> Self

Performs a spherical linear interpolation between self and rhs based on the value s.

This corresponds to interpolating between the two directions at a constant angular velocity.

When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs.

§Example
let dir1 = Dir3::X;
let dir2 = Dir3::Y;

let result1 = dir1.slerp(dir2, 1.0 / 3.0);
#[cfg(feature = "approx")]
assert_relative_eq!(
    result1,
    Dir3::from_xyz(0.75_f32.sqrt(), 0.5, 0.0).unwrap(),
    epsilon = 0.000001
);

let result2 = dir1.slerp(dir2, 0.5);
#[cfg(feature = "approx")]
assert_relative_eq!(result2, Dir3::from_xyz(0.5_f32.sqrt(), 0.5_f32.sqrt(), 0.0).unwrap());
Source

pub fn fast_renormalize(self) -> Self

Returns self after an approximate normalization, assuming the value is already nearly normalized. Useful for preventing numerical error accumulation.

§Example

The following seemingly benign code would start accumulating errors over time, leading to dir eventually not being normalized anymore.

let mut dir = Dir3::X;
let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0);
for i in 0..N {
    dir = quaternion * dir;
}

Instead, do the following.

let mut dir = Dir3::X;
let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0);
for i in 0..N {
    dir = quaternion * dir;
    dir = dir.fast_renormalize();
}

Methods from Deref<Target = Vec3>§

Source

pub fn map<F>(self, f: F) -> Vec3
where F: FnMut(f32) -> f32,

Returns a vector containing each element of self modified by a mapping function f.

Source

pub fn to_array(&self) -> [f32; 3]

Converts self to [x, y, z]

Source

pub fn write_to_slice(self, slice: &mut [f32])

Writes the elements of self to the first 3 elements in slice.

§Panics

Panics if slice is less than 3 elements long.

Source

pub fn extend(self, w: f32) -> Vec4

Creates a 4D vector from self and the given w value.

Source

pub fn truncate(self) -> Vec2

Creates a 2D vector from the x and y elements of self, discarding z.

Truncation may also be performed by using self.xy().

Source

pub fn to_homogeneous(self) -> Vec4

Creates a homogeneous coordinate from self, equivalent to self.extend(1.0).

Source

pub fn to_vec3a(self) -> Vec3A

Source

pub fn with_x(self, x: f32) -> Vec3

Creates a 3D vector from self with the given value of x.

Source

pub fn with_y(self, y: f32) -> Vec3

Creates a 3D vector from self with the given value of y.

Source

pub fn with_z(self, z: f32) -> Vec3

Creates a 3D vector from self with the given value of z.

Source

pub fn dot(self, rhs: Vec3) -> f32

Computes the dot product of self and rhs.

Source

pub fn dot_into_vec(self, rhs: Vec3) -> Vec3

Returns a vector where every component is the dot product of self and rhs.

Source

pub fn cross(self, rhs: Vec3) -> Vec3

Computes the cross product of self and rhs.

Source

pub fn min(self, rhs: Vec3) -> Vec3

Returns a vector containing the minimum values for each element of self and rhs.

In other words this computes [min(x, rhs.x), min(self.y, rhs.y), ..].

NaN propogation does not follow IEEE 754-2008 semantics for minNum and may differ on different SIMD architectures.

Source

pub fn max(self, rhs: Vec3) -> Vec3

Returns a vector containing the maximum values for each element of self and rhs.

In other words this computes [max(self.x, rhs.x), max(self.y, rhs.y), ..].

NaN propogation does not follow IEEE 754-2008 semantics for maxNum and may differ on different SIMD architectures.

Source

pub fn clamp(self, min: Vec3, max: Vec3) -> Vec3

Component-wise clamping of values, similar to f32::clamp.

Each element in min must be less-or-equal to the corresponding element in max.

NaN propogation does not follow IEEE 754-2008 semantics and may differ on different SIMD architectures.

§Panics

Will panic if min is greater than max when glam_assert is enabled.

Source

pub fn min_element(self) -> f32

Returns the horizontal minimum of self.

In other words this computes min(x, y, ..).

NaN propogation does not follow IEEE 754-2008 semantics and may differ on different SIMD architectures.

Source

pub fn max_element(self) -> f32

Returns the horizontal maximum of self.

In other words this computes max(x, y, ..).

NaN propogation does not follow IEEE 754-2008 semantics and may differ on different SIMD architectures.

Source

pub fn min_position(self) -> usize

Returns the index of the first minimum element of self.

Source

pub fn max_position(self) -> usize

Returns the index of the first maximum element of self.

Source

pub fn element_sum(self) -> f32

Returns the sum of all elements of self.

In other words, this computes self.x + self.y + ...

Source

pub fn element_product(self) -> f32

Returns the product of all elements of self.

In other words, this computes self.x * self.y * ...

Source

pub fn cmpeq(self, rhs: Vec3) -> BVec3

Returns a vector mask containing the result of a == comparison for each element of self and rhs.

In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Source

pub fn cmpne(self, rhs: Vec3) -> BVec3

Returns a vector mask containing the result of a != comparison for each element of self and rhs.

In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Source

pub fn cmpge(self, rhs: Vec3) -> BVec3

Returns a vector mask containing the result of a >= comparison for each element of self and rhs.

In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Source

pub fn cmpgt(self, rhs: Vec3) -> BVec3

Returns a vector mask containing the result of a > comparison for each element of self and rhs.

In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Source

pub fn cmple(self, rhs: Vec3) -> BVec3

Returns a vector mask containing the result of a <= comparison for each element of self and rhs.

In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Source

pub fn cmplt(self, rhs: Vec3) -> BVec3

Returns a vector mask containing the result of a < comparison for each element of self and rhs.

In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Source

pub fn abs(self) -> Vec3

Returns a vector containing the absolute value of each element of self.

Source

pub fn signum(self) -> Vec3

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN
Source

pub fn copysign(self, rhs: Vec3) -> Vec3

Returns a vector with signs of rhs and the magnitudes of self.

Source

pub fn is_negative_bitmask(self) -> u32

Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of self.

A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

An element is negative if it has a negative sign, including -0.0, NaNs with negative sign bit and negative infinity.

Source

pub fn is_negative_mask(self) -> BVec3

Returns a mask indicating which components are negative.

An element is negative if it has a negative sign, including -0.0, NaNs with negative sign bit and negative infinity.

Source

pub fn is_finite(self) -> bool

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Source

pub fn is_finite_mask(self) -> BVec3

Performs is_finite on each element of self, returning a vector mask of the results.

In other words, this computes [x.is_finite(), y.is_finite(), ...].

Source

pub fn is_nan(self) -> bool

Returns true if any elements are NaN.

Source

pub fn is_nan_mask(self) -> BVec3

Performs is_nan on each element of self, returning a vector mask of the results.

In other words, this computes [x.is_nan(), y.is_nan(), ...].

Source

pub fn length(self) -> f32

Computes the length of self.

Source

pub fn length_squared(self) -> f32

Computes the squared length of self.

This is faster than length() as it avoids a square root operation.

Source

pub fn length_recip(self) -> f32

Computes 1.0 / length().

For valid results, self must not be of length zero.

Source

pub fn distance(self, rhs: Vec3) -> f32

Computes the Euclidean distance between two points in space.

Source

pub fn distance_squared(self, rhs: Vec3) -> f32

Compute the squared euclidean distance between two points in space.

Source

pub fn div_euclid(self, rhs: Vec3) -> Vec3

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Source

pub fn rem_euclid(self, rhs: Vec3) -> Vec3

Returns the element-wise remainder of Euclidean division of self by rhs.

Source

pub fn normalize(self) -> Vec3

Returns self normalized to length 1.0.

For valid results, self must be finite and not of length zero, nor very close to zero.

See also Self::try_normalize() and Self::normalize_or_zero().

§Panics

Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Source

pub fn try_normalize(self) -> Option<Vec3>

Returns self normalized to length 1.0 if possible, else returns None.

In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be None.

See also Self::normalize_or_zero().

Source

pub fn normalize_or(self, fallback: Vec3) -> Vec3

Returns self normalized to length 1.0 if possible, else returns a fallback value.

In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value.

See also Self::try_normalize().

Source

pub fn normalize_or_zero(self) -> Vec3

Returns self normalized to length 1.0 if possible, else returns zero.

In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero.

See also Self::try_normalize().

Source

pub fn normalize_and_length(self) -> (Vec3, f32)

Returns self normalized to length 1.0 and the length of self.

If self is zero length then (Self::X, 0.0) is returned.

Source

pub fn is_normalized(self) -> bool

Returns whether self is length 1.0 or not.

Uses a precision threshold of approximately 1e-4.

Source

pub fn project_onto(self, rhs: Vec3) -> Vec3

Returns the vector projection of self onto rhs.

rhs must be of non-zero length.

§Panics

Will panic if rhs is zero length when glam_assert is enabled.

Source

pub fn reject_from(self, rhs: Vec3) -> Vec3

Returns the vector rejection of self from rhs.

The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs).

rhs must be of non-zero length.

§Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Source

pub fn project_onto_normalized(self, rhs: Vec3) -> Vec3

Returns the vector projection of self onto rhs.

rhs must be normalized.

§Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Source

pub fn reject_from_normalized(self, rhs: Vec3) -> Vec3

Returns the vector rejection of self from rhs.

The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs).

rhs must be normalized.

§Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Source

pub fn round(self) -> Vec3

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Source

pub fn floor(self) -> Vec3

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Source

pub fn ceil(self) -> Vec3

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Source

pub fn trunc(self) -> Vec3

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Source

pub fn step(self, rhs: Vec3) -> Vec3

Returns a vector containing 0.0 if rhs < self and 1.0 otherwise.

Similar to glsl’s step(edge, x), which translates into edge.step(x)

Source

pub fn smoothstep(self, edge0: Vec3, edge1: Vec3) -> Vec3

Performs Hermite interpolation between 0.0 and 1.0 using x normalized to [edge0, edge1].

This is equivalent to t * t * (3.0 - 2.0 * t), where t is clamped to [0.0, 1.0]. Results are undefined if any element of edge0 is greater than or equal to the corresponding element of edge1.

§Panics

Will panic if any element of edge0 is greater than or equal to the corresponding element of edge1, when glam_assert is enabled.

Source

pub fn saturate(self) -> Vec3

Returns a vector containing all elements of self clamped to the range of [0, 1].

Source

pub fn fract(self) -> Vec3

Returns a vector containing the fractional part of the vector as self - self.trunc().

Note that this differs from the GLSL implementation of fract which returns self - self.floor().

Note that this is fast but not precise for large numbers.

Source

pub fn fract_gl(self) -> Vec3

Returns a vector containing the fractional part of the vector as self - self.floor().

Note that this differs from the Rust implementation of fract which returns self - self.trunc().

Note that this is fast but not precise for large numbers.

Source

pub fn exp(self) -> Vec3

Returns a vector containing e^self (the exponential function) for each element of self.

Source

pub fn exp2(self) -> Vec3

Returns a vector containing 2^self for each element of self.

Source

pub fn ln(self) -> Vec3

Returns a vector containing the natural logarithm for each element of self. This returns NaN when the element is negative and negative infinity when the element is zero.

Source

pub fn log2(self) -> Vec3

Returns a vector containing the base 2 logarithm for each element of self. This returns NaN when the element is negative and negative infinity when the element is zero.

Source

pub fn powf(self, n: f32) -> Vec3

Returns a vector containing each element of self raised to the power of n.

Source

pub fn sqrt(self) -> Vec3

Returns a vector containing the square root for each element of self. This returns NaN when the element is negative.

Source

pub fn cos(self) -> Vec3

Returns a vector containing the cosine for each element of self.

Source

pub fn sin(self) -> Vec3

Returns a vector containing the sine for each element of self.

Source

pub fn sin_cos(self) -> (Vec3, Vec3)

Returns a tuple of two vectors containing the sine and cosine for each element of self.

Source

pub fn recip(self) -> Vec3

Returns a vector containing the reciprocal 1.0/n of each element of self.

Source

pub fn lerp(self, rhs: Vec3, s: f32) -> Vec3

Performs a linear interpolation between self and rhs based on the value s, using the form self * (1.0 - s) + rhs * s.

When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of the range [0, 1], the result is linearly extrapolated.

The result is guaranteed to be self at s == 0.0 and rhs at s == 1.0, even when the values differ greatly in magnitude, but it is not monotonic in s for nearly equal inputs and may not preserve equal inputs exactly. Consider lerp_monotonic instead when interpolating between values that may be equal or nearly equal.

Source

pub fn lerp_monotonic(self, rhs: Vec3, s: f32) -> Vec3

Performs a linear interpolation between self and rhs based on the value s, using the monotonic form self + (rhs - self) * s.

When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of the range [0, 1], the result is linearly extrapolated.

Prefer this over lerp when interpolating between values that may be equal or nearly equal: the result is monotonic in s and equal inputs are preserved exactly, avoiding the rounding jitter that lerp can introduce. The tradeoff is that rhs - self is evaluated first, so this is less accurate than lerp when self and rhs differ greatly in magnitude, and overflows to infinity when they have opposite signs and large magnitudes.

On SIMD back-ends the multiply and add are fused when the target supports it, which has a single rounding step and can be more accurate than a separate multiply and add.

Source

pub fn move_towards(self, rhs: Vec3, d: f32) -> Vec3

Moves towards rhs based on the value d.

When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Source

pub fn midpoint(self, rhs: Vec3) -> Vec3

Calculates the midpoint between self and rhs.

The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Source

pub fn abs_diff_eq(self, rhs: Vec3, max_abs_diff: f32) -> bool

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff.

This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against.

For more see comparing floating point numbers.

Source

pub fn clamp_length(self, min: f32, max: f32) -> Vec3

Returns a vector with a length no less than min and no more than max.

§Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Source

pub fn clamp_length_max(self, max: f32) -> Vec3

Returns a vector with a length no more than max.

§Panics

Will panic if max is negative when glam_assert is enabled.

Source

pub fn clamp_length_min(self, min: f32) -> Vec3

Returns a vector with a length no less than min.

§Panics

Will panic if min is negative when glam_assert is enabled.

Source

pub fn mul_add(self, a: Vec3, b: Vec3) -> Vec3

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add.

Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Source

pub fn reflect(self, normal: Vec3) -> Vec3

Returns the reflection vector for a given incident vector self and surface normal normal.

normal must be normalized.

§Panics

Will panic if normal is not normalized when glam_assert is enabled.

Source

pub fn refract(self, normal: Vec3, eta: f32) -> Vec3

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned.

self and normal must be normalized.

§Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Source

pub fn angle_between(self, rhs: Vec3) -> f32

Returns the angle (in radians) between two vectors in the range [0, +π].

For the full rotation between two vectors as a quaternion, see Quat::from_rotation_arc.

The inputs do not need to be unit vectors however they must be non-zero.

§Panics

Will panic if self or rhs has zero length when glam_assert is enabled.

Source

pub fn angle_to(self, rhs: Vec3, axis: Vec3) -> f32

Returns the signed angle (in radians) from self to rhs around axis in the range [-π, +π].

The axis must be a unit vector. The angle follows the right-hand rule around axis and can be used with Self::rotate_axis, e.g. self.rotate_axis(axis, self.angle_to(rhs, axis)) will be equal to rhs.

For the unsigned angle without a reference axis, see Self::angle_between.

The inputs do not need to be unit vectors however they must be non-zero.

§Panics

Will panic if axis is not normalized when glam_assert is enabled. Will panic if self or rhs has zero length when glam_assert is enabled.

Source

pub fn rotate_x(self, angle: f32) -> Vec3

Rotates around the x axis by angle (in radians).

Source

pub fn rotate_y(self, angle: f32) -> Vec3

Rotates around the y axis by angle (in radians).

Source

pub fn rotate_z(self, angle: f32) -> Vec3

Rotates around the z axis by angle (in radians).

Source

pub fn rotate_axis(self, axis: Vec3, angle: f32) -> Vec3

Rotates around axis by angle (in radians).

The axis must be a unit vector.

§Panics

Will panic if axis is not normalized when glam_assert is enabled.

Source

pub fn rotate_towards(self, rhs: Vec3, max_angle: f32) -> Vec3

Rotates towards rhs up to max_angle (in radians).

When max_angle is 0.0, the result will be equal to self. When max_angle is equal to self.angle_between(rhs), the result will be parallel to rhs. If max_angle is negative, rotates towards the exact opposite of rhs. Will not go past the target.

§Panics

Will panic if self or rhs are zero length when glam_assert is enabled.

Source

pub fn any_orthogonal_vector(self) -> Vec3

Returns some vector that is orthogonal to the given one.

The input vector must be finite and non-zero.

The output vector is not necessarily unit length. For that use Self::any_orthonormal_vector() instead.

Source

pub fn any_orthonormal_vector(self) -> Vec3

Returns any unit vector that is orthogonal to the given one.

The input vector must be unit length.

§Panics

Will panic if self is not normalized when glam_assert is enabled.

Source

pub fn any_orthonormal_pair(self) -> (Vec3, Vec3)

Given a unit vector return two other vectors that together form a right-handed orthonormal basis. That is, all three vectors are orthogonal to each other and are normalized.

§Panics

Will panic if self is not normalized when glam_assert is enabled.

Source

pub fn slerp(self, rhs: Vec3, s: f32) -> Vec3

Performs a spherical linear interpolation between self and rhs based on the value s.

When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

§Panics

Will panic if self or rhs has zero length when glam_assert is enabled.

Source

pub fn as_dvec3(self) -> DVec3

Available on crate feature f64 only.

Casts all elements of self to f64.

Source

pub fn as_i8vec3(self) -> I8Vec3

Available on crate feature i8 only.

Casts all elements of self to i8.

Source

pub fn as_u8vec3(self) -> U8Vec3

Available on crate feature u8 only.

Casts all elements of self to u8.

Source

pub fn as_i16vec3(self) -> I16Vec3

Available on crate feature i16 only.

Casts all elements of self to i16.

Source

pub fn as_u16vec3(self) -> U16Vec3

Available on crate feature u16 only.

Casts all elements of self to u16.

Source

pub fn as_ivec3(self) -> IVec3

Available on crate feature i32 only.

Casts all elements of self to i32.

Source

pub fn as_uvec3(self) -> UVec3

Available on crate feature u32 only.

Casts all elements of self to u32.

Source

pub fn as_i64vec3(self) -> I64Vec3

Available on crate feature i64 only.

Casts all elements of self to i64.

Source

pub fn as_u64vec3(self) -> U64Vec3

Available on crate feature u64 only.

Casts all elements of self to u64.

Trait Implementations§

Source§

impl AbsDiffEq for Dir3

Available on crate feature approx only.
Source§

type Epsilon = f32

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> f32

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: f32) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl Clone for Dir3

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Dir3

Source§

impl Debug for Dir3

Source§

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

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

impl Deref for Dir3

Source§

type Target = Vec3

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de> Deserialize<'de> for Dir3

Available on crate feature serialize only.
Source§

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

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

impl Display for Dir3

Source§

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

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

impl Distribution<Dir3> for StandardUniform

Available on crate feature rand only.
Source§

fn sample<R: RngExt + ?Sized>(&self, rng: &mut R) -> Dir3

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T> ⓘ
where R: Rng, Self: Sized,

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

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl From<Dir3> for Vec3

Source§

fn from(value: Dir3) -> Self

Converts to this type from the input type.
Source§

impl From<Dir3> for Dir3A

Source§

fn from(value: Dir3) -> Self

Converts to this type from the input type.
Source§

impl From<Dir3A> for Dir3

Source§

fn from(value: Dir3A) -> Self

Converts to this type from the input type.
Source§

impl FromReflect for Dir3

Available on crate feature bevy_reflect only.
Source§

fn from_reflect(reflect: &dyn PartialReflect) -> Option<Self>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl FromRng for Dir3

Available on crate feature rand only.
Source§

fn from_rng<R: RngExt + ?Sized>(rng: &mut R) -> Self

Construct a value of this type uniformly at random using rng as the source of randomness.
Source§

impl GetTypeRegistration for Dir3

Available on crate feature bevy_reflect only.
Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl Mul<Dir3> for f32

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Dir3) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Dir3> for Quat

Source§

fn mul(self, direction: Dir3) -> Self::Output

Rotates the Dir3 using a Quat.

Source§

type Output = Dir3

The resulting type after applying the * operator.
Source§

impl Mul<Dir3> for Isometry3d

Source§

type Output = Dir3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Dir3) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for Dir3

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for Dir3

Source§

type Output = Dir3

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for Dir3

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialReflect for Dir3

Available on crate feature bevy_reflect only.
Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<Self>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<Self>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&dyn Reflect>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<Self>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &dyn PartialReflect

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut dyn PartialReflect

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq(&self, value: &dyn PartialReflect) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn reflect_partial_cmp(&self, value: &dyn PartialReflect) -> Option<Ordering>

Returns a “partial comparison” result. Read more
Source§

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

Debug formatter for the value. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn to_dynamic(&self) -> Result<Box<dyn PartialReflect>, ReflectCloneError>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails.
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl Reflect for Dir3

Available on crate feature bevy_reflect only.
Source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &dyn Any

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &dyn Reflect

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut dyn Reflect

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl RelativeEq for Dir3

Available on crate feature approx only.
Source§

fn default_max_relative() -> f32

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq(&self, other: &Self, epsilon: f32, max_relative: f32) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl Serialize for Dir3

Available on crate feature serialize only.
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 StableInterpolate for Dir3

Source§

fn interpolate_stable(&self, other: &Self, t: f32) -> Self

Interpolate between this value and the other given value using the parameter t. At t = 0.0, a value equivalent to self is recovered, while t = 1.0 recovers a value equivalent to other, with intermediate values interpolating between the two. See the trait-level documentation for details.
Source§

fn interpolate_stable_assign(&mut self, other: &Self, t: f32)

A version of interpolate_stable that assigns the result to self for convenience. Read more
Source§

fn smooth_nudge(&mut self, target: &Self, decay_rate: f32, delta: f32)

Smoothly nudge this value towards the target at a given decay rate. The decay_rate parameter controls how fast the distance between self and target decays relative to the units of delta; the intended usage is for decay_rate to generally remain fixed, while delta is something like delta_time from an updating system. This produces a smooth following of the target that is independent of framerate. Read more
Source§

impl StructuralPartialEq for Dir3

Source§

impl TryFrom<Vec3> for Dir3

Source§

type Error = InvalidDirectionError

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

fn try_from(value: Vec3) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TupleStruct for Dir3

Available on crate feature bevy_reflect only.
Source§

fn field(&self, index: usize) -> Option<&dyn PartialReflect>

Returns a reference to the value of the field with index index as a &dyn Reflect.
Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn PartialReflect>

Returns a mutable reference to the value of the field with index index as a &mut dyn Reflect.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the tuple struct.
Source§

fn iter_fields(&self) -> TupleStructFieldIter<'_> ⓘ

Returns an iterator over the values of the tuple struct’s fields.
Source§

fn to_dynamic_tuple_struct( &self, ) -> Result<DynamicTupleStruct, ReflectCloneError>

Creates a new DynamicTupleStruct from this tuple struct. Read more
Source§

fn get_represented_tuple_struct_info(&self) -> Option<&'static TupleStructInfo>

Will return None if TypeInfo is not available.
Source§

impl TypePath for Dir3

Available on crate feature bevy_reflect only.
Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl Typed for Dir3

Available on crate feature bevy_reflect only.
Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl UlpsEq for Dir3

Available on crate feature approx only.
Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq(&self, other: &Self, epsilon: f32, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.

Auto Trait Implementations§

§

impl Freeze for Dir3

§

impl RefUnwindSafe for Dir3

§

impl Send for Dir3

§

impl Sync for Dir3

§

impl Unpin for Dir3

§

impl UnsafeUnpin for Dir3

§

impl UnwindSafe for Dir3

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<S> GetTupleStructField for S
where S: TupleStruct,

Source§

fn get_field<T>(&self, index: usize) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field with index index, downcast to T.
Source§

fn get_field_mut<T>(&mut self, index: usize) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field with index index, downcast to T.
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<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Reflectable for T

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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> TryStableInterpolate for T

Source§

type Error = !

Error produced when the value cannot be interpolated.
Source§

fn try_interpolate_stable( &self, other: &T, t: f32, ) -> Result<T, <T as TryStableInterpolate>::Error>

Attempt to interpolate the value. This may fail if the two interpolation values have different units, or if the type is not interpolable.
Source§

fn try_interpolate_stable_assign( &mut self, other: &T, t: f32, ) -> Result<(), <T as TryStableInterpolate>::Error>

A version of try_interpolate_stable that assigns the result to self for convenience. On failure, self remains unchanged. Read more
Source§

fn try_smooth_nudge( &mut self, target: &Self, decay_rate: f32, delta: f32, ) -> Result<(), Self::Error>

Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of self.