EgtGeomKernel 1.3a1 : primo salvatraggio.
This commit is contained in:
+144
@@ -0,0 +1,144 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Point3d.cpp Data : 20.11.13 Versione : 1.3a1
|
||||
// Contenuto : Funzioni della classe Punto 3d.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 04.01.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "\EgtDev\Include\EGkPoint3d.h"
|
||||
#include "\EgtDev\Include\EGkFrame3d.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Traslazione
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Point3d::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
*this = *this + vtMove ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dall'asse al punto
|
||||
vtDiff = *this - ptAx ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
// rotazione del vettore
|
||||
if ( ! vtDiff.Rotate( vtAx, dCosAng, dSinAng))
|
||||
return false ;
|
||||
|
||||
// ricostruisco il punto
|
||||
*this = ptAx + vtDiff ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Scalatura non uniforme
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Scale( const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dal centro al punto
|
||||
vtDiff = *this - ptCen ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
// scalatura del vettore
|
||||
if ( ! vtDiff.Scale( dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
|
||||
// ricostruisco il punto
|
||||
*this = ptCen + vtDiff ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Specchiatura
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dal riferimento al punto
|
||||
vtDiff = *this - ptOn ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
// specchiatura del vettore
|
||||
if ( ! vtDiff.Mirror( vtNorm))
|
||||
return false ;
|
||||
|
||||
// ricostruisco il punto
|
||||
*this = ptOn + vtDiff ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal riferimento al globale
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
Point3d ptT( x, y, z) ;
|
||||
|
||||
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// eseguo trasformazione
|
||||
x = ptT.x * frRef.VersX().x + ptT.y * frRef.VersY().x + ptT.z * frRef.VersZ().x + frRef.Orig().x ;
|
||||
y = ptT.x * frRef.VersX().y + ptT.y * frRef.VersY().y + ptT.z * frRef.VersZ().y + frRef.Orig().y ;
|
||||
z = ptT.x * frRef.VersX().z + ptT.y * frRef.VersY().z + ptT.z * frRef.VersZ().z + frRef.Orig().z ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal globale al riferimento
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
Vector3d vtT( x - frRef.Orig().x, y - frRef.Orig().y, z - frRef.Orig().z) ;
|
||||
|
||||
x = vtT.x * frRef.VersX().x + vtT.y * frRef.VersX().y + vtT.z * frRef.VersX().z ;
|
||||
y = vtT.x * frRef.VersY().x + vtT.y * frRef.VersY().y + vtT.z * frRef.VersY().z ;
|
||||
z = vtT.x * frRef.VersZ().x + vtT.y * frRef.VersZ().y + vtT.z * frRef.VersZ().z ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user