#include <cgridposition.h>
Public Member Functions | |
CGridPosition () | |
Default constructor. Initializes to an invalid value (N=0). | |
CGridPosition (unsigned int arg_T, int arg_u, int arg_v) | |
Construction from exponential level, u and v. | |
CGridPosition (CGridPosition p1, CGridPosition p2) | |
bool | operator== (const CGridPosition &p) const |
bool | operator!= (const CGridPosition &p) const |
Inequality test. Equivalent to !operator==(p). | |
double | getLatitude () const |
Returns the latitude (in radians) of the position. | |
double | getLongitude () const |
Returns the longitude (in radians) of the position. | |
CVector | getDirection () const |
Returns the direction vector (length 1.0) from the center of the planet to the position. | |
CMatrix | getOrientation () const |
double | getScale () const |
CGridPosition | getParentGridPos () const |
Returns the grid position of the parent tile. | |
bool | makeLowerLevel (bool force=false) |
void | makeHigherLevel () |
Converts this position into an equivalent position at the higher level (T+1). | |
Move to neighbor grid position | |
CGridPosition | getLeftPos () const |
Returns the position directly left to this position. | |
CGridPosition | getRightPos () const |
Returns the position directly right to this position. | |
CGridPosition | getTopPos () const |
Returns the position directly above this position. | |
CGridPosition | getBottomPos () const |
Returns the position directly below this position. | |
Public Attributes | |
unsigned int | T |
Exponential grid level. When changing this manually, make sure to change N too, such that N==1<<T. | |
unsigned int | N |
Linear grid level. When changing this manually, make sure to change T too, such that N==1<<T. | |
int | u |
Integer longitudinal grid position. Recommended range is [0..N). | |
int | v |
Integer latitudinal grid position. Zero indicates a position on the equator. |
Every grid position has a scale and integer map coordinates.
The scale is represented in two ways by the numbers T and N. T uses an exponential scale, such that an increase of T by one means a twice as high resolution. N uses a linear scale, in such a way that N is always the number of longitudinal grid positions on the equator. They are (should always be) related by the formula N = 2^T.
The map coordinates are represented by u and v. They need to be understood w.r.t. N, in such a way that u/N and v/N are actual measures of the position on the sphere. They are coordinates on a Mercator projection map: v/N is simply the longitude (divided by 360 degrees), but the relation between latitude and u/N is more complicated. It is such that, for any given scale and position, a small increase in u represents the same distance as the same small increase in v.
libProcTer::CGridPosition::CGridPosition | ( | ) |
Default constructor. Initializes to an invalid value (N=0).
libProcTer::CGridPosition::CGridPosition | ( | unsigned int | arg_T, | |
int | arg_u, | |||
int | arg_v | |||
) |
Construction from exponential level, u and v.
libProcTer::CGridPosition::CGridPosition | ( | CGridPosition | p1, | |
CGridPosition | p2 | |||
) |
Construction from two other grid positions. The constructed object will contain the mid position between p1 and p2.
CGridPosition libProcTer::CGridPosition::getBottomPos | ( | ) | const |
Returns the position directly below this position.
CVector libProcTer::CGridPosition::getDirection | ( | ) | const |
Returns the direction vector (length 1.0) from the center of the planet to the position.
double libProcTer::CGridPosition::getLatitude | ( | ) | const |
Returns the latitude (in radians) of the position.
CGridPosition libProcTer::CGridPosition::getLeftPos | ( | ) | const |
Returns the position directly left to this position.
double libProcTer::CGridPosition::getLongitude | ( | ) | const |
Returns the longitude (in radians) of the position.
CMatrix libProcTer::CGridPosition::getOrientation | ( | ) | const |
Returns the orientation matrix of the surface at this position w.r.t. the planet.
CGridPosition libProcTer::CGridPosition::getParentGridPos | ( | ) | const |
Returns the grid position of the parent tile.
CGridPosition libProcTer::CGridPosition::getRightPos | ( | ) | const |
Returns the position directly right to this position.
double libProcTer::CGridPosition::getScale | ( | ) | const |
Returns the scale of the grid at the position. This is the distance equivalent to an increase of u or v with 1. The scale is normalized to a planet radius of 1.0.
CGridPosition libProcTer::CGridPosition::getTopPos | ( | ) | const |
Returns the position directly above this position.
void libProcTer::CGridPosition::makeHigherLevel | ( | ) |
Converts this position into an equivalent position at the higher level (T+1).
bool libProcTer::CGridPosition::makeLowerLevel | ( | bool | force = false |
) |
Converts this position into an equivalent position at the lower level (T-1).
force | If force=true is given, the conversion is done even when no exact equivalent position exists in the lower level grid. In that case, the parent grid position is assigned. |
bool libProcTer::CGridPosition::operator!= | ( | const CGridPosition & | p | ) | const [inline] |
Inequality test. Equivalent to !operator==(p).
bool libProcTer::CGridPosition::operator== | ( | const CGridPosition & | p | ) | const |
Equality test. Only returns true if both positions are exactly equal. Returns false on two objects that represent the same position on different scales.
unsigned int libProcTer::CGridPosition::N |
Linear grid level. When changing this manually, make sure to change T too, such that N==1<<T.
unsigned int libProcTer::CGridPosition::T |
Exponential grid level. When changing this manually, make sure to change N too, such that N==1<<T.
Integer longitudinal grid position. Recommended range is [0..N).
Integer latitudinal grid position. Zero indicates a position on the equator.