points_equal

Function points_equal 

Source
pub fn points_equal<T>(point1: &[T], point2: &[T], tol: Option<T>) -> bool
where T: PartialOrd + Sub<Output = T> + Copy + FromPrimitive + Zero,
Expand description

Check if two points are equal within a tolerance

Compares each element of the points to determine if they are approximately equal within a specified tolerance.

§Arguments

  • point1 - First point as a slice
  • point2 - Second point as a slice
  • tol - Tolerance (default: 1e-8)

§Returns

  • True if points are equal within tolerance

§Examples

use scirs2_core::utils::points_equal;

let point1 = [1.0, 2.0, 3.0];
let point2 = [1.0, 2.0, 3.0];
let point3 = [1.0, 2.0, 3.001];

assert!(points_equal(&point1, &point2, None));
assert!(!points_equal(&point1, &point3, None));
assert!(points_equal(&point1, &point3, Some(0.01)));