Position
This class manages the coordinate of a point on the surface of any spherical object.
Controller: will
Interface
C++
Class Position
This class hold the position as (latitude, longitude) in radians relative to the center of any spherical object. Storing positions in this way is essential in spherical geometry, and great circle calculations about the earths surface.Example 1
#include <codecogs/maths/geometry/spherical/latlong.h> #include <codecogs/maths/geometry/spherical/position.h> #include <codecogs/maths/geometry/spherical/angulardistance.h> #include <iostream> int main() { Position NewYork(latitude(40,47,0,'N'), longitude(73,58,0,'W')); Position London(latitude(51,32,0,'N'), longitude(0,5,0,'W')); std::cout << "If you stand in NewYork, London is " << distance(NewYork, London, 3951.0881) << " miles away" << std::endl; return 0; }
Output:If you stand in NewYork, London is 3451.07 miles away
Authors
- John Douglas (Dec, 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.
Members of Position
Position
This constructor creates a position using the specified latitude and longitude values. By convention, northern latitudes and eastern longitudes are positive angles and southern latitudes and western longitudes are negative angles.Position( double latitude = 0
double longitude = 0
bool radians = false
)[constructor] latitude The latitude of the position in degrees within the range . longitude The longitude of the position in degrees within the range . radians A flag to indicate if the longitude and latitude are measured in radians rather than degrees.
GetLatitude
Returns the Latitude of the position in degrees (by default).doublegetLatitude( bool radians = false
) radians A flag to indicate if the returned longitude is in radians rather than degrees.
GetLongitude
Returns the Longitude of the position in degrees (by default).doublegetLongitude( bool radians = false
) radians A flag to indicate if the returned longitude is in radians rather than degrees.
SetLatitude
Assigns a new latitude to the position. By convention, northern latitudes are positive angles and southern latitudes are negative angles.voidsetLatitude( double latitude bool radians = false
) latitude The latitude of the position in the range . radians A flag to indicate if the provided latitude is measured in radians rather than degrees.
SetLongitude
Assigns a new longitude to the position. By convention, eastern longitudes are positive angles and western longitudes are negative angles.voidsetLongitude( double longitude bool radians = false
) longitude The longitude of the position in the range . radians A flag to indicate if the provided longitude is measured in radians rather than degrees.
=
Copies one position to anotherPosition operator&=( const Position& rhs ) rhs is the position to be copied.
Returns
- the address of the current position.