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

#include <Position.h>

Public Member Functions

 Position ()
 
 Position (const LatLonAlt &lla)
 
 Position (const Vect3 &v)
 
 Position (const Position &p)
 
bool almostEquals (const Position &v) const
 
bool almostEquals (const Position &pp, double epsilon_horiz, double epsilon_vert) const
 
bool almostEquals2D (const Position &pp, double epsilon_horiz) const
 
bool operator== (const Position &v) const
 
bool operator!= (const Position &v) const
 
Vect2 vect2 () const
 
const Vect3vect3 () const
 
const LatLonAltlla () const
 
bool isInvalid () const
 
double x () const
 
double y () const
 
double z () const
 
double lat () const
 
double lon () const
 
double alt () const
 
double latitude () const
 
double longitude () const
 
double altitude () const
 
double xCoordinate () const
 
double yCoordinate () const
 
double zCoordinate () const
 
bool isLatLon () const
 
const Position mkX (const double xx) const
 
const Position mkLon (const double lon) const
 
const Position mkY (const double yy) const
 
const Position mkLat (const double lat) const
 
const Position mkZ (const double zz) const
 
const Position mkAlt (const double alt) const
 
const Position zeroAlt () const
 
double distanceH (const Position &p) const
 
double distanceV (const Position &p) const
 
double signedDistanceV (const Position &p) const
 
const Position linear (const Velocity &v, double time) const
 
const Position linearEst (double dn, double de) const
 
const Position linearEst (const Velocity &vo, double time) const
 
const std::pair< Position, VelocitylinearDist2D (double track, double d, double gsAt_d) const
 
const Position linearDist2D (double track, double d) const
 
const Position midPoint (const Position &p2) const
 
Position interpolate (const Position &p2, double f) const
 
double track (const Position &p) const
 
Velocity initialVelocity (const Position &p2, double time) const
 
Velocity finalVelocity (const Position &p2, double time) const
 
double representativeTrack (const Position &p) const
 
Velocity averageVelocity (const Position &p2, double speed) const
 
Velocity avgVelocity (const Position &p2, double dt) const
 
bool isWest (const Position &a) const
 
bool LoS (const Position &p2, double D, double H)
 
bool collinear (Position p1, Position p2) const
 
std::string toUnitTest () const
 
std::string toUnitTestSI () const
 
std::string toString () const
 
std::string toString (int prec) const
 
std::string toString2D (int prec) const
 
std::string toStringUnits (const std::string &xunit, const std::string &yunit, const std::string &zunit) const
 
std::vector< std::string > toStringList () const
 
std::vector< std::string > toStringList (int precision) const
 
std::vector< std::string > toStringList (int precision, int latLonExtraPrecision, bool internalUnits) const
 
std::string toStringNP () const
 
std::string toStringNP (int precision) const
 

Static Public Member Functions

static Position makeLatLonAlt (double lat, double lon, double alt)
 
static Position makeLatLonAlt (double lat, std::string lat_unit, double lon, std::string lon_unit, double alt, std::string alt_unit)
 
static Position mkLatLonAlt (double lat, double lon, double alt)
 
static Position makeXYZ (double x, double y, double z)
 
static Position mkXYZ (double x, double y, double z)
 
static Position makeXYZ (double x, std::string x_unit, double y, std::string y_unit, double z, std::string z_unit)
 
static Position make (const LatLonAlt &lla)
 
static Position make (const Vect3 &p)
 
static const PositionZERO_LL ()
 
static const PositionZERO_XYZ ()
 
static const PositionINVALID ()
 
static std::pair< Position, double > intersection (const Position &so, const Velocity &vo, const Position &si, const Velocity &vi)
 
static std::pair< Position, double > intersection (const Position &so, const Position &so2, double dto, const Position &si, const Position &si2)
 
static Position intersection2D (const Position &so, const Position &so2, const Position &si, const Position &si2)
 
static const Position parseLL (const std::string &s)
 
static const Position parseXYZ (const std::string &s)
 
