correced the point-edge distance functor and added a pair of templated helper functions for edges (lenght and center)
This commit is contained in:
parent
37716e73e5
commit
952913c1de
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <vcg/math/base.h>
|
#include <vcg/math/base.h>
|
||||||
#include <vcg/space/point3.h>
|
#include <vcg/space/point3.h>
|
||||||
|
#include <vcg/space/distance3.h>
|
||||||
#include <vcg/space/segment3.h>
|
#include <vcg/space/segment3.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,8 +49,11 @@ namespace vcg {
|
||||||
s.P0()=e.V(0)->P();
|
s.P0()=e.V(0)->P();
|
||||||
s.P1()=e.V(1)->P();
|
s.P1()=e.V(1)->P();
|
||||||
typename EdgeType::CoordType nearest;
|
typename EdgeType::CoordType nearest;
|
||||||
nearest=vcg::ClosestPoint<typename EdgeType::ScalarType>(s,q);
|
typename EdgeType::ScalarType d;
|
||||||
typename EdgeType::ScalarType d=(q-nearest).Norm();
|
// nearest=vcg::ClosestPoint<typename EdgeType::ScalarType>(s,q);
|
||||||
|
// d=(q-nearest).Norm();
|
||||||
|
vcg::SegmentPointDistance(s,q ,nearest,d);
|
||||||
|
|
||||||
if (d<dist){
|
if (d<dist){
|
||||||
dist=d;
|
dist=d;
|
||||||
p=nearest;
|
p=nearest;
|
||||||
|
|
@ -78,6 +82,19 @@ namespace vcg {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class EdgeType>
|
||||||
|
typename EdgeType::ScalarType Length(const EdgeType &e)
|
||||||
|
{
|
||||||
|
return Distance(e.cV(0)->cP(),e.cV(1)->cP());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class EdgeType>
|
||||||
|
typename EdgeType::VertexType::CoordType Center(const EdgeType &e)
|
||||||
|
{
|
||||||
|
return (e.cV(0)->cP()+e.cV(1)->cP())/2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end namespace edge
|
} // end namespace edge
|
||||||
|
|
||||||
} // end namespace vcg
|
} // end namespace vcg
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue