diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index ee398e49ecd1ee062c66e5956a7ffedd8d1f4b20..b8fa5b673470556943795b1fb9d4b272e3ad10c1 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -229,14 +229,12 @@ bool isPointInTriangle(GeoLib::Point const& q, return false; } - -static -double getOrientedTriArea(GeoLib::Point const& a, GeoLib::Point const& b, GeoLib::Point const& c) +double calcTriangleArea(GeoLib::Point const& a, GeoLib::Point const& b, GeoLib::Point const& c) { - const MathLib::Vector3 u(a,c); - const MathLib::Vector3 v(a,b); - const MathLib::Vector3 w(MathLib::crossProduct(u, v)); - return 0.5 * sqrt(MathLib::scalarProduct(w, w)); + MathLib::Vector3 const u(a,c); + MathLib::Vector3 const v(a,b); + MathLib::Vector3 const w(MathLib::crossProduct(u, v)); + return 0.5 * w.getLength(); } // NewellPlane from book Real-Time Collision detection p. 494 diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h index 123034a74c75b205e06fbc676ddc720c5b2d83ef..1a6b1a48d9dd33275de281d3b8fc77d547cf23ae 100644 --- a/GeoLib/AnalyticalGeometry.h +++ b/GeoLib/AnalyticalGeometry.h @@ -98,6 +98,13 @@ void rotatePointsToXY(std::vector<GeoLib::Point*> &pnts); */ void rotatePointsToXZ(std::vector<GeoLib::Point*> &pnts); +/** + * Calculates the area of the triangle defined by its edge nodes a, b and c.. + * The formula is \f$A= \frac{1}{2} \cdot |u \times v|\f$, i.e. half of the area of the + * parallelogram specified by the vectors\f$u=b-a\f$ and \f$v=c-a\f. + */ +double calcTriangleArea(GeoLib::Point const& a, GeoLib::Point const& b, GeoLib::Point const& c); + bool isPointInTriangle (const GeoLib::Point* p, const GeoLib::Point* a, const GeoLib::Point* b, const GeoLib::Point* c);