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
fn is_close_to(&self, rhs: &Self, max_diff: Self::BaseType) -> bool
Provided Methods
fn is_approx_eq(&self, rhs: &Self) -> bool
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 f32
impl ApproxEq for f64
[src]
impl ApproxEq for f64
Implementors
impl<T: BaseFloat> ApproxEq for Vector2<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Vector3<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Vector4<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix2<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix3x2<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix4x2<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix2x3<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix3<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix4x3<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix2x4<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix3x4<T> type BaseType = T;
impl<T: BaseFloat> ApproxEq for Matrix4<T> type BaseType = T;