EgtGeomKernel 2.5e4 :
- modifiche per verifica collisione con TriMesh chiuse - aggiunta gestione Capsule.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2023-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLineCaps.cpp Data : 22.05.23 Versione : 2.5e3
|
||||
// Contenuto : Implementazione della intersezione linea/capsule.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 22.05.23 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "IntersLineCaps.h"
|
||||
#include "DistLineLine.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSphere.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e capsule sono nel medesimo riferimento.
|
||||
// Il capsule è definito con centri delle due estremità, e raggio.
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineCaps( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptCaps1, const Point3d& ptCaps2, double dRad,
|
||||
double& dU1, double& dU2)
|
||||
{
|
||||
// Determino versore e lunghezza asse Capsule
|
||||
Vector3d vtCaps = ptCaps2 - ptCaps1 ;
|
||||
double dLen = vtCaps.Len() ;
|
||||
if ( dLen < EPS_SMALL) {
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
if ( IntersLineSphere( ptL, vtL, Media( ptCaps1, ptCaps2), dRad, ptInt1, ptInt2) != ILST_SEC)
|
||||
return false ;
|
||||
dU1 = ( ptInt1 - ptL) * vtL ;
|
||||
dU2 = ( ptInt2 - ptL) * vtL ;
|
||||
return true ;
|
||||
}
|
||||
vtCaps /= dLen ;
|
||||
// Distanza tra la linea e il segmento asse del capsule
|
||||
DistLineLine dstLL( ptL, vtL, 1, ptCaps1, vtCaps, dLen, false, true) ;
|
||||
double dSqDist ;
|
||||
if ( dstLL.GetSqDist( dSqDist) && dSqDist >= dRad * dRad)
|
||||
return false ;
|
||||
// Calcolo i punti di intersezione
|
||||
Point3d ptRef, ptTmp ;
|
||||
dstLL.GetMinDistPoints( ptRef, ptTmp) ;
|
||||
double dSqDelta = dRad * dRad - dSqDist ;
|
||||
double dDist = sqrt( dSqDelta) ;
|
||||
dU1 = ( ptRef - ptL) * vtL - dDist ;
|
||||
dU2 = dU1 + 2 * dDist ;
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user