From d256abfaaf16ccb003ea2c508a9505f032cdbbd5 Mon Sep 17 00:00:00 2001 From: ganovelli Date: Wed, 21 Dec 2011 16:15:32 +0000 Subject: [PATCH] added PointScaledDistanceFunctor --- vcg/simplex/vertex/distance.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/vcg/simplex/vertex/distance.h b/vcg/simplex/vertex/distance.h index 131a312b..f3e437d1 100644 --- a/vcg/simplex/vertex/distance.h +++ b/vcg/simplex/vertex/distance.h @@ -105,6 +105,32 @@ class PointNormalDistanceFunctor { } }; +template +class PointScaledDistanceFunctor { + public: + typedef typename VERTEXYPE::ScalarType ScalarType; + typedef Point3 QueryType; + static inline const Point3 & Pos(const QueryType & qt) {return qt;} + + static Point3 & Cen(){static Point3 cen(0,0,0); return cen;} + + + inline bool operator () (const VERTEXYPE & p, const QueryType & qp, ScalarType & minDist, Point3 & q) { + + Point3 ed = (qp-p.P()); + Point3 dir = (p.P()-Cen()).Normalize(); + Point3 odir = (dir^((ed)^dir)).Normalize(); + ScalarType d = fabs(ed * dir) + fabs(ed *odir); + + if(d < minDist){ + minDist = d; + q = p.P(); + return true; + } + return false; + } + }; + template class ApproximateGeodesicDistanceFunctor { public: