8
$\begingroup$

Is there a way to work with angles in DMS without converting them to decimal degrees, that is to sum them, subtract them?

I do not know how to even enter it without using string. My idea is something like: 20°32'15.828'' - 22°32'12.8''.

$\endgroup$
9
$\begingroup$

You may use either MixedRadixQuantity or Quantity with MixedMagnitude and MixedUnit.

In both cases the units you need are {"AngularDegrees", "ArcMinutes", "ArcSeconds"}.

p1 = MixedRadixQuantity[{20, 32, 15.828}, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}];
p2 = MixedRadixQuantity[{22, 32, 12.8}, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}];

p1 - p2
(* Quantity[MixedMagnitude[{-1, -59, -56.972}], 
     MixedUnit[{"AngularDegrees", "ArcMinutes", "ArcSeconds"}]] *)

From the output above you can see the longer form using Quantity.

Hope this helps.

$\endgroup$
  • 1
    $\begingroup$ OK, I guess +1 for technical correctness, but...OMG...it's worse than COBOL. :) $\endgroup$ – Michael E2 Aug 27 '16 at 23:04
  • $\begingroup$ @MichaelE2 Of course a helper function can be used: dms=MixedRadixQuantity[#, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}]& $\endgroup$ – Edmund Aug 27 '16 at 23:14
  • 1
    $\begingroup$ I suppose it's clear that I'm complaining about M, not your answer. I think carrying around these large, slow data structures internally is a waste. It's ok for UI purposes, although in this case, the formatted output is not highly readable. $\endgroup$ – Michael E2 Aug 27 '16 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.