diff --git a/vcg/simplex/edge/distance.h b/vcg/simplex/edge/distance.h index 90bbf35c..a1a6c05a 100644 --- a/vcg/simplex/edge/distance.h +++ b/vcg/simplex/edge/distance.h @@ -31,6 +31,7 @@ #include #include +#include #include @@ -48,8 +49,11 @@ namespace vcg { s.P0()=e.V(0)->P(); s.P1()=e.V(1)->P(); typename EdgeType::CoordType nearest; - nearest=vcg::ClosestPoint(s,q); - typename EdgeType::ScalarType d=(q-nearest).Norm(); + typename EdgeType::ScalarType d; +// nearest=vcg::ClosestPoint(s,q); +// d=(q-nearest).Norm(); + vcg::SegmentPointDistance(s,q ,nearest,d); + if (d + typename EdgeType::ScalarType Length(const EdgeType &e) + { + return Distance(e.cV(0)->cP(),e.cV(1)->cP()); + } + + template + typename EdgeType::VertexType::CoordType Center(const EdgeType &e) + { + return (e.cV(0)->cP()+e.cV(1)->cP())/2.0; + } + + } // end namespace edge } // end namespace vcg