Cart3Convert(1)

# NAME

Cart3Convert -- convert geocentric coordinates for a triaxial ellipsoid

# SYNOPSIS

Cart3Convert [ -E | -G | -P | -C | -GX | -PX | -CX ] [ -r ] [ -3 | -D ] [ -R nrand ] [ --seed s ] [ -t a b c | -e b e2 k2 kp2 ] [ -d | -: ] [ -w ] [ -p prec ] [ --comment-delimiter commentdelim ] [ --version | -h | --help ] [ --input-file infile | --input-string instring ] [ --line-separator linesep ] [ --output-file outfile ]

# DESCRIPTION

Convert coordinates for a triaxial ellipsoid to geocentric coordinates. Geocentric coordinates have the origin at the center of the earth, with the X, Y, and Z axes aligned with the major, median, and minor semiaxes, a, b, and c. By default, the conversion is to geocentric coordinates. Specifying -r causes the reverse conversion to be performed.

Seven latitude/longitude/heading coordinate systems are supported

1. Ellipsoidal coordinates, beta, omega, and alpha, signified by -En (the default)

2. Geodetic coordinates, phi, lambda, and zeta, signified by -G.

3. Parametric coordinates, phi', lambda', and zeta, signified by -P.

4. Geocentric coordinates, phi", lambda", and zeta, signified by -C.

5. Geodetic coordinates, phi*, lambda*, and zeta*, with the north pole lying on the X axis, signified by -GX.

6. Parametric coordinates, phi*', lambda*', and zeta*, with the north pole lying on the X axis, signified by -PX.

7. Geocentric coordinates, phi*", lambda*", and zeta*, with the north pole lying on the X axis, signified by -CX.

In general, only ellipsoidal coordinates are orthogonal. However for all coordinates, we define the heading as the direction measured clockwise from a line of constant longitude. zeta is the same for the geodetic, parametric, and geocentric coordinate systems.

Points away from the surface of the ellipsoid can be described by the orthogonal height h above from the ellipsoid and the position is given by phi, lambda (giving the closest point on the ellipsoid), and h. Alternatively, the confocal ellipsoid of minor radius c + H point can be found and the position of the point is then given by beta, omega for the confocal ellipsoid and H.

By default, coordinates are provided on standard input as a set of lines containing (blank separated) latitude and longitude (decimal degrees or degrees, minutes and seconds). The interpretation of the coordinates is governed by the -E, -G, -P, -C -GX, -PX, and -CX flags. For each set of coordinates, the corresponding cartesian coordinates X, Y, Z (meters) are printed on standard output. If -r is provided, the reserve operation is undertaken reading X, Y, Z (which are assumed to denote a point on the ellipsoid) on standard input and printing the latitude and longitude.

If the -3 flag is given (this cannot be combined with -D), an arbitrary point in three-dimensional space is specified either with beta omega H or with phi lambda h.

If the -D flag is given (this cannot be combined with -3), the heading (direction) is included in the computation converting beta omega alpha or phi lambda zeta to X, Y, Z Vx, Vy, Vz where [vx, vy, vz] is a unit vector lying in the surface of the ellipsoid.

If the -R flag is given, do not read any input; instead output random cartesian points lying on the surface of the ellipsoid. If the -r flag is specified the cartesian points are converted into one of the triaxial coordinate systems.

# OPTIONS

-E

  latitude and longitude is interpreted as ellipsoidal coordinates beta and omega. This is the default.

-G or -GX

  latitude and longitude is interpreted as geodetic coordinates phi and lambda. The X added to the flags means that the north pole lies on the X axis.

-P or -PX

  latitude and longitude is interpreted as parametric coordinates phi' and lambda'. The X added to the flags means that the north pole lies on the X axis.

-C or -CX

  latitude and longitude is interpreted as geocentric coordinates phi" and lambda". The X added to the flags means that the north pole lies on the X axis.

-r

  perform the reverse projection from x, y, z to latitude, longitude. Unless -3 is given, it is assumed that the point lies on the surface of the ellipsoid.

