
Boost : 
From: Matthias Schabel (boost_at_[hidden])
Date: 20031210 20:50:31
> You want to redefine the trig functions to only take SI<double>::Angle
> units? The trig functions don't take things with units, they take
> numbers. It is completely reasonable and common to take sin(A/B),
> where A and B both have the same units. You would require people to
> write sin(radians *A/B), which is just wrong.
I'm proposing no such thing; the new overloaded trig functions I defined
will match dimensioned quantities representing any angle type in any
unit model you desire, automatically convert to radians if necessary,
and
compute the desired value. They have no impact whatsoever on users
who prefer to call the standard cmath functions. Furthermore, I can't
see
anything _wrong_ with allowing people to write sin(_radians*A/B) or
sin(_degrees*A/B) or, for that matter,
sin(_my_funky_angular_unit_type*A/B).
It's a way of making the intent transparent and guarantee correctness by
having the compiler do the conversion. It's a common source of errors,
especially
for beginning programmers and people who don't have much familiarity
with trig, to try
using degrees as the argument to std::sin and to be unpleasantly
surprised
with a runtime problem. Explicitly specifying the unit of angular
measure
allows the compiler to catch these otherwise nasty bugs...
> You don't normally put degrees or gradians into a Taylor series. You
> do that all the time with radians. It is true that you can convert a
> degree to a radian, but you can also convert a centimeter to a second
> using the rather common conversion factor of the speed of light.
Radians happen to be the "natural" unit for measuring angular
quantities in
that there are defined to be precisely 2 pi radians in a unit circle so
that the ratio
of radians in a full circle to the circumference of that circle is
exactly one as
opposed to 360/(2 pi) as it is for degrees. As far as Taylor series
go, it may not
be "normal", but there's no problem doing a Taylor series expansion of
the
function sin with a degree argument :
sin(x > radians) = x  x^3/3! + x^5/5!  ...
sin(x > degrees) = sin(2 pi x/360)
= (2 pi/360) x  (2 pi/360)^3 x^3/3! +
(2 pi/360)^5 x^5/5!  ...
The natural units analogy is specious  degrees and radians are
different ways
of measuring the same quantity, which is an abstract mathematical
entity,
irrespective of other assumptions. Natural units take advantage of the
fact that
fundamental physical constants exist. In a parallel universe with
different values
of c, hbar, etc... lengths expressed in natural units would differ
while angles would
not.
Cheers,
Matthias


Matthias Schabel, Ph.D.
Utah Center for Advanced Imaging Research
729 Arapeen Drive
Salt Lake City, UT 84108
8015879413 (work)
8015853592 (fax)
8017065760 (cell)
8014840811 (home)
mschabel at ucair med utah edu
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk