|
|
|
#[cfg(test)] |
|
use super::{CircleArc, Subpath}; |
|
use crate::consts::MAX_ABSOLUTE_DIFFERENCE; |
|
#[cfg(test)] |
|
use crate::utils::f64_compare; |
|
use glam::DVec2; |
|
|
|
|
|
#[cfg(test)] |
|
pub fn compare_f64s(f1: f64, f2: f64) -> bool { |
|
f64_compare(f1, f2, MAX_ABSOLUTE_DIFFERENCE) |
|
} |
|
|
|
|
|
pub fn compare_points(p1: DVec2, p2: DVec2) -> bool { |
|
p1.abs_diff_eq(p2, MAX_ABSOLUTE_DIFFERENCE) |
|
} |
|
|
|
|
|
#[cfg(test)] |
|
pub fn compare_vec_of_points(a: Vec<DVec2>, b: Vec<DVec2>, max_absolute_difference: f64) -> bool { |
|
a.len() == b.len() && a.into_iter().zip(b).all(|(p1, p2)| p1.abs_diff_eq(p2, max_absolute_difference)) |
|
} |
|
|
|
|
|
#[cfg(test)] |
|
pub fn compare_arcs(arc1: CircleArc, arc2: CircleArc) -> bool { |
|
compare_points(arc1.center, arc2.center) |
|
&& f64_compare(arc1.radius, arc1.radius, MAX_ABSOLUTE_DIFFERENCE) |
|
&& f64_compare(arc1.start_angle, arc2.start_angle, MAX_ABSOLUTE_DIFFERENCE) |
|
&& f64_compare(arc1.end_angle, arc2.end_angle, MAX_ABSOLUTE_DIFFERENCE) |
|
} |
|
|
|
|
|
|
|
#[cfg(test)] |
|
pub fn compare_subpaths<PointId: crate::Identifier>(subpath1: &Subpath<PointId>, subpath2: &Subpath<PointId>) -> bool { |
|
subpath1.len() == subpath2.len() && subpath1.closed() == subpath2.closed() && subpath1.iter().eq(subpath2.iter()) |
|
} |
|
|