EgtGeomKernel :
- in Zmap aggiunta AvoidSphere - aggiunta funzione IntersLineSphere - migliorie a visualizzazione Zmap.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2018-2018
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLineSphere.cpp Data : 04.02.18 Versione : 1.9b1
|
||||
// Contenuto : Implementazione della intersezione linea/sfera.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 04.02.18 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSphere.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
IntersLineSphere( const Point3d& ptL, const Vector3d& vtL, const Point3d& ptCen, double dRad,
|
||||
Point3d& ptI1, Point3d& ptI2)
|
||||
{
|
||||
// Verifiche su versore linea
|
||||
Vector3d vtDir = vtL ;
|
||||
if ( ! vtDir.Normalize( EPS_ZERO))
|
||||
return ILST_NO ;
|
||||
// Proiezione del centro della sfera sulla linea
|
||||
Point3d ptP = ptL + (( ptCen - ptL) * vtL) * vtL ;
|
||||
// Distanza di questo punto di proiezione dal centro della sfera
|
||||
double dDist = Dist( ptCen, ptP) ;
|
||||
// Se distanza uguale al raggio, intersezione tangente
|
||||
if ( abs( dDist - dRad) < EPS_SMALL) {
|
||||
ptI1 = ptP ;
|
||||
ptI2 = ptP ;
|
||||
return ILST_TG ;
|
||||
}
|
||||
// Se distanza superiore al raggio, nessuna intersezione
|
||||
if ( dDist > dRad)
|
||||
return ILST_NO ;
|
||||
// Distanza inferiore al raggio, due intersezioni secanti
|
||||
double dDist2 = sqrt( dRad * dRad - dDist * dDist) ;
|
||||
ptI1 = ptP - dDist2 * vtL ;
|
||||
ptI2 = ptP + dDist2 * vtL ;
|
||||
return ILST_SEC ;
|
||||
}
|
||||
Reference in New Issue
Block a user