UNCLASSIFIED

GeographicTranslator
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
LocalSpherical.cpp
Go to the documentation of this file.
1 // CLASSIFICATION: UNCLASSIFIED
2 
3 /***************************************************************************/
4 /* RSC IDENTIFIER: LOCAL SPHERICAL
5  *
6  *
7  * MODIFICATIONS
8  *
9  * Date Description
10  * ---- ------------
11  * 03-10-19 Original Code
12  *
13  */
14 
15 #include <math.h>
16 
17 #include "Geocentric.h"
18 #include "LocalSpherical.h"
19 #include "CartesianCoordinates.h"
20 #include "GeodeticCoordinates.h"
21 #include "SphericalCoordinates.h"
23 #include "ErrorMessages.h"
24 
25 using namespace MSP::CCS;
26 
27 /***************************************************************************/
28 /* FUNCTIONS */
29 
30 
32  double ellipsoidSemiMajorAxis, double ellipsoidFlattening,
33  double originLongitude, double originLatitude, double originHeight, double orientation) :
35  ellipsoidSemiMajorAxis, ellipsoidFlattening,
36  originLongitude, originLatitude, originHeight, orientation)
37 {
38 }
39 
41  : LocalCartesian(lc)
42 {
43 }
44 
46 {
47 }
48 
50  MSP::CCS::GeodeticCoordinates* geodeticCoordinate)
51 {
52  CartesianCoordinates *localCartesian =
53  LocalCartesian::convertFromGeodetic(geodeticCoordinate);
54 
55  double x = localCartesian->x();
56  double y = localCartesian->y();
57  double z = localCartesian->z();
58  delete localCartesian;
59 
60  double az, el, range;
61  localCartesianToLocalSpherical(x, y, z, az, el, range);
62 
63  return new SphericalCoordinates(CoordinateType::localSpherical, az, el, range);
64 }
65 
67  MSP::CCS::SphericalCoordinates* localSphericalCoordinate)
68 {
69  double az = localSphericalCoordinate->azimuth();
70  double el = localSphericalCoordinate->elevationAngle();
71  double range = localSphericalCoordinate->range();
72 
73  double x, y, z;
74 
75  localSphericalToLocalCartesian(az, el, range, x, y, z);
77 
78  return LocalCartesian::convertToGeodetic(&localCartesian);
79 }
80 
82  const double azimuth,
83  const double elevation,
84  const double range,
85  double &x,
86  double &y,
87  double &z) const
88 {
89  double sinAz = sin(azimuth);
90  double cosAz = cos(azimuth);
91  double sinEl = sin(elevation);
92  double cosEl = cos(elevation);
93 
94  x = range * cosEl * sinAz;
95  y = range * cosEl * cosAz;
96  z = range * sinEl;
97 }
98 
100  const double x,
101  const double y,
102  const double z,
103  double &azimuth,
104  double &elevation,
105  double &range) const
106 {
107  if(x == 0.0 && y == 0.0)
108  azimuth = 0.0;
109  else
110  azimuth = atan2(x, y);
111 
112  range = sqrt(x*x + y*y + z*z);
113  if (range == 0.0)
114  elevation = 0.0;
115  else
116  elevation = asin(z / range);
117 }
118 
void localSphericalToLocalCartesian(const double azimuth, const double elevation, const double radius, double &x, double &y, double &z) const
MSP::CCS::GeodeticCoordinates * convertToGeodetic(MSP::CCS::CartesianCoordinates *cartesianCoordinates)
MSP::CCS::CartesianCoordinates * convertFromGeodetic(MSP::CCS::GeodeticCoordinates *geodeticCoordinates)
MSP::CCS::SphericalCoordinates * convertFromGeodetic(MSP::CCS::GeodeticCoordinates *geodeticCoordinates)
void localCartesianToLocalSpherical(const double x, const double y, const double z, double &azimuth, double &elevation, double &radius) const
LocalSpherical(double ellipsoidSemiMajorAxis, double ellipsoidFlattening, double originLongitude, double originLatitude, double originHeight, double orientation)
MSP::CCS::GeodeticCoordinates * convertToGeodetic(MSP::CCS::SphericalCoordinates *sphericalCoordinate)