static const Position parse (const std::string &s)
 

Private Member Functions

 Position (const double x, const double y, const double z)
 

Private Attributes

bool latlon
 
LatLonAlt ll
 
Vect3 s3
 

Detailed Description

This class captures a single position represented in either Euclidean or Lat/Lon coordinates.
This class is immutable.

This class is designed to be resilient; The methods do not return errors when a position in the "wrong" geometry is provided. So the method x() will return a value even when the original position was provided in LatLonAlt.
The correspondence is as follows:

Constructor & Destructor Documentation

◆ Position() [1/3]

larcfm::Position::Position ( )

Create an empty Position object

◆ Position() [2/3]

larcfm::Position::Position ( const LatLonAlt lla)
explicit

Construct a new Position object from a LatLonAlt object. The position will be a Lat/Lon position.

Parameters
llaa latitude/longitude/altitude object

◆ Position() [3/3]

larcfm::Position::Position ( const Vect3 v)
explicit

Construct a new Position object from a Vect3 object. This method assumes the Vect3 is in internal units.

Parameters
vthree dimensional vector

Member Function Documentation

◆ almostEquals() [1/2]

bool larcfm::Position::almostEquals ( const Position pp,
double  epsilon_horiz,
double  epsilon_vert 
) const

Checks if two Positions are almost the same.

Parameters
ppPosition for comparison
epsilon_horizallowable horizontal deviation [m]
epsilon_vertallowable vertical deviation [m]
Returns
true, if this Position is almost equal to v.

◆ almostEquals() [2/2]

bool larcfm::Position::almostEquals ( const Position v) const

Checks if two Positions are almost the same.

Parameters
vPosition for comparison
Returns
true, if this Position is almost equal to v.

◆ almostEquals2D()

bool larcfm::Position::almostEquals2D ( const Position pp,
double  epsilon_horiz 
) const
Parameters
pp
epsilon_horizmax distance in meters
Returns

◆ alt()

double larcfm::Position::alt ( ) const

Return the altitude

Returns
altitude [internal]

◆ altitude()

double larcfm::Position::altitude ( ) const

Return the altitude in feet

Returns
altitude [ft]

◆ averageVelocity()

Velocity larcfm::Position::averageVelocity ( const Position p2,
double  speed 
) const

Return the average velocity between the current position and the given position, with the given speed [internal units].

Parameters
p2another position
speedthe ground speed going from this Position to the given position
Returns
velocity (3D)

Return the average velocity between the current position and the given position, with the given speed [internal units].

◆ avgVelocity()

Velocity larcfm::Position::avgVelocity ( const Position p2,
double  dt 
) const

Return the average velocity between the current position and the given position, with the given delta time dt.

Parameters
p2another position
dtdelta time
Returns
average velocity

Return the average velocity between the current position and the given position, with the given delta time dt.

◆ distanceH()

double larcfm::Position::distanceH ( const Position p) const

Return the horizontal distance between the current Position and the given Position

Parameters
panother position
Returns
horizontal distance

◆ distanceV()

double larcfm::Position::distanceV ( const Position p) const

Return the vertical distance between the current Position and the given Position.

Parameters
panother position
Returns
vertical distance (absolute distance)

◆ finalVelocity()

Velocity larcfm::Position::finalVelocity ( const Position p2,
double  time 
) const

return the velocity going from this to p over dt seconds. Returns a ZERO velocity if dt <= 0

◆ intersection()

std::pair< Position, double > larcfm::Position::intersection ( const Position so,
const Position so2,
double  dto,
const Position si,
const Position si2 
)
static

Returns intersection point and time of intersection relative to the time of position so for time return value, it assumes that an aircraft travels from so1 to so2 in dto seconds and the other aircraft from si to si2 a negative time indicates that the intersection occurred in the past (relative to directions of travel of so1)

◆ intersection2D()

Position larcfm::Position::intersection2D ( const Position so,
const Position so2,
const Position si,
const Position si2 
)
static

