int usage(int retval, bool brief) {
  if (brief)
    ( retval ? std::cerr : std::cout ) << "Usage:\n"
"    Cart3Convert [ -E | -G | -P | -C | -GX | -PX | -CX ] [ -r ] [ -3 | -D ]\n"
"    [ -R nrand ] [ --seed s ] [ -t a b c | -e b e2 k2 kp2 ] [ -d | -: ] [\n"
"    -w ] [ -p prec ] [ --comment-delimiter commentdelim ] [ --version | -h\n"
"    | --help ] [ --input-file infile | --input-string instring ] [\n"
"    --line-separator linesep ] [ --output-file outfile ]\n"
"\n"
"For full documentation type:\n"
"    Cart3Convert --help\n"
"or visit:\n"
"    https://geographiclib.sourceforge.io/C++/2.7/Cart3Convert.1.html\n";
  else
    ( retval ? std::cerr : std::cout ) << "Man page:\n"
"\n"
"SYNOPSIS\n"
"       Cart3Convert [ -E | -G | -P | -C | -GX | -PX | -CX ] [ -r ] [ -3 | -D ]\n"
"       [ -R nrand ] [ --seed s ] [ -t a b c | -e b e2 k2 kp2 ] [ -d | -: ] [\n"
"       -w ] [ -p prec ] [ --comment-delimiter commentdelim ] [ --version | -h\n"
"       | --help ] [ --input-file infile | --input-string instring ] [\n"
"       --line-separator linesep ] [ --output-file outfile ]\n"
"\n"
"DESCRIPTION\n"
"       Convert coordinates for a triaxial ellipsoid to geocentric coordinates.\n"
"       Geocentric coordinates have the origin at the center of the earth, with\n"
"       the X, Y, and Z axes aligned with the major, median, and minor\n"
"       semiaxes, a, b, and c.  By default, the conversion is to geocentric\n"
"       coordinates.  Specifying -r causes the reverse conversion to be\n"
"       performed.\n"
"\n"
"       Seven latitude/longitude/heading coordinate systems are supported\n"
"\n"
"       1.  Ellipsoidal coordinates, beta, omega, and alpha, signified by -En\n"
"           (the default)\n"
"\n"
"       2.  Geodetic coordinates, phi, lambda, and zeta, signified by -G.\n"
"\n"
"       3.  Parametric coordinates, phi', lambda', and zeta, signified by -P.\n"
"\n"
"       4.  Geocentric coordinates, phi\", lambda\", and zeta, signified by -C.\n"
"\n"
"       5.  Geodetic coordinates, phi*, lambda*, and zeta*, with the north pole\n"
"           lying on the X axis, signified by -GX.\n"
"\n"
"       6.  Parametric coordinates, phi*', lambda*', and zeta*, with the north\n"
"           pole lying on the X axis, signified by -PX.\n"
"\n"
"       7.  Geocentric coordinates, phi*\", lambda*\", and zeta*, with the north\n"
"           pole lying on the X axis, signified by -CX.\n"
"\n"
"       In general, only ellipsoidal coordinates are orthogonal.  However for\n"
"       all coordinates, we define the heading as the direction measured\n"
"       clockwise from a line of constant longitude.  zeta is the same for the\n"
"       geodetic, parametric, and geocentric coordinate systems.\n"
"\n"
"       Points away from the surface of the ellipsoid can be described by the\n"
"       orthogonal height h above from the ellipsoid and the position is given\n"
"       by phi, lambda (giving the closest point on the ellipsoid), and h.\n"
"       Alternatively, the confocal ellipsoid of minor radius c + H point can\n"
"       be found and the position of the point is then given by beta, omega for\n"
"       the confocal ellipsoid and H.\n"
"\n"
"       By default, coordinates are provided on standard input as a set of\n"
"       lines containing (blank separated) latitude and longitude (decimal\n"
"       degrees or degrees, minutes and seconds).  The interpretation of the\n"
"       coordinates is governed by the -E, -G, -P, -C -GX, -PX, and -CX flags.\n"
"       For each set of coordinates, the corresponding cartesian coordinates X,\n"
"       Y, Z (meters) are printed on standard output.  If -r is provided, the\n"
"       reserve operation is undertaken reading X, Y, Z (which are assumed to\n"
"       denote a point on the ellipsoid) on standard input and printing the\n"
"       latitude and longitude.\n"
"\n"
"       If the -3 flag is given (this cannot be combined with -D), an arbitrary\n"
"       point in three-dimensional space is specified either with beta omega H\n"
"       or with phi lambda h.\n"
"\n"
"       If the -D flag is given (this cannot be combined with -3), the heading\n"
"       (direction) is included in the computation converting beta omega alpha\n"
"       or phi lambda zeta to X, Y, Z Vx, Vy, Vz where [vx, vy, vz] is a unit\n"
"       vector lying in the surface of the ellipsoid.\n"
"\n"
"       If the -R flag is given, do not read any input; instead output random\n"
"       cartesian points lying on the surface of the ellipsoid.  If the -r flag\n"
"       is specified the cartesian points are converted into one of the\n"
"       triaxial coordinate systems.\n"
"\n"
"OPTIONS\n"
"       -E  latitude and longitude is interpreted as ellipsoidal coordinates\n"
"           beta and omega.  This is the default.\n"
"\n"
"       -G or -GX\n"
"           latitude and longitude is interpreted as geodetic coordinates phi\n"
"           and lambda.  The X added to the flags means that the north pole\n"
"           lies on the X axis.\n"
"\n"
"       -P or -PX\n"
"           latitude and longitude is interpreted as parametric coordinates\n"
"           phi' and lambda'.  The X added to the flags means that the north\n"
"           pole lies on the X axis.\n"
"\n"
"       -C or -CX\n"
"           latitude and longitude is interpreted as geocentric coordinates\n"
"           phi\" and lambda\".  The X added to the flags means that the north\n"
"           pole lies on the X axis.\n"
"\n"
"       -r  perform the reverse projection from x, y, z to latitude, longitude.\n"
"           Unless -3 is given, it is assumed that the point lies on the\n"
"           surface of the ellipsoid.\n"
"\n"
"       -3  include the height h or H in the calculation.  This cannot be\n"
"           combined with -D.\n"
"\n"
"       -D  include the direction alpha or zeta in the calculation.  With the\n"
"           -r option, it is assumed that the vector [vx, vy, vz] is tangent to\n"
"           the surface of the ellipsoid.  This cannot be combined with -3.\n"
"\n"
"       -R nrand\n"
"           output nrand random points on the surface of the ellipsoid as\n"
"           cartesian coordinates.  With -D add also a random cartesian\n"
"           direction tangent to the surface of the ellipsoid.  In this mode,\n"
"           nothing is read from standard input.  With the -r option the random\n"
"           points are converted into one of the triaxial coordinate systems\n"
"           (and the direction is converted to a heading if -D is given).\n"
"\n"
"       --seed s\n"
"           set the random number seed to s when using -R.  s = 0 (the default)\n"
"           causes a random seed to be used.\n"
"\n"
"       -t a b c\n"
"           specify the ellipsoid via its major semiaxis a, median semiaxis b,\n"
"           and minor semixis c.  By default, we have a = 6378172 m, b =\n"
"           6378102 m, c = 6356752 m, an approximate triaxial model of the\n"
"           earth.  (With this model omg = 0deg, corresponds to lon =\n"
"           -14.93deg.\n"
"\n"
"       -e b e2 k2 kp2\n"
"           specify the ellipsoid via the median semiaxis, b and the shape\n"
"           parameters e2 = (a^2 - c^2)/b^2, k2 = (b^2 - c^2)/(a^2 - c^2), and\n"
"           kp2 = (a^2 - b^2)/(a^2 - c^2).  Simple fractions are allowed for\n"
"           e2, k2, and kp2.  Internally, the supplied values of k2 and kp2 are\n"
"           normalized so that k2 + kp2 = 1.\n"
"\n"
"       -d  output angles as degrees, minutes, seconds instead of decimal\n"
"           degrees.\n"
"\n"
"       -:  like -d, except use : as a separator instead of the d, ', and \"\n"
"           delimiters.\n"
"\n"
"       -w  toggle the longitude first flag (it starts off); if the flag is on,\n"
"           then on input and output, longitude precedes latitude (except that,\n"
"           on input, this can be overridden by a hemisphere designator, N, S,\n"
"           E, W).\n"
"\n"
"       -p prec\n"
"           set the output precision to prec (default 3).  For distances, prec\n"
"           is the number of digits after the decimal point for ellipsoids\n"
"           which are approximately the same size as the Earth; for other\n"
"           ellipsoids the precision is adjusted to retain the same relative\n"
"           precision.  For latitudes and longitudes (in degrees), the number\n"
"           of digits after the decimal point is prec + 5.  For cartesian\n"
"           directions, the precision is prec + 7.\n"
"\n"
"       --comment-delimiter commentdelim\n"
"           set the comment delimiter to commentdelim (e.g., \"#\" or \"//\").  If\n"
"           set, the input lines will be scanned for this delimiter and, if\n"
"           found, the delimiter and the rest of the line will be removed prior\n"
"           to processing and subsequently appended to the output line\n"
"           (separated by a space).\n"
"\n"
"       --version\n"
"           print version and exit.\n"
"\n"
"       -h  print usage and exit.\n"
"\n"
"       --help\n"
"           print full documentation and exit.\n"
"\n"
"       --input-file infile\n"
"           read input from the file infile instead of from standard input; a\n"
"           file name of \"-\" stands for standard input.\n"
"\n"
"       --input-string instring\n"
"           read input from the string instring instead of from standard input.\n"
"           All occurrences of the line separator character (default is a\n"
"           semicolon) in instring are converted to newlines before the reading\n"
"           begins.\n"
"\n"
"       --line-separator linesep\n"
"           set the line separator character to linesep.  By default this is a\n"
"           semicolon.\n"
"\n"
"       --output-file outfile\n"
"           write output to the file outfile instead of to standard output; a\n"
"           file name of \"-\" stands for standard output.\n"
"\n"
"EXAMPLES\n"
"          echo 1 2 3 | Cart3Convert -t 3 2 1 -3 -p 0 -r\n"
"          => 58.69140 75.11263 2.5860649\n"
"          echo 58.69140 75.11263 2.5860649 | Cart3Convert -t 3 2 1 -3 -p 0\n"
"          => 1.0000001 2.0000003 2.9999999\n"
"\n"
"ERRORS\n"
"       An illegal line of input will print an error message to standard output\n"
"       beginning with \"ERROR:\" and causes Cart3Convert to return an exit code\n"
"       of 1.  However, an error does not cause Cart3Convert to terminate;\n"
"       following lines will be converted.\n"
"\n"
"AUTHOR\n"
"       Cart3Convert was written by Charles Karney.\n"
"\n"
"SEE ALSO\n"
"       Geod3Solve(1).\n"
"\n"
"       The algorithms are described in Appendices A and B of C. F. F. Karney,\n"
"       Jacobi's solution for geodesics on a triaxial ellipsoid, Technical\n"
"       Report, SRI International, Nov. 2025,\n"
"       <https://arxiv.org/abs/2511.01621>.\n"
"\n"
"       The Wikipedia page, Geodesics on an ellipsoid,\n"
"       <https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid>.\n"
"\n"
"HISTORY\n"
;
  return retval;
}
