ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Static Public Member Functions | Static Public Attributes | Static Private Member Functions | List of all members
larcfm::GreatCircle Class Reference

#include <GreatCircle.h>

Static Public Member Functions

static double angle_from_distance (double distance, double h)
 
static double distance_from_angle (double angle, double h)
 
static double angular_distance (double lat1, double lon1, double lat2, double lon2)
 
static double angular_distance (const LatLonAlt &p1, const LatLonAlt &p2)
 
static double distance (double lat1, double lon1, double lat2, double lon2)
 
static double distance (const LatLonAlt &p1, const LatLonAlt &p2)
 
static bool almost_equals (double lat1, double lon1, double lat2, double lon2)
 
static bool almost_equals (double lat1, double lon1, double lat2, double lon2, double epsilon)
 
static bool almostEquals (const LatLonAlt &b, const LatLonAlt &v)
 
static bool almostEquals (const LatLonAlt &b, const LatLonAlt &a, double horizEps, double vertEps)
 
static bool almostEquals2D (const LatLonAlt &b, const LatLonAlt &v, double horizEps)
 
static double initial_course (double lat1, double lon1, double lat2, double lon2)
 
static double initial_course (const LatLonAlt &p1, const LatLonAlt &p2)
 
static double final_course (const LatLonAlt &p1, const LatLonAlt &p2)
 
static double representative_course (double lat1, double lon1, double lat2, double lon2)
 
static double representative_course (const LatLonAlt &p1, const LatLonAlt &p2)
 
static double max_latitude_gc (double lat1, double lon1, double lat2, double lon2)
 
static double max_latitude_gc (const LatLonAlt &p1, const LatLonAlt &p2)
 
static double min_latitude_gc (double lat1, double lon1, double lat2, double lon2)
 
static double min_latitude_gc (const LatLonAlt &p1, const LatLonAlt &p2)
 
static double lonCross (double lat1, double lon1, double lat2, double lon2, double lat3)
 
static double max_latitude (double lat1, double lon1, double lat2, double lon2)
 
static double max_latitude (const LatLonAlt &p1, const LatLonAlt &p2)
 
static double min_latitude (double lat1, double lon1, double lat2, double lon2)
 
static double min_latitude (const LatLonAlt &p1, const LatLonAlt &p2)
 
static LatLonAlt interpolate (const LatLonAlt &p1, const LatLonAlt &p2, double f)
 
static LatLonAlt interpolateEst (const LatLonAlt &p1, const LatLonAlt &p2, double f)
 
static LatLonAlt linear_gcgs (const LatLonAlt &p1, const LatLonAlt &p2, const Velocity &v, double t)
 
static LatLonAlt linear_gc (LatLonAlt p1, LatLonAlt p2, double d)
 
static LatLonAlt linear_rhumb (const LatLonAlt &s, const Velocity &v, double t)
 
static LatLonAlt linear_rhumb (const LatLonAlt &s, double track, double dist)
 
static Triple< double, double, double > side_side_angle (double b, double a, double A, bool firstSolution)
 
static Triple< double, double, double > side_angle_angle (double a, double A, double B, bool firstSolution)
 
static Triple< double, double, double > side_angle_side (double a, double C, double b)
 
static Triple< double, double, double > angle_side_angle (double A, double c, double B)
 
static LatLonAlt intersectionSegment (double T, const LatLonAlt &so, const Velocity &vo, const LatLonAlt &si, const LatLonAlt &si2)
 
static LatLonAlt intersectSegments (const LatLonAlt &so, const LatLonAlt &so2, const LatLonAlt &si, const LatLonAlt &si2)
 
static LatLonAlt linear_initial (const LatLonAlt &s, const Velocity &v, double t)
 
static LatLonAlt linear_initial (const LatLonAlt &s, double track, double dist)
 
static double cross_track_distance (const LatLonAlt &p1, const LatLonAlt &p2, const LatLonAlt &offCircle)
 
static bool collinear (const LatLonAlt &p1, const LatLonAlt &p2, const LatLonAlt &p3)
 
static LatLonAlt closest_point_circle (const LatLonAlt &p1, const LatLonAlt &p2, const LatLonAlt &x)
 
static LatLonAlt closest_point_segment (const LatLonAlt &p1, const LatLonAlt &p2, const LatLonAlt &x)
 
static LatLonAlt intersection (const LatLonAlt &a1, const LatLonAlt &a2, const LatLonAlt &b1, const LatLonAlt &b2)
 
static std::pair< LatLonAlt, double > intersectionExtrapAlt (const LatLonAlt &so, const LatLonAlt &so2, double dto, const LatLonAlt &si, const LatLonAlt &si2)
 
