EgtGeomKernel 1.6b7 :
- aggiunto calcolo baricentro di Curve - migliorata gestione richiesta nuovo Id - aggiunta intersezione linea-piano e linea-triangolo - corretto errore in PointGrid3d con 1 solo punto (non faceva alcunchè) - aggiunte funzioni di accesso a dati di SurfTM.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLinePlane.cpp Data : 18.02.15 Versione : 1.6b7
|
||||
// Contenuto : Implementazione della intersezione linea/piano.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 18.02.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
IntersLinePlane( const Point3d& ptL1, const Point3d& ptL2, const Plane3d& plPlane, Point3d& ptInt)
|
||||
{
|
||||
Vector3d vtL = ptL2 - ptL1 ;
|
||||
double dLen = vtL.Len() ;
|
||||
if ( dLen > EPS_SMALL)
|
||||
vtL /= dLen ;
|
||||
else
|
||||
vtL = V_NULL ;
|
||||
return IntersLinePlane( ptL1, vtL, dLen, plPlane, ptInt) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
IntersLinePlane( const Point3d& ptL, const Vector3d& vtL, double dLen, const Plane3d& plPlane, Point3d& ptInt)
|
||||
{
|
||||
Vector3d vtDir = vtL ;
|
||||
if ( dLen > EPS_SMALL && ! vtDir.Normalize( EPS_ZERO))
|
||||
return ILPT_NO ;
|
||||
// coseno dell'angolo tra direzione linea e normale al piano
|
||||
double dCosAng = vtDir * plPlane.vtN ;
|
||||
// posizione del punto rispetto al piano
|
||||
double dPosL = ( ptL - ORIG) * plPlane.vtN - plPlane.dDist ;
|
||||
// verifico se linea parallela al piano (ovvero ortogonale alla normale)
|
||||
if ( fabs( dCosAng) < COS_ORTO_ANG_ZERO) {
|
||||
// se il punto giace nel piano, vi giace anche la linea
|
||||
if ( fabs( dPosL) < EPS_SMALL)
|
||||
return ILPT_INPLANE ;
|
||||
// alrimenti paralleli e non ci sono intersezioni
|
||||
else
|
||||
return ILPT_NO ;
|
||||
}
|
||||
// determino il punto di intersezione
|
||||
double dDistI = - dPosL / dCosAng ;
|
||||
ptInt = ptL + vtDir * dDistI ;
|
||||
// intersezione sul primo estremo
|
||||
if ( fabs( dDistI) < EPS_SMALL)
|
||||
return ILPT_START ;
|
||||
else if ( fabs( dDistI - dLen) < EPS_SMALL)
|
||||
return ILPT_END ;
|
||||
else if ( dDistI > 0 && dDistI < dLen)
|
||||
return ILPT_YES ;
|
||||
else
|
||||
return ILPT_NO ;
|
||||
}
|
||||
Reference in New Issue
Block a user