EgtGeomKernel 2.5e4 :
- modifiche per verifica collisione con TriMesh chiuse - aggiunta gestione Capsule.
This commit is contained in:
+5
-63
@@ -182,78 +182,21 @@ CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, cons
|
||||
return CDeSimpleBoxTria( Frame3d(), vtDiag, trTriaL) ;
|
||||
|
||||
// Verifica preliminare con box esteso
|
||||
Frame3d frEst( Point3d( -dSafeDist, -dSafeDist, -dSafeDist)) ;
|
||||
if ( ! CDeSimpleBoxTria( frEst, vtDiag + 2 * Vector3d( dSafeDist, dSafeDist, dSafeDist), trTriaL))
|
||||
Frame3d frTmp( Point3d( -dSafeDist, -dSafeDist, -dSafeDist)) ;
|
||||
if ( ! CDeSimpleBoxTria( frTmp, vtDiag + 2 * Vector3d( dSafeDist, dSafeDist, dSafeDist), trTriaL))
|
||||
return false ;
|
||||
|
||||
// Tre box aumentati con distanza di sicurezza in un sola dimensione
|
||||
Frame3d frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersX()) ;
|
||||
frTmp.ChangeOrig( Point3d( -dSafeDist, 0, 0)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * X_AX, trTriaL))
|
||||
return true ;
|
||||
frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersY()) ;
|
||||
frTmp.ChangeOrig( Point3d( 0, -dSafeDist, 0)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Y_AX, trTriaL))
|
||||
return true ;
|
||||
frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersZ()) ;
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, -dSafeDist)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Z_AX, trTriaL))
|
||||
return true ;
|
||||
|
||||
#if 1
|
||||
// Sfere centrate negli otto vertici
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, 0, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, 0, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
|
||||
// Cilindri centrati sui dodici spigoli
|
||||
frTmp.Set( Point3d( 0, 0, 0), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, vtDiag.y, 0), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, 0, 0), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, 0, 0), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, 0, vtDiag.z), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, vtDiag.y, vtDiag.z), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, 0, vtDiag.z), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, 0, vtDiag.z), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0., 0., 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, 0., 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, vtDiag.y, 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0., vtDiag.y, 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
#else
|
||||
// Capsule centrati sui dodici spigoli
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( vtDiag.x, 0, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
@@ -279,7 +222,6 @@ CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, cons
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, 0), Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
#endif
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
+24
-10
@@ -16,6 +16,7 @@
|
||||
#include "CDeCapsTria.h"
|
||||
#include "CDeSpheTria.h"
|
||||
#include "ProjPlane.h"
|
||||
#include "IntersLineCaps.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||
@@ -31,6 +32,7 @@ CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Tr
|
||||
|
||||
// Dati della capsule come sfera che si muove
|
||||
Point3d ptC = ptP1 ;
|
||||
Point3d ptE = ptP2 ;
|
||||
Vector3d vtDir = ptP2 - ptP1 ;
|
||||
double dLen = vtDir.Len() ;
|
||||
if ( dLen < EPS_SMALL)
|
||||
@@ -39,6 +41,13 @@ CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Tr
|
||||
if ( vtDir * trTria.GetN() > 0) {
|
||||
vtDir.Invert() ;
|
||||
ptC = ptP2 ;
|
||||
ptE = ptP1 ;
|
||||
}
|
||||
// Se sfera finale dista dal piano come o meno del raggio, devo verificarla direttamente (il retro è escluso dal calcolo standard)
|
||||
double dDistE = DistPointPlane( ptE, trTria.GetPlane()) ;
|
||||
if ( abs( dDistE) <= dR) {
|
||||
if ( CDeSimpleSpheTria( ptE, dR, trTria))
|
||||
return true ;
|
||||
}
|
||||
// Determinazione primo possibile punto di contatto della sfera con il piano
|
||||
Point3d ptD = ptC - trTria.GetN() * dR ;
|
||||
@@ -48,15 +57,20 @@ CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Tr
|
||||
// Se non c'è intersezione passante
|
||||
if ( nLpRes != ILPT_YES) {
|
||||
// se il centro dista dal piano non meno del raggio, allora non c'è sicuramente collisione
|
||||
double dDist = DistPointPlane( ptP, trTria.GetPlane()) ;
|
||||
if ( abs( dDist) >= dR)
|
||||
double dDistM = DistPointPlane( Media( ptP1, ptP2), trTria.GetPlane()) ;
|
||||
if ( abs( dDistM) >= dR)
|
||||
return false ;
|
||||
// !!! DA FARE !!!!
|
||||
// si deve intersecare l'asse del capsule con i cilindri centrati sui lati del triangolo
|
||||
// se intersezione inferiore a dLen allora collisione
|
||||
// altrimenti si deve intersecare l'asse del capsule con le sfere centrate sui vertici del triangolo
|
||||
// se intersezione inferiore a dLen allora collisione
|
||||
// per ora salto
|
||||
// interseco l'asse del capsule con capsule di pari raggio con asse i lati del triangolo
|
||||
double dU1 = INFINITO, dU2 = -INFINITO ;
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
double dInt1, dInt2 ;
|
||||
if ( IntersLineCaps( ptC, vtDir, trTria.GetP( i), trTria.GetP( ( i + 1) % 3), dR, dInt1, dInt2)) {
|
||||
dU1 = min( dU1, dInt1) ;
|
||||
dU2 = max( dU2, dInt2) ;
|
||||
if ( ! ( dU1 >= dLen || dU2 <= 0))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// Determino la posizione dell'intersezione rispetto al triangolo
|
||||
@@ -65,7 +79,7 @@ CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Tr
|
||||
double dSqDist ;
|
||||
if ( dptDist.GetSqDist( dSqDist) && dSqDist < 4 * SQ_EPS_SMALL) {
|
||||
double dPos = ( ptP - ptD) * vtDir ;
|
||||
return ( dPos > -dR && dPos < dLen) ;
|
||||
return ( dPos > 0 && dPos < dLen) ;
|
||||
}
|
||||
// Altrimenti, recupero il punto del triangolo più vicino all'intersezione
|
||||
Point3d ptQ ;
|
||||
@@ -75,7 +89,7 @@ CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Tr
|
||||
if ( nLsRes != ILST_SEC)
|
||||
return false ;
|
||||
double dPos = ( ptQ - ptI1) * vtDir ;
|
||||
return ( dPos > -dR && dPos < dLen) ;
|
||||
return ( dPos > 0 && dPos < dLen) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
|
||||
+33
-53
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CDeRectPrismoidTria.h"
|
||||
#include "CDeCapsTria.h"
|
||||
#include "CDeBoxTria.h"
|
||||
#include "CDeCylTria.h"
|
||||
#include "CDeSpheTria.h"
|
||||
@@ -141,9 +142,13 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
|
||||
dHeight < EPS_SMALL || ! trTria.IsValid())
|
||||
return false ;
|
||||
|
||||
// Porto il triangolo nel riferimento del prismoide
|
||||
Triangle3d trTriaL = trTria ;
|
||||
trTriaL.ToLoc( frPrismoid) ;
|
||||
|
||||
// Se distanza di sicurezza nulla
|
||||
if ( dSafeDist < EPS_SMALL)
|
||||
return CDeSimpleRectPrismoidTria( frPrismoid, dLenghtBaseX, dLenghtBaseY, dLenghtTopX, dLenghtTopY, dHeight, trTria) ;
|
||||
return CDeSimpleRectPrismoidTria( Frame3d(), dLenghtBaseX, dLenghtBaseY, dLenghtTopX, dLenghtTopY, dHeight, trTriaL) ;
|
||||
|
||||
// Verifiche con offset esteso
|
||||
double dHDiffX = ( dLenghtBaseX - dLenghtTopX) / 2 ;
|
||||
@@ -156,37 +161,37 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
|
||||
double dSecAy = sqrt( 1 + dTgAy * dTgAy) ;
|
||||
double dOffsBaseY = dSafeDist * ( dSecAy + dTgAy) ;
|
||||
double dOffsTopY = dSafeDist * ( dSecAy - dTgAy) ;
|
||||
Frame3d frFrame = frPrismoid ; frFrame.Translate( - dSafeDist * frFrame.VersZ()) ;
|
||||
if ( ! CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX + 2 * dOffsBaseX, dLenghtBaseY + 2 * dOffsBaseY,
|
||||
dLenghtTopX + 2 * dOffsTopX, dLenghtTopY + 2 * dOffsTopY, dHeight + 2 * dSafeDist, trTria))
|
||||
Frame3d frTmp( Point3d( 0, 0, -dSafeDist)) ;
|
||||
if ( ! CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX + 2 * dOffsBaseX, dLenghtBaseY + 2 * dOffsBaseY,
|
||||
dLenghtTopX + 2 * dOffsTopX, dLenghtTopY + 2 * dOffsTopY, dHeight + 2 * dSafeDist, trTriaL))
|
||||
return false ;
|
||||
|
||||
// Offset fine
|
||||
// Box sotto
|
||||
frFrame = frPrismoid ; frFrame.Translate( - dSafeDist * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleBoxTria( frFrame, Vector3d( dLenghtBaseX, dLenghtBaseY, dSafeDist), trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, -dSafeDist)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, Vector3d( dLenghtBaseX, dLenghtBaseY, dSafeDist), trTriaL))
|
||||
return true ;
|
||||
// Box sopra
|
||||
frFrame = frPrismoid ; frFrame.Translate( dHeight * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleBoxTria( frFrame, Vector3d( dLenghtTopX, dLenghtTopY, dSafeDist), trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, dHeight)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, Vector3d( dLenghtTopX, dLenghtTopY, dSafeDist), trTriaL))
|
||||
return true ;
|
||||
// Prismoide allungato in X
|
||||
double dHypoX = sqrt( dHDiffX * dHDiffX + dHeight * dHeight) ;
|
||||
double dOffsX = dSafeDist * dHeight / dHypoX ;
|
||||
double dMoveXZ = dSafeDist * dHDiffX / dHypoX ;
|
||||
frFrame = frPrismoid ; frFrame.Translate( dMoveXZ * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX + 2 * dOffsX, dLenghtBaseY,
|
||||
dLenghtTopX + 2 * dOffsX, dLenghtTopY, dHeight, trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, dMoveXZ)) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX + 2 * dOffsX, dLenghtBaseY,
|
||||
dLenghtTopX + 2 * dOffsX, dLenghtTopY, dHeight, trTriaL))
|
||||
return true ;
|
||||
// Prismoide allungato in Y
|
||||
double dHypoY = sqrt( dHDiffY * dHDiffY + dHeight * dHeight) ;
|
||||
double dOffsY = dSafeDist * dHeight / dHypoY ;
|
||||
double dMoveYZ = dSafeDist * dHDiffY / dHypoY ;
|
||||
frFrame = frPrismoid ; frFrame.Translate( dMoveYZ * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX, dLenghtBaseY + 2 * dOffsY,
|
||||
dLenghtTopX, dLenghtTopY + 2 * dOffsY, dHeight, trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, dMoveYZ)) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX, dLenghtBaseY + 2 * dOffsY,
|
||||
dLenghtTopX, dLenghtTopY + 2 * dOffsY, dHeight, trTriaL))
|
||||
return true ;
|
||||
// Sfere centrate nei vertici
|
||||
// Vertici
|
||||
double dHalfBaseX = dLenghtBaseX / 2 ;
|
||||
double dHalfBaseY = dLenghtBaseY / 2 ;
|
||||
double dHalfTopX = dLenghtTopX / 2 ;
|
||||
@@ -199,55 +204,30 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
|
||||
Point3d( dHalfTopX, -dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, dHalfTopY, dHeight),
|
||||
Point3d( -dHalfTopX, dHalfTopY, dHeight)} ;
|
||||
for ( auto& ptV : vVert) {
|
||||
ptV.ToGlob( frPrismoid) ;
|
||||
if ( CDeSimpleSpheTria( ptV, dSafeDist, trTria))
|
||||
return true ;
|
||||
}
|
||||
// Cilindri con i segmenti come asse
|
||||
frFrame.Set( vVert[0], frPrismoid.VersX()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseX, trTria))
|
||||
// Capsule centrati sui dodici spigoli
|
||||
if ( CDeSimpleCapsTria( vVert[0], vVert[1], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[1], frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[1], vVert[2], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[2], -frPrismoid.VersX()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseX, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[2], vVert[3], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[3], -frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[3], vVert[0], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[4], frPrismoid.VersX()) ;
|
||||
if (CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopX, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[4], vVert[5], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[5], frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[5], vVert[6], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[6], -frPrismoid.VersX()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopX, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[6], vVert[7], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[7], -frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[7], vVert[4], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg04 = vVert[4] - vVert[0] ;
|
||||
double dLenSeg04 = vtSeg04.Len() ;
|
||||
frFrame.Set( vVert[0], vtSeg04) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg04, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[0], vVert[4], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg15 = vVert[5] - vVert[1] ;
|
||||
double dLenSeg15 = vtSeg15.Len() ;
|
||||
frFrame.Set( vVert[1], vtSeg15) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg15, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[1], vVert[5], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg26 = vVert[6] - vVert[2] ;
|
||||
double dLenSeg26 = vtSeg26.Len() ;
|
||||
frFrame.Set( vVert[2], vtSeg26) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg26, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[2], vVert[6], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg37 = vVert[7] - vVert[3] ;
|
||||
double dLenSeg37 = vtSeg37.Len();
|
||||
frFrame.Set( vVert[3], vtSeg37) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg37, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[3], vVert[7], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
|
||||
Binary file not shown.
@@ -331,6 +331,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="ExtDimension.cpp" />
|
||||
<ClCompile Include="HashGrids1d.cpp" />
|
||||
<ClCompile Include="IntersLineBox.cpp" />
|
||||
<ClCompile Include="IntersLineCaps.cpp" />
|
||||
<ClCompile Include="IntersLineCone.cpp" />
|
||||
<ClCompile Include="IntersLineCyl.cpp" />
|
||||
<ClCompile Include="IntersLineSphere.cpp" />
|
||||
@@ -601,6 +602,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="IntersCrvCompoCrvCompo.h" />
|
||||
<ClInclude Include="IntersLineArc.h" />
|
||||
<ClInclude Include="IntersLineBox.h" />
|
||||
<ClInclude Include="IntersLineCaps.h" />
|
||||
<ClInclude Include="IntersLineCone.h" />
|
||||
<ClInclude Include="IntersLineCyl.h" />
|
||||
<ClInclude Include="IntersLineLine.h" />
|
||||
|
||||
@@ -477,6 +477,9 @@
|
||||
<ClCompile Include="IntersLineCone.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineCaps.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -1115,6 +1118,9 @@
|
||||
<ClInclude Include="IntersLineCone.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IntersLineCaps.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
@@ -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 ;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2023-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLineCaps.h Data : 22.05.23 Versione : 2.5e4
|
||||
// Contenuto : Dichiarazione funzioni base per intersezione linea/capsule.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 22.05.23 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// 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) ;
|
||||
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "IntersLineCyl.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -116,3 +117,45 @@ IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e cilindro sono nel medesimo riferimento.
|
||||
// Il cilindro è definito con centro della base, asse, raggio e altezza.
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptCyl, const Vector3d& vtCyl, double dRad, double dHeight,
|
||||
double& dU1, double& dU2)
|
||||
{
|
||||
// Riferimento intrinseco del cilindro
|
||||
Frame3d frCyl ;
|
||||
if ( ! frCyl.Set( ptCyl, vtCyl))
|
||||
return false ;
|
||||
// Ora eseguo i conti nel riferimento intrinseco
|
||||
return IntersLineCyl( GetToLoc( ptL, frCyl), GetToLoc( vtL, frCyl), dRad, dHeight, dU1, dU2) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e cilindro sono nel medesimo riferimento.
|
||||
// Il cilindro è definito con centri delle due basi, e raggio.
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptCyl1, const Point3d& ptCyl2, double dRad,
|
||||
double& dU1, double& dU2)
|
||||
{
|
||||
// Determino asse ed altezza del cilindro
|
||||
Vector3d vtCyl = ptCyl2 - ptCyl1 ;
|
||||
double dHeight = vtCyl.Len() ;
|
||||
if ( dHeight < EPS_SMALL)
|
||||
return false ;
|
||||
vtCyl /= dHeight ;
|
||||
// Riferimento intrinseco del cilindro
|
||||
Frame3d frCyl ;
|
||||
if ( ! frCyl.Set( ptCyl1, vtCyl))
|
||||
return false ;
|
||||
// Ora eseguo i conti nel riferimento intrinseco
|
||||
return IntersLineCyl( GetToLoc( ptL, frCyl), GetToLoc( vtL, frCyl), dRad, dHeight, dU1, dU2) ;
|
||||
}
|
||||
|
||||
+21
-4
@@ -20,10 +20,9 @@
|
||||
// Il cilindro è centrato sull'asse Z e appoggiato sul piano XY.
|
||||
// Con intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dRad, double dHeight,
|
||||
double& dU1, double& dU2) ;
|
||||
bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dRad, double dHeight,
|
||||
double& dU1, double& dU2) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
@@ -33,3 +32,21 @@ TestIntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dU1, dU2 ;
|
||||
return IntersLineCyl( ptL, vtL, dRad, dHeight, dU1, dU2) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e cilindro sono nel medesimo riferimento.
|
||||
// Il cilindro è definito con centro della base, asse raggio e altezza.
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptCyl, const Vector3d& vtCyl, double dRad, double dHeight,
|
||||
double& dU1, double& dU2) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e cilindro sono nel medesimo riferimento.
|
||||
// Il cilindro è definito con centri delle due basi, e raggio.
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptCyl1, const Point3d& ptCyl2, double dRad,
|
||||
double& dU1, double& dU2) ;
|
||||
|
||||
Reference in New Issue
Block a user