From 0524e1ac62e1da547777313a0e40187a5ec8d6ca Mon Sep 17 00:00:00 2001 From: ganovelli Date: Wed, 29 Apr 2009 09:37:42 +0000 Subject: [PATCH] corrected the implementation of IntersectionSegmentPlane (compiled .net only) --- vcg/space/intersection3.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/vcg/space/intersection3.h b/vcg/space/intersection3.h index c4ba754c..00eaff77 100644 --- a/vcg/space/intersection3.h +++ b/vcg/space/intersection3.h @@ -349,13 +349,12 @@ namespace vcg { /// intersection between segment and plane template - inline bool IntersectionSegmentPlane( const Plane3 & pl, const Segment3 & s, Point3 & po){ - vcg::Line3 l; - l.Set(s.P0(),s.P1()-s.P0()); - l.Normalize(); - if (IntersectionLinePlane(pl,l,po)) - return((po-s.P0()).Norm()<=(s.P0()-s.P1()).Norm()); - return false; + inline bool IntersectionSegmentPlane( const Plane3 & pl, const Segment3 & s, Point3 & p0){ + T p1_proj = s.P1()*pl.Direction()-pl.Offset(); + T p0_proj = s.P0()*pl.Direction()-pl.Offset(); + if ( (p1_proj>0)-(p0_proj<0)) return false; + p0 = s.P0() + (s.P1()-s.P0()) * fabs(p0_proj/(p1_proj-p0_proj)); + return true; } /// intersection between segment and plane @@ -867,7 +866,7 @@ public: return (bret); } }; - + /*@}*/