Returns intersection point between two lines defined by the four positions. If the Postions are LatLonAlt then the lines are Great Circle lines, otherwise they are infinite lines in Euclidean space.

Parameters
sofirst point of infinite line A
so2second point of infinite line A
sifirst point of infinite line B
si2second point of infinite line B
Returns
the intersection point. If parallel, return INVALID

Returns intersection point and time of intersection relative to the time of position so for time return value, it assumes that an aircraft travels from so1 to so2 in dto seconds and the other aircraft from si to si2 a negative time indicates that the intersection occurred in the past (relative to directions of travel of so1)

◆ isInvalid()

bool larcfm::Position::isInvalid ( ) const

Returns true if this Position is invalid

Returns
true, if invalid position

◆ isLatLon()

bool larcfm::Position::isLatLon ( ) const

Return if this Position is a latitude or longitude

Returns
true if latitude/longitude

◆ isWest()

bool larcfm::Position::isWest ( const Position a) const

Return true if this point is west of the given point (this.x < a.x)

Parameters
aother point
Returns
true if this.x < a.x (or this.lon < a.lon, accounting for wraparound)

◆ lat()

double larcfm::Position::lat ( ) const

Return the latitude

Returns
latitude [internal]

◆ latitude()

double larcfm::Position::latitude ( ) const

Return the latitude in degrees north

Returns
latitude

◆ linear()

const Position larcfm::Position::linear ( const Velocity v,
double  time 
) const

Perform a linear projection of the current Position with given velocity and time. If isLatLon() is true, then a great circle route is followed and the velocity represents the initial velocity along the great circle.

Reminder: If this is used in a stepwise fashion over lat/lon, be careful when passing over or near the poles and keep the velocity track in mind.

Parameters
vthe velocity
timethe time from the current point Note: using a negative time value is the same a velocity moving in the opposite direction (along the great circle, if appropriate)
Returns
linear projection of the position

◆ linearDist2D()

const Position larcfm::Position::linearDist2D ( double  track,
double  d 
) const

Returns a new position in the given direction at the given distance from this point The altitude is not changed!

Parameters
tracktrack
ddistance
Returns
position

◆ linearEst() [1/2]

const Position larcfm::Position::linearEst ( const Velocity vo,
double  time 
) const

Perform a estimation of a linear projection of the current Position with the given velocity and time.

Parameters
vothe velocity
timethe time from the current point
Returns
linear projection of the position

◆ linearEst() [2/2]

const Position larcfm::Position::linearEst ( double  dn,
double  de 
) const

Calculate a new position that is offset from the current position by (dn,de)

Parameters
dnoffset in north direction (m)
deoffset in east direction (m)
Returns
linear projection of the position

◆ lla()

const LatLonAlt & larcfm::Position::lla ( ) const

Return the associated LatLonAlt object

◆ lon()

double larcfm::Position::lon ( ) const

Return the longitude

Returns
longitude [internal]

◆ longitude()

double larcfm::Position::longitude ( ) const

Return the longitude in degrees east

Returns
longitude

◆ LoS()

bool larcfm::Position::LoS ( const Position p2,
double  D,
double  H 
)

Determine if a loss of separation has occurred (using either geodesic or Euclidean calculations)

Parameters
p2the position of the other aircraft
Dhorizontal distance to specify loss of separation
Hvertical distance to specify loss of separation
Returns
true if there is a loss of separation

◆ make() [1/2]

Position larcfm::Position::make ( const LatLonAlt lla)
static

Construct a new Position object from a LatLonAlt object. The position will be a Lat/Lon position.

Parameters
llaa latitude/longitude/altitude object
Returns
new Position object

◆ make() [2/2]

Position larcfm::Position::make ( const Vect3 p)
static

Construct a new Position object from a Vect3 object. This method assumes the Vect3 is in internal units.

Parameters
vthree dimensional vector
Returns
new Position object

◆ makeLatLonAlt() [1/2]

