From 989999ea45217abf24956531c91deec6f750d2bb Mon Sep 17 00:00:00 2001 From: Daniel Warner Date: Fri, 27 May 2011 00:10:31 +0100 Subject: [PATCH] Converted CoordGeodetic to struct --- CoordGeodetic.cpp | 24 ++++++++++++------------ CoordGeodetic.h | 41 ++++++++--------------------------------- Eci.cpp | 6 +++--- Observer.cpp | 12 ++++++------ 4 files changed, 29 insertions(+), 54 deletions(-) diff --git a/CoordGeodetic.cpp b/CoordGeodetic.cpp index 436f625..9580d9a 100644 --- a/CoordGeodetic.cpp +++ b/CoordGeodetic.cpp @@ -2,17 +2,17 @@ CoordGeodetic::CoordGeodetic(const CoordGeodetic& b) { - lat_ = b.lat_; - lon_ = b.lon_; - alt_ = b.alt_; + latitude = b.latitude; + longitude = b.longitude; + altitude = b.altitude; } CoordGeodetic& CoordGeodetic::operator =(const CoordGeodetic& b) { if (this != &b) { - lat_ = b.lat_; - lon_ = b.lon_; - alt_ = b.alt_; + latitude = b.latitude; + longitude = b.longitude; + altitude = b.altitude; } return (*this); @@ -20,9 +20,9 @@ CoordGeodetic& CoordGeodetic::operator =(const CoordGeodetic& b) { bool CoordGeodetic::operator ==(const CoordGeodetic& b) const { - if (lat_ == b.lat_ && - lon_ == b.lon_ && - alt_ == b.alt_) { + if (latitude == b.latitude && + longitude == b.longitude && + altitude == b.altitude) { return true; } else { return false; @@ -31,9 +31,9 @@ bool CoordGeodetic::operator ==(const CoordGeodetic& b) const { bool CoordGeodetic::operator !=(const CoordGeodetic& b) const { - if (lat_ == b.lat_ && - lon_ == b.lon_ && - alt_ == b.alt_) { + if (latitude == b.latitude && + longitude == b.longitude && + altitude == b.altitude) { return false; } else { return true; diff --git a/CoordGeodetic.h b/CoordGeodetic.h index 98714cc..50a22db 100644 --- a/CoordGeodetic.h +++ b/CoordGeodetic.h @@ -1,18 +1,18 @@ #ifndef COORDGEODETIC_H_ #define COORDGEODETIC_H_ -class CoordGeodetic { +struct CoordGeodetic { public: CoordGeodetic() - : lat_(0.0), lon_(0.0), alt_(0.0) { + : latitude(0.0), longitude(0.0), altitude(0.0) { } /* * radians */ - CoordGeodetic(double latitude, double longitude, double altitude) - : lat_(latitude), lon_(longitude), alt_(altitude) { + CoordGeodetic(double lat, double lon, double alt) + : latitude(lat), longitude(lon), altitude(alt) { } CoordGeodetic(const CoordGeodetic& g); @@ -23,44 +23,19 @@ public: CoordGeodetic & operator =(const CoordGeodetic& b); bool operator ==(const CoordGeodetic& b) const; bool operator !=(const CoordGeodetic& b) const; - - void SetLatitude(const double latitude) { - lat_ = latitude; - } - - void SetLongitude(const double longitude) { - lon_ = longitude; - } - - void SetAltitude(const double altitude) { - alt_ = altitude; - } - - double GetLatitude() const { - return lat_; - } - - double GetLongitude() const { - return lon_; - } - - double GetAltitude() const { - return alt_; - } - -private: + /* * radians (north positive, south negative) */ - double lat_; + double latitude; /* * radians (east positive, west negative) */ - double lon_; + double longitude; /* * kilometers */ - double alt_; + double altitude; }; #endif diff --git a/Eci.cpp b/Eci.cpp index 4618f7b..2b0ecc1 100644 --- a/Eci.cpp +++ b/Eci.cpp @@ -4,9 +4,9 @@ Eci::Eci(const Julian &date, const CoordGeodetic &geo) : date_(date) { static const double mfactor = kTWOPI * (kOMEGA_E / kSECONDS_PER_DAY); - const double latitude = geo.GetLatitude(); - const double longitude = geo.GetLongitude(); - const double altitude = geo.GetAltitude(); + const double latitude = geo.latitude; + const double longitude = geo.longitude; + const double altitude = geo.altitude; /* * Calculate Local Mean Sidereal Time for observers longitude diff --git a/Observer.cpp b/Observer.cpp index 743e393..383556c 100644 --- a/Observer.cpp +++ b/Observer.cpp @@ -7,9 +7,9 @@ */ Observer::Observer(const double latitude, const double longitude, const double altitude) { - geo_.SetLatitude(DegreesToRadians(latitude)); - geo_.SetLongitude(DegreesToRadians(longitude)); - geo_.SetAltitude(altitude); + geo_.latitude = DegreesToRadians(latitude); + geo_.longitude = DegreesToRadians(longitude); + geo_.altitude = altitude; UpdateObserversEci(Julian()); } @@ -51,10 +51,10 @@ CoordTopographic Observer::GetLookAngle(const Eci &eci) { /* * Calculate Local Mean Sidereal Time for observers longitude */ - double theta = eci.GetDate().ToLocalMeanSiderealTime(geo_.GetLongitude()); + double theta = eci.GetDate().ToLocalMeanSiderealTime(geo_.longitude); - double sin_lat = sin(geo_.GetLatitude()); - double cos_lat = cos(geo_.GetLatitude()); + double sin_lat = sin(geo_.latitude); + double cos_lat = cos(geo_.latitude); double sin_theta = sin(theta); double cos_theta = cos(theta);