support for various angular units in std.math

Walter Bright newshound2 at digitalmars.com
Sun Feb 27 22:49:33 PST 2011


Colin Wallace wrote:
> When using trigonometric functions, they all deal with radians. So
> I've been having to do lots of converting. Converting is very
> straightforward, but I still think it would be nice if there were some
> built in functions for dealing with other units than radians. I think
> a system that looked like what is used for the Duration struct in
> core.time would make things more readable. The code for taking the
> sine of a number measured in degrees could look like:
> sin!"degrees"(45)
> rather than
> sin(45*PI/180)

I appreciate the suggestion, but suspect that adding a parallel set of trig 
functions that do nothing more than multiply the arg by a constant is more 
cognitive load for the user than benefit.


More information about the Digitalmars-d mailing list