FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Vector2

    struct · ferroui-base · v0.5.0

    struct Vector2
    

    A vector with two single-precision components.

    View source

    Members

    x

    x: f32
    

    The X component of the vector.

    Source

    y

    y: f32
    

    The Y component of the vector.

    Source

    ZERO

    const ZERO: Vector2
    

    The vector (0, 0).

    Source

    ONE

    const ONE: Vector2
    

    The vector (1, 1).

    Source

    UNIT_X

    const UNIT_X: Vector2
    

    The vector (1, 0).

    Source

    UNIT_Y

    const UNIT_Y: Vector2
    

    The vector (0, 1).

    Source

    new

    const fn new(x: f32, y: f32) -> Self
    

    Creates a vector from its components.

    Source

    from_value

    const fn from_value(value: f32) -> Self
    

    Creates a vector whose components all have the same value.

    Source

    abs

    fn abs(value: Vector2) -> Vector2
    

    Returns a vector whose elements are the absolute values of each of the specified vector's elements.

    Source

    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).

    Source

    distance

    fn distance(value1: Vector2, value2: Vector2) -> f32
    

    Computes the Euclidean distance between the two given points.

    Source

    distance_squared

    fn distance_squared(value1: Vector2, value2: Vector2) -> f32
    

    Returns the Euclidean distance squared between two specified points.

    Source

    dot

    fn dot(value1: Vector2, value2: Vector2) -> f32
    

    Returns the dot product of two vectors.

    Source

    length

    fn length(self: &Self) -> f32
    

    Returns the length of the vector.

    Source

    length_squared

    fn length_squared(self: &Self) -> f32
    

    Returns the length of the vector squared.

    Source

    lerp

    fn lerp(value1: Vector2, value2: Vector2, amount: f32) -> Vector2
    

    Performs a linear interpolation between two vectors based on the given weighting.

    Source

    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.

    Source

    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.

    Source

    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).

    Source

    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.

    Source

    transform

    fn transform(position: Vector2, matrix: Matrix3x2) -> Vector2
    

    Transforms a vector by a specified 3x2 matrix.

    Source

    transform_matrix4x4

    fn transform_matrix4x4(position: Vector2, matrix: Matrix4x4) -> Vector2
    

    Transforms a vector by a specified 4x4 matrix.

    Source

    transform_quaternion

    fn transform_quaternion(value: Vector2, rotation: Quaternion) -> Vector2
    

    Transforms a vector by the specified rotation.

    Source

    transform_normal

    fn transform_normal(normal: Vector2, matrix: Matrix3x2) -> Vector2
    

    Transforms a vector normal by the given 3x2 matrix.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • Copy
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Default
    • From<Vector>
    • From<Vector2>
    • Add
    • Sub
    • Mul
    • Mul<f32>
    • Mul<Vector2>
    • Div
    • Div<f32>
    • Neg
    • AddAssign
    • SubAssign
    • MulAssign
    • MulAssign<f32>
    • DivAssign
    • DivAssign<f32>
    • Display
    • IInterpolator<Vector2>
    • SpringValue
    • ExpressionVariantValue
    • BatchValue

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.