fcd7fab8a8
- modifiche a Vector3d e Point3d - migliorie a FromString - aggiunta struttura Plane3d - migliorie varie.
60 lines
2.0 KiB
C++
60 lines
2.0 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : EGkTria3d.h Data : 30.03.14 Versione : 1.5c9
|
|
// Contenuto : Dichiarazione classe triangolo Triangle3d.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 30.03.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "/EgtDev/Include/EGkPoint3d.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
class Triangle3d
|
|
{
|
|
public :
|
|
Triangle3d( void)
|
|
{}
|
|
void Set( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2)
|
|
{ ptP[0] = ptP0 ; ptP[1] = ptP1 ; ptP[2] = ptP2 ; vtN.Set( 0, 0, 0) ; }
|
|
void Set( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV)
|
|
{ ptP[0] = ptP0 ; ptP[1] = ptP1 ; ptP[2] = ptP2 ; vtN = vtV ; }
|
|
bool Validate( void)
|
|
{ if ( AreSamePointNear( ptP[0], ptP[1]) || AreSamePointNear( ptP[0], ptP[2]))
|
|
return false ;
|
|
Vector3d vtV = ( ptP[1] - ptP[0]) ^ ( ptP[2] - ptP[0]) ;
|
|
vtV.Normalize() ;
|
|
if ( ! vtN.IsZero())
|
|
return AreSameVectorNear( vtV, vtN) ;
|
|
vtN = vtV ;
|
|
return true ;
|
|
}
|
|
const Point3d& GetP( int nId) const
|
|
{ if ( nId >= 0 && nId < 3)
|
|
return ptP[nId] ;
|
|
else if ( nId < 0)
|
|
return ptP[0] ;
|
|
else
|
|
return ptP[2] ;
|
|
}
|
|
const Vector3d& GetN( void) const
|
|
{ return vtN ; }
|
|
|
|
private :
|
|
Point3d ptP[3] ;
|
|
Vector3d vtN ;
|
|
} ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
class TriNormals3d
|
|
{
|
|
public :
|
|
Vector3d vtN[3] ;
|
|
} ;
|