From 30f39cd5b8e424f6f0a2c7ebf0645949ceda36f0 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 14 Nov 2016 06:23:46 +0000 Subject: [PATCH] Include : - aggiornamenti. --- EGkGeoConst.h | 2 ++ EGkPoint3d.h | 12 ++++++------ EGkTriangle3d.h | 4 ++-- EGkVector3d.h | 10 ++++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/EGkGeoConst.h b/EGkGeoConst.h index b0d4c90..a2fb01f 100644 --- a/EGkGeoConst.h +++ b/EGkGeoConst.h @@ -24,6 +24,8 @@ const double EPS_SMALL = 1e-3 ; const double EPS_ZERO = 1e-8 ; const double EPS_PARAM = 1e-8 ; const double SPAN_PARAM = 1.0 ; // intervallo di curva o superficie semplici +const double SQ_EPS_SMALL = EPS_SMALL * EPS_SMALL ; +const double SQ_EPS_ZERO = EPS_ZERO * EPS_ZERO ; // infinito per lunghezze const double INFINITO = 1e10 ; diff --git a/EGkPoint3d.h b/EGkPoint3d.h index 19cc175..f7ab7e7 100644 --- a/EGkPoint3d.h +++ b/EGkPoint3d.h @@ -44,10 +44,10 @@ class EGK_EXPORT Point3d public : //! Verifica se il punto è quasi l'origine bool IsSmall( void) const - { return ( ( x * x + y * y + z * z) < ( EPS_SMALL * EPS_SMALL)) ; } + { return ( ( x * x + y * y + z * z) < SQ_EPS_SMALL) ; } //! Verifica se il punto è esattamente l'origine bool IsZero( void) const - { return ( ( x * x + y * y + z * z) < ( EPS_ZERO * EPS_ZERO)) ; } + { return ( ( x * x + y * y + z * z) < SQ_EPS_ZERO) ; } //! Somma sul posto con un vettore Point3d& operator +=( const Vector3d& vtV) { this->x += vtV.x ; this->y += vtV.y ; this->z += vtV.z ; return *this ; } @@ -335,7 +335,7 @@ AreSamePointXYEpsilon( const Point3d& ptP1, const Point3d& ptP2, double dToler) inline bool AreSamePointApprox( const Point3d& ptP1, const Point3d& ptP2) { - return ( SqDist( ptP1, ptP2) < ( EPS_SMALL * EPS_SMALL)) ; + return ( SqDist( ptP1, ptP2) < SQ_EPS_SMALL) ; } //---------------------------------------------------------------------------- @@ -344,7 +344,7 @@ AreSamePointApprox( const Point3d& ptP1, const Point3d& ptP2) inline bool AreSamePointXYApprox( const Point3d& ptP1, const Point3d& ptP2) { - return ( SqDistXY( ptP1, ptP2) < ( EPS_SMALL * EPS_SMALL)) ; + return ( SqDistXY( ptP1, ptP2) < SQ_EPS_SMALL) ; } //---------------------------------------------------------------------------- @@ -353,7 +353,7 @@ AreSamePointXYApprox( const Point3d& ptP1, const Point3d& ptP2) inline bool AreSamePointExact( const Point3d& ptP1, const Point3d& ptP2) { - return ( SqDist( ptP1, ptP2) < ( EPS_ZERO * EPS_ZERO)) ; + return ( SqDist( ptP1, ptP2) < SQ_EPS_ZERO) ; } //---------------------------------------------------------------------------- @@ -362,5 +362,5 @@ AreSamePointExact( const Point3d& ptP1, const Point3d& ptP2) inline bool AreSamePointXYExact( const Point3d& ptP1, const Point3d& ptP2) { - return ( SqDistXY( ptP1, ptP2) < ( EPS_ZERO * EPS_ZERO)) ; + return ( SqDistXY( ptP1, ptP2) < SQ_EPS_ZERO) ; } diff --git a/EGkTriangle3d.h b/EGkTriangle3d.h index 2eb3763..1c8dbfb 100644 --- a/EGkTriangle3d.h +++ b/EGkTriangle3d.h @@ -71,7 +71,7 @@ class Triangle3d double dSqDistB = SqDist( ptP[1], ptP[2]) ; double dSqDistC = SqDist( ptP[2], ptP[0]) ; double dTwoArea = (( ptP[1] - ptP[0]) ^ ( ptP[2] - ptP[0])).Len() ; - if ( dTwoArea < EPS_SMALL * EPS_SMALL) + if ( dTwoArea < SQ_EPS_SMALL) return INFINITO ; else return ( (std::max)( dSqDistA, (std::max)( dSqDistB, dSqDistC)) / dTwoArea) ; @@ -179,7 +179,7 @@ BarycentricCoord( const Point3d& ptP, const Triangle3d& Tria, return false ; // verifico che l'area (doppia) non sia nulla double d2Area = TwoAreaInPlane( nPlane, Tria.GetP( 0), Tria.GetP( 1), Tria.GetP( 2)) ; - if ( fabs( d2Area) < EPS_SMALL * EPS_SMALL) + if ( fabs( d2Area) < SQ_EPS_SMALL) return false ; // calcolo delle coordinate baricentriche double dDenom = 1 / d2Area ; diff --git a/EGkVector3d.h b/EGkVector3d.h index fd173b5..40639f7 100644 --- a/EGkVector3d.h +++ b/EGkVector3d.h @@ -55,10 +55,16 @@ class EGK_EXPORT Vector3d double LenXY( void) const ; //! Verifica se il vettore è quasi nullo bool IsSmall( void) const - { return ( ( x * x + y * y + z * z) < ( EPS_SMALL * EPS_SMALL)) ; } + { return ( ( x * x + y * y + z * z) < SQ_EPS_SMALL) ; } //! Verifica se il vettore è esattamente nullo bool IsZero( void) const - { return ( ( x * x + y * y + z * z) < ( EPS_ZERO * EPS_ZERO)) ; } + { return ( ( x * x + y * y + z * z) < SQ_EPS_ZERO) ; } + //! Verifica se il vettore è quasi nullo nel piano XY + bool IsSmallXY( void) const + { return ( ( x * x + y * y) < SQ_EPS_SMALL) ; } + //! Verifica se il vettore è esattamente nullo nel piano XY + bool IsZeroXY( void) const + { return ( ( x * x + y * y) < SQ_EPS_ZERO) ; } //! Verifica se il vettore è normalizzato (è un versore) bool IsNormalized( void) const { return ( fabs( 1.0 - (x * x + y * y + z * z)) < ( 2 * EPS_ZERO)) ; }