From 1797f4cb3ea4f76e1ebacb99f1e8a0fc08704c6f Mon Sep 17 00:00:00 2001 From: frohlich Date: Sun, 2 May 2010 21:57:08 +0000 Subject: [PATCH] Use methods from SGMath when possible. Modified Files: src/Airports/apt_loader.cxx src/Navaids/positioned.cxx src/Navaids/positioned.hxx --- src/Airports/apt_loader.cxx | 1 + src/Navaids/positioned.cxx | 49 ++----------------------------------- src/Navaids/positioned.hxx | 4 +-- 3 files changed, 4 insertions(+), 50 deletions(-) diff --git a/src/Airports/apt_loader.cxx b/src/Airports/apt_loader.cxx index 8984214d9..e63e76b30 100644 --- a/src/Airports/apt_loader.cxx +++ b/src/Airports/apt_loader.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include diff --git a/src/Navaids/positioned.cxx b/src/Navaids/positioned.cxx index bbd044306..500de332b 100644 --- a/src/Navaids/positioned.cxx +++ b/src/Navaids/positioned.cxx @@ -30,11 +30,10 @@ #include #include -#include #include #include #include -#include +#include #include "positioned.hxx" @@ -55,27 +54,6 @@ namespace Octree const double LEAF_SIZE = SG_NM_TO_METER * 8.0; const double LEAF_SIZE_SQR = LEAF_SIZE * LEAF_SIZE; -typedef SGBox SGBoxd; - -template -inline bool -intersects(const SGVec3& v, const SGBox& box) -{ - if (v[0] < box.getMin()[0]) - return false; - if (box.getMax()[0] < v[0]) - return false; - if (v[1] < box.getMin()[1]) - return false; - if (box.getMax()[1] < v[1]) - return false; - if (v[2] < box.getMin()[2]) - return false; - if (box.getMax()[2] < v[2]) - return false; - return true; -} - /** * Decorate an object with a double value, and use that value to order * items, for the purpoises of the STL algorithms @@ -156,28 +134,11 @@ public: double distSqrToNearest(const SGVec3d& aPos) const { - return distSqr(aPos, getClosestPoint(aPos)); + return distSqr(aPos, _box.getClosestPoint(aPos)); } virtual void insert(FGPositioned* aP) = 0; - SGVec3d getClosestPoint(const SGVec3d& aPos) const - { - SGVec3d r; - - for (unsigned int i=0;i<3; ++i) { - if (aPos[i] < _box.getMin()[i]) { - r[i] = _box.getMin()[i]; - } else if (aPos[i] > _box.getMax()[i]) { - r[i] = _box.getMax()[i]; - } else { - r[i] = aPos[i]; - } - } // of axis iteration - - return r; - } - virtual void visit(const SGVec3d& aPos, double aCutoff, FGPositioned::Filter* aFilter, FindNearestResults& aResults, FindNearestPQueue&) = 0; @@ -728,12 +689,6 @@ FGPositioned::createUserWaypoint(const std::string& aIdent, const SGGeod& aPos) return new FGPositioned(WAYPOINT, aIdent, aPos, true); } -SGBucket -FGPositioned::bucket() const -{ - return SGBucket(mPosition); -} - SGVec3d FGPositioned::cart() const { diff --git a/src/Navaids/positioned.hxx b/src/Navaids/positioned.hxx index 37f8910c1..d5f9b3672 100644 --- a/src/Navaids/positioned.hxx +++ b/src/Navaids/positioned.hxx @@ -24,7 +24,7 @@ #include #include -#include +#include class FGPositioned; @@ -88,8 +88,6 @@ public: */ SGVec3d cart() const; - SGBucket bucket() const; - double latitude() const { return mPosition.getLatitudeDeg(); }