Struct Vec4 Copy item path Source #[repr(C)]
pub struct Vec4 {
pub x: f32 ,
pub y: f32 ,
pub z: f32 ,
pub w: f32 ,
}
Expand description A 4-dimensional vector with f32
components, often used for homogeneous coordinates.
In 3D graphics, Vec4
is primarily used to represent points (w
=1.0) and
vectors (w
=0.0) in homogeneous space, allowing them to be transformed by a Mat4
.
The x component of the vector.
The y component of the vector.
The z component of the vector.
The w component, used for homogeneous coordinates.
A vector with all components set to 0.0
.
A vector with all components set to 1.0
.
The unit vector pointing along the positive X-axis.
The unit vector pointing along the positive Y-axis.
The unit vector pointing along the positive Z-axis.
The unit vector pointing along the positive W-axis.
Creates a new Vec4
with the specified components.
Returns a new vector with the absolute value of each component.
Creates a Vec4
from a Vec3
and a w
component.
Returns the [x, y, z]
components of the vector as a Vec3
, discarding w
.
Calculates the dot product of this vector and another.
Retrieves a component of the vector by its index.
§ Panics
Panics if index
is not between 0 and 3.
Adds two vectors component-wise.
The resulting type after applying the +
operator.
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 Divides the vector by a scalar.
The resulting type after applying the /
operator.
Allows accessing a vector component by index.
§ Panics
Panics if index
is not between 0 and 3.
The returned type after indexing.
Allows mutably accessing a vector component by index.
§ Panics
Panics if index
is not between 0 and 3.
Transforms a Vec4
by this matrix.
The resulting type after applying the *
operator.
Multiplies a scalar by a vector.
The resulting type after applying the *
operator.
Multiplies the vector by a scalar.
The resulting type after applying the *
operator.
Multiplies two vectors component-wise.
The resulting type after applying the *
operator.
The resulting type after applying the -
operator.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Subtracts two vectors component-wise.
The resulting type after applying the -
operator.
Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit
)
Performs copy-assignment from
self
to
dest
.
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 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.