summaryrefslogtreecommitdiffstats
path: root/src/2geom/point.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2009-01-26 14:41:05 +0000
committercilix42 <cilix42@users.sourceforge.net>2009-01-26 14:41:05 +0000
commit87f6a22451870cf5993212d1e90327280b2e14ae (patch)
tree25cea0126b6df96208c4d6301f971630cd2f48a0 /src/2geom/point.cpp
parentremoving a g_warning (diff)
downloadinkscape-87f6a22451870cf5993212d1e90327280b2e14ae.tar.gz
inkscape-87f6a22451870cf5993212d1e90327280b2e14ae.zip
display guide anchor on canvas; anchor and angle can be edited by mouse
(bzr r7180)
Diffstat (limited to 'src/2geom/point.cpp')
-rw-r--r--src/2geom/point.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/2geom/point.cpp b/src/2geom/point.cpp
index 5dd7b52f2..b8a858f8d 100644
--- a/src/2geom/point.cpp
+++ b/src/2geom/point.cpp
@@ -2,7 +2,7 @@
#include <assert.h>
#include <2geom/coord.h>
#include <2geom/isnan.h> //temporary fix for isnan()
-#include <2geom/matrix.h>
+#include <2geom/transforms.h>
namespace Geom {
@@ -150,6 +150,18 @@ Point &Point::operator*=(Matrix const &m)
return *this;
}
+Point constrain_angle(Point const &ref, Point const &pt, unsigned int n, Point const &dir)
+{
+ // for special cases we could perhaps use faster routines
+ if (n == 0.0) {
+ return pt;
+ }
+ Point diff(pt - ref);
+ double angle = -angle_between(diff, dir);
+ double k = round(angle * (double)n / (2.0*M_PI));
+ return ref + dir * Rotate(k * 2.0 * M_PI / (double)n) * L2(diff);
+}
+
} //Namespace Geom
/*