diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-05-19 16:01:37 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-05-19 16:01:37 +0000 |
| commit | 1f1b86fd1ee30c6735c72c4b75778aee63833159 (patch) | |
| tree | 0610956e29a6dc5cbf4c7fd19e7fb2e7c109aaf5 /src | |
| parent | noop: add emacs/vim footer to ui/dialog/livepatheffect-editor.cpp (diff) | |
| download | inkscape-1f1b86fd1ee30c6735c72c4b75778aee63833159.tar.gz inkscape-1f1b86fd1ee30c6735c72c4b75778aee63833159.zip | |
Nearest point from point to line (simplicistic convenience function)
(bzr r5705)
Diffstat (limited to 'src')
| -rw-r--r-- | src/2geom/nearest-point.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/2geom/nearest-point.h b/src/2geom/nearest-point.h index 43b76c3ab..73ac0c3ce 100644 --- a/src/2geom/nearest-point.h +++ b/src/2geom/nearest-point.h @@ -48,6 +48,17 @@ namespace Geom
{
+/*
+ * Given a line L specified by a point A and direction vector v,
+ * return the point on L nearest to p. Note that the returned value
+ * is with respect to the _normalized_ direction of v!
+ */
+inline double nearest_point(Point const &p, Point const &A, Point const &v)
+{
+ Point d(p - A);
+ return d[0] * v[0] + d[1] * v[1];
+}
+
////////////////////////////////////////////////////////////////////////////////
// D2<SBasis> versions
|
