104 using namespace MSP::CCS;
112 const double PI = 3.14159265358979323e0;
122 LocalCartesian::LocalCartesian(
double ellipsoidSemiMajorAxis,
double ellipsoidFlattening,
double originLongitude,
double originLatitude,
double originHeight,
double orientation ) :
125 es2( 0.0066943799901413800 ),
129 LocalCart_Origin_Long( 0.0 ),
130 LocalCart_Origin_Lat( 0.0 ),
131 LocalCart_Origin_Height( 0.0 ),
132 LocalCart_Orientation( 0.0 ),
133 Sin_LocalCart_Origin_Lat( 0.0 ),
134 Cos_LocalCart_Origin_Lat( 1.0 ),
135 Sin_LocalCart_Origin_Lon( 0.0 ),
136 Cos_LocalCart_Origin_Lon( 1.0 ),
137 Sin_LocalCart_Orientation( 0.0 ),
138 Cos_LocalCart_Orientation( 1.0 ),
139 Sin_Lat_Sin_Orient( 0.0 ),
140 Sin_Lat_Cos_Orient( 0.0 )
156 double inv_f = 1 / ellipsoidFlattening;
159 if (ellipsoidSemiMajorAxis <= 0.0)
163 if ((inv_f < 250) || (inv_f > 350))
171 if ((originLongitude < -
PI) || (originLongitude >
TWO_PI))
175 if ((orientation < -
PI) || (orientation >
TWO_PI))
183 LocalCart_Origin_Lat = originLatitude;
184 if (originLongitude >
PI)
185 originLongitude -=
TWO_PI;
186 LocalCart_Origin_Long = originLongitude;
187 LocalCart_Origin_Height = originHeight;
188 if (orientation >
PI)
190 LocalCart_Orientation = orientation;
193 Sin_LocalCart_Origin_Lat = sin(LocalCart_Origin_Lat);
194 Cos_LocalCart_Origin_Lat = cos(LocalCart_Origin_Lat);
195 Sin_LocalCart_Origin_Lon = sin(LocalCart_Origin_Long);
196 Cos_LocalCart_Origin_Lon = cos(LocalCart_Origin_Long);
197 Sin_LocalCart_Orientation = sin(LocalCart_Orientation);
198 Cos_LocalCart_Orientation = cos(LocalCart_Orientation);
200 Sin_Lat_Sin_Orient = Sin_LocalCart_Origin_Lat * Sin_LocalCart_Orientation;
201 Sin_Lat_Cos_Orient = Sin_LocalCart_Origin_Lat * Cos_LocalCart_Orientation;
203 N0 =
semiMajorAxis / sqrt(1 - es2 * Sin_LocalCart_Origin_Lat * Sin_LocalCart_Origin_Lat);
205 val = (N0 + LocalCart_Origin_Height) * Cos_LocalCart_Origin_Lat;
206 u0 = val * Cos_LocalCart_Origin_Lon;
207 v0 = val * Sin_LocalCart_Origin_Lon;
208 w0 = ((N0 * (1 - es2)) + LocalCart_Origin_Height) * Sin_LocalCart_Origin_Lat;
216 geocentric =
new Geocentric( *( lc.geocentric ) );
223 LocalCart_Origin_Long = lc.LocalCart_Origin_Long;
224 LocalCart_Origin_Lat = lc.LocalCart_Origin_Lat;
225 LocalCart_Origin_Height = lc.LocalCart_Origin_Height;
226 LocalCart_Orientation = lc.LocalCart_Orientation;
227 Sin_LocalCart_Origin_Lat = lc.Sin_LocalCart_Origin_Lat;
228 Cos_LocalCart_Origin_Lat = lc.Cos_LocalCart_Origin_Lat;
229 Sin_LocalCart_Origin_Lon = lc.Sin_LocalCart_Origin_Lon;
230 Cos_LocalCart_Origin_Lon = lc.Cos_LocalCart_Origin_Lon;
231 Sin_LocalCart_Orientation = lc.Sin_LocalCart_Orientation;
232 Cos_LocalCart_Orientation = lc.Cos_LocalCart_Orientation;
233 Sin_Lat_Sin_Orient = lc.Sin_Lat_Sin_Orient;
234 Sin_Lat_Cos_Orient = lc.Sin_Lat_Cos_Orient;
249 geocentric->operator=( *lc.geocentric );
256 LocalCart_Origin_Long = lc.LocalCart_Origin_Long;
257 LocalCart_Origin_Lat = lc.LocalCart_Origin_Lat;
258 LocalCart_Origin_Height = lc.LocalCart_Origin_Height;
259 LocalCart_Orientation = lc.LocalCart_Orientation;
260 Sin_LocalCart_Origin_Lat = lc.Sin_LocalCart_Origin_Lat;
261 Cos_LocalCart_Origin_Lat = lc.Cos_LocalCart_Origin_Lat;
262 Sin_LocalCart_Origin_Lon = lc.Sin_LocalCart_Origin_Lon;
263 Cos_LocalCart_Origin_Lon = lc.Cos_LocalCart_Origin_Lon;
264 Sin_LocalCart_Orientation = lc.Sin_LocalCart_Orientation;
265 Cos_LocalCart_Orientation = lc.Cos_LocalCart_Orientation;
266 Sin_Lat_Sin_Orient = lc.Sin_Lat_Sin_Orient;
267 Sin_Lat_Cos_Orient = lc.Sin_Lat_Cos_Orient;
309 double longitude = geodeticCoordinates->
longitude();
310 double latitude = geodeticCoordinates->
latitude();
311 double height = geodeticCoordinates->
height();
317 if ((longitude < -
PI) || (longitude >
TWO_PI))
327 geodeticCoordinates );
329 delete geocentricCoordinates;
333 delete geocentricCoordinates;
334 delete cartesianCoordinates;
338 return cartesianCoordinates;
362 geocentricCoordinates );
364 double longitude = geodeticCoordinates->
longitude();
369 longitude = geodeticCoordinates->
longitude();
374 delete geocentricCoordinates;
378 delete geocentricCoordinates;
379 delete geodeticCoordinates;
383 return geodeticCoordinates;
404 double u_MINUS_u0, v_MINUS_v0, w_MINUS_w0;
406 double U = cartesianCoordinates->
x();
407 double V = cartesianCoordinates->
y();
408 double W = cartesianCoordinates->
z();
414 if (LocalCart_Orientation == 0.0)
416 double cos_lon_u_MINUS_u0 = Cos_LocalCart_Origin_Lon * u_MINUS_u0;
417 double sin_lon_v_MINUS_v0 = Sin_LocalCart_Origin_Lon * v_MINUS_v0;
419 X = -Sin_LocalCart_Origin_Lon * u_MINUS_u0 + Cos_LocalCart_Origin_Lon * v_MINUS_v0;
420 Y = -Sin_LocalCart_Origin_Lat * cos_lon_u_MINUS_u0 + -Sin_LocalCart_Origin_Lat * sin_lon_v_MINUS_v0 + Cos_LocalCart_Origin_Lat * w_MINUS_w0;
421 Z = Cos_LocalCart_Origin_Lat * cos_lon_u_MINUS_u0 + Cos_LocalCart_Origin_Lat * sin_lon_v_MINUS_v0 + Sin_LocalCart_Origin_Lat * w_MINUS_w0;
425 double cos_lat_w_MINUS_w0 = Cos_LocalCart_Origin_Lat * w_MINUS_w0;
427 X = (-Cos_LocalCart_Orientation * Sin_LocalCart_Origin_Lon + Sin_Lat_Sin_Orient * Cos_LocalCart_Origin_Lon) * u_MINUS_u0 +
428 (Cos_LocalCart_Orientation * Cos_LocalCart_Origin_Lon + Sin_Lat_Sin_Orient * Sin_LocalCart_Origin_Lon) * v_MINUS_v0 +
429 (-Sin_LocalCart_Orientation * cos_lat_w_MINUS_w0);
431 Y = (-Sin_LocalCart_Orientation * Sin_LocalCart_Origin_Lon - Sin_Lat_Cos_Orient * Cos_LocalCart_Origin_Lon) * u_MINUS_u0 +
432 (Sin_LocalCart_Orientation * Cos_LocalCart_Origin_Lon - Sin_Lat_Cos_Orient * Sin_LocalCart_Origin_Lon) * v_MINUS_v0 +
433 (Cos_LocalCart_Orientation * cos_lat_w_MINUS_w0);
435 Z = (Cos_LocalCart_Origin_Lat * Cos_LocalCart_Origin_Lon) * u_MINUS_u0 +
436 (Cos_LocalCart_Origin_Lat * Sin_LocalCart_Origin_Lon) * v_MINUS_v0 +
437 Sin_LocalCart_Origin_Lat * w_MINUS_w0;
461 double X = cartesianCoordinates->
x();
462 double Y = cartesianCoordinates->
y();
463 double Z = cartesianCoordinates->
z();
465 if (LocalCart_Orientation == 0.0)
467 double sin_lat_y = Sin_LocalCart_Origin_Lat * Y;
468 double cos_lat_z = Cos_LocalCart_Origin_Lat * Z;
470 U = -Sin_LocalCart_Origin_Lon * X - sin_lat_y * Cos_LocalCart_Origin_Lon + cos_lat_z * Cos_LocalCart_Origin_Lon + u0;
471 V = Cos_LocalCart_Origin_Lon * X - sin_lat_y * Sin_LocalCart_Origin_Lon + cos_lat_z * Sin_LocalCart_Origin_Lon + v0;
472 W = Cos_LocalCart_Origin_Lat * Y + Sin_LocalCart_Origin_Lat * Z + w0;
476 double rotated_x, rotated_y;
477 double rotated_y_sin_lat, z_cos_lat;
479 rotated_x = Cos_LocalCart_Orientation * X + Sin_LocalCart_Orientation * Y;
480 rotated_y = -Sin_LocalCart_Orientation * X + Cos_LocalCart_Orientation * Y;
482 rotated_y_sin_lat = rotated_y * Sin_LocalCart_Origin_Lat;
483 z_cos_lat = Z * Cos_LocalCart_Origin_Lat;
485 U = -Sin_LocalCart_Origin_Lon * rotated_x - Cos_LocalCart_Origin_Lon * rotated_y_sin_lat + Cos_LocalCart_Origin_Lon * z_cos_lat + u0;
486 V = Cos_LocalCart_Origin_Lon * rotated_x - Sin_LocalCart_Origin_Lon * rotated_y_sin_lat + Sin_LocalCart_Origin_Lon * z_cos_lat + v0;
487 W = Cos_LocalCart_Origin_Lat * rotated_y + Sin_LocalCart_Origin_Lat * Z + w0;