diff --git a/IntersLineArc.cpp b/IntersLineArc.cpp index 99115cb..e042b48 100644 --- a/IntersLineArc.cpp +++ b/IntersLineArc.cpp @@ -34,7 +34,6 @@ IntersLineArc::IntersLineArc( const CurveLine& Line, const CurveArc& Arc) // verifico che l'angolo al centro non superi il giro if ( abs( Arc.GetAngCenter()) > ANG_FULL + EPS_ANG_ZERO) return ; - // !!! Gestire l'arco proiettato come ellisse // verifico sovrapposizione box BBox3d boxLine ; @@ -69,6 +68,13 @@ IntersLineArc::IntersLineArc( const CurveLine& Line, const CurveArc& Arc) if ( dSqDelta < - 2 * m_Arc.GetRadius() * EPS_SMALL) return ; + // se punto proiettato approssima uno degli estremi dell'arco, annullo dSqDelta + Point3d ptArcStart, ptArcEnd ; + if ( m_Arc.GetStartPoint( ptArcStart) && AreSamePointXYApprox( ptPrjCen, ptArcStart)) + dSqDelta = 0 ; + else if ( m_Arc.GetEndPoint( ptArcEnd) && AreSamePointXYApprox( ptPrjCen, ptArcEnd)) + dSqDelta = 0 ; + // se distanza uguale al raggio -> una intersezione tangente, è la proiezione // (corrisponde a una differenza max di EPS_SMALL tra le intersezioni) if ( dSqDelta < EPS_SMALL * EPS_SMALL) { diff --git a/IntersPlanePlane.cpp b/IntersPlanePlane.cpp index ab7530c..a4259a5 100644 --- a/IntersPlanePlane.cpp +++ b/IntersPlanePlane.cpp @@ -24,12 +24,12 @@ IntersPlanePlane( const Plane3d& plPlane1, const Plane3d& plPlane2, Point3d& ptI vtDir = plPlane1.GetVersN() ^ plPlane2.GetVersN() ; // Verifico se piani praticamente paralleli double dDenom = vtDir * vtDir ; - if ( dDenom < EPS_ZERO * EPS_ZERO) + if ( dDenom < SIN_EPS_ANG_ZERO * SIN_EPS_ANG_ZERO) return ( AreSamePointApprox( ORIG + plPlane1.GetVersN() * plPlane1.GetDist(), ORIG + plPlane2.GetVersN() * plPlane2.GetDist()) ? IPPT_OVERLAPS : IPPT_NO) ; // Calcolo un punto sulla retta di intersezione ptInt = ORIG + ( ( plPlane1.GetDist() * plPlane2.GetVersN() - plPlane2.GetDist() * plPlane1.GetVersN()) ^ vtDir) / dDenom ; // Normalizzo la direzione - vtDir.Normalize() ; + vtDir.Normalize( SIN_EPS_ANG_ZERO) ; return IPPT_YES ; } diff --git a/IntersTriaTria.cpp b/IntersTriaTria.cpp index 36ff54b..72b81b0 100644 --- a/IntersTriaTria.cpp +++ b/IntersTriaTria.cpp @@ -80,12 +80,14 @@ IntersTriaTria( const Triangle3d& trTria1, const Triangle3d& trTria2, Point3d& p // intersezione tra i piani dei due triangoli Point3d ptL1 ; Vector3d vtL1 ; - int nresPP = IntersPlanePlane( plTria1, plTria2, ptL1, vtL1) ; - if ( nresPP == IPPT_NO) + int nResPP = IntersPlanePlane( plTria1, plTria2, ptL1, vtL1) ; + if ( nResPP == IPPT_NO) return ITTT_NO ; // se i triangoli sono complanari - if ( nresPP == IPPT_OVERLAPS || ( nVertPos1 == 0 && nVertNeg1 == 0) || ( nVertPos2 == 0 && nVertNeg2 == 0)) + if ( nResPP == IPPT_OVERLAPS || + ((( nVertPos1 == 0 && nVertNeg1 == 0) || ( nVertPos2 == 0 && nVertNeg2 == 0)) && + ( trTria1.GetN() ^ trTria2.GetN()).SqLen() < SIN_EPS_ANG_SMALL)) return IntersCoplanarTriaTria( trTria1, trTria2, vTria) ; // limito la linea di intersezione con il primo triangolo