Files
EgtGeomKernel/CurveAux.cpp
T
Dario Sassi 81a1e3d994 EgtGeomKernel : completata gestione DB geometrico di base.
Aggiunto esecutore di comandi per script.
2013-11-26 15:00:46 +00:00

83 lines
2.3 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : CurveAux.cpp Data : 22.11.13 Versione : 1.3a1
// Contenuto : Implementazione di alcune funzioni di utilità per le curve.
//
//
//
// Modifiche : 22.11.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "CurveAux.h"
//----------------------------------------------------------------------------
bool
IsClosed( const ICurve& crvC)
{
Point3d ptStart ;
Point3d ptEnd ;
return ( crvC.GetStartPoint( ptStart) && crvC.GetEndPoint( ptEnd) && AreSamePointNear( ptStart, ptEnd)) ;
}
//----------------------------------------------------------------------------
bool
GetPoint( const ICurve& crvC, double dU, Point3d& ptPos)
{
Vector3d vtDer1 ;
Vector3d vtDer2 ;
return crvC.GetPointD1D2( dU, ptPos, vtDer1, vtDer2) ;
}
//----------------------------------------------------------------------------
bool
GetPointTang( const ICurve& crvC, double dU, Point3d& ptPos, Vector3d& vtTang)
{
Vector3d vtDer2 ;
if ( ! crvC.GetPointD1D2( dU, ptPos, vtTang, vtDer2))
return false ;
return ( vtTang.Normalize()) ;
}
//----------------------------------------------------------------------------
bool
GetPointTangNormCurv( const ICurve& crvC, double dU, Point3d& ptPos, Vector3d& vtT, Vector3d& vtN, double& dCurv)
{
double dLenSqD1 ;
Vector3d vtDer2 ;
if ( ! crvC.GetPointD1D2( dU, ptPos, vtT, vtDer2))
return false ;
// se esiste la derivata prima non nulla
dLenSqD1 = vtT.LenSq() ;
if ( vtT.Normalize()) {
// del vettore deriv2^ tengo la sola componente perpendicolare al vettore tangente
vtN = vtDer2 - ( vtDer2 * vtT) * vtT ;
if ( vtN.Normalize())
dCurv = ( vtT ^ vtDer2).Len() / dLenSqD1 ;
else
dCurv = 0 ;
}
else {
// se esiste derivata seconda non nulla, definisce la tangente
if ( vtDer2.Normalize())
vtT = vtDer2 ;
vtN.Set( 0, 0, 0) ;
dCurv = 0 ;
}
return true ;
}