Retrun to document top page

Nemo Library, section 4


UniSpherical Coordinate System transformations
   UniSpherical Coordinate mapping and un-mapping.
Description:
   Near-conformal (NCS) spherical coordinates of a point consist of three
   (i, j and k) components of the normalized spherical radius-vector of the
   point. Each vector component is commonly encoded as a "double", normally
   an 8-byte real ("floating point") number data type. Each point thus
   requires 24 bytes of storage. On the other hand, such coordinate
   representation provides orders of magnitude higher spatial resolution than
   any application might require for representation of points or vertices of
   line/area data objects on the planetary surface.
   ·
   UniSpherical Coordinate System provides a numerical representation of the
   location of a point on the planetary surface with a much better balance
   between the storage requirements and spatial resolution, and at the same
   time can be efficiently transferred (in both directions) between its
   coordinate format and the three direction cosines vector form, normally
   required for spherical geometry computations.
   ·
   Important characteristics of this coordinate encoding are:
   ·
   1) Storage efficiency.
   ·
   2) Very fast transformation from and to near-conformal sphere normalized
      vector components coordinates (and, from there - if required - to
      ellipsoid i, j, k vector coordinates). This is due to the fact that all
      transformations are based on closed algebraic productions that require
      no evaluation of trigonometric functions.
   ·
   3) Point location is represented by a single integer number, thus many
      applications can consider points to represent the same location if
      their UniSpherical integer coordinates are equal.
   ·
   4) The internal numerical format of UniSpherical coordinates ensures -
      to the maximum extent possible - that the coordinates of the points
      that are close to each on the planetary surface will be close to each
      order in the numeric order of their coordinates.
   The maximum difference ("Δ max") of a point location encoded into this
   coordinate format and decoded back from it on the planet with the size of
   the Earth is 15 mm, and the standard deviation ("σ") is 5 mm. While such
   "grid resolution" is not sufficiently fine for geodetic framework point
   coordinate computations, it is more than adequate for data storage and
   inter-system transfer of any GPS topographic detail surveys, road, sea,
   air and orbital navigation systems, cadastral data, terrestrial object
   location tracking, radar detection, mobile radio communication - and a
   large number of other practical applications.
   ·
   As the encoding uses the bit-level manipulation, the coordinate item
   binary representation is endian-sensitive. If the library is compiled
   and the resulting code executed on the common little-endian hardware, and
   if the coordinates are exchanged in binary form with systems executing on
   (much less common) big-endian hardware, the application must reverse byte
   order upon the import. Note however that UniSpherical unsigned integer
   coordinate representation in text (commonly as a 16-character hexadecimal
   number string, double in width compared with its internal binary format)
   does not merits any endiannes consideration).
   ·
   Following is an example of the coordinates of a recognizable location
   (Aoraki) in different coordinate formats used by the Library functions:
   .
   Ellipsoid φ and λ in angular measurement:
   -43°35′42″, 170°08′31″
   As i, j, k, NCS direction cosines:
   -0.715813190  0.124389483 -0.687123522
   8-byte UniSpherical, decimal number string (printed with "%020lu" format):
   05261955426777545240
   8-byte UniSpherical, hexadecimal (printed with "%016lx" format):
   49063894e503ba18
   4-byte UniSpherical, decimal (i.e., printed using "%010u" format):
   1225144467
   4-byte UniSpherical, hexadecimal (i.e., printed using "%08x" format):
   49063893
   ·
   For an extensive discussion of the UniSpherical Coordinate System, see
   the web publication at: http://www.lukatela.com/uniSpherical/

nemo_NcsToUs8()   NCS (3 doubles) to 8-byte UniSpherical
nemo_Us8ToNcs()   8-byte UniSpherical to NCS (3 doubles)
nemo_NcsToUs4()   NCS (3 doubles) to 4-byte UniSpherical
nemo_Us4ToNcs()   4-byte UniSpherical to NCS (3 doubles)

nemo_NcsToUs8()
Synopsis:
   #include <nemo.h>
   nemoPtUs8 nemo_NcsToUs8(const nemoPtNcs *pPtNcs);
Argument:
   ptNcs:
      Pointer to nemoPtNcs structure, given NCS point coordinates.
Return Value:
   An integer of nemoPtUs8 type (8-byte, unsigned), UniSpherical
   coordinate of ptNcs.
Example:
   ...
   nemoPtNcs ptNcs;
   nemoPtUs8 ptUs8;
   ...
   ptUs8 = nemo_NcsToUs8(&ptNcs);        /* from NCS di,dj,dk to Us8 */
   /* Write UniSpherical point coordinate to a text file: */
   printf("%016lx\n", ptUs8);
   ...
See Also:
   nemo_Us8ToNcs()

nemo_Us8ToNcs()
Synopsis:
   #include <nemo.h>
   void nemo_Us8ToNcs(nemoPtUs4 ptUs4, nemoPtNcs *pPtNcs);
Arguments:
   ptUs8:
      An integer of nemoPtUs8 type (8-byte, unsigned), given UniSpherical
      encoded coordinates.
   ptNcs:
     Pointer to a receiving nemoPtNcs structure, returned coordinates.
Example:
   ...
   nemoPtNcs ptNcs;
   nemoPtUs8 ptUs8;
   const char delimiters[] = ", \r\n";
   ...
   lineSize = getLine(&lineBuf, &lineBufSize, aprtFp);
   ...
   /* Read UniSpherical point coordinate from text file: */
   token = strtok(lineBuf, delimiters);
   ptUs8 = strtoul(token, NULL, 16);
   nemo_Us8ToNcs(ptUs8, &ptNcs);  /* convert from Us8 to NCS di,dj,dk */
See Also:
   nemo_NcsToUs8()

nemo_NcsToUs4()
Synopsis:
   #include <nemo.h>
   nemoPtUs4 nemo_NcsToUs4(const nemoPtNcs *pPtNcs);
Argument:
   ptNcs:
      Pointer to nemoPtNcs structure, given NCS point coordinates.
Return Value:
   An integer of nemoPtUs4 type (4-byte, unsigned), UniSpherical
   coordinate of ptNcs.
Example:
   ...
   nemoPtNcs ptNcs;
   nemoPtUs4 ptUs4;
   ...
   ptUs4 = nemo_NcsToUs4(&ptNcs);        /* from NCS di,dj,dk to Us4 */
   /* Write UniSpherical point coordinate to a text file: */
   printf("%08lx\n", ptUs4);
   ...
See Also:
   nemo_Us4ToNcs()

nemo_Us4ToNcs()
Synopsis:
   #include <nemo.h>
   void nemo_Us4ToNcs(nemoPtUs4 ptUs4, nemoPtNcs *pPtNcs);
Arguments:
   ptUs4:
      An integer of nemoPtUs4 type (4-byte, unsigned), given UniSpherical
      encoded coordinates.
   ptNcs:
     Pointer to a receiving nemoPtNcs structure, returned coordinates.
Example:
   ...
   nemoPtNcs ptNcs;
   nemoPtUs4 ptUs4;
   const char delimiters[] = ", \r\n";
   ...
   lineSize = getLine(&lineBuf, &lineBufSize, aprtFp);
   ...
   /* Read UniSpherical point coordinate from text file: */
   token = strtok(lineBuf, delimiters);
   ptUs4 = strtoul(token, NULL, 16);
   nemo_Us4ToNcs(ptUs4, &ptNcs);  /* convert from Us8 to NCS di,dj,dk */
See Also:
   nemo_NcsToUs4()