Skip to content
Snippets Groups Projects
Commit 4feda7ef authored by Tom Fischer's avatar Tom Fischer
Browse files

[MaL/GL] Mv calcTriangleArea() from GL to MaL.

parent 2d1ad723
No related branches found
No related tags found
No related merge requests found
......@@ -321,15 +321,6 @@ bool barycentricPointInTriangle(MathLib::Point3d const& p,
return true;
}
double calcTriangleArea(MathLib::Point3d const& a,
MathLib::Point3d const& b, MathLib::Point3d const& c)
{
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();
}
void computeRotationMatrixToXZ(MathLib::Vector3 const& plane_normal, MathLib::DenseMatrix<double> & rot_mat)
{
// *** some frequently used terms ***
......
......@@ -176,14 +176,6 @@ MathLib::DenseMatrix<double> rotatePointsToXY(InputIterator1 p_pnts_begin,
*/
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(MathLib::Point3d const& a, MathLib::Point3d const& b,
MathLib::Point3d const& c);
/**
* Tests if the given point p is within the triangle, defined by its edge nodes a, b and c.
* Using two eps-values it is possible to test an 'epsilon' neighbourhood around the triangle
......
......@@ -20,6 +20,8 @@
#include "GeoLib/Surface.h"
#include "GeoLib/Triangle.h"
#include "MathLib/GeometricBasics.h"
namespace GeoLib
{
namespace IO
......@@ -92,7 +94,7 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname,
// check area of triangle
double const d_eps(std::numeric_limits<double>::epsilon());
if (GeoLib::calcTriangleArea(p0, p1, p2) < d_eps) {
if (MathLib::calcTriangleArea(p0, p1, p2) < d_eps) {
ERR("readTIN: Triangle %d has zero area.", id);
if (errors)
errors->push_back (std::string("readTIN: Triangle ")
......
......@@ -36,6 +36,15 @@ double calcTetrahedronVolume(MathLib::Point3d const& a,
return std::abs(MathLib::scalarTriple(ac, ad, ab)) / 6.0;
}
double calcTriangleArea(MathLib::Point3d const& a, MathLib::Point3d const& b,
MathLib::Point3d const& c)
{
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();
}
bool isPointInTetrahedron(MathLib::Point3d const& p, MathLib::Point3d const& a,
MathLib::Point3d const& b, MathLib::Point3d const& c,
MathLib::Point3d const& d, double eps)
......
......@@ -45,6 +45,15 @@ double calcTetrahedronVolume(MathLib::Point3d const& x1,
MathLib::Point3d const& x2,
MathLib::Point3d const& x3,
MathLib::Point3d const& x4);
/**
* 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(MathLib::Point3d const& a, MathLib::Point3d const& b,
MathLib::Point3d const& c);
/**
* Tests if the given point p is located within a tetrahedron spanned by points
* a, b, c, d.
......
......@@ -12,6 +12,7 @@
#include "logog/include/logog.hpp"
#include "GeoLib/AnalyticalGeometry.h"
#include "MathLib/GeometricBasics.h"
#include "MeshLib/Node.h"
......@@ -27,8 +28,8 @@ const unsigned QuadRule4::edge_nodes[4][2] =
double QuadRule4::computeVolume(Node const* const* _nodes)
{
return GeoLib::calcTriangleArea(*_nodes[0], *_nodes[1], *_nodes[2])
+ GeoLib::calcTriangleArea(*_nodes[2], *_nodes[3], *_nodes[0]);
return MathLib::calcTriangleArea(*_nodes[0], *_nodes[1], *_nodes[2])
+ MathLib::calcTriangleArea(*_nodes[2], *_nodes[3], *_nodes[0]);
}
bool QuadRule4::isPntInElement(Node const* const* _nodes, MathLib::Point3d const& pnt, double eps)
......
......@@ -12,6 +12,7 @@
#include "logog/include/logog.hpp"
#include "GeoLib/AnalyticalGeometry.h"
#include "MathLib/GeometricBasics.h"
#include "MeshLib/Node.h"
......@@ -26,7 +27,7 @@ const unsigned TriRule3::edge_nodes[3][2] =
double TriRule3::computeVolume(Node const* const* _nodes)
{
return GeoLib::calcTriangleArea(*_nodes[0], *_nodes[1], *_nodes[2]);
return MathLib::calcTriangleArea(*_nodes[0], *_nodes[1], *_nodes[2]);
}
bool TriRule3::isPntInElement(Node const* const* _nodes, MathLib::Point3d const& pnt, double eps)
......
......@@ -17,10 +17,11 @@
#include <cassert>
#include <numeric>
#include "MathLib/Vector3.h"
#include "GeoLib/Surface.h"
#include "GeoLib/Triangle.h"
#include "GeoLib/AnalyticalGeometry.h"
#include "MathLib/Vector3.h"
#include "MathLib/GeometricBasics.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Node.h"
#include "MeshGeoToolsLib/MeshNodesAlongSurface.h"
......@@ -77,7 +78,7 @@ double LinearInterpolationOnSurface::interpolateInTri(
GeoLib::Point const& v2(pnts[1]);
GeoLib::Point const& v3(pnts[2]);
GeoLib::Point const& v_pnt(pnts[3]);
const double area = GeoLib::calcTriangleArea(v1, v2, v3);
const double area = MathLib::calcTriangleArea(v1, v2, v3);
if (area==.0) {
// take average if all points have the same coordinates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment