Files
EgtGeomKernel/CurveAux.cpp
T
2013-11-22 21:16:56 +00:00

75 lines
2.1 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 ;
dLenSqD1 = vtT.LenSq() ;
if ( ! vtT.Normalize())
return false ;
// del vettore deriv2^ tengo la sola componente perpendicolare al vettore tangente
vtN = vtDer2 - ( vtDer2 * vtT) * vtT ;
if ( ! vtN.Normalize())
return false ;
// curvatura
dCurv = ( vtT ^ vtDer2).Len() / dLenSqD1 ;
return true ;
}