#[repr(C)]
pub struct Vec3 { pub x: f32, pub y: f32, pub z: f32, }
Expand description

A 3-dimensional vector without SIMD support.

Fields

x: f32y: f32z: f32

Implementations

Creates a new Vec3.

Creates a Vec3 with all elements set to 0.0.

Creates a Vec3 with all elements set to 1.0.

Creates a Vec3 with values [x: 1.0, y: 0.0, z: 0.0].

Creates a Vec3 with values [x: 0.0, y: 1.0, z: 0.0].

Creates a Vec3 with values [x: 0.0, y: 0.0, z: 1.0].

Creates a Vec3 with all elements set to v.

Creates a Vec4 from self and the given w value.

Creates a Vec2 from the x and y elements of self, discarding z.

Truncation may also be performed by using self.xy() or Vec2::from().

👎Deprecated since 0.10.0:

please use .x instead

👎Deprecated since 0.10.0:

please use .y instead

👎Deprecated since 0.10.0:

please use .z instead

👎Deprecated since 0.10.0:

please use .x instead

👎Deprecated since 0.10.0:

please use .y instead

👎Deprecated since 0.10.0:

please use .z instead

👎Deprecated since 0.10.0:

please use .x instead

👎Deprecated since 0.10.0:

please use .y instead

👎Deprecated since 0.10.0:

please use .z instead

Computes the dot product of self and other.

Computes the cross product of self and other.

Computes the length of self.

Computes the squared length of self.

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

Computes 1.0 / Vec3::length().

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

Computes the Euclidean distance between two points in space.

Compute the squared Euclidean distance between two points in space.

Returns self normalized to length 1.0.

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

Returns the vertical minimum of self and other.

In other words, this computes [x: min(x1, x2), y: min(y1, y2), z: min(z1, z2)], taking the minimum of each element individually.

Returns the vertical maximum of self and other.

In other words, this computes [x: max(x1, x2), y: max(y1, y2), z: max(z1, z2)], taking the maximum of each element individually.

Returns the horizontal minimum of self’s elements.

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

Returns the horizontal maximum of self’s elements.

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

Performs a vertical == comparison between self and other, returning a Vec3Mask of the results.

In other words, this computes [x1 == x2, y1 == y2, z1 == z2].

Performs a vertical != comparison between self and other, returning a Vec3Mask of the results.

In other words, this computes [x1 != x2, y1 != y2, z1 != z2].

Performs a vertical >= comparison between self and other, returning a Vec3Mask of the results.

In other words, this computes [x1 >= x2, y1 >= y2, z1 >= z2].

Performs a vertical > comparison between self and other, returning a Vec3Mask of the results.

In other words, this computes [x1 > x2, y1 > y2, z1 > z2].

Performs a vertical <= comparison between self and other, returning a Vec3Mask of the results.

In other words, this computes [x1 <= x2, y1 <= y2, z1 <= z2].

Performs a vertical < comparison between self and other, returning a Vec3Mask of the results.

In other words, this computes [x1 < x2, y1 < y2, z1 < z2].

Creates a Vec3 from the first three values in slice.

Panics

Panics if slice is less than three elements long.

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

Panics

Panics if slice is less than three elements long.

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

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

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

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

Performs is_nan() on each element of self, returning a Vec3Mask of the results.

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

Returns a Vec3 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

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

Performs a linear interpolation between self and other 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 other.

Returns whether self of length 1.0 or not.

Uses a precision threshold of 1e-6.

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

This can be used to compare if two Vec3’s 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 on floating point comparisons see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Returns the angle between two vectors, in radians.

The vectors do not need to be unit length, but this function does perform a sqrt.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

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

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

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

Formats the value using the given formatter. 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

Converts to this type from the input type.

Converts to this type from the input type.

Creates a Vec2 from the x and y elements of the Vec3, discarding z.

Converts to this type from the input type.

Converts to this type from the input type.

Creates a Vec3 from the x, y and z elements of the Vec4, discarding z.

The returned type after indexing.

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

Performs the mutable indexing (container[index]) 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

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

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

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.

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.