Vector4
struct · ferroui-base · v0.5.0
struct Vector4
A vector with four single-precision components.
Members
xyzwZEROONEUNIT_XUNIT_YUNIT_ZUNIT_Wnewfrom_valuefrom_vector2from_vector3absclampdistancedistance_squareddotlengthlength_squaredlerpmaxminnormalizesquare_roottransformtransform_vector3transform_vector2
x
x: f32
The X component of the vector.
y
y: f32
The Y component of the vector.
z
z: f32
The Z component of the vector.
w
w: f32
The W component of the vector.
ZERO
const ZERO: Vector4
The vector (0, 0, 0, 0).
ONE
const ONE: Vector4
The vector (1, 1, 1, 1).
UNIT_X
const UNIT_X: Vector4
The vector (1, 0, 0, 0).
UNIT_Y
const UNIT_Y: Vector4
The vector (0, 1, 0, 0).
UNIT_Z
const UNIT_Z: Vector4
The vector (0, 0, 1, 0).
UNIT_W
const UNIT_W: Vector4
The vector (0, 0, 0, 1).
new
const fn new(x: f32, y: f32, z: f32, w: f32) -> Self
Creates a vector from its components.
from_value
const fn from_value(value: f32) -> Self
Creates a vector whose components all have the same value.
from_vector2
const fn from_vector2(value: Vector2, z: f32, w: f32) -> Self
Creates a vector from a Vector2 and the Z and W components.
from_vector3
const fn from_vector3(value: Vector3, w: f32) -> Self
Creates a vector from a Vector3 and a W component.
abs
fn abs(value: Vector4) -> Vector4
Returns a vector whose elements are the absolute values of each of the specified vector's elements.
clamp
fn clamp(value1: Vector4, min: Vector4, max: Vector4) -> Vector4
Restricts a vector between a minimum and a maximum value
(min(max(value, min), max), so max wins when the bounds are inverted).
distance
fn distance(value1: Vector4, value2: Vector4) -> f32
Computes the Euclidean distance between the two given points.
distance_squared
fn distance_squared(value1: Vector4, value2: Vector4) -> f32
Returns the Euclidean distance squared between two specified points.
dot
fn dot(vector1: Vector4, vector2: Vector4) -> f32
Returns the dot product of two vectors.
length
fn length(self: &Self) -> f32
Returns the length of the vector.
length_squared
fn length_squared(self: &Self) -> f32
Returns the length of the vector squared.
lerp
fn lerp(value1: Vector4, value2: Vector4, amount: f32) -> Vector4
Performs a linear interpolation between two vectors based on the given weighting.
max
fn max(value1: Vector4, value2: Vector4) -> Vector4
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
min
fn min(value1: Vector4, value2: Vector4) -> Vector4
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
normalize
fn normalize(vector: Vector4) -> Vector4
Returns a vector with the same direction as the specified vector, but with a length of one (NaN components for a zero-length vector).
square_root
fn square_root(value: Vector4) -> Vector4
Returns a vector whose elements are the square root of each of a specified vector's elements.
transform
fn transform(vector: Vector4, matrix: Matrix4x4) -> Vector4
Transforms a four-dimensional vector by a specified 4x4 matrix.
transform_vector3
fn transform_vector3(position: Vector3, matrix: Matrix4x4) -> Vector4
Transforms a three-dimensional vector (with an implied w of one) by
a specified 4x4 matrix.
transform_vector2
fn transform_vector2(position: Vector2, matrix: Matrix4x4) -> Vector4
Transforms a two-dimensional vector (with an implied z of zero and
w of one) by a specified 4x4 matrix.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneCopyDebugStructuralPartialEqPartialEqDefaultAddSubMulMul<f32>Mul<Vector4>DivDiv<f32>NegAddAssignSubAssignMulAssignMulAssign<f32>DivAssignDivAssign<f32>DisplayIInterpolator<Vector4>From<Vector4>ExpressionVariantValueBatchValue
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.