9ad9339af0
- aggiunto import BTL.
103 lines
4.2 KiB
C++
103 lines
4.2 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : EGkPlane3d.h Data : 25.02.15 Versione : 1.6b7
|
|
// Contenuto : Dichiarazione classe piano Plane3d.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 08.04.14 DS Creazione modulo.
|
|
// 25.02.15 DS Agg. PointInPlane*.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "/EgtDev/Include/EGkFrame3d.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
class Plane3d
|
|
{
|
|
public :
|
|
Vector3d vtN ;
|
|
double dDist ;
|
|
|
|
public :
|
|
void Translate( const Vector3d& vtMove)
|
|
{ Point3d ptP = ORIG + dDist * vtN ;
|
|
ptP.Translate( vtMove) ;
|
|
dDist = ( ptP - ORIG) * vtN ; }
|
|
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
|
{ double dAngRad = dAngDeg * DEGTORAD ;
|
|
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
|
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
|
{ Point3d ptP = ORIG + dDist * vtN ;
|
|
if ( ! ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) || ! vtN.Rotate( vtAx, dCosAng, dSinAng))
|
|
return false ;
|
|
dDist = ( ptP - ORIG) * vtN ;
|
|
return true ; }
|
|
bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
|
{ Point3d ptP = ORIG + dDist * vtN ;
|
|
Frame3d frOCS ;
|
|
if ( ! frOCS.Set( ptP, vtN) || ! frOCS.PseudoScale( frRef, dCoeffX, dCoeffY, dCoeffZ))
|
|
return false ;
|
|
vtN = frOCS.VersZ() ;
|
|
dDist = ( frOCS.Orig() - ORIG) * vtN ;
|
|
return true ; }
|
|
bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
|
{ Point3d ptP = ORIG + dDist * vtN ;
|
|
if ( ! ptP.Mirror( ptOn, vtNorm) || ! vtN.Mirror( vtNorm))
|
|
return false ;
|
|
dDist = ( ptP - ORIG) * vtN ;
|
|
return true ; }
|
|
bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
|
{ Point3d ptP = ORIG + dDist * vtN ;
|
|
Frame3d frOCS ;
|
|
if ( ! frOCS.Set( ptP, vtN) || ! frOCS.PseudoShear( ptOn, vtNorm, vtDir, dCoeff))
|
|
return false ;
|
|
vtN = frOCS.VersZ() ;
|
|
dDist = ( frOCS.Orig() - ORIG) * vtN ;
|
|
return true ; }
|
|
bool ToGlob( const Frame3d& frRef)
|
|
{ Point3d ptP = ORIG + dDist * vtN ;
|
|
if ( ! ptP.ToGlob( frRef) || ! vtN.ToGlob( frRef))
|
|
return false ;
|
|
dDist = ( ptP - ORIG) * vtN ;
|
|
return true ; }
|
|
bool ToLoc( const Frame3d& frRef)
|
|
{ Point3d ptP = ORIG + dDist * vtN ;
|
|
if ( ! ptP.ToLoc( frRef) || ! vtN.ToLoc( frRef))
|
|
return false ;
|
|
dDist = ( ptP - ORIG) * vtN ;
|
|
return true ; }
|
|
bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
|
{ if ( AreSameFrame( frOri, frDest))
|
|
return true ;
|
|
return ( ToGlob( frOri) && ToLoc( frDest)) ; }
|
|
} ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
inline bool
|
|
SetPlane( const Point3d& ptP, const Vector3d& vtN, Plane3d& plPlane)
|
|
{
|
|
plPlane.vtN = vtN ;
|
|
if ( ! plPlane.vtN.Normalize())
|
|
return false ;
|
|
plPlane.dDist = ( ptP - ORIG) * plPlane.vtN ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
inline bool
|
|
PointInPlaneApprox( const Point3d& ptP, const Plane3d& plPlane)
|
|
{
|
|
return ( fabs( (( ptP - ORIG) * plPlane.vtN) - plPlane.dDist) < EPS_SMALL) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
inline bool
|
|
PointInPlaneExact( const Point3d& ptP, const Plane3d& plPlane)
|
|
{
|
|
return ( fabs( (( ptP - ORIG) * plPlane.vtN) - plPlane.dDist) < EPS_ZERO) ;
|
|
}
|