TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

struct LatLon in Tinman.Terrain.Georef

A set of longitude/latitude coordinates, measured in degrees, with 64-bit floating-point precision.

struct LatLon implements IEquatable<LatLon>

Remarks

A set of longitude/latitude values represent a location on a planetary body, for example on earth:

+---------------------------------------------------------------------------------+  90°N
|                     @@ @@@@@@@@     @@@           @                             | +90°
|             @           @@@@@@              @     @@@@                          |
|    @@@@  @  @@@ @   @    @@@@@        @      @ @@@@@@@@@@@@@@@@@  @             |
|  @@@@@@@@@@@@@@@   @@@  @@           @ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@         |
| @@@@@@@@@@@@@@@   @     @          @  @@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@          |
|      @@@@@@@@@   @@@                @  @@@@@@@@@@@@@@@@@@@@@@@@@                |
|      @@@@@@@@@@@@@@@             @  @@ @@@@@@@@@@@ @@@@@@@@@@@@@    @           |
|      @@@@@@@@@@@@@@@              @@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@              |
|      @@@@@@@  @@@@@              @@@ @@@@@ @@ @@@@@@@@@@@@@@@ @@@@              |
|     @@@@@@@@@@@@@              @@   @  @   @@ @@@@@@@@@@@@@@@@@@@  @            |
|     @@@@@@@@@@@                @@    @@ @@@@@  @@@@@@@@@@@@@@@                  |
|     @@@@@@@@@@@                  @@@      @@@@@@@@@@ @@@@@@@@@@  @ @            |
|     @@@@@@@@@                  @@@@@@     @@@@@@@@@@@@@@@@@@@@@@                |
|      @@@@                      @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@                |
|       @@@                     @@@@@@@@@@@@ @@@@   @@@@@@ @ @@@@@                |    L
|       @@     @               @@@@@@@@@ @@@@ @@@@@  @@@@@ @@@@@                  |    a
|        @@@@  @               @@@@@@@@ @@@@@ @@@@    @@@   @ @                   |    t
|          @@@                 @@@@@@@@@@@@@@  @       @     @ @                  |    i
|               @@              @@@@@@@@@@@@@@  @      @      @@                  + 0° t
|              @@@@@            @@  @@ @@@@@@@@@        @    @      @ @         @ |    u
|              @@@@@@@                @@@@@@@@@@                 @                |    d
|             @@@@@@@@                @@@@@@@@@              @  @@                |    e
|             @@@@@@@@@@@             @@@@@@@@                @  @   @@@@         |
|             @@@@@@@@@@@@             @@@@@@@                 @        @@        |
|              @@@@@@@@@@@             @@@@@@@                            @       |
|               @@@@@@@@@              @@@@@@@                       @@ @         |
|                @@@@@@@@               @  @@  @                   @@@@@@         |
|                @@@ @@@@              @@@@@   @                  @@@@@@@@        |
|                @@@ @@                @ @@@                     @@@@@@@@@        |
|                @@@@@@                  @@@                    @@@@@@@@@@        |
|                 @@@@                  @@@                      @@@ @@@@@        |
|                 @@@                                                 @@@     @   |
|                 @@                                                          @   |
|                 @@                                                  @           |
|                 @@                                                       @      |
|                  @                                                              |
|                   @                                                             |  90°S
+-----------------------------------------+---------------------------------------+ -90°
180°W                                    0°                                  180°E
-180°                                 Longitude                              +180°
The mapping from longitude/latitude coordinates to cubemap coordinates (see Cubemap class) is defined as follows:
Cubemap | Face center lies at:
 face   | Longitude | Latitude
--------+-----------+---------
   X-   |     90°W  |   0°N
        |    -90°   |   0°
--------+-----------+---------
   X+   |     90°E  |   0°N
        |    +90°   |   0°
--------+-----------+---------
   Y-   |      0°E  |  90°N
        |      0°   | +90°
