This class manages the coordinate of a point on the surface of any spherical object.

You're viewing an older version of this page (#332). View the current version.

View versions (1)

Interface

Overview

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
GPL Licence — free for non commercial use. See Licence details.

Members of Position

CLASS MEMBER

m_latitude

CLASS MEMBER

m_longitude

CLASS METHOD

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.

Parameters

radians
A flag to indicate if the longitude and latitude are measured in radians rather than degrees.
longitude
The longitude of the position in degrees within the range [-180, 180].
latitude
The latitude of the position in degrees within the range [-90, 90].

CLASS METHOD

Position

CLASS METHOD

getLatitude

Returns the Latitude of the position in degrees (by default).

Parameters

radians
A flag to indicate if the returned longitude is in radians rather than degrees.

CLASS METHOD

getLongitude

Returns the Longitude of the position in degrees (by default).

Parameters

radians
A flag to indicate if the returned longitude is in radians rather than degrees.

CLASS METHOD

setLatitude

Assigns a new latitude to the position. By convention, northern latitudes are positive angles and southern latitudes are negative angles.

Parameters

radians
A flag to indicate if the provided latitude is measured in radians rather than degrees.
latitude
The latitude of the position in the range [-90^\circ , 90^\circ].

CLASS METHOD

setLongitude

Assigns a new longitude to the position. By convention, eastern longitudes are positive angles and western longitudes are negative angles.

Parameters

radians
A flag to indicate if the provided longitude is measured in radians rather than degrees.
longitude
The longitude of the position in the range [-180, 180].

CLASS METHOD

operator=

Copies one position to another

Parameters

rhs
is the position to be copied.

Returns

the address of the current position.

CLASS METHOD

operator==