-3

  include the height h or H in the calculation. This cannot be combined with -D.

-D

  include the direction alpha or zeta in the calculation. With the -r option, it is assumed that the vector [vx, vy, vz] is tangent to the surface of the ellipsoid. This cannot be combined with -3.

-R nrand

  output nrand random points on the surface of the ellipsoid as cartesian coordinates. With -D add also a random cartesian direction tangent to the surface of the ellipsoid. In this mode, nothing is read from standard input. With the -r option the random points are converted into one of the triaxial coordinate systems (and the direction is converted to a heading if -D is given).

--seed s

  set the random number seed to s when using -R. s = 0 (the default) causes a random seed to be used.

-t a b c

  specify the ellipsoid via its major semiaxis a, median semiaxis b, and minor semixis c. By default, we have a = 6378172 m, b = 6378102 m, c = 6356752 m, an approximate triaxial model of the earth. (With this model omg = 0deg, corresponds to lon = -14.93deg.

-e b e2 k2 kp2

  specify the ellipsoid via the median semiaxis, b and the shape parameters e2 = (a^2 - c^2)/b^2, k2 = (b^2 - c^2)/(a^2 - c^2), and kp2 = (a^2 - b^2)/(a^2 - c^2). Simple fractions are allowed for e2, k2, and kp2. Internally, the supplied values of k2 and kp2 are normalized so that k2 + kp2 = 1.

-d

  output angles as degrees, minutes, seconds instead of decimal degrees.

-:

  like -d, except use : as a separator instead of the d, ', and " delimiters.

-w

  toggle the longitude first flag (it starts off); if the flag is on, then on input and output, longitude precedes latitude (except that, on input, this can be overridden by a hemisphere designator, N, S, E, W).

-p prec

  set the output precision to prec (default 3). For distances, prec is the number of digits after the decimal point for ellipsoids which are approximately the same size as the Earth; for other ellipsoids the precision is adjusted to retain the same relative precision. For latitudes and longitudes (in degrees), the number of digits after the decimal point is prec + 5. For cartesian directions, the precision is prec + 7.

--comment-delimiter commentdelim

  set the comment delimiter to commentdelim (e.g., "#" or "//"). If set, the input lines will be scanned for this delimiter and, if found, the delimiter and the rest of the line will be removed prior to processing and subsequently appended to the output line (separated by a space).

--version

  print version and exit.

-h

  print usage and exit.

--help

  print full documentation and exit.

--input-file infile

  read input from the file infile instead of from standard input; a file name of "-" stands for standard input.

--input-string instring

  read input from the string instring instead of from standard input. All occurrences of the line separator character (default is a semicolon) in instring are converted to newlines before the reading begins.

--line-separator linesep

  set the line separator character to linesep. By default this is a semicolon.

--output-file outfile

  write output to the file outfile instead of to standard output; a file name of "-" stands for standard output.

# EXAMPLES

    echo 1 2 3 | Cart3Convert -t 3 2 1 -3 -p 0 -r
    => 58.69140 75.11263 2.5860649
    echo 58.69140 75.11263 2.5860649 | Cart3Convert -t 3 2 1 -3 -p 0
    => 1.0000001 2.0000003 2.9999999

# ERRORS

An illegal line of input will print an error message to standard output beginning with `ERROR:` and causes Cart3Convert to return an exit code of 1. However, an error does not cause Cart3Convert to terminate; following lines will be converted.

# AUTHOR

Cart3Convert was written by Charles Karney.

# SEE ALSO

Geod3Solve(1).

The algorithms are described in Appendices A and B of C. F. F. Karney, Jacobi's solution for geodesics on a triaxial ellipsoid, Technical Report, SRI International, Nov. 2025, https://arxiv.org/abs/2511.01621.

The Wikipedia page, Geodesics on an ellipsoid, https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid.

# HISTORY

Cart3Convert was added to GeographicLib, https://geographiclib.sourceforge.io, in version 2.6.