--------+-----------+---------
   Y+   |      0°E  |  90°S
        |      0°   | -90°
--------+-----------+---------
   Z-   |      0°E  |   0°N
        |      0°   |   0°
--------+-----------+---------
   Z+   |    180°W  |   0°N
        |   -180°   |   0°

Serialization

Serializer

The serialization helper object for values of LatLon.

public static readonly field Serializer
type ITypeSerializer<LatLon>

Public / Constants

East

0°N 180°E

public static readonly field East
type LatLon

North

90°N 0°E

public static readonly field North
type LatLon

NorthEast

90°N 180°E

public static readonly field NorthEast
type LatLon

NorthWest

90°N 180°W

public static readonly field NorthWest
type LatLon

OneDegree

One degree longitude/latitude.

public constant OneDegree = 1
type float64

OneMillisecond

One thousandth of a second longitude/latitude.

public constant OneMillisecond = 1 / 3600000
type float64

OneMinute

One minute longitude/latitude.

public constant OneMinute = 1 / 60
type float64

OneSecond

One second longitude/latitude.

public constant OneSecond = 1 / 3600
type float64

South

90°S 0°E

public static readonly field South
type LatLon

SouthEast

90°S 180°E

public static readonly field SouthEast
type LatLon

SouthWest

90°S 180°W

public static readonly field SouthWest
type LatLon

Undefined

Undefined location.

public static readonly field Undefined
type LatLon

See also:

IsUndefined

West

0°N 180°W

public static readonly field West
type LatLon

Zero

0°N 0°E

public static readonly field Zero
type LatLon

Public / Attributes

IsNormalized

Are these geographic coordinates normalized?

public property IsNormalized { get }
type bool
value true if the coordinates are normalized, false if not.

Remarks:

Normalized latitude angles are in the range [-90..90], normalized longitude angles are in the range [-180..180].

See also:

Normalize

IsUndefined

Is this coordinate set undefined?

public property IsUndefined { get }
type bool
value true if the coordinates are undefined, false if not.

See also:

Undefined
IsUndefinedCoordinate

Latitude

The latitude in the range [-90..90].

public readonly field Latitude
type float64

LatitudeRadians

The latitude in the range [-pi/2..pi/2].

public property LatitudeRadians { get }
type float64
value The latitude angle, in radians.

Longitude

The longitude in the range [-180..180].

public readonly field Longitude
type float64

LongitudeRadians

The longitude in the range [-pi..pi].

public property LongitudeRadians { get }
type float64
value The longitude angle, in radians.

Public / Constructors

ForCubemapFace

Returns the LatLon value that represents the center of the given cubemap face.

[Pure]
public static method ForCubemapFace (CubemapFace face)
type LatLon
params face The cubemap face (see Cubemap).
returns The resulting value.

FromCube

Converts the given cubemap coordinates to longitude/latitude coordinates.

[Pure]
public static method FromCube (Vec3I cube, int32 n = HeightmapsUtil.MaxCoord)
type LatLon
params cube The cubemap coordinates.
  n Size of cubemap, minus one.
returns The longitude/latitude coordinates.

Converts the given cubemap coordinates to longitude/latitude coordinates.

[Pure]
public static method FromCube (Vec3D cube, int32 n = HeightmapsUtil.MaxCoord)
type LatLon
params cube The cubemap coordinates.
  n Size of cubemap, minus one.
returns The longitude/latitude coordinates.

Converts the given cubemap coordinates to longitude/latitude coordinates.

[Pure]
public static method FromCube (int32 x, int32 y, int32 z, int32 n = HeightmapsUtil.MaxCoord)
type LatLon
params x The cubemap X-coordinate.
  y The cubemap X-coordinate.
  z The cubemap X-coordinate.
  n Size of cubemap, minus one.
returns The longitude/latitude coordinates.

Converts the given cubemap coordinates to longitude/latitude coordinates.

