Skip to content

Commit 59540e4

Browse files
committed
Add check comparing with bezier perimeter result
1 parent e48bae6 commit 59540e4

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/arc.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,27 @@ mod tests {
501501
assert!((a.arclen(0.000_1) - 0.448555).abs() <= EPSILON);
502502
}
503503

504+
#[test]
505+
fn length_compare_with_bez_length() {
506+
const EPSILON: f64 = 1e-3;
507+
508+
for radii in [(1., 1.), (0.5, 1.), (2., 1.)] {
509+
for start_angle in [0., 0.5, 1., 2., PI, -1.] {
510+
for sweep_angle in [0., 0.5, 1., 2., PI, -1.] {
511+
let a = Arc::new((0., 0.), radii, start_angle, sweep_angle, 0.);
512+
513+
let arc_length = a.arclen(0.000_1);
514+
let bez_length = a.path_segments(0.000_1).perimeter(0.000_1);
515+
516+
assert!(
517+
(arc_length - bez_length).abs() < EPSILON,
518+
"Numerically approximated arc length ({arc_length}) does not match bezier segment perimeter length ({bez_length}) for arc {a:?}"
519+
);
520+
}
521+
}
522+
}
523+
}
524+
504525
#[test]
505526
fn carlson_numerical_checks() {
506527
// TODO: relative bound on error doesn't seem to be quite correct yet, use a large epsilon

0 commit comments

Comments
 (0)