mp-units
mp-units copied to clipboard
Add angular degrees
Currently <units/generic/angle.h>
contains radians, but doesn't have support for angular degrees. Are there plans to add this?
Also maybe adding the concept of rotations as well would be great.
There are plans, but there are technical difficulties (namely the transcendental conversion ratio between radians and degrees). See #99 and #195.
Gotcha! Thank you for the response.
I don't know where to put it in the discussion or issue but I'd like to throw my chip into the pi = 1 camp.
I do really like the idea of making pi = 1 or pi = 2. And by pi = 2, I really mean move away from radians as the basis for angles and use 1 revolution as the basis. So you can keep some integer factional of revolutions such as 0.5 rev = 180 deg = pi = 0.5 tau. Final conversion to a real radians number could be left up to the user or something like that.
Final conversion to a real radians number could be left up to the user
This will definitely become a source of errors, because people can't be trusted.
Final conversion to a real radians number could be left up to the user
This will definitely become a source of errors, because people can't be trusted.
Gotcha. Maybe only do the conversion to actual radians when the value is formatted to decimal?
Or better yet, format it to 12.455 x 2π
. So completely side step the need to perform work with transandentals.
And if the user needs to get the real raw value like78.2571...
in the output, then pi could be multiplied in using the representation type.
Your timing is impeccable! We are at the tail end of implementing #300, which will definitively resolve #195. All that remains is for the final PR, #368, to be reviewed and merged by @mpusz.
Once that is done, adding degrees should be trivial. (There may be more work needed to support other features, such as deciding how to print scale factors which contain irrational contributions, but the mechanics of working with a degree unit should already be supported.)
It should also be a lot more robust than "pi = 1", a concept which I frankly do not understand. pi is a dimensionless number; we cannot "set it equal to 1" by a choice of units in the same way that high-energy physicists do for c or h-bar (or, for that matter, the way that mathematicians and the SI do for the "Cotes angle" of 1 radian). Fortunately, we won't need to consider this route, as we already have something better.
Incidentally, with the new Magnitude representation, even though the "base unit" for angles will be the radian, we will still be able to perform exact integer conversions between, e.g., degrees and revolutions.