static std::pair< LatLonAlt, double > intersectionAvgAlt (const LatLonAlt &so, const LatLonAlt &so2, double dto, const LatLonAlt &si, const LatLonAlt &si2)
 
static std::pair< LatLonAlt, double > intersection (const LatLonAlt &so, const Velocity &vo, const LatLonAlt &si, const Velocity &vi)
 
static double angleBetween (const LatLonAlt &a1, const LatLonAlt &a2, const LatLonAlt &b1, const LatLonAlt &b2)
 
static double angle_betweenOLD (const LatLonAlt &a, const LatLonAlt &b, const LatLonAlt &c)
 
static double angle_between (const LatLonAlt &a, const LatLonAlt &b, const LatLonAlt &c)
 
static double angle_between (const LatLonAlt &a, const LatLonAlt &b, const LatLonAlt &c, int dir)
 
static bool behind (const LatLonAlt &x, const LatLonAlt &ll, const Velocity &v)
 
static int passingDirection (const LatLonAlt &so, const Velocity &vo, const LatLonAlt &si, const Velocity &vi)
 
static int dirForBehind (const LatLonAlt &so, const Velocity &vo, const LatLonAlt &si, const Velocity &vi)
 
static Velocity velocity_average (const LatLonAlt &p1, const LatLonAlt &p2, double t)
 
static Velocity velocity_average_speed (const LatLonAlt &s1, const LatLonAlt &s2, double speed)
 
static Velocity velocity_initial (const LatLonAlt &p1, const LatLonAlt &p2, double t)
 
static Velocity velocity_final (const LatLonAlt &p1, const LatLonAlt &p2, double t)
 
static Vect3 spherical2xyz (double lat, double lon)
 
static Vect3 spherical2xyz (const LatLonAlt &lla)
 
static LatLonAlt xyz2spherical (const Vect3 &v)
 
static double chord_distance (double lat1, double lon1, double lat2, double lon2)
 
static double chord_distance (double surface_dist)
 
static double surface_distance (double chord_distance)
 
static double to_chordal_radius (double surface_radius)
 
static double to_surface_radius (double chord_radius)
 
static LatLonAlt small_circle_rotation (const LatLonAlt &so, const LatLonAlt &center, double angle)
 
static double small_circle_arc_length (double radius, double arcAngle)
 
static double small_circle_arc_angle (double radius, double arcLength)
 

Static Public Attributes

static const double minDt = 1E-5
 
static const double spherical_earth_radius = 6366707.0194937070000000000
 

Static Private Member Functions

static double max_latitude_gc_course (double lat1, double trk)
 
static double min_latitude_gc_course (double lat1, double trk)
 
static bool gauss_check (double a, double b, double c, double A, double B, double C)
 
static LatLonAlt closest_point_circle (const LatLonAlt &p1, const LatLonAlt &p2, const LatLonAlt &x, double a, double b, double c, double A, double B, double C)
 
static double angle_from_distance (double distance)
 

Detailed Description

This class contains common formulas used for modeling a spherical Earth, in particular, Great Circle calculations. Many of the formulas are based on the Aviation Formulary (v1.44) by Ed Williams.

Notes:

Member Function Documentation

◆ almost_equals() [1/2]

bool larcfm::GreatCircle::almost_equals ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Determines if two points are close to each other, see Constants.get_horizontal_accuracy().

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
true, if almost equals

◆ almost_equals() [2/2]

bool larcfm::GreatCircle::almost_equals ( double  lat1,
double  lon1,
double  lat2,
double  lon2,
double  epsilon 
)
static

Determines if two points are close to each other, where 'close' is defined by the distance value given in meters.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
epsilonmaximum difference in meters
Returns
true, if almost equals

◆ almostEquals()

bool larcfm::GreatCircle::almostEquals ( const LatLonAlt b,
const LatLonAlt a,
double  horizEps,
double  vertEps 
)
static

Are these two LatLonAlt almost equal, where 'almost' is defined by the given distances [m]

Parameters
bLatLonAlt object
aLatLonAlt object
horizEpsallowed difference in horizontal dimension
vertEpsallowed difference in vertical dimension
Returns
true if the two are almost equals

◆ angle_between() [1/2]

double larcfm::GreatCircle::angle_between ( const LatLonAlt a,
const LatLonAlt b,
const LatLonAlt c 
)
static

Return the turn angle between great circles (this will return a value between 0 and PI) (uses coordinate transformation)

Parameters
apoint on gc1
bintersection of gc1 and gc2
cpoint on gc2
Returns
magnitude of angle between the two great circles, from a-b to b-c

◆ angle_between() [2/2]

double larcfm::GreatCircle::angle_between ( const LatLonAlt a,
const LatLonAlt b,
const LatLonAlt c,
int  dir 
)
static

Return the turn angle between two great circles, measured in the indicated direction. This can return a value larger than PI.

