Vector2
struct · ferroui-base · v0.5.0
struct Vector2
A vector with two single-precision components.
Members
xyZEROONEUNIT_XUNIT_Ynewfrom_valueabsclampdistancedistance_squareddotlengthlength_squaredlerpmaxminnormalizesquare_roottransformtransform_matrix4x4transform_quaterniontransform_normal
x
x: f32
The X component of the vector.
y
y: f32
The Y component of the vector.
ZERO
const ZERO: Vector2
The vector (0, 0).
ONE
const ONE: Vector2
The vector (1, 1).
UNIT_X
const UNIT_X: Vector2
The vector (1, 0).
UNIT_Y
const UNIT_Y: Vector2
The vector (0, 1).
new
const fn new(x: f32, y: 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.
abs
fn abs(value: Vector2) -> Vector2
Returns a vector whose elements are the absolute values of each of the specified vector's elements.
clamp
fn clamp(value1: Vector2, min: Vector2, max: Vector2) -> Vector2
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: Vector2, value2: Vector2) -> f32
Computes the Euclidean distance between the two given points.
distance_squared
fn distance_squared(value1: Vector2, value2: Vector2) -> f32
Returns the Euclidean distance squared between two specified points.
dot
fn dot(value1: Vector2, value2: Vector2) -> 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: Vector2, value2: Vector2, amount: f32) -> Vector2
Performs a linear interpolation between two vectors based on the given weighting.
max
fn max(value1: Vector2, value2: Vector2) -> Vector2
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
min
fn min(value1: Vector2, value2: Vector2) -> Vector2
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
normalize
fn normalize(value: Vector2) -> Vector2
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: Vector2) -> Vector2
Returns a vector whose elements are the square root of each of a specified vector's elements.
transform
fn transform(position: Vector2, matrix: Matrix3x2) -> Vector2
Transforms a vector by a specified 3x2 matrix.
transform_matrix4x4
fn transform_matrix4x4(position: Vector2, matrix: Matrix4x4) -> Vector2
Transforms a vector by a specified 4x4 matrix.
transform_quaternion
fn transform_quaternion(value: Vector2, rotation: Quaternion) -> Vector2
Transforms a vector by the specified rotation.
transform_normal
fn transform_normal(normal: Vector2, matrix: Matrix3x2) -> Vector2
Transforms a vector normal by the given 3x2 matrix.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneCopyDebugStructuralPartialEqPartialEqDefaultFrom<Vector>From<Vector2>AddSubMulMul<f32>Mul<Vector2>DivDiv<f32>NegAddAssignSubAssignMulAssignMulAssign<f32>DivAssignDivAssign<f32>DisplayIInterpolator<Vector2>SpringValueExpressionVariantValueBatchValue
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.