Files
EgtGeomKernel/IntersPlanePlane.cpp
T
Dario Sassi 5bcd4bb67d EgtGeomKernel 1.8j4 :
- aggiunta classe Polygon3d (da EgtExchange)
- razionalizzata classe Plane3d
- corretta funzione IntersLineTria.
2017-10-16 07:56:04 +00:00

47 lines
1.9 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2017-2017
//----------------------------------------------------------------------------
// File : IntersPlanePlane.cpp Data : 15.10.17 Versione : 1.8j3
// Contenuto : Implementazione della intersezione piano/piano.
//
//
//
// Modifiche : 15.12.17 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "/EgtDev/Include/EGkIntersLinePlane.h"
#include "/EgtDev/Include/EGkIntersPlanePlane.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 ( abs( plPlane1.GetDist() - plPlane2.GetDist()) < EPS_SMALL ? 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) ;
}