Vector3
struct · ferroui-base · v0.5.0
struct Vector3
A vector with three single-precision components.
The layout is the one of the reference runtime and is relied on when the
value is passed to a graphics API by address (as a vertex attribute, for
example): three consecutive singles, x, y, z.
Members
xyzZEROONEUNIT_XUNIT_YUNIT_Znewfrom_valuefrom_vector2absclampcrossdistancedistance_squareddotlengthlength_squaredlerpmaxminnormalizesquare_roottransformtransform_quaterniontransform_normal
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.
ZERO
const ZERO: Vector3
The vector (0, 0, 0).
ONE
const ONE: Vector3
The vector (1, 1, 1).
UNIT_X
const UNIT_X: Vector3
The vector (1, 0, 0).
UNIT_Y
const UNIT_Y: Vector3
The vector (0, 1, 0).
UNIT_Z
const UNIT_Z: Vector3
The vector (0, 0, 1).
new
const fn new(x: f32, y: f32, z: 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) -> Self
Creates a vector from a Vector2 and a Z component.
abs
fn abs(value: Vector3) -> Vector3
Returns a vector whose elements are the absolute values of each of the specified vector's elements.
clamp
fn clamp(value1: Vector3, min: Vector3, max: Vector3) -> Vector3
Restricts a vector between a minimum and a maximum value
(min(max(value, min), max), so max wins when the bounds are inverted).
cross
fn cross(vector1: Vector3, vector2: Vector3) -> Vector3
Computes the cross product of two vectors.
distance
fn distance(value1: Vector3, value2: Vector3) -> f32
Computes the Euclidean distance between the two given points.
distance_squared
fn distance_squared(value1: Vector3, value2: Vector3) -> f32
Returns the Euclidean distance squared between two specified points.
dot
fn dot(vector1: Vector3, vector2: Vector3) -> 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: Vector3, value2: Vector3, amount: f32) -> Vector3
Performs a linear interpolation between two vectors based on the given weighting.
max
fn max(value1: Vector3, value2: Vector3) -> Vector3
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
min
fn min(value1: Vector3, value2: Vector3) -> Vector3
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
normalize
fn normalize(value: Vector3) -> Vector3
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: Vector3) -> Vector3
Returns a vector whose elements are the square root of each of a specified vector's elements.
transform
fn transform(position: Vector3, matrix: Matrix4x4) -> Vector3
Transforms a vector by a specified 4x4 matrix.
transform_quaternion
fn transform_quaternion(value: Vector3, rotation: Quaternion) -> Vector3
Transforms a vector by the specified rotation.
transform_normal
fn transform_normal(normal: Vector3, matrix: Matrix4x4) -> Vector3
Transforms a vector normal by the given 4x4 matrix.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneCopyDebugStructuralPartialEqPartialEqDefaultFrom<Vector3D>From<Vector3>AddSubMulMul<f32>Mul<Vector3>DivDiv<f32>NegAddAssignSubAssignMulAssignMulAssign<f32>DivAssignDivAssign<f32>DisplayIInterpolator<Vector3>SpringValueExpressionVariantValueBatchValue
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.