Improve panic message

Previously, computing the `sqrt` could have resulted in `NaN`, which
would have lead to a generic panic in `Scalar` complaining about just
that.
This commit is contained in:
Hanno Braun 2025-04-22 12:37:40 +02:00
parent 161546522a
commit e6528bef3b

View File

@ -71,6 +71,16 @@ impl Sketch {
let c = radius;
let b_squared = c * c - a * a;
if b_squared < Scalar::ZERO {
panic!(
"Radius of arc (`{radius}`) is too small: \
Must be at least half the distance between \
start (`{start:?}`) and end (`{end:?}`) \
points, or the arc is not possible."
);
}
b_squared.sqrt()
};