corrected the implementation of IntersectionSegmentPlane (compiled .net only)

This commit is contained in:
ganovelli 2009-04-29 09:37:42 +00:00
parent a7e5e51ddc
commit 0524e1ac62
1 changed files with 7 additions and 8 deletions

View File

@ -349,13 +349,12 @@ namespace vcg {
/// intersection between segment and plane /// intersection between segment and plane
template<class T> template<class T>
inline bool IntersectionSegmentPlane( const Plane3<T> & pl, const Segment3<T> & s, Point3<T> & po){ inline bool IntersectionSegmentPlane( const Plane3<T> & pl, const Segment3<T> & s, Point3<T> & p0){
vcg::Line3<T> l; T p1_proj = s.P1()*pl.Direction()-pl.Offset();
l.Set(s.P0(),s.P1()-s.P0()); T p0_proj = s.P0()*pl.Direction()-pl.Offset();
l.Normalize(); if ( (p1_proj>0)-(p0_proj<0)) return false;
if (IntersectionLinePlane(pl,l,po)) p0 = s.P0() + (s.P1()-s.P0()) * fabs(p0_proj/(p1_proj-p0_proj));
return((po-s.P0()).Norm()<=(s.P0()-s.P1()).Norm()); return true;
return false;
} }
/// intersection between segment and plane /// intersection between segment and plane