summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ba88551)
raw | patch | inline | side by side (parent: ba88551)
author | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 19 May 2008 16:01:37 +0000 (16:01 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 19 May 2008 16:01:37 +0000 (16:01 +0000) |
src/2geom/nearest-point.h | patch | blob | history |
index 43b76c3ab0a9eee72b88aea6745e5b7a84124f1a..73ac0c3ce73f9785a68d19d3afb9f83bdf310f79 100644 (file)
namespace Geom\r
{\r
\r
+/*\r
+ * Given a line L specified by a point A and direction vector v,\r
+ * return the point on L nearest to p. Note that the returned value\r
+ * is with respect to the _normalized_ direction of v!\r
+ */\r
+inline double nearest_point(Point const &p, Point const &A, Point const &v)\r
+{\r
+ Point d(p - A);\r
+ return d[0] * v[0] + d[1] * v[1];\r
+}\r
+\r
////////////////////////////////////////////////////////////////////////////////\r
// D2<SBasis> versions\r
\r