Function File: degrees2dms (deg)

Convert decimal degrees to its degrees, minutes, and seconds components.

Separates the fractional part of an angle in decimal degrees and converts it into minutes and seconds. Each row of the output corresponds to one angle the first and second column to the degree and minute component (both integers), and the third to the seconds (which may have a fractional part).

degrees2dms (10 + 20/60 + 20/3600)
⇒  [ 10   20   20 ]

degrees2dms (10 + 20/60 + pi)
⇒  [ 10   28   29.734 ]

The sign of the first non-zero component indicates the sign of the angle, i.e., if the degree and minute components are zero, the sign of the seconds indicates the sign of the angle, but if the degree component is non-zero, both the minute and second components will be positive independently of the sign of the angle.

angles = [  10.5
           -10.5
            -0.5
             0.5 ];
degrees2dms (angles)
  ⇒
         10   30   0
        -10   30   0
         -0  -30   0
          0   30   0

See also: degrees2dm, dm2degrees, dms2degrees.

Package: mapping