[librsvg/librsvg-2.44] Fix rounding error on i386 (#455).
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.44] Fix rounding error on i386 (#455).
- Date: Thu, 11 Apr 2019 00:40:37 +0000 (UTC)
commit e02cbd62257a870424a62d0f04cc9d4e1059bd66
Author: Olivier Tilloy <olivier tilloy canonical com>
Date: Wed Apr 10 23:28:20 2019 +0200
Fix rounding error on i386 (#455).
rsvg_internals/src/marker.rs | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index ddc4624e..49362ccd 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -588,18 +588,15 @@ fn find_outgoing_directionality_forwards(
}
// Normalizes an angle to [0.0, 2*PI)
-fn normalize_angle(mut angle: f64) -> f64 {
- if angle < 0.0 {
- while angle < 0.0 {
- angle += PI * 2.0;
- }
+fn normalize_angle(rad: f64) -> f64 {
+ let res = rad % (PI * 2.0);
+ if res.abs() < std::f64::EPSILON {
+ res.abs()
+ } else if res < 0.0 {
+ res + PI * 2.0
} else {
- while angle > PI * 2.0 {
- angle -= PI * 2.0;
- }
+ res
}
-
- angle
}
fn angle_from_vector(vx: f64, vy: f64) -> f64 {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]