Trait glm::ApproxEq [] [src]

pub trait ApproxEq {
    type BaseType: BaseFloat;
    fn is_close_to(&self, rhs: &Self, max_diff: Self::BaseType) -> bool;

    fn is_approx_eq(&self, rhs: &Self) -> bool { ... }
}

Trait for comparing types that are derived from float numbers.

Note

Comparing float numbers is tricky. This trait is mainly for convenience. See this article for the details of comparing float numbers.

Associated Types

Required Methods

Returns true if the difference between x and y is less than max_diff.

Note

The meanings of "difference" and "less than" are up to the implementations.

Example

use glm::*;

let v1 = vec2(1000., 2000.); let v2 = vec2(1010., 1080.); assert!(v1.is_close_to(&v2, 50.)); assert!(!v1.is_close_to(&v2, 10.));

Provided Methods

Returns true if the difference between x and y is less than machine epsilon.

Example

use glm::*;

let f = 0.1_f32;
let mut sum = 0f32;
for i in 0..10 {
    sum += f;
}
assert_eq!(1.0_f32 == sum, false);
assert_eq!(1f32.is_approx_eq(&sum), true);

Implementations on Foreign Types

impl ApproxEq for f32
[src]

impl ApproxEq for f64
[src]

Implementors