1
0
Fork 0

Added a routine to calculate triangle area.

Cleaned up some debugging output.
This commit is contained in:
curt 2000-11-22 20:42:18 +00:00
parent 59a35fbe8a
commit a115f756c7
3 changed files with 16 additions and 7 deletions

View file

@ -764,9 +764,7 @@ static Point3D point_inside_contour( FGContourNode *node, const FGPolygon &p ) {
Point3D p1 = out_pts[ t.get_n1() ]; Point3D p1 = out_pts[ t.get_n1() ];
Point3D p2 = out_pts[ t.get_n2() ]; Point3D p2 = out_pts[ t.get_n2() ];
Point3D p3 = out_pts[ t.get_n3() ]; Point3D p3 = out_pts[ t.get_n3() ];
double area = fabs(0.5 * ( p1.x() * p2.y() - p2.x() * p1.y() + double area = triangle_area( p1, p2, p3 );
p2.x() * p3.y() - p3.x() * p2.y() +
p3.x() * p1.y() - p1.x() * p3.y() ));
if ( area > max_area ) { if ( area > max_area ) {
max_area = area; max_area = area;
biggest = i; biggest = i;
@ -991,8 +989,8 @@ bool find_intermediate_node( const Point3D& start, const Point3D& end,
Point3D p1 = end; Point3D p1 = end;
// cout << " add_intermediate_nodes()" << endl; // cout << " add_intermediate_nodes()" << endl;
printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n", // printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n",
p0.x(), p0.y(), p0.z(), p1.x(), p1.y(), p1.z() ); // p0.x(), p0.y(), p0.z(), p1.x(), p1.y(), p1.z() );
double xdist = fabs(p0.x() - p1.x()); double xdist = fabs(p0.x() - p1.x());
double ydist = fabs(p0.y() - p1.y()); double ydist = fabs(p0.y() - p1.y());

View file

@ -40,6 +40,17 @@
#include "trinodes.hxx" #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 // basic triangulation of a polygon with out adding points or
// splitting edges // splitting edges
void polygon_tesselate( const FGPolygon &p, void polygon_tesselate( const FGPolygon &p,

View file

@ -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. // B is "inside" A if the polygon_diff( B, A ) is not null.
FGPolygon result = polygon_diff( B, A ); FGPolygon result = polygon_diff( B, A );
if ( result.contours() == 0 ) { if ( result.contours() == 0 ) {
cout << " is_inside() result = true" << endl; // cout << " is_inside() result = true" << endl;
return true; return true;
} }
cout << " is_inside() result = false" << endl;
// cout << " is_inside() result = false" << endl;
return false; return false;
} }