Position
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.
Interface
#include <codecogs/maths/geometry/spherical/position.h>
using namespace Maths::Geometry::Spherical;
double m_latitude;double m_longitude;Position (double latitude=0, double longitude=0, bool radians=false)Position (const Position& rhs)double getLatitude(bool radians=false) constdouble getLongitude(bool radians=false) constvoid setLatitude (double latitude, bool radians=false)void setLongitude (double longitude, bool radians=false)Position& operator =(const Position& rhs)bool operator ==(const Position& rhs)const
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 awayMembers 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
CLASS METHOD
Position
CLASS METHOD
getLatitude
Returns the Latitude of the position in degrees (by default).
Parameters
CLASS METHOD
getLongitude
Returns the Longitude of the position in degrees (by default).
Parameters
CLASS METHOD
setLatitude
Assigns a new latitude to the position. By convention, northern latitudes are positive angles and southern latitudes are negative angles.
Parameters
CLASS METHOD
setLongitude
Assigns a new longitude to the position. By convention, eastern longitudes are positive angles and western longitudes are negative angles.
Parameters
CLASS METHOD
operator=
Copies one position to another
Parameters
Returns
CLASS METHOD