diff --git a/quality/inc/gmds/quality/QuadQuality.h b/quality/inc/gmds/quality/QuadQuality.h index e408facb1..323f694f4 100644 --- a/quality/inc/gmds/quality/QuadQuality.h +++ b/quality/inc/gmds/quality/QuadQuality.h @@ -31,6 +31,7 @@ struct GMDSQuality_API QuadQuality double angleDeviation() const; double minAngle() const; double maxAngle() const; + double skew() const; math::Vector3d L0() const { return p[1]- p[0];} math::Vector3d L1() const { return p[2]- p[1];} diff --git a/quality/src/HexQuality.cpp b/quality/src/HexQuality.cpp index aa8e075f2..22022865b 100644 --- a/quality/src/HexQuality.cpp +++ b/quality/src/HexQuality.cpp @@ -186,9 +186,9 @@ double HexQuality::skew() const { return 0; double sk[3] ={ - std::fabs(X1().dot(X2())), - std::fabs(X1().dot(X3())), - std::fabs(X2().dot(X3()))}; + std::fabs(X1().normalize().dot(X2().normalize())), + std::fabs(X1().normalize().dot(X3().normalize())), + std::fabs(X2().normalize().dot(X3().normalize()))}; return *std::max_element(sk,sk+3); } diff --git a/quality/src/QuadQuality.cpp b/quality/src/QuadQuality.cpp index 7c2654be7..8a7b5212a 100644 --- a/quality/src/QuadQuality.cpp +++ b/quality/src/QuadQuality.cpp @@ -79,3 +79,15 @@ QuadQuality::maxAngle() const { throw GMDSException("Not yet implemented!"); } /*---------------------------------------------------------------------------*/ +double +QuadQuality::skew() const { + + if(X1().norm() <= std::numeric_limits::min()) + return 0; + if(X2().norm() <= std::numeric_limits::min()) + return 0; + + return std::fabs(X1().normalize().dot(X2().normalize())); +} + +/*---------------------------------------------------------------------------*/ \ No newline at end of file diff --git a/quality/tst/HexEvalTestSuite.h b/quality/tst/HexEvalTestSuite.h index 6d63f3151..93a3515b0 100644 --- a/quality/tst/HexEvalTestSuite.h +++ b/quality/tst/HexEvalTestSuite.h @@ -76,3 +76,18 @@ TEST(HexQualityTestClass, test2) ASSERT_NEAR(he.taper(), 0, 0.01); } +/*----------------------------------------------------------------------------*/ +TEST(HexQualityTestClass, test3) +{ + HexQuality he = HexQuality::build(math::Point(188,28,29), + math::Point(191,28,29), + math::Point(191,31,26), + math::Point(188,31,26), + math::Point(188,27,28), + math::Point(191,27,28), + math::Point(191,29,25), + math::Point(188,29,25)); + + ASSERT_NEAR(he.skew(), 0.106, 0.01); + +} diff --git a/quality/tst/QuadEvalTestSuite.h b/quality/tst/QuadEvalTestSuite.h index 13013a6fe..7640f4130 100644 --- a/quality/tst/QuadEvalTestSuite.h +++ b/quality/tst/QuadEvalTestSuite.h @@ -34,6 +34,7 @@ TEST(QuadQualityTestClass, test1) ASSERT_NEAR(qe.aspectRatio(),1,0.01); ASSERT_NEAR(qe.signedArea(),1,0.01); ASSERT_NEAR(qe.angleDeviation(),0,0.01); + ASSERT_NEAR(qe.skew(),0,0.01); QuadQuality qe2 = QuadQuality::build(math::Point(0,0,0), math::Point(2,0,0), @@ -50,5 +51,12 @@ TEST(QuadQualityTestClass, test1) ASSERT_NEAR(qe2.aspectRatio(),6,0.01); ASSERT_NEAR(qe2.signedArea(),2,0.01); ASSERT_NEAR(qe2.angleDeviation(),0,0.01); + ASSERT_NEAR(qe2.skew(),0,0.01); + + QuadQuality qe3 = QuadQuality::build(math::Point(0,0,0), + math::Point(2,0,0), + math::Point(2,1,0), + math::Point(1,1,0)); + ASSERT_NEAR(qe3.skew(),0.447,0.01); }