Files
EgtGeomKernel/IntersPlanePlane.cpp
T
Dario Sassi 970b901895 EgtGeomKernel 2.1k3 :
- in intersezione curve miglioramento gestione intorni quasi non-manifold di curve chiuse per classificazione
- velocizzata funzione per decidere se curve chiuse non intersecantesi sono esterne o no
- corretta IntersPlanePlane per piani coincidenti con normali opposte da riconoscersi come sovrapposti.
2019-11-14 07:21:34 +00:00

47 lines
2.1 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2017-2019
//----------------------------------------------------------------------------
// File : IntersPlanePlane.cpp Data : 13.11.19 Versione : 2.1k3
// Contenuto : Implementazione della intersezione piano/piano.
//
//
//
// Modifiche : 15.10.17 DS Creazione modulo.
// 13.11.19 MS Piani coincidenti controversi sono riconosciuti sovrapposti.
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "/EgtDev/Include/EGkIntersPlanePlane.h"
#include "/EgtDev/Include/EGkIntersLinePlane.h"
//----------------------------------------------------------------------------
int
IntersPlanePlane( const Plane3d& plPlane1, const Plane3d& plPlane2, Point3d& ptInt, Vector3d& vtDir)
{
// Direzione linea di intersezione
vtDir = plPlane1.GetVersN() ^ plPlane2.GetVersN() ;
// Verifico se piani praticamente paralleli
double dDenom = vtDir * vtDir ;
if ( dDenom < EPS_ZERO * EPS_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() ;
return IPPT_YES ;
}
//----------------------------------------------------------------------------
int
Inters3Planes( const Plane3d& plPlane1, const Plane3d& plPlane2, const Plane3d& plPlane3, Point3d& ptInt)
{
// linea di intersezione tra i primi due piani
Point3d ptL ; Vector3d vtL ;
if ( IntersPlanePlane( plPlane1, plPlane2, ptL, vtL) != IPPT_YES)
return IPPT_NO ;
// intersezione della linea con il terzo piano
return ( IntersLinePlane( ptL, vtL, 1, plPlane3, ptInt) == ILPT_YES ? IPPT_YES : IPPT_NO) ;
}