Position larcfm::Position::makeLatLonAlt ( double  lat,
double  lon,
double  alt 
)
static

Creates a new lat/lon position with coordinates (lat,lon,alt).

Parameters
latlatitude [deg north latitude]
lonlongitude [deg east longitude]
altaltitude [ft]
Returns
new position

◆ makeLatLonAlt() [2/2]

Position larcfm::Position::makeLatLonAlt ( double  lat,
std::string  lat_unit,
double  lon,
std::string  lon_unit,
double  alt,
std::string  alt_unit 
)
static

Creates a new lat/lon position with coordinates (lat,lon,alt).

Parameters
latlatitude [lat_unit north latitude]
lat_unitunits of latitude
lonlongitude [lon_unit east longitude]
lon_unitunits of latitude
altaltitude [alt_unit]
alt_unitunits of altitude
Returns
new position

◆ makeXYZ() [1/2]

Position larcfm::Position::makeXYZ ( double  x,
double  y,
double  z 
)
static

Creates a new Euclidean position with coordinates (x,y,z).

Parameters
xcoordinate [nmi]
ycoordinate [nmi]
zaltitude [ft]
Returns
new position

◆ makeXYZ() [2/2]

Position larcfm::Position::makeXYZ ( double  x,
std::string  x_unit,
double  y,
std::string  y_unit,
double  z,
std::string  z_unit 
)
static

Creates a new Euclidean position with coordinates (x,y,z).

Parameters
xcoordinate [x_unit]
x_unitunits of x coordinate
ycoordinate [y_unit]
y_unitunits of y coordinate
zaltitude [z_unit]
z_unitunits of z coordinate
Returns
new position

◆ midPoint()

const Position larcfm::Position::midPoint ( const Position p2) const

Return the mid point between the current position and the given position

Parameters
p2the other position
Returns
the midpoint

◆ mkAlt()

const Position larcfm::Position::mkAlt ( const double  alt) const

Make a new Position from the current one with the altitude changed (internal units)

Parameters
altnew altitude value
Returns
a new Position

◆ mkLat()

const Position larcfm::Position::mkLat ( const double  lat) const

Make a new Position from the current one with the latitude changed

Parameters
latnew latitude value
Returns
a new Position

◆ mkLatLonAlt()

Position larcfm::Position::mkLatLonAlt ( double  lat,
double  lon,
double  alt 
)
static

Creates a new lat/lon position with coordinates (lat,lon,alt).

Parameters
latlatitude [radians]
lonlongitude [radians]
altaltitude [m]
Returns
new position

◆ mkLon()

const Position larcfm::Position::mkLon ( const double  lon) const

Make a new Position from the current one with the longitude changed

Parameters
lonnew longitude value
Returns
a new Position

◆ mkX()

const Position larcfm::Position::mkX ( const double  xx) const

Make a new Position from the current one with the X coordinate changed

◆ mkXYZ()

Position larcfm::Position::mkXYZ ( double  x,
double  y,
double  z 
)
static

Creates a new Euclidean position with coordinates (x,y,z).

Parameters
xcoordinate [m]
ycoordinate [m]
zaltitude [m]
Returns
new position

◆ mkY()

const Position larcfm::Position::mkY ( const double  yy) const

Make a new Position from the current one with the Y coordinate changed

◆ mkZ()

const Position larcfm::Position::mkZ ( const double  zz) const

Make a new Position from the current one with the Z coordinate changed

◆ operator!=()

bool larcfm::Position::operator!= ( const Position v) const

Are these two positions unequal?

◆ operator==()

bool larcfm::Position::operator== ( const Position v) const

Are these two positions equal?

◆ parse()

const Position larcfm::Position::parse ( const std::string &  s)
static

This interprets a string into a LatLonAlt or XYZ position, if appropriate units are given. If no units are present, it returns an invalid Position.

Parameters
sstring to parse
Returns
position

◆ parseLL()

const Position larcfm::Position::parseLL ( const std::string &  s)
static

