From cfdb3d7ffed160f1f094bab7162ff06f0420b874 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sun, 23 Dec 2007 21:52:23 +0000 Subject: [PATCH] fix angle description of guides --- src/sp-guide.cpp | 9 ++++----- src/sp-guide.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 7ee29e231..26d60601c 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -33,6 +33,7 @@ #include "inkscape.h" #include "desktop.h" #include "sp-namedview.h" +#include <2geom/angle.h> using std::vector; @@ -367,11 +368,9 @@ char *sp_guide_description(SPGuide const *guide) } else if ( guide->normal_to_line == component_vectors[Y] ) { return g_strdup_printf(_("horizontal guideline at %s"), position_string_y->str); } else { - double const radians = atan2(guide->normal_to_line[X], - guide->normal_to_line[Y]); - /* flip y axis and rotate 90 degrees to convert to line angle */ - double const degrees = ( radians / M_PI ) * 180.0; - int const degrees_int = (int) floor( degrees + .5 ); + double const radians = guide->angle(); + double const degrees = Geom::rad_to_deg(radians); + int const degrees_int = (int) round(degrees); return g_strdup_printf("%d degree guideline at (%s,%s)", degrees_int, position_string_x->str, position_string_y->str); /* Alternative suggestion: "angled guideline". */ } diff --git a/src/sp-guide.h b/src/sp-guide.h index 819457cb7..dbbebadb7 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -36,6 +36,7 @@ struct SPGuide : public SPObject { inline bool is_horizontal() const { return (normal_to_line[Geom::X] == 0.); }; inline bool is_vertical() const { return (normal_to_line[Geom::Y] == 0.); }; + inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); }; }; struct SPGuideClass { -- 2.30.2