[goffice] Rotation selector: avoid rounding errors.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Rotation selector: avoid rounding errors.
- Date: Sun, 18 Jan 2015 02:24:49 +0000 (UTC)
commit af365f3c9322ab4bc52f828785b5254c47cca39a
Author: Morten Welinder <terra gnome org>
Date: Sat Jan 17 21:24:27 2015 -0500
Rotation selector: avoid rounding errors.
ChangeLog | 5 +++++
goffice/gtk/go-rotation-sel.c | 13 +++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8cf62af..f70539b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-17 Morten Welinder <terra gnome org>
+
+ * goffice/gtk/go-rotation-sel.c (cb_rotate_changed): Avoid
+ rounding errors by using go_cospi and go_sinpi.
+
2015-01-16 Jean Brefort <jean brefort normalesup org>
* plugins/plot_distrib/gog-histogram.c
diff --git a/goffice/gtk/go-rotation-sel.c b/goffice/gtk/go-rotation-sel.c
index 4cc7024..5ff0202 100644
--- a/goffice/gtk/go-rotation-sel.c
+++ b/goffice/gtk/go-rotation-sel.c
@@ -75,12 +75,13 @@ cb_rotate_changed (GORotationSel *grs)
}
if (grs->line != NULL) {
- double rad = grs->angle * M_PI / 180.;
+ double c = go_cospi (grs->angle / 180.);
+ double s = go_sinpi (grs->angle / 180.);
goc_item_set (grs->line,
- "x0", x0 + cos (rad) * grs->rot_width,
- "y0", 100 - sin (rad) * grs->rot_width,
- "x1", x0 + cos (rad) * 72.,
- "y1", 100 - sin (rad) * 72.,
+ "x0", x0 + c * grs->rot_width,
+ "y0", 100 - s * grs->rot_width,
+ "x1", x0 + c * 72.,
+ "y1", 100 - s * 72.,
NULL);
}
@@ -161,7 +162,7 @@ set_rot_from_point (GORotationSel *grs, double x, double y)
x -= grs->full? 100.: 15.; if (!grs->full && x < 0.) x = 0.;
y -= 100.;
- degrees = atan2 (-y, x) * 180 / M_PI;
+ degrees = go_atan2pi (-y, x) * 180;
gtk_spin_button_set_value (GTK_SPIN_BUTTON (grs->rotate_spinner),
go_fake_round (degrees));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]