[librsvg: 1/3] marker: simplify normalize_angle



commit ac7ea809b2a42d9901fa64835fbaa7eef2f2336f
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Dec 8 21:10:30 2018 +0100

    marker: simplify normalize_angle
    
    No need to manually loop

 rsvg_internals/src/marker.rs | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index a6f1b341..ac87aab1 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -589,18 +589,13 @@ 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(angle: f64) -> f64 {
+    let res = angle % (PI * 2.0);
+    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]