14 #include "Constants.h"
28 Ellipsoid(
double maj,
double ecc) : _a(maj), _e2(ecc) {}
44 double a()
const {
return _a;}
48 double b()
const {
return _a * std::sqrt(1.0 - _e2);}
52 double e2()
const {
return _e2;}
57 void a(
double val) {_a = val;}
62 void e2(
double val) {_e2 = val;}
66 inline double rEast(
double lat)
const;
70 inline double rNorth(
double lat)
const;
74 inline double rDir(
double hdg,
double lat)
const;
87 void xyzToLonLat(
const cartesian_t &xyz, cartesian_t &llh)
const;
88 CUDA_HOSTDEV Vec3
xyzToLonLat(
const Vec3& xyz)
const {
96 inline void nVector(
double lon,
double lat, cartesian_t &vec)
const;
98 inline Vec3
nVector(
double lon,
double lat)
const {
106 inline void xyzOnEllipse(
double lon,
double lat, cartesian_t &xyz)
const;
110 const cartesian_t &los,
double &azi,
double &look)
const;
129 return _a / std::sqrt(1.0 - (_e2 * std::pow(std::sin(lat), 2)));
139 return (_a * (1.0 - _e2)) / std::pow((1.0 - (_e2 * std::pow(std::sin(lat), 2))), 1.5);
149 auto re = rEast(lat);
150 auto rn = rNorth(lat);
151 return (re * rn) / ((re * std::pow(std::cos(hdg), 2))
152 + (rn * std::pow(std::sin(hdg), 2)));
164 double clat = std::cos(lat);
165 vec[0] = clat * std::cos(lon);
166 vec[1] = clat * std::sin(lon);
167 vec[2] = std::sin(lat);
179 nVector(lon, lat, vec);
194 auto re = rEast(llh[1]);
196 xyz[0] = (re + llh[2]) * std::cos(llh[1]) * std::cos(llh[0]);
197 xyz[1] = (re + llh[2]) * std::cos(llh[1]) * std::sin(llh[0]);
199 xyz[2] = ((re * (1.0 - _e2)) + llh[2]) * std::sin(llh[1]);
213 const double e4 = _e2 * _e2;
214 const double a2 = _a * _a;
216 double p = (std::pow(xyz[0], 2) + std::pow(xyz[1], 2)) / a2;
218 double q = ((1. - _e2) * std::pow(xyz[2], 2)) / a2;
219 double r = (p + q - e4) / 6.;
220 double s = (e4 * p * q) / (4. * std::pow(r, 3));
221 double t = std::pow(1. + s + std::sqrt(s * (2. + s)), (1./3.));
222 double u = r * (1. + t + (1. / t));
223 double rv = std::sqrt(std::pow(u, 2) + (e4 * q));
224 double w = (_e2 * (u + rv - q)) / (2. * rv);
225 double k = std::sqrt(u + rv + std::pow(w, 2)) - w;
227 double d = (k * std::sqrt(std::pow(xyz[0], 2) + std::pow(xyz[1], 2))) / (k + _e2);
229 llh[1] = std::atan2(xyz[2], d);
231 llh[0] = std::atan2(xyz[1], xyz[0]);
233 llh[2] = ((k + _e2 - 1.) * sqrt(std::pow(d, 2) + std::pow(xyz[2], 2))) / k;
CUDA_HOSTDEV void xyzOnEllipse(double lon, double lat, cartesian_t &xyz) const
Return ECEF coordinates of point on ellipse.
Definition: Ellipsoid.h:177
void a(double val)
Set semi-major axis.
Definition: Ellipsoid.h:57
void e2(double val)
Set eccentricity^2.
Definition: Ellipsoid.h:62
CUDA_HOSTDEV double rDir(double hdg, double lat) const
Return directional local radius.
Definition: Ellipsoid.h:148
CUDA_HOSTDEV double e2() const
Return eccentricity^2.
Definition: Ellipsoid.h:52
Data structure to store Ellipsoid information.
Definition: Ellipsoid.h:20
CUDA_HOSTDEV void xyzToLonLat(const cartesian_t &xyz, cartesian_t &llh) const
Transform ECEF xyz to Lon/Lat/Hgt.
Definition: Ellipsoid.h:207
void getImagingAnglesAtPlatform(const cartesian_t &pos, const cartesian_t &vel, const cartesian_t &los, double &azi, double &look) const
Estimate azimuth angle and look angle for a given LOS vector.
Definition: Ellipsoid.cpp:22
CUDA_HOSTDEV Ellipsoid(double maj, double ecc)
Constructor using semi-major axis and eccentricity^2.
Definition: Ellipsoid.h:28
CUDA_HOSTDEV void lonLatToXyz(const cartesian_t &llh, cartesian_t &xyz) const
Transform WGS84 Lon/Lat/Hgt to ECEF xyz.
Definition: Ellipsoid.h:188
CUDA_HOSTDEV double a() const
Return semi-major axis.
Definition: Ellipsoid.h:44
const double EarthEccentricitySquared
Eccentricity^2 for WGS84.
Definition: Constants.h:44
const double EarthSemiMajorAxis
Semi-major axis for WGS84.
Definition: Constants.h:41
CUDA_HOSTDEV double b() const
Return semi-minor axis.
Definition: Ellipsoid.h:48
CUDA_HOSTDEV double rNorth(double lat) const
Return local radius in NS direction.
Definition: Ellipsoid.h:137
CUDA_HOSTDEV void nVector(double lon, double lat, cartesian_t &vec) const
Return normal to the ellipsoid at given lon, lat.
Definition: Ellipsoid.h:162
Ellipsoid & operator=(const Ellipsoid &)
Overloaded assignment operator.
Definition: Ellipsoid.h:117
Ellipsoid(const Ellipsoid &ellps)
Copy constructor.
Definition: Ellipsoid.h:37
CUDA_HOSTDEV double rEast(double lat) const
Return local radius in EW direction.
Definition: Ellipsoid.h:127