b1acf7f4f0
- correzione a Inters3Planes (la linea deve essere infinita) - modifiche varie e correzioni a ProjectCurveOnSurf per gestire spigoli e per far funzionare l'eliminazione dei punti superflui.
47 lines
2.1 KiB
C++
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 < 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( SIN_EPS_ANG_ZERO) ;
|
|
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, false) == ILPT_YES ? IPPT_YES : IPPT_NO) ;
|
|
}
|