From d4ed39eb56e07a95f27740d3b1d25cf9475fb945 Mon Sep 17 00:00:00 2001 From: Claire Roche Date: Thu, 4 Jul 2024 14:53:22 +0200 Subject: [PATCH] - Add skew function to QuadQuality - Add unit test to QuadQuality for skew function --- quality/inc/gmds/quality/QuadQuality.h | 1 + quality/src/QuadQuality.cpp | 12 ++++++++++++ quality/tst/QuadEvalTestSuite.h | 8 ++++++++ 3 files changed, 21 insertions(+) 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/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/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); }