This interprets a string as a LatLonAlt position with units in deg/deg/ft or the specified units (inverse of toString())

Parameters
sstring to parse
Returns
position

This interprets a string as a LatLonAlt position with units of deg/deg/ft or in the specified units (inverse of toString())

◆ parseXYZ()

const Position larcfm::Position::parseXYZ ( const std::string &  s)
static

This interprets a string as a XYZ position with units in NM/NM/ft or the specified units (inverse of toString())

Parameters
sstring to parse
Returns
position

This interprets a string as a XYZ position with units of nmi/nmi/ft or in the specified units (inverse of toString())

◆ representativeTrack()

double larcfm::Position::representativeTrack ( const Position p) const

Return the track angle of the vector from the current Position to the given Position, based on representative course

Parameters
panother position
Returns
representative course

◆ signedDistanceV()

double larcfm::Position::signedDistanceV ( const Position p) const

Return the vertical distance between the current Position and the given Position. Positive values mean the current Position is above the given Position

Parameters
panother position
Returns
vertical distance (positive values mean current position is above the given position

◆ toString() [1/2]

std::string larcfm::Position::toString ( ) const

Return a string representation

◆ toString() [2/2]

std::string larcfm::Position::toString ( int  prec) const

Return a string representation

Parameters
precdigits of precision
Returns
string representation

◆ toString2D()

std::string larcfm::Position::toString2D ( int  prec) const

Return a string representation

Parameters
precdigits of precision
Returns
string representation

◆ toStringNP() [1/2]

std::string larcfm::Position::toStringNP ( ) const

Return a string representation with a default precision but without parentheses.

Returns
string representation

◆ toStringNP() [2/2]

std::string larcfm::Position::toStringNP ( int  precision) const

Return a string representation, with a user-specified digits of precision (0-15) without units or parentheses.

Parameters
precisiondigits of precision
Returns
string representation

◆ toStringUnits()

std::string larcfm::Position::toStringUnits ( const std::string &  xunit,
const std::string &  yunit,
const std::string &  zunit 
) const

Return a string representation using the given unit conversions (latitude and longitude, if appropriate, are always in degrees, so only the z unit is used in that case)

Return a string representation using the given unit conversions (latitude and longitude, if appropriate, are always in degrees, so only the z unit is used in that case).

◆ track()

double larcfm::Position::track ( const Position p) const

Return the track angle of the vector from the current Position to the given Position, based on initial course

Parameters
panother position
Returns
track angle within [0..2PI]

◆ vect2()

Vect2 larcfm::Position::vect2 ( ) const

Return the horizontal position as a standard vect2(). This returns either (x,y), or, equivalently, (lon, lat).

Returns
2D vector

◆ vect3()

const Vect3 & larcfm::Position::vect3 ( ) const

Return the three dimensional position vector

◆ x()

double larcfm::Position::x ( ) const

Return the x coordinate

Returns
x coordinate

◆ xCoordinate()

double larcfm::Position::xCoordinate ( ) const

Return the x coordinate in [NM]

Returns
x coordinate [NM]

◆ y()

double larcfm::Position::y ( ) const

Return the y coordinate

Returns
y coordinate

◆ yCoordinate()

double larcfm::Position::yCoordinate ( ) const

Return the y coordinate in [NM]

Returns
y coordinate [NM]

◆ z()

double larcfm::Position::z ( ) const

Return the z coordinate

Returns
z coordinate

◆ zCoordinate()

double larcfm::Position::zCoordinate ( ) const

Return the z coordinate in [ft]

Returns
z coordinate [ft]

◆ ZERO_LL()

const Position & larcfm::Position::ZERO_LL ( )
static

Zero latitude, longitude and altitude

◆ ZERO_XYZ()

const Position & larcfm::Position::ZERO_XYZ ( )
static

Zero x, y, and z

◆ zeroAlt()

const Position larcfm::Position::zeroAlt ( ) const

Make a new Position from the current one with an altitude of zero

Returns
a new Position

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