[librsvg/rustification] marker.rs: Normalize negative angles into positive ones
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] marker.rs: Normalize negative angles into positive ones
- Date: Mon, 19 Dec 2016 22:36:33 +0000 (UTC)
commit 605408a2abeda045fb26a553f9ca2bf546f76eec
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Dec 19 16:25:02 2016 -0600
marker.rs: Normalize negative angles into positive ones
This way our averaging of angles will work.
rust/src/marker.rs | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/rust/src/marker.rs b/rust/src/marker.rs
index 2426cbf..10f2170 100644
--- a/rust/src/marker.rs
+++ b/rust/src/marker.rs
@@ -2,6 +2,7 @@ extern crate libc;
extern crate cairo;
extern crate cairo_sys;
+use std::f64;
use path_builder::*;
use drawing_ctx::RsvgDrawingCtx;
@@ -302,11 +303,15 @@ fn find_outgoing_directionality_forwards (segments: &[Segment], start_index: usi
}
fn angle_from_vector (vx: f64, vy: f64) -> f64 {
- let angle = vy.atan2 (vx);
+ let mut angle = vy.atan2 (vx);
if angle.is_nan () {
0.0
} else {
+ while angle < 0.0 {
+ angle += f64::consts::PI * 2.0;
+ }
+
angle
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]