[Pure]
public static method FromCube (float64 x, float64 y, float64 z, int32 n = HeightmapsUtil.MaxCoord)
type LatLon
params x The cubemap X-coordinate.
  y The cubemap Y-coordinate.
  z The cubemap Z-coordinate.
  n Size of cubemap, minus one.
returns The longitude/latitude coordinates.

FromDegrees

Creates a new instance of LatLon from the given angles.

[Pure]
public static method FromDegrees (Vec2D v)
type LatLon
params v The longitude (see X) and latitude (see Y) angles, in degrees.
returns The LatLon value.

See also:

ToDegrees

FromProjection

Computes a LatLon value by projecting the given rectangular map coordinates to cubemap coordinates.

[Pure]
public static method FromProjection (IMapProjection projectRectToCube, Vec2D v)
type LatLon
params projectRectToCube [not-null] The map projection to use. Must project from Rect ( Source) to Cube ( Target).
  v The map coordinates in the source raster (see Source) of projectRectToCube.
returns The LatLon value.

FromRadians

Creates a new instance of LatLon from the given angles.

[Pure]
public static method FromRadians (Vec2D v)
type LatLon
params v The longitude (see X) and latitude (see Y) angles, in radians.
returns The LatLon value.

See also:

ToRadians

Creates a new instance of LatLon from the given angles.

[Pure]
public static method FromRadians (float64 latitude, float64 longitude)
type LatLon
params latitude The latitude angle, in radians.
  longitude The longitude angle, in radians.
returns The LatLon value.

See also:

ToRadians

FromString

Creates a LatLon value from the given string representation.

[Pure]
public static method FromString (string str)
type LatLon
params str The string representation.
returns The LatLon value.

Exceptions:


Creates a LatLon value from the given string representation.

[Pure]
public static method FromString (string str, LatLon defaultValue)
type LatLon
params str The string representation.
  defaultValue The value to return if str is invalid.
returns The LatLon value.

FromStringTry

Creates a LatLon value from the given string representation.

[Pure]
public static method FromStringTry (string str, out LatLon latLon)
type bool
params str The string representation.
  latLon The output LatLon value.
returns true if a LatLon value has been parsed and stored into latLon, false if the input string was invalid ( latLon will be set to Undefined in this case).

LatLon

Creates a new instance of LatLon.

public constructor LatLon (float64 latitude, float64 longitude)
params latitude The latitude in the range [-90..90].
  longitude The longitude in the range [-180..180].s

Creates a new instance of LatLon.

public constructor LatLon (float64 latDeg, float64 latMin, float64 latSec, float64 lonDeg, float64 lonMin, float64 lonSec)
params latDeg The latitude degrees.
  latMin The latitude minutes.
  latSec The latitude seconds.
  lonDeg The longitude degrees.
  lonMin The longitude minutes.
  lonSec The longitude seconds.

Public / Methods

Add

Adds the given longitude/latitude values to this LatLon value.

[Pure]
public method Add (LatLon value)
type LatLon
params value The longitude/latitude values to add to this value.
returns The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows).

Adds the given longitude/latitude values to this LatLon value.

[Pure]
public method Add (float64 latitude, float64 longitude)
type LatLon
params latitude The value to add to the latitude of this value.
  longitude The value to add to the longitude of this value.
returns The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows).

ClampLatitude

Clamps the latitude to the given range.

[Pure]
public method ClampLatitude (float64 max)
type LatLon
params max The latitude range: [-max..max].
returns The clamped value.

Clamps the latitude to the given range: [a..b] resp. [b..a].

[Pure]
public method ClampLatitude (float64 a, float64 b)
type LatLon
params a First range bound.
  b Second range bound.
returns The clamped value.

Div

Divides the longitude and latitude values of this LatLon value by the given scalar.

[Pure]
public method Div (float64 value)
type LatLon
params value The scalar value to divide by.
returns The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows).

DMS

