diff --git a/src/Lib/Geometry/poly_support.cxx b/src/Lib/Geometry/poly_support.cxx index 29d27a2b..ea699e3c 100644 --- a/src/Lib/Geometry/poly_support.cxx +++ b/src/Lib/Geometry/poly_support.cxx @@ -764,9 +764,7 @@ static Point3D point_inside_contour( FGContourNode *node, const FGPolygon &p ) { Point3D p1 = out_pts[ t.get_n1() ]; Point3D p2 = out_pts[ t.get_n2() ]; Point3D p3 = out_pts[ t.get_n3() ]; - double area = fabs(0.5 * ( p1.x() * p2.y() - p2.x() * p1.y() + - p2.x() * p3.y() - p3.x() * p2.y() + - p3.x() * p1.y() - p1.x() * p3.y() )); + double area = triangle_area( p1, p2, p3 ); if ( area > max_area ) { max_area = area; biggest = i; @@ -991,8 +989,8 @@ bool find_intermediate_node( const Point3D& start, const Point3D& end, Point3D p1 = end; // cout << " add_intermediate_nodes()" << endl; - printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n", - p0.x(), p0.y(), p0.z(), p1.x(), p1.y(), p1.z() ); + // printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n", + // p0.x(), p0.y(), p0.z(), p1.x(), p1.y(), p1.z() ); double xdist = fabs(p0.x() - p1.x()); double ydist = fabs(p0.y() - p1.y()); diff --git a/src/Lib/Geometry/poly_support.hxx b/src/Lib/Geometry/poly_support.hxx index bf2ddda7..88eec7f9 100644 --- a/src/Lib/Geometry/poly_support.hxx +++ b/src/Lib/Geometry/poly_support.hxx @@ -40,6 +40,17 @@ #include "trinodes.hxx" +// Calculate the area of a triangle +inline double triangle_area( const Point3D p1, + const Point3D p2, + const Point3D p3 ) +{ + return fabs(0.5 * ( p1.x() * p2.y() - p2.x() * p1.y() + + p2.x() * p3.y() - p3.x() * p2.y() + + p3.x() * p1.y() - p1.x() * p3.y() )); +} + + // basic triangulation of a polygon with out adding points or // splitting edges void polygon_tesselate( const FGPolygon &p, diff --git a/src/Lib/Polygon/polygon.cxx b/src/Lib/Polygon/polygon.cxx index 5b93e407..86a61e22 100644 --- a/src/Lib/Polygon/polygon.cxx +++ b/src/Lib/Polygon/polygon.cxx @@ -160,11 +160,11 @@ bool FGPolygon::is_inside( int a, int b ) const { // B is "inside" A if the polygon_diff( B, A ) is not null. FGPolygon result = polygon_diff( B, A ); if ( result.contours() == 0 ) { - cout << " is_inside() result = true" << endl; + // cout << " is_inside() result = true" << endl; return true; } - cout << " is_inside() result = false" << endl; + // cout << " is_inside() result = false" << endl; return false; }