00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef __CXUTILS_MATH_COORDINATES_H
00052 #define __CXUTILS_MATH_COORDINATES_H
00053
00054 #include "point3d.h"
00055 #include "quaternion.h"
00056
00057 namespace CxUtils
00058 {
00059 class Wgs;
00060 class Utm;
00061 class Gcc;
00062 class Orientation;
00063
00073 class CX_UTILS_DLL Wgs
00074 {
00075 public:
00076 Wgs();
00077 Wgs(const Wgs& wgs);
00078 Wgs(const Utm& utm);
00079 Wgs(const double latitude, const double longitude);
00080 Wgs(const double latitude, const double longitude, const double elevation);
00081 int Set(const double latitude, const double longitude);
00082 int Set(const double latitude, const double longitude, const double elevation);
00083 int Set(const double latDeg, const double latMin, const double latSec,
00084 const double lonDeg, const double lonMin, const double lonSec);
00085 int Set(const double latDeg, const double latMin, const double latSec,
00086 const double lonDeg, const double lonMin, const double lonSec,
00087 const double elevation);
00088 int Get(double& latitude, double& longitude) const;
00089 int Get(double& latitude, double& longitude, double &elevation) const;
00090 int Get(double& latDeg, double& latMin, double& latSec,
00091 double& lonDeg, double& lonMin, double& lonSec,
00092 double& elevation) const;
00093 void Print() const;
00094 std::string ToString(const bool degreesMinutesFlag = false) const;
00095 static double GreatCircleDistance(const Wgs& p1, const Wgs& p2);
00096 Wgs& operator()(const double lat, const double lon, const double elev);
00097 Wgs& operator=(const Wgs& wgs);
00098 Wgs& operator<<(const Utm& utm);
00099 Wgs& operator<<(const Gcc& gcc);
00100 void operator>>(Utm& utm) const;
00101 bool operator==(const Wgs& wgs) const;
00102 inline void operator>>(Gcc& gcc) const;
00103 double mLatitude;
00104 double mLongitude;
00105 double mElevation;
00106 };
00107
00119 class CX_UTILS_DLL Utm
00120 {
00121 public:
00122 Utm();
00123 Utm(const Utm& utm);
00124 Utm(const Wgs& wgs);
00125 Utm(const double northing, const double easting,
00126 const int zoneNumber, const int zoneLetter);
00127 int Set(const double northing, const double easting,
00128 const int zoneNumber, const int zoneLetter);
00129 int Set(const double northing, const double easting,
00130 const int zoneNumber, const int zoneLetter,
00131 const double elevation);
00132 int Get(double& northing, double& easting,
00133 int& zoneNumber, int& zoneLetter) const;
00134 int Get(double& northing, double& easting,
00135 int& zoneNumber, int& zoneLetter,
00136 double& elevation) const;
00137 void Print() const;
00138 inline Utm& operator()(const double northing, const double easting,
00139 const int zoneNumber, const int zoneLetter,
00140 const double elevation = 0)
00141 {
00142 Set(northing, easting, zoneNumber, zoneLetter, elevation);
00143 return *this;
00144 }
00145 static double Distance(const Utm& utm1, const Utm& utm2);
00146 Utm& operator=(const Utm& utm);
00147 Utm& operator<<(const Wgs& wgs);
00148 Utm& operator<<(const Gcc& gcc);
00149 void operator>>(Gcc& gcc) const;
00150 void operator>>(Wgs& wgs) const;
00151 bool operator==(const Utm& utm) const;
00152 int mZoneNumber;
00153 int mZoneLetter;
00154 double mNorthing;
00155 double mEasting;
00156 double mElevation;
00157 };
00158
00173 class CX_UTILS_DLL Gcc : public Point3D
00174 {
00175 public:
00176 Gcc();
00177 Gcc(const Gcc& gcc);
00178 Gcc(const double x, const double y, const double z);
00179 void Print() const;
00180 double GetMagnitude() const;
00181 operator Point3D() const { return *((Point3D*)(this)); }
00182 inline Gcc& operator()(const double x, const double y, const double z)
00183 {
00184 mX = x; mY = y; mZ = z;
00185 return *this;
00186 }
00187 Gcc& operator=(const Point3D& p3d);
00188 Gcc& operator=(const Gcc& gcc);
00189 bool operator==(const Gcc& gcc) const;
00190 Gcc& operator<<(const Wgs& wgs);
00191 Gcc& operator<<(const Utm& utm);
00192 void operator>>(Wgs& wgs) const;
00193 void operator>>(Utm& utm) const;
00194 };
00195
00196
00204 class CX_UTILS_DLL Orientation
00205 {
00206 public:
00219 static double AngleDiff(const double angleSrc,
00220 const double angleDest,
00221 const bool radiansFlag = true);
00222
00235 static Point3D AngleDiff(const Point3D& angleSrc,
00236 const Point3D& angleDest,
00237 const bool radiansFlag = true);
00238
00250 static double AddToAngle(const double angleSrc,
00251 const double angleDiff,
00252 const bool radiansFlag = true);
00264 static Point3D AddAngles(const Point3D& src,
00265 const Point3D& delta,
00266 const bool radiansFlag = true);
00278 static double GetGlobalAngle(const Wgs& srcPos,
00279 const Wgs& destPos,
00280 const bool radiansFlag = true);
00292 static double GetGlobalAngle(const Utm& srcPos,
00293 const Utm& destPos,
00294 const bool radiansFlag = true);
00295 };
00296
00297
00323 CX_UTILS_DLL void GccXyzToWgsHpr(const Gcc& gcc, const Point3D& xyz, Wgs& wgs, Point3D& hpr);
00324
00350 CX_UTILS_DLL void WgsHprToGccXyz(const Wgs& wgs, const Point3D& hpr, Gcc& gcc, Point3D& xyz);
00351
00376 CX_UTILS_DLL void WgsHprToGccXyz(const Wgs& wgs, const Point3D& hpr, Point3D& xyz);
00377
00378 inline void WgsToUtm(const Wgs& wgs, Utm& utm) { utm << wgs; }
00379 inline void WgsToGcc(const Wgs& wgs, Gcc& gcc) { gcc << wgs; }
00380 inline void UtmToWgs(const Utm& utm, Wgs& wgs) { wgs << utm; }
00381 inline void UtmToGcc(const Utm& utm, Gcc& gcc) { gcc << utm; }
00382 inline void GccToWgs(const Gcc& gcc, Wgs& wgs) { wgs << gcc; }
00383 inline void GccToUtm(const Gcc& gcc, Utm& utm) { utm << gcc; }
00384 }
00385
00386 #endif // __COORDINATES_H
00387
00388