Computes an angle in degrees from the given DMS tuple.

[Pure]
public static method DMS (float64 degrees, float64 minutes = 0, float64 seconds = 0)
type float64
params degrees The degrees part.
  minutes The minutes part (1/60th degree).
  seconds The seconds part (1/60th minute).
returns The angle in degrees.

Equals

Compares this LatLon value with the given one.

[Pure]
public method Equals (LatLon other)
type bool
params other The other LatLon value.
returns true if both values are equal, false if they are not.

IsUndefinedCoordinate

Is the given geographic coordinate undefined?

public static method IsUndefinedCoordinate (float64 coordinate)
type bool
params coordinate The coordinate value.
returns true if coordinate is undefined, false if it is valid.

See also:

Undefined
IsUndefined

Mul

Multiplies the longitude/latitude values of this LatLon value by the given scalar factor.

[Pure]
public method Mul (float64 value)
type LatLon
params value The scalar multiplication factor.
returns The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows).

Neg

Negates the longitude and latitude values of this LatLon value.

[Pure]
public method Neg ()
type LatLon
returns The resulting LatLon value.

NiceStepFind

Returns a nice-looking angle value that is similar to the given angle value..

[Pure]
public static method NiceStepFind (float64 angle, bool divisible = false)
type int32
params angle The angle value, in degrees.
  divisible Return nice-looking values that are also nicely divisible (see remarks)? Defaults to false.
returns [0..60] Index of nice-looking value that is nearest to angle.

Remarks:

A nice-looking angle value sums up without creating big fractions, i.e. degrees are always a divisor of 360, minutes and seconds are always a divisor of 60 and milliseconds are always a divisor of 1000:

By setting the divisible parameter to true, the list of nice-looking angle values is reduced to this:

See also:

NiceStepGet

NiceStepGet

Returns a nice-looking angle step value.

[Pure]
public static method NiceStepGet (int32 index)
type float64
params index [0..60] Index of nice-looking value to get (see remarks).
returns The nice-looking angle value, in degrees.

Remarks:

A nice-looking angle value sums up without creating big fractions, i.e. degrees are always a divisor of 360, minutes and seconds are always a divisor of 60 and milliseconds are always a divisor of 1000:

See also:

NiceStepFind

NiceStepList

public static method NiceStepList ()
type IVectorConst<float64>

NiceStepRound

Rounds this latitude/longitude tuple to the given nice-looking step value.

[Pure]
public method NiceStepRound (int32 step)
type LatLon
params step [0..60] Index of nice-looking step value.
returns The rounded latitude/longitude tuple.

See also:

NiceStepFind
NiceStepGet

Rounds the given latitude resp. longitude angle to the given nice-looking step value.

[Pure]
public static method NiceStepRound (int32 step, float64 degrees)
type float64
params step [0..60] Index of nice-looking step value.
  degrees The latitude resp. longitude angle, in degrees.
returns The rounded latitude/longitude tuple.

See also:

NiceStepFind
NiceStepGet

Normalize

Normalizes this pair of latitude/longitude values so that the longitude value lies in the range [-180..180] and the latitude lies within [-90..90].

[Pure]
public method Normalize ()
type LatLon
returns The normalized value pair.

Remarks:

Longitude values are wrapped at the normalization range boundaries; latitude values are clamped to the range boundaries.

See also:

NormalizeLatitude
NormalizeLongitude180
IsNormalized

NormalizeLatitude

Normalizes the given latitude angle.

[Pure]
public static method NormalizeLatitude (float64 latitude)
type float64
params latitude The input latitude angle, in degrees.
returns [-90..90] The normalized latitude angle.

See also:

Normalize

NormalizeLongitude180

Normalizes the given longitude angle.

[Pure]
public static method NormalizeLongitude180 (float64 longitude, bool unique = true)
type float64
params longitude The input longitude angle, in degrees.
  unique Return -180 instead of 180? Defaults to true.
