EgtGeomKernel 1.5f4 :

- aggiunto punto base a GeoVector3d
- aggiunta creazione linea Pt+TgArc e Tg2Arcs
- aggiunta creazione arco Cen+TgArc e PDi + TgArc
- aggiunta a tutte le curve funzione IsPointOn
- aggiunta CurveLine e CurveArc la funzione Offset
- ottimizzata rotazione Vector3d attorno ad assi canonici
- corretta emissione Group e Frame in OutTsc.
This commit is contained in:
Dario Sassi
2014-06-14 18:03:04 +00:00
parent e9d45f84df
commit 26c2ad702a
21 changed files with 1537 additions and 209 deletions
+68 -13
View File
@@ -75,14 +75,11 @@ Vector3d::Len( void) const
void
Vector3d::ToSpherical( double* pdLen, double* pdAngVertDeg, double* pdAngOrizzDeg) const
{
double dLen ;
// lunghezza
double dLen = Len() ;
// angoli
double dAngVertDeg ;
double dAngOrizzDeg ;
// lunghezza
dLen = Len() ;
// se vettore nullo
if ( dLen < EPS_ZERO) {
dAngVertDeg = 0 ;
@@ -126,21 +123,17 @@ Vector3d::ToSpherical( double* pdLen, double* pdAngVertDeg, double* pdAngOrizzDe
bool
Vector3d::Normalize( double dEps)
{
double dSqLen ;
double dLen ;
// se già normalizzato, ok
dSqLen = x * x + y * y + z * z ;
double dSqLen = x * x + y * y + z * z ;
if ( fabs( 1.0 - dSqLen) < ( 2 * EPS_ZERO))
return true ;
// se troppo piccolo, errore
if ( fabs( dSqLen) < ( dEps * dEps))
if ( dSqLen < ( dEps * dEps))
return false ;
// eseguo la normalizzazione
dLen = sqrt( dSqLen) ;
double dLen = sqrt( dSqLen) ;
*this = *this / dLen ;
return true ;
@@ -167,6 +160,68 @@ Vector3d::Rotate( const Vector3d& vtAx, double dCosAng, double dSinAng)
if ( ! vtDirAx.Normalize())
return false ;
// se rotazione attorno all'asse Z+
if ( vtAx.IsZplus()) {
// salvo i componenti originali
double dX = x ;
double dY = y ;
// calcolo i nuovi componenti ruotati
x = dCosAng * dX - dSinAng * dY ;
y = dSinAng * dX + dCosAng * dY ;
return true ;
}
// se rotazione attorno all'asse Z-
else if ( vtAx.IsZminus()) {
// salvo i componenti originali
double dX = x ;
double dY = y ;
// calcolo i nuovi componenti ruotati
x = dCosAng * dX + dSinAng * dY ;
y = - dSinAng * dX + dCosAng * dY ;
return true ;
}
// se rotazione attorno all'asse X+
else if ( vtAx.IsXplus()) {
// salvo i componenti originali
double dY = y ;
double dZ = z ;
// calcolo i nuovi componenti ruotati
y = dCosAng * dY - dSinAng * dZ ;
z = dSinAng * dY + dCosAng * dZ ;
return true ;
}
// se rotazione attorno all'asse X-
else if ( vtAx.IsXminus()) {
// salvo i componenti originali
double dY = y ;
double dZ = z ;
// calcolo i nuovi componenti ruotati
y = dCosAng * dY + dSinAng * dZ ;
z = - dSinAng * dY + dCosAng * dZ ;
return true ;
}
// se rotazione attorno all'asse Y+
else if ( vtAx.IsYplus()) {
// salvo i componenti originali
double dZ = z ;
double dX = x ;
// calcolo i nuovi componenti ruotati
z = dCosAng * dZ - dSinAng * dX ;
x = dSinAng * dZ + dCosAng * dX ;
return true ;
}
// se rotazione attorno all'asse Y-
else if ( vtAx.IsYminus()) {
// salvo i componenti originali
double dZ = z ;
double dX = x ;
// calcolo i nuovi componenti ruotati
z = dCosAng * dZ + dSinAng * dX ;
x = - dSinAng * dZ + dCosAng * dX ;
return true ;
}
// rotazione attorno ad un asse generico
// separazione del vettore nelle componenti parallela e perp. asse
double dCompPar = *this * vtDirAx ;
Vector3d vtCompPar = vtDirAx * dCompPar ;