Parameters
afirst point
bturn point
clast point
dir+1 is right (clockwise), -1 is left (counterclockwise)
Returns
Value of angle of turn from a-b to b-c

◆ angle_betweenOLD()

double larcfm::GreatCircle::angle_betweenOLD ( const LatLonAlt a,
const LatLonAlt b,
const LatLonAlt c 
)
static

Return angle between great circles (old version, uses spherical trig)

Parameters
apoint on gc1
bintersection of gc1 and gc2
cpoint on gc2
Returns
angle between the two great circles

◆ angle_from_distance() [1/2]

double larcfm::GreatCircle::angle_from_distance ( double  distance)
staticprivate

Convert the distance (in internal length units) across the surface of the (spherical) Earth into an angle.

◆ angle_from_distance() [2/2]

double larcfm::GreatCircle::angle_from_distance ( double  distance,
double  h 
)
static

Convert the distance (in internal length units) across a sphere at a height of h (in internal length units) above surface of the (spherical) Earth into an angle.

Parameters
distancedistance [m]
hheight above surface of spherical Earth
Returns
angular distance [radian]

◆ angle_side_angle()

Triple< double, double, double > larcfm::GreatCircle::angle_side_angle ( double  A,
double  c,
double  B 
)
static

This implements the supplemental (polar triangle) spherical cosine rule to complete a triangle on the unit sphere