returns [-180..180] The normalized longitude angle.

See also:

Normalize

NormalizeLongitude360

Normalizes the given longitude angle.

[Pure]
public static method NormalizeLongitude360 (float64 longitude, bool unique = true)
type float64
params longitude The input longitude angle, in degrees.
  unique Return 0 instead of 360? Defaults to true.
returns [0..360] The normalized longitude angle.

See also:

Normalize

Sub

Subtracts the given longitude/latitude values from this LatLon value.

[Pure]
public method Sub (LatLon value)
type LatLon
params value The longitude/latitude values to subtract from this value.
returns The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows).

Subtracts the given longitude/latitude values from this LatLon value.

[Pure]
public method Sub (float64 latitude, float64 longitude)
type LatLon
params latitude The value to subtract from the latitude of this value, in degrees.
  longitude The value to subtract from the longitude of this value, in degrees.
returns The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows).

ToCubeD

Converts this set of longitude/latitude coordinates to cubemap coordinates.

[Pure]
public method ToCubeD (int32 n = HeightmapsUtil.MaxCoord)
type Vec3D
params n Size of cubemap, minus one.
returns The cubemap coordinates.

ToCubeI

Converts this set of longitude/latitude coordinates to cubemap coordinates.

[Pure]
public method ToCubeI (int32 n = HeightmapsUtil.MaxCoord)
type Vec3I
params n Size of cubemap, minus one.
returns The cubemap coordinates.

ToDegrees

Converts this LatLon value to a vector of longitude/latitude in degrees.

[Pure]
public method ToDegrees ()
type Vec2D
returns The resulting vector holding the longitude (see X) and latitude (see Y) angles, in degrees.

ToProjection

Projects this LatLon value onto a rectangular map.

[Pure]
public method ToProjection (IMapProjection projectCubeToRect)
type Vec2D
params projectCubeToRect [not-null] The map projection to use. Must project from Cube ( Source) to Rect ( Target).
returns The map coordinates in the target raster (see Target) of projectCubeToRect.

ToRadians

Converts this LatLon value to a vector of longitude/latitude in radians.

[Pure]
public method ToRadians ()
type Vec2D
returns The resulting vector holding the longitude (see X) and latitude (see Y) angles, in radians.

ToString

public override method ToString ()
type string

Returns the string representation of this set of latitude/longitude coordinates.

[Pure]
public method ToString (LatLonFormat format)
type string
params format The formatting options.
returns [not-null] The string representation.

Remarks:

The string representation has the following form:

a°b'c".dX e°f'g".hY
where...
... a, b, c and d are the latitude degrees, minutes, seconds and milliseconds, X is either N (positive latitude) or S (negative latitude).
... e, f, g and h are the longitude degrees, minutes, seconds and milliseconds, Y is either E (positive longitude) or W (negative longitude).

The parts for minutes, seconds and milliseconds are omitted if their value is zero:

12°34'56.789"N 123°45'57.891"E
12°34'56"N 123°45'57"E
12°34'N 123°45'E
12°N 123°E


Returns the string representation of the given latitude/longitude angle.

[Pure]
public static method ToString (float64 angle, bool latOrLon, LatLonFormat format = LatLonFormat.Default)
type string
params angle The angle value to format, in degrees.
  latOrLon true if angle is a latitude angle, false if it is a longitude angle.
  format The formatting options.
returns [not-null] The string representation.

Remarks:

The string representation has the following form:

a°b'c".dX
where...
... a, b, c and d are the latitude degrees, minutes, seconds and milliseconds, X is either N (positive latitude), S (negative latitude), E (positive longitude) or W (negative longitude).

Public / Extensions

ToCoords

Translates these longitude/latitude coordinates into geocentric coordinates.

method ToCoords (float64 elevation, IGeometry geometry)
type Vec3D
params elevation The terrain-space elevation.
  geometry [not-null] The geometry object.
returns The geocentric coordinates.