1
0
Fork 0

a better fix for the boundary box fix

This commit is contained in:
Peter Sadrozinski 2012-11-07 21:55:58 -05:00
parent c6d60ecd5b
commit 619bc7f1f7
2 changed files with 28 additions and 9 deletions

View file

@ -144,6 +144,8 @@ public:
bool IsWithin( Point3D min, Point3D max ) const; bool IsWithin( Point3D min, Point3D max ) const;
bool IsWithin( double xmin, double xmax, double ymin, double ymax ) const; bool IsWithin( double xmin, double xmax, double ymin, double ymax ) const;
bool IsAlmostWithin( Point3D min, Point3D max ) const;
bool IsAlmostWithin( double xmin, double xmax, double ymin, double ymax ) const;
#ifdef _MSC_VER #ifdef _MSC_VER
double round(double d) double round(double d)
@ -431,13 +433,6 @@ inline bool Point3D::HasElevation() const
inline bool Point3D::IsWithin( Point3D min, Point3D max ) const inline bool Point3D::IsWithin( Point3D min, Point3D max ) const
{ {
// make sure we take epsilon into account
min.n[PX] -= fgPoint3_Epsilon;
min.n[PY] -= fgPoint3_Epsilon;
max.n[PX] += fgPoint3_Epsilon;
max.n[PY] += fgPoint3_Epsilon;
return ( (min.n[PX] <= n[PX]) && (min.n[PY] <= n[PY]) && return ( (min.n[PX] <= n[PX]) && (min.n[PY] <= n[PY]) &&
(max.n[PX] >= n[PX]) && (max.n[PY] >= n[PY]) ); (max.n[PX] >= n[PX]) && (max.n[PY] >= n[PY]) );
} }
@ -455,6 +450,30 @@ inline bool Point3D::IsWithin( double xmin, double xmax, double ymin, double yma
(xmax >= n[PX]) && (ymax >= n[PY]) ); (xmax >= n[PX]) && (ymax >= n[PY]) );
} }
inline bool Point3D::IsAlmostWithin( Point3D min, Point3D max ) const
{
// make sure we take epsilon into account
min.n[PX] -= fgPoint3_Epsilon;
min.n[PY] -= fgPoint3_Epsilon;
max.n[PX] += fgPoint3_Epsilon;
max.n[PY] += fgPoint3_Epsilon;
return ( IsWithin(min, max) );
}
inline bool Point3D::IsAlmostWithin( double xmin, double xmax, double ymin, double ymax ) const
{
// make sure we take epsilon into account
xmin -= fgPoint3_Epsilon;
ymin -= fgPoint3_Epsilon;
xmax += fgPoint3_Epsilon;
ymax += fgPoint3_Epsilon;
return ( IsWithin( xmin, xmax, ymin,ymax ) );
}
// FRIENDS // FRIENDS
inline Point3D operator - (const Point3D& a) inline Point3D operator - (const Point3D& a)

View file

@ -239,11 +239,11 @@ point_list TGNodes::get_geod_inside( Point3D min, Point3D max ) const {
for ( ; current != last; ++current ) { for ( ; current != last; ++current ) {
Point3D pt = (*current).GetPosition(); Point3D pt = (*current).GetPosition();
if ( pt.IsWithin( min, max ) ) { if ( pt.IsAlmostWithin( min, max ) ) {
points.push_back( pt ); points.push_back( pt );
} else { } else {
if ( (pt < max) && (pt > min) ) { if ( (pt < max) && (pt > min) ) {
SG_LOG(SG_GENERAL, SG_ALERT, "pt " << pt << " failes IsWithin, but sholdn't have: min " << min << " max " << max ); SG_LOG(SG_GENERAL, SG_ALERT, "pt " << pt << " fails IsAlmostWithin, but sholdn't have: min " << min << " max " << max );
} }
} }
} }