diff --git a/CoordTopographic.cpp b/CoordTopographic.cpp deleted file mode 100644 index 873c8a5..0000000 --- a/CoordTopographic.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "CoordTopographic.h" - -#include "Globals.h" - -#include -#include - -CoordTopographic::CoordTopographic(const CoordTopographic& b) { - - azimuth = b.azimuth; - elevation = b.elevation; - range = b.range; - range_rate = b.range_rate; -} - -CoordTopographic& CoordTopographic::operator =(const CoordTopographic& b) { - - if (this != &b) { - azimuth = b.azimuth; - elevation = b.elevation; - range = b.range; - range_rate = b.range_rate; - } - - return (*this); -} - -bool CoordTopographic::operator ==(const CoordTopographic& b) const { - - if (azimuth == b.azimuth && - elevation == b.elevation && - range == b.range && - range_rate == b.range_rate) { - return true; - } else { - return false; - } -} - -bool CoordTopographic::operator !=(const CoordTopographic& b) const { - - if (azimuth == b.azimuth && - elevation == b.elevation && - range == b.range && - range_rate == b.range_rate) { - return false; - } else { - return true; - } -} - -std::ostream& operator<< (std::ostream& stream, const CoordTopographic& topo) { - std::stringstream out; - out << std::right << std::fixed << std::setprecision(2); - out << "Az: " << std::setw(7) << RadiansToDegrees(topo.azimuth); - out << ", El: " << std::setw(7) << RadiansToDegrees(topo.elevation); - out << ", Rng: " << std::setw(9) << topo.range; - out << ", Rng Rt: " << std::setw(6) << topo.range_rate; - stream << out.str(); - return stream; -} - - diff --git a/CoordTopographic.h b/CoordTopographic.h index 2004159..d9ae035 100644 --- a/CoordTopographic.h +++ b/CoordTopographic.h @@ -1,29 +1,68 @@ #ifndef COORDTOPOGRAPHIC_H_ #define COORDTOPOGRAPHIC_H_ +#include "Globals.h" + #include +#include +#include -struct CoordTopographic { +struct CoordTopographic +{ public: - CoordTopographic() - : azimuth(0.0), elevation(0.0), range(0.0), range_rate(0.0) { + : azimuth(0.0), elevation(0.0), range(0.0), range_rate(0.0) + { } CoordTopographic(double az, double el, double rnge, double rnge_rate) - : azimuth(az), elevation(el), range(rnge), range_rate(rnge_rate) { + : azimuth(az), elevation(el), range(rnge), range_rate(rnge_rate) + { } - CoordTopographic(const CoordTopographic& b); + CoordTopographic(const CoordTopographic& t) + { + azimuth = t.azimuth; + elevation = t.elevation; + range = t.range; + range_rate = t.range_rate; + } - virtual ~CoordTopographic() { + virtual ~CoordTopographic() + { }; - CoordTopographic & operator =(const CoordTopographic& b); - bool operator ==(const CoordTopographic& b) const; - bool operator !=(const CoordTopographic& b) const; - - friend std::ostream& operator<< (std::ostream& stream, const CoordTopographic& topo); + CoordTopographic& operator=(const CoordTopographic& t) + { + if (this != &t) { + azimuth = t.azimuth; + elevation = t.elevation; + range = t.range; + range_rate = t.range_rate; + } + return *this; + } + + bool operator==(const CoordTopographic& t) const + { + return IsEqual(t); + } + + bool operator !=(const CoordTopographic& t) const + { + return !IsEqual(t); + } + + std::string ToString() const + { + std::stringstream ss; + ss << std::right << std::fixed << std::setprecision(2); + ss << "Az: " << std::setw(7) << RadiansToDegrees(azimuth); + ss << ", El: " << std::setw(7) << RadiansToDegrees(elevation); + ss << ", Rng: " << std::setw(9) << range; + ss << ", Rng Rt: " << std::setw(6) << range_rate; + return ss.str(); + } /* * radians @@ -41,7 +80,27 @@ public: * kilometers / second */ double range_rate; + +protected: + bool IsEqual(const CoordTopographic& t) const + { + if (azimuth == t.azimuth && elevation == t.elevation && + range == t.range && range_rate == t.range_rate) + { + return true; + } + else + { + return false; + } + } }; + +inline std::ostream& operator<<(std::ostream& strm, const CoordTopographic& t) +{ + return strm << t.ToString(); +} + #endif diff --git a/Makefile b/Makefile index 5fff29f..a52743a 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,7 @@ endif LDFLAGS= -SOURCES=CoordTopographic.cpp \ - Eci.cpp \ +SOURCES=Eci.cpp \ Globals.cpp \ Julian.cpp \ Observer.cpp \