FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    MathUtilities

    struct · ferroui-base · v0.5.0

    struct MathUtilities
    

    Provides math utilities not provided by the standard library.

    View source

    Members

    DOUBLE_EPSILON

    const DOUBLE_EPSILON: f64
    

    Smallest value such that 1.0 + DOUBLE_EPSILON != 1.0.

    Source

    FLOAT_EPSILON

    const FLOAT_EPSILON: f32
    

    Source

    are_close

    fn are_close(value1: f64, value2: f64) -> bool
    

    Returns whether or not two doubles are "close", i.e. within a relative epsilon of each other.

    Source

    are_close_eps

    fn are_close_eps(value1: f64, value2: f64, eps: f64) -> bool
    

    Returns whether or not two doubles are within the fixed epsilon eps of each other.

    Source

    are_close_f32

    fn are_close_f32(value1: f32, value2: f32) -> bool
    

    Returns whether or not two floats are "close".

    Source

    less_than

    fn less_than(value1: f64, value2: f64) -> bool
    

    Returns whether the first double is strictly less than and not close to the second.

    Source

    less_than_f32

    fn less_than_f32(value1: f32, value2: f32) -> bool
    

    Returns whether the first float is strictly less than and not close to the second.

    Source

    greater_than

    fn greater_than(value1: f64, value2: f64) -> bool
    

    Returns whether the first double is strictly greater than and not close to the second.

    Source

    greater_than_f32

    fn greater_than_f32(value1: f32, value2: f32) -> bool
    

    Returns whether the first float is strictly greater than and not close to the second.

    Source

    less_than_or_close

    fn less_than_or_close(value1: f64, value2: f64) -> bool
    

    Returns whether the first double is less than or close to the second.

    Source

    less_than_or_close_f32

    fn less_than_or_close_f32(value1: f32, value2: f32) -> bool
    

    Returns whether the first float is less than or close to the second.

    Source

    greater_than_or_close

    fn greater_than_or_close(value1: f64, value2: f64) -> bool
    

    Returns whether the first double is greater than or close to the second.

    Source

    greater_than_or_close_f32

    fn greater_than_or_close_f32(value1: f32, value2: f32) -> bool
    

    Returns whether the first float is greater than or close to the second.

    Source

    is_one

    fn is_one(value: f64) -> bool
    

    Returns whether the double is "close" to 1. Same as are_close(value, 1.0) but faster.

    Source

    is_one_f32

    fn is_one_f32(value: f32) -> bool
    

    Returns whether the float is "close" to 1.

    Source

    is_zero

    fn is_zero(value: f64) -> bool
    

    Returns whether the double is "close" to 0. Same as are_close(value, 0.0) but faster.

    Source

    is_zero_f32

    fn is_zero_f32(value: f32) -> bool
    

    Returns whether the float is "close" to 0.

    Source

    clamp

    fn clamp(val: f64, min: f64, max: f64) -> f64
    

    Clamps a value between a minimum and maximum value. NaN is returned unchanged.

    Panics

    Panics if min > max (a programmer error).

    Source

    clamp_f32

    fn clamp_f32(value: f32, min: f32, max: f32) -> f32
    

    Clamps a value between a minimum and maximum value. The bounds may be given in either order.

    Source

    clamp_i32

    fn clamp_i32(val: i32, min: i32, max: i32) -> i32
    

    Clamps a value between a minimum and maximum value.

    Panics

    Panics if min > max (a programmer error).

    Source

    clamp_decimal

    fn clamp_decimal(val: Decimal, min: Decimal, max: Decimal) -> Decimal
    

    Clamps a value between a minimum and maximum value.

    Panics

    Panics if min > max (a programmer error).

    Source

    deg2rad

    fn deg2rad(angle: f64) -> f64
    

    Converts an angle in degrees to radians.

    Source

    grad2rad

    fn grad2rad(angle: f64) -> f64
    

    Converts an angle in gradians to radians.

    Source

    turn2rad

    fn turn2rad(angle: f64) -> f64
    

    Converts an angle in turns to radians.

    Source

    get_ellipse_point

    fn get_ellipse_point(centre: Point, radius_x: f64, radius_y: f64, angle: f64) -> Point
    

    Calculates the point of an angle (in radians) on an ellipse.

    Source

    get_min_max

    fn get_min_max(a: f64, b: f64) -> (f64, f64)
    

    Gets the minimum and maximum from the specified numbers.

    Source

    get_min_max_from_delta

    fn get_min_max_from_delta(initial_value: f64, delta: f64) -> (f64, f64)
    

    Gets the minimum and maximum from the specified number and the difference with that number.

    Source

    is_negative_or_non_finite

    fn is_negative_or_non_finite(d: f64) -> bool
    

    True for negative values (including -0.0), infinities and NaN.

    Source

    is_finite

    fn is_finite(d: f64) -> bool
    

    Source

    which_polygon_side_intersects

    fn which_polygon_side_intersects(c_poly: u32, p_pt_poly: &[Vector], pt_current: Vector, vec_edge: Vector) -> i32
    

    Classifies on which side of an edge a polygon lies: 1 when all of its first c_poly points are on the positive side, -1 when all are on the negative side, 0 when it straddles (or touches) the edge.

    Source

    do_polygons_intersect

    fn do_polygons_intersect(c_poly_a: u32, p_pt_poly_a: &[Vector], c_poly_b: u32, p_pt_poly_b: &[Vector]) -> bool
    

    Separating-axis test for two convex polygons.

    Source

    is_entirely_contained

    fn is_entirely_contained(c_poly_a: u32, p_pt_poly_a: &[Vector], c_poly_b: u32, p_pt_poly_b: &[Vector]) -> bool
    

    Returns whether polygon A lies entirely inside convex polygon B.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither

    Availability

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