nalgebra/nalgebra-glm/src/gtc/epsilon.rs

32 lines
1.1 KiB
Rust
Raw Normal View History

2018-09-22 23:36:08 +08:00
// NOTE those are actually duplicates of vector_relational.rs
/*
use approx::AbsDiffEq;
use na::DefaultAllocator;
2019-03-23 21:29:07 +08:00
use crate::traits::{Alloc, Number, Dimension};
use crate::aliases::TVec;
2018-09-22 19:21:02 +08:00
/// Component-wise approximate equality beween two vectors.
2021-04-11 17:00:38 +08:00
pub fn epsilon_equal<T: Number, const D: usize>(x: &TVec<T, D>, y: &TVec<T, D>, epsilon: T) -> TVec<bool, D>
where DefaultAllocator: Alloc<T, D> {
x.zip_map(y, |x, y| abs_diff_eq!(x, y, epsilon = epsilon))
}
2018-09-22 19:21:02 +08:00
/// Component-wise approximate equality beween two scalars.
2021-04-11 17:00:38 +08:00
pub fn epsilon_equal2<T: AbsDiffEq<Epsilon = T>>(x: T, y: T, epsilon: T) -> bool {
abs_diff_eq!(x, y, epsilon = epsilon)
}
2018-09-22 19:21:02 +08:00
/// Component-wise approximate non-equality beween two vectors.
2021-04-11 17:00:38 +08:00
pub fn epsilon_not_equal<T: Number, const D: usize>(x: &TVec<T, D>, y: &TVec<T, D>, epsilon: T) -> TVec<bool, D>
where DefaultAllocator: Alloc<T, D> {
x.zip_map(y, |x, y| abs_diff_ne!(x, y, epsilon = epsilon))
}
2018-09-22 19:21:02 +08:00
/// Component-wise approximate non-equality beween two scalars.
2021-04-11 17:00:38 +08:00
pub fn epsilon_not_equal2<T: AbsDiffEq<Epsilon = T>>(x: T, y: T, epsilon: T) -> bool {
abs_diff_ne!(x, y, epsilon = epsilon)
}
2018-10-22 04:11:27 +08:00
*/