Parameters
Aangle A
cside between A and B (angular distance
Bangle B
Returns
triple of a,b,C (side opposite A, side opposite B, angle opposite c)

◆ angleBetween()

double larcfm::GreatCircle::angleBetween ( const LatLonAlt a1,
const LatLonAlt a2,
const LatLonAlt b1,
const LatLonAlt b2 
)
static

Given two great circles defined by a1, a2 and b1, b2 return the angle between them at the intersection point.
This is the same as the dihedral angle, or angle between the two GC planes. This may not be the same angle as the one projected into the Euclidean (unless the projection point is the intersection point). and will generally not be the same as the (non-projected) track angle difference between them (though that can be very close). This will always return a value between 0 and PI.

Note: When two great circles intersect, they form supplementary angles, that is, two angles that sum to 180. This method can return either the smaller (less than 90) or the larger (greater than 90). It is a little complicated to determine which one will be returned. Imagine a 'right-handed' vector going from a1 to a2 and another one going from b1 to b2. If these two vectors point mostly in the same direction, then the smaller supplementary angle will be returned. If they point in mostly opposite directions, then the larger supplementary angle will be returned. As an example. Imagine three points, two points (a and c) on the equator, less than 90 degrees apart and point b at the north pole. angleBetween(a,b,c,b) will return the smaller supplementary angle, and angleBetween(a,b,b,c) will return the larger supplementary angle.

Parameters
a1one point on the first great circle
a2second point on the first great circle
b1one point on the second great circle
b2second point on the second great circle
Returns
angle between two great circles

◆ angular_distance() [1/2]

double larcfm::GreatCircle::angular_distance ( const LatLonAlt p1,
const LatLonAlt p2 
)
static

Compute the great circle distance in radians between the two points. The calculation applies to any sphere, not just a spherical Earth. The current implementation uses the haversine formula.

Parameters
p1one point
p2another point
Returns
angular distance

◆ angular_distance() [2/2]

double larcfm::GreatCircle::angular_distance ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Compute the great circle distance in radians between the two points. The calculation applies to any sphere, not just a spherical Earth. The current implementation uses the haversine formula.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
angular distance

◆ behind()

bool larcfm::GreatCircle::behind ( const LatLonAlt x,
const LatLonAlt ll,
const Velocity v 
)
static

Return true if x is "behind" ll, considering its current direction of travel, v. "Behind" here refers to the hemisphere aft of ll. That is, x is within the region behind the perpendicular line to v through ll.

Parameters
llaircraft position
vaircraft velocity
xintruder position
Returns
true, if x is behind ll

Return true if x is "behind" ll, considering its current direction of travel, v. "Behind" here refers to the hemisphere aft of ll. That is, x is within the region behind the perpendicular line to v through ll.

Parameters
llaircraft position
vaircraft velocity
xintruder positino
Returns

◆ chord_distance() [1/2]

double larcfm::GreatCircle::chord_distance ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Return the straight-line chord distance (through a spherical earth) from two points on the surface of the earth.

Parameters
lat1latitude of first point
lon1longitude of first point
lat2latitude of second point
lon2longitude of second point
Returns
the chord distance

◆ chord_distance() [2/2]

double larcfm::GreatCircle::chord_distance ( double  surface_dist)
static

Return the chord distance (through the earth) corresponding to a given surface distance (at the nominal earth radius). This is the distance of a direct line between two surface points.

Parameters
surface_distdistance across surface
Returns
chord distance

◆ closest_point_circle()

LatLonAlt larcfm::GreatCircle::closest_point_circle ( const LatLonAlt p1,
const LatLonAlt p2,
const LatLonAlt x 
)
static

This returns the point on the great circle running through p1 and p2 that is closest to point x. The altitude of the output is the same as x.

If p1 and p2 are the same point, then every great circle runs through them, thus x is on one of these great circles. In this case, x will be returned.

Parameters
p1the starting point of the great circle
p2another point on the great circle
xpoint to determine closest segment point to.
Returns
the LatLonAlt point on the segment that is closest (horizontally) to x

This returns the point on the great circle running through p1 and p2 that is closest to point x. The altitude of the output is the same as x.

If p1 and p2 are the same point, then every great circle runs through them, thus x is on one of these great circles. In this case, x will be returned. This assumes any 2 points will be within 90 degrees of each other (angular distance).

Parameters
p1the starting point of the great circle
p2another point on the great circle
xpoint to determine closest segment point to.
Returns
the LatLonAlt point on the segment that is closest (horizontally) to x

◆ closest_point_segment()

LatLonAlt larcfm::GreatCircle::closest_point_segment ( const LatLonAlt p1,
const LatLonAlt p2,
const LatLonAlt x 
)
static

This returns the point on the great circle segment running through p1 and p2 that is closest to point x. This will return either p1 or p2 if the actual closest point is outside the segment.

Parameters
p1the starting point of the great circle
p2another point on the great circle
xpoint to determine closest segment point to.
Returns
the LatLonAlt point on the segment that is closest (horizontally) to x

◆ collinear()

bool larcfm::GreatCircle::collinear ( const LatLonAlt p1,
const LatLonAlt p2,
const LatLonAlt p3 
)
static

Determines if the three points are on the same great circle.

Parameters
p1One point
p2Second point
p3Third point
Returns
true, if the three points are collinear (2d)

◆ cross_track_distance()

double larcfm::GreatCircle::cross_track_distance ( const LatLonAlt p1,
const LatLonAlt p2,
const LatLonAlt offCircle 
)
static

This function forms a great circle from p1 to p2, then computes the shortest distance of another point (offCircle) to the great circle. This is the cross track distance. A positive value means offCircle is to the right of the path from p1 to p2. A negative value means offCircle is to the left of the path from p1 to p2.

Parameters
p1the starting point of the great circle
p2another point on the great circle
offCirclethe point to measure the cross track distance
Returns
the signed cross track distance [m]

◆ distance() [1/2]

double larcfm::GreatCircle::distance ( const LatLonAlt p1,
const LatLonAlt p2 
)
static

Compute the great circle distance between the two given points. The calculation assumes the Earth is a sphere. This ignores the altitudes.

Parameters
p1one point
p2another point
Returns
angular distance

◆ distance() [2/2]

double larcfm::GreatCircle::distance ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Compute the great circle distance between the two given points. The calculation assumes the Earth is a sphere

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
distance in meters

◆ distance_from_angle()

double larcfm::GreatCircle::distance_from_angle ( double  angle,
double  h 
)
static

Convert the given angle into a distance across a (spherical) Earth at height above the surface of h.

Parameters
angleangular distance [radian]
hheight above surface of spherical Earth
Returns
linear distance [m]

◆ final_course()

double larcfm::GreatCircle::final_course ( const LatLonAlt p1,
const LatLonAlt p2 
)
static

Course of the great circle coming in from point #1 to point #2. This value is NOT a compass angle (in the 0 to 2 Pi range), but is in radians from clockwise from true north.

Usage Note: If point #1 and #2 are close to each other, then the course may become unstable. In the extreme case when point #1 equals point #2, then the course is undefined.

Parameters
p1point #1
p2point #2
Returns
final course

◆ initial_course() [1/2]

double larcfm::GreatCircle::initial_course ( const LatLonAlt p1,
const LatLonAlt p2 
)
static

The initial true course (course relative to true north) at point #1 on the great circle route from point #1 to point #2. The value is in internal units of angles (radians), and is a compass angle [0..2*Pi]: clockwise from true north.

Usage Note: If point #1 and #2 are close to each other, then the course may become unstable. In the extreme case when point #1 equals point #2, then the course is undefined.

Parameters
p1a point
p2another point
Returns
initial course

◆ initial_course() [2/2]

double larcfm::GreatCircle::initial_course ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

The initial true course (course relative to true north) at lat/long #1 on the great circle route from lat/long #1 to lat/long #2. The value is in internal units of angles (radians), and is a compass angle [0..2*Pi]: clockwise from true north.

Usage Note: If lat/long #1 and #2 are close to each other, then the initial course may become unstable. In the extreme case when lat/long #1 equals lat/long #2, then the initial course is undefined.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
initial course

◆ interpolate()

LatLonAlt larcfm::GreatCircle::interpolate ( const LatLonAlt p1,
const LatLonAlt p2,
double  f 
)
static

Find the position (latitude, longitude, and altitude) of a point on the great circle from point #1 to point #2 as a fraction of the distance between the two points. If the fraction is 0.0 then point #1 is returned, if the fraction is 1.0 then point #2 is returned. If a fraction less than zero or greater than one is used, then this function will extrapolate along the great circle.

Usage Notes:

  • The return value r has r.x as latitude and r.y as longitude. This is different than in the Vect4 class.
  • Behavior of this function is undefined if the two points are antipodal (i.e. lat1+lat2=0 and abs(lon1-lon2)=pi) because a unique great circle line is undefined (there are infinitely many of them).
  • if lat/long #1 is almost the same as #2, then #1 is returned
Parameters
p1point #1
p2point #1
fdecimal fraction
Returns
a new point between p1 and p2

◆ interpolateEst()

LatLonAlt larcfm::GreatCircle::interpolateEst ( const LatLonAlt p1,
const LatLonAlt p2,
double  f 
)
static

This is a fast but crude way of interpolating between relatively close geodesic points

Parameters
p1point #1
p2point #1
fdecimal fraction
Returns
a new point between p1 and p2

◆ intersection()

LatLonAlt larcfm::GreatCircle::intersection ( const LatLonAlt a1,
const LatLonAlt a2,
const LatLonAlt b1,
const LatLonAlt b2 
)
static

Given two great circles defined by a1,a2 and b1,b2, return the intersection point that is closest a1. Use LatLonAlt.antipode() to get the other value. This assumes that the arc distance between a1,a2 < 90 and b1,b2 < 90 The altitude of the return value is equal to a1.alt() This returns an INVALID value if both segments are collinear

Parameters
a1point #1 to form great circle #1
a2point #2 to form great circle #1
b1point #1 to form great circle #2
b2point #2 to form great circle #2
Returns
the point that intersects the two great circles

Given two great circles defined by a1,a2 and b1,b2, return the intersection poin that is closest a1. Use LatLonAlt.antipode() to get the other value. This assumes that the arc distance between a1,a2 < 90 and b1,b2 < 90 This returns an INVALID value if both segments are collinear EXPERIMENTAL

◆ intersectionExtrapAlt()

std::pair< LatLonAlt, double > larcfm::GreatCircle::intersectionExtrapAlt ( const LatLonAlt so,
const LatLonAlt so2,
double  dto,
const LatLonAlt si,
const LatLonAlt si2 
)
static

Given two great circles defined by so, so2 and si, si2 return the intersection point that is closest to so. (Note. because on a sphere there are two intersection points) Calculate altitude of intersection using linear extrapolation from line (so,so2)

Parameters
sofirst point of line o
so2second point of line o
dtothe delta time between point so and point so2.
sifirst point of line i
si2second point of line i
Returns
a pair: intersection point and the delta time from point "so" to the intersection, can be negative if intersect point is in the past. If intersection point is invalid then the returned delta time is -1

◆ intersectSegments()

LatLonAlt larcfm::GreatCircle::intersectSegments ( const LatLonAlt so,
const LatLonAlt so2,
const LatLonAlt si,
const LatLonAlt si2 
)
static

EXPERIMENTAL Given two great circle segments defined by a1,a2 and b1,b2, return the intersection point that is closest a1.
This assumes that the arc distance between a1,a2 < 90 and b1,b2 < 90 The altitude of the return value is equal to a1.alt() This returns an INVALID value if both segments are collinear or there is no intersection

Note: This is very slow compared to the equivalent Vect3 method.

Parameters
sostarting point of segment [so,so2]
so2ending point of segment [so,so2]
sistarting point of segment [si,si2]
si2ending point of segment [si,si2]
Returns
the point that intersects the two "great circle" segments

◆ linear_gc()

LatLonAlt larcfm::GreatCircle::linear_gc ( LatLonAlt  p1,
LatLonAlt  p2,
double  d 
)
static

Return a new location on the great circle path from p1 to p2 that is distance d from p1

Parameters
p1the first point to define the great circle
p2the second point to define the great circle
ddistance from point #1 [m]
Returns
a new position that is distance d from point #1

◆ linear_gcgs()

LatLonAlt larcfm::GreatCircle::linear_gcgs ( const LatLonAlt p1,
const LatLonAlt p2,
const Velocity v,
double  t 
)
static

Find a point on the great circle route from point #1 to point #2, traveling at the given velocity (only ground speed and vertical speed, not track angle) for the given amount of time. If points #1 and #2 are essentially the same, then the direction between these two points is undefined, so the first point is returned.

This calculation ignores altitude. Small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
p1a point
p2another point
vvelocity
ttime
Returns
end point of a linear extrapolation

◆ linear_initial() [1/2]

LatLonAlt larcfm::GreatCircle::linear_initial ( const LatLonAlt s,
const Velocity v,
double  t 
)
static

Find a point from the given lat/lon ('s') when traveling along the great circle with the given initial velocity for the given amount of time.

This calculation is approximate: small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
sa position
vvelocity
ttime
Returns
position that is t seconds from s going velocity v

◆ linear_initial() [2/2]

LatLonAlt larcfm::GreatCircle::linear_initial ( const LatLonAlt s,
double  track,
double  dist 
)
static

Find a point from the given lat/lon ('s') with an initial 'track' angle at a distance of 'dist'. This calculation follows the great circle.

Note: this method does not compute an accurate altitude

Parameters
sa position
trackthe initial course coming from point s, assuming a great circle is followed
distdistance from point #1 over the surface of the Earth [m], for very small distances, this method returns inaccurate results.
Returns
a new position that is distance d from point #1

◆ linear_rhumb() [1/2]

LatLonAlt larcfm::GreatCircle::linear_rhumb ( const LatLonAlt s,
const Velocity v,
double  t 
)
static

Find a point from the given lat/lon when traveling at the given velocity for the given amount of time. This calculation follows the rhumb line (loxodrome or line of constant track).

Modern aircraft (and most ships) usually travel great circles not rhumb lines, therefore linear_initial() is usually the preferred over this function.

At "normal" latitudes, rhumb lines are usually within a few percent of the great circle route. However, near the poles the behavior of rhumb lines is not intuitive: if the destination is a point near the pole, then the rhumb line may spiral around the pole to get to the destination. In fact, if you maintain a constant track angle along a rhumb line for a long enough distance, gradually the line will spiral in towards one of the poles.

Rhumb lines are not defined at the exact north and south poles, therefore if the origin or destination is precisely at a pole, this function will choose a point near the pole.

This calculation is approximate: small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
sposition
vvelocity
ttime
Returns
linear extrapolation along a rhumb line

◆ linear_rhumb() [2/2]

LatLonAlt larcfm::GreatCircle::linear_rhumb ( const LatLonAlt s,
double  track,
double  dist 
)
static

Find a point from the given lat/lon at an angle of 'track' at a distance of 'dist'. This calculation follows the rhumb line (loxodrome or line of constant track).

Modern aircraft (and most ships) usually travel great circles not rhumb lines, therefore linear_initial() is usually preferred over this function.

At "normal" latitudes, rhumb lines are usually within a few percent of the great circle route. However, near the poles the behavior of rhumb lines is not intuitive: if the destination is a point near the pole, then the rhumb line may spiral around the pole to get to the destination. In fact, if you maintain a constant track angle along a rhumb line for a long enough distance, gradually the line will spiral in towards one of the poles.

Rhumb lines are not defined at the exact north and south poles, therefore if the origin or destination is precisely at a pole, this function will choose a point near the pole.

This calculation is approximate: small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
sposition
tracktrack angle
distdistance
Returns
linear extrapolation along a rhumb line

◆ max_latitude()

double larcfm::GreatCircle::max_latitude ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Find the maximum (northern-most) latitude of the line segment defined by the two points along a great circle path.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
maximum latitude

◆ max_latitude_gc() [1/2]

double larcfm::GreatCircle::max_latitude_gc ( const LatLonAlt p1,
const LatLonAlt p2 
)
static

Estimate the maximum latitude of the great circle defined by the two points.

Parameters
p1point 1
p2point 2
Returns
maximum latitude

◆ max_latitude_gc() [2/2]

double larcfm::GreatCircle::max_latitude_gc ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Estimate the maximum latitude of the great circle defined by the two points.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
maximum latitude

◆ min_latitude()

double larcfm::GreatCircle::min_latitude ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Find the minimum (southern-most) latitude of the line segment defined by the two points along a great circle path.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
minimum latitude

◆ min_latitude_gc() [1/2]

double larcfm::GreatCircle::min_latitude_gc ( const LatLonAlt p1,
const LatLonAlt p2 
)
static

Estimate the minimum latitude of the great circle defined by the two points.

Parameters
p1point 1
p2point 2
Returns
minimum latitude

◆ min_latitude_gc() [2/2]

double larcfm::GreatCircle::min_latitude_gc ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

Estimate the minimum latitude of the great circle defined by the two points.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
minimum latitude

◆ passingDirection()

int larcfm::GreatCircle::passingDirection ( const LatLonAlt so,
const Velocity vo,
const LatLonAlt si,
const Velocity vi 
)
static

Returns values describing if the ownship state will pass in front of or behind the intruder (from a horizontal perspective)

Parameters
soownship position
voownship velocity
siintruder position
viintruder velocity
Returns
1 if ownship will pass in front (or collide, from a horizontal sense), -1 if ownship will pass behind, 0 if collinear or parallel or closest intersection is behind you

◆ representative_course()

double larcfm::GreatCircle::representative_course ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
static

A representative course (course relative to true north) for the entire arc on the great circle route from lat/long #1 to lat/long #2. The value is in internal units of angles (radians), and is a compass angle [0..2*Pi]: clockwise from true north. This is currently calculated as the initial course from the midpoint of the arc to its endpoint.

Parameters
lat1latitude of point 1
lon1longitude of point 1
lat2latitude of point 2
lon2longitude of point 2
Returns
representative course

◆ side_angle_angle()

Triple< double, double, double > larcfm::GreatCircle::side_angle_angle ( double  a,
double  A,
double  B,
bool  firstSolution 
)
static

Solve the spherical triangle when one has a side (in angular distance), and two angles. The side is not between the angles. The sides are labeled a, b, and c. The angles are labelled A, B, and C. Side a is opposite angle A, and so forth.

Given these constraints, in some cases two solutions are possible. To get one solution set the parameter firstSolution to true, to get the other set firstSolution to false. A firstSolution == true will return a smaller side, b, than firstSolution == false.

Parameters
aone side (in angular distance)
Athe angle opposite the side a
Banother angle
firstSolutionselect which solution to use
Returns
a Triple of side b, angle C, and the side c.

◆ side_angle_side()

Triple< double, double, double > larcfm::GreatCircle::side_angle_side ( double  a,
double  C,
double  b 
)
static

This implements the spherical cosine rule to complete a triangle on the unit sphere

Parameters
aside a (angular distance)
Cangle between sides a and b
bside b (angular distance)
Returns
triple of A,B,c (angle opposite a, angle opposite b, side opposite C)

◆ side_side_angle()

Triple< double, double, double > larcfm::GreatCircle::side_side_angle ( double  b,
double  a,
double  A,
bool  firstSolution 
)
static

Solve the spherical triangle when one has a side (in angular distance), another side, and an angle between sides. The angle is not between the sides. The sides are labeled a, b, and c. The angles are labelled A, B, and C. Side a is opposite angle A, and so forth.

Given these constraints, in some cases two solutions are possible. To get one solution set the parameter firstSolution to true, to get the other set firstSolution to false. A firstSolution == true will return a smaller angle, B, than firstSolution == false.

Parameters
bone side (in angular distance)
aanother side (in angular distance)
Athe angle opposite the side a
firstSolutionselect which solution to use
Returns
a Triple of angles B and C, and the side c.

◆ small_circle_arc_angle()

double larcfm::GreatCircle::small_circle_arc_angle ( double  radius,
double  arcLength 
)
static

Accurately calculate the angular distance of an arc on a small circle (turn) on the sphere.

Parameters
radiusalong-surface radius of small circle
arcLengthlinear (m) length of the arc. This is the along-line length of the arc.
Returns
Angular distance of the arc around the small circle (from 0 o 2pi) Note: A 100 km radius turn over 100 km of turn produces about 0.0024 degrees of error.

◆ small_circle_arc_length()

double larcfm::GreatCircle::small_circle_arc_length ( double  radius,
double  arcAngle 
)
static

Accurately calculate the linear distance of an arc on a small circle (turn) on the sphere.

Parameters
radiusalong-surface radius of small circle
arcAngleangular (radian) length of the arc. This is the angle between two great circles that intersect at the small circle's center.
Returns
linear distance of the small circle arc Note: A 100 km radius turn over 60 degrees produces about 4.3 m error.

◆ small_circle_rotation()

LatLonAlt larcfm::GreatCircle::small_circle_rotation ( const LatLonAlt so,
const LatLonAlt center,
double  angle 
)
static

EXPERIMENTAL Given a small circle, rotate a point

Parameters
sopoint on circle
centercenter of circle
angleangle of rotation around center (positive is clockwise)
Returns
another position on the circle

◆ spherical2xyz() [1/2]

Vect3 larcfm::GreatCircle::spherical2xyz ( const LatLonAlt lla)
static

Transforms a lat/lon position to a point in R3 (on a sphere) This is an Earth-Centered, Earth-Fixed translation (ECEF, assuming earth-surface altitude). From Wikipedia: en.wikipedia.org/wiki/Curvilinear_coordinates (contents apparently moved to Geodetic datum entry)

The x-axis intersects the sphere of the earth at 0 latitude (the equator) and 0 longitude (Greenwich).

Parameters
llalattitude/longitude point
Returns
point in R3 on surface of the earth (zero altitude)

◆ spherical2xyz() [2/2]

Vect3 larcfm::GreatCircle::spherical2xyz ( double  lat,
double  lon 
)
static

Transforms a lat/lon position to a point in R3 (on a sphere) This is an Earth-Centered, Earth-Fixed translation (assuming earth-surface altitude). From Wikipedia: en.wikipedia.org/wiki/Curvilinear_coordinates (contents apparently moved to Geodetic datum entry)

The x-axis intersects the sphere of the earth at 0 latitude (the equator) and 0 longitude (Greenwich).

Parameters
latlatitude
lonlongitude
Returns
point in R3 on surface of the earth (zero altitude)

◆ surface_distance()

double larcfm::GreatCircle::surface_distance ( double  chord_distance)
static

Return the surface distance (at the nominal earth radius) corresponding to a given chord distance (through the earth).

Parameters
chord_distancecordal distance
Returns
surface distance

◆ velocity_average()

Velocity larcfm::GreatCircle::velocity_average ( const LatLonAlt p1,
const LatLonAlt p2,
double  t 
)
static

Estimate the velocity on the great circle from lat/lon #1 to lat/lon #2 with the given amount of time. Essentially, the velocity at the mid point between lat/lon #1 and lat/lon #2. If points #1 and #2 are essentially the same (about 1 meter apart), then a zero vector is returned. Also if the absolute value of time is less than 1 [ms], then a zero vector is returned.

If the time is negative, then the velocity is along the great circle formed by #1 and #2, but in the opposite direction from #2.

This is an estimate of the velocity. This calculation ignores altitude when calculating great circle distance. Small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
p1a point
p2another point
ttime
Returns
average velocity

◆ velocity_average_speed()

Velocity larcfm::GreatCircle::velocity_average_speed ( const LatLonAlt s1,
const LatLonAlt s2,
double  speed 
)
static

Estimate the velocity on the great circle from lat/lon #1 to lat/lon #2 with the given speed. If the time is negative, then the velocity is along the great circle formed by #1 and #2, but in the opposite direction from #2.

This is an estimate of the velocity. This calculation ignores altitude when calculating great circle distance. Small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
s1a point
s2another point
speedspeed between point
Returns
average velocity

◆ velocity_final()

Velocity larcfm::GreatCircle::velocity_final ( const LatLonAlt p1,
const LatLonAlt p2,
double  t 
)
static

Estimate the final velocity on the great circle from lat/lon #1 to lat/lon #2 with the given amount of time. The track angle of the velocity is the course from point #1 to #2 roughly at point #2. If points #1 and #2 are essentially the same (about 1 meter apart), then a zero vector is returned. Also if the absolute value of time is less than 1 [ms], then a zero vector is returned.

If the time is negative, then the velocity is along the great circle formed by #1 and #2, but in the opposite direction from #2.

This is an estimate of the velocity. This calculation ignores altitude when calculating great circle distance. Small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
p1a point
p2another point
ttime
Returns
final velocity

◆ velocity_initial()

Velocity larcfm::GreatCircle::velocity_initial ( const LatLonAlt p1,
const LatLonAlt p2,
double  t 
)
static

Compute the initial velocity on the great circle from lat/lon #1 to lat/lon #2 with the given amount of time. If points #1 and #2 are essentially the same (about 1 meter apart), then a zero vector is returned. Also if the absolute value of time is less than 1 [ms], then a zero vector is returned.

If the time is negative, then the velocity is along the great circle formed by #1 and #2, but in the opposite direction from #2.

This calculation ignores altitude when calculating great circle distance. Small errors (typically less than 0.5%) will be introduced at typical aircraft altitudes.

Parameters
p1point 1
p2point 2
ttime
Returns
velocity from point 1 to point 2, taking time t

◆ xyz2spherical()

LatLonAlt larcfm::GreatCircle::xyz2spherical ( const Vect3 v)
static

Transforms a R3 position on the earth surface into lat/lon coordinates This is an Earth-Centered, Earth-Fixed translation (ECEF, assuming earth-surface altitude). From Wikipedia: en.wikipedia.org/wiki/Curvilinear_coordinates (contents apparently moved to Geodetic datum entry) We take a standard radius of the earth as defined in GreatCircle, and treat altitude as 0.

Parameters
vposition in R3, with ECEF origin
Returns
LatLonAlt point on surface of the earth (zero altitude)

Member Data Documentation

◆ spherical_earth_radius

const double larcfm::GreatCircle::spherical_earth_radius = 6366707.0194937070000000000
static

The radius of a spherical "Earth" assuming 1 nautical mile is 1852 meters (as defined by various international committees) and that one nautical mile is equal to one minute of arc (traditional definition of a nautical mile). This value lies between the major and minor axis as defined by WGS84.


The documentation for this class was generated from the following files: