Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2003-12-10 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,
compute the desired value. They have no impact whatsoever on users
who prefer to call the standard cmath functions. Furthermore, I can't
anything _wrong_ with allowing people to write sin(_radians*A/B) or
sin(_degrees*A/B) or, for that matter,
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,
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
with a runtime problem. Explicitly specifying the unit of angular
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
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
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


Matthias Schabel, Ph.D.
Utah Center for Advanced Imaging Research
729 Arapeen Drive
Salt Lake City, UT 84108
801-587-9413 (work)
801-585-3592 (fax)
801-706-5760 (cell)
801-484-0811 (home)
mschabel at ucair med utah edu

Boost list run by bdawes at, gregod at, cpdaniel at, john at