FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Vector

    struct · ferroui-base · v0.5.0

    struct Vector
    

    Defines a vector.

    View source

    Members

    x

    x: f64
    

    The X component.

    Source

    y

    y: f64
    

    The Y component.

    Source

    ZERO

    const ZERO: Vector
    

    The zero vector.

    Source

    ONE

    const ONE: Vector
    

    The one vector.

    Source

    UNIT_X

    const UNIT_X: Vector
    

    The X unit vector.

    Source

    UNIT_Y

    const UNIT_Y: Vector
    

    The Y unit vector.

    Source

    new

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

    Initializes a new instance of the Vector structure.

    Source

    parse

    fn parse(s: &str) -> Result<Self, FormatError>
    

    Parses a Vector string ("x, y" or "x y").

    Source

    length

    fn length(self: &Self) -> f64
    

    Length of the vector.

    Source

    squared_length

    fn squared_length(self: &Self) -> f64
    

    Squared length of the vector.

    Source

    equals

    fn equals(self: &Self, other: Vector) -> bool
    

    Check if two vectors are equal (exact comparison of the components).

    Source

    nearly_equals

    fn nearly_equals(self: &Self, other: Vector) -> bool
    

    Check if two vectors are nearly equal (numerically).

    Source

    with_x

    const fn with_x(self: &Self, x: f64) -> Vector
    

    Returns a new vector with the specified X component.

    Source

    with_y

    const fn with_y(self: &Self, y: f64) -> Vector
    

    Returns a new vector with the specified Y component.

    Source

    normalize

    fn normalize(self: &Self) -> Vector
    

    Returns a normalized version of this vector. A zero-length vector yields NaN components.

    Source

    negate

    fn negate(self: &Self) -> Vector
    

    Returns a negated version of this vector.

    Source

    dot

    fn dot(a: Vector, b: Vector) -> f64
    

    Returns the dot product of two vectors.

    Source

    cross

    fn cross(a: Vector, b: Vector) -> f64
    

    Returns the cross product of two vectors.

    Source

    normalize_vector

    fn normalize_vector(vector: Vector) -> Vector
    

    Normalizes the given vector (static form of normalize).

    Source

    divide

    fn divide(a: Vector, b: Vector) -> Vector
    

    Divides the first vector by the second, component-wise.

    Source

    divide_scalar

    fn divide_scalar(vector: Vector, scalar: f64) -> Vector
    

    Divides the vector by the given scalar.

    Source

    multiply

    fn multiply(a: Vector, b: Vector) -> Vector
    

    Multiplies the first vector by the second, component-wise.

    Source

    multiply_scalar

    fn multiply_scalar(vector: Vector, scalar: f64) -> Vector
    

    Multiplies the vector by the given scalar.

    Source

    add

    fn add(a: Vector, b: Vector) -> Vector
    

    Adds the second to the first vector.

    Source

    subtract

    fn subtract(a: Vector, b: Vector) -> Vector
    

    Subtracts the second from the first vector.

    Source

    negate_vector

    fn negate_vector(vector: Vector) -> Vector
    

    Negates the vector (static form of negate).

    Source

    deconstruct

    const fn deconstruct(self: &Self) -> (f64, f64)
    

    Deconstructs the vector into its X and Y components.

    Source

    abs

    fn abs(self: &Self) -> Vector
    

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

    Source

    clamp

    fn clamp(value: Vector, min: Vector, max: Vector) -> Vector
    

    Restricts a vector between a minimum and a maximum value.

    Source

    max

    fn max(left: Vector, right: Vector) -> Vector
    

    Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.

    Source

    min

    fn min(left: Vector, right: Vector) -> Vector
    

    Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.

    Source

    distance

    fn distance(value1: Vector, value2: Vector) -> f64
    

    Computes the Euclidean distance between the two given points.

    Source

    distance_squared

    fn distance_squared(value1: Vector, value2: Vector) -> f64
    

    Returns the Euclidean distance squared between two specified points.

    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
    • Transition<Vector>
    • From<Vector>
    • From<Vector2>
    • IInterpolator<Vector>
    • ExpressionVariantValue
    • ServerPropertyValue
    • BatchValue
    • MarkupTyped
    • ValueTypeRegistration
    • From<Point>
    • Add<Vector>
    • Sub<Vector>
    • AddAssign<Vector>
    • SubAssign<Vector>
    • Mul<Vector>
    • Div<Vector>
    • MulAssign<Vector>
    • DivAssign<Vector>
    • Clone
    • Copy
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Default
    • Mul
    • Mul<f64>
    • Div<f64>
    • Neg
    • Add
    • Sub
    • AddAssign
    • SubAssign
    • MulAssign<f64>
    • DivAssign<f64>
    • FromStr
    • Display

    Availability

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