Avoid taking the square root of a negative number in `arc_from_cos()`.

This commit is contained in:
Patrick Walton 2020-03-31 13:28:55 -07:00
parent df4021e3c5
commit 9212c742b7
1 changed files with 4 additions and 0 deletions

View File

@ -84,6 +84,10 @@ impl Segment {
// approximates a small arc", 2004. // approximates a small arc", 2004.
// //
// https://www.tinaja.com/glib/bezcirc2.pdf // https://www.tinaja.com/glib/bezcirc2.pdf
if cos_sweep_angle >= 1.0 - EPSILON {
return Segment::line(LineSegment2F::new(vec2f(1.0, 0.0), vec2f(1.0, 0.0)));
}
let term = F32x4::new(cos_sweep_angle, -cos_sweep_angle, let term = F32x4::new(cos_sweep_angle, -cos_sweep_angle,
cos_sweep_angle, -cos_sweep_angle); cos_sweep_angle, -cos_sweep_angle);
let signs = F32x4::new(1.0, -1.0, 1.0, 1.0); let signs = F32x4::new(1.0, -1.0, 1.0, 1.0);