Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] newbie : plane_angle
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-11 17:58:02


AMDG

Damien R wrote:
> I just discover boost::units and I want to know how it works in this
> case :
> quantity<si::plane_angle> angle(45 * degree);
>
> When the constructor is called, is the argument converted in radian or
> not ?

The value is converted into radians.

> Moreover, it is possible to have :
> quantity<??::plane_angle> angle(45 * degree);
> angle += pi / 4 * radian;
> cout << angle << endl;
> cout << quantity<degree::plane_angle>(angle) << endl;
> cout << quantity<radian::plane_angle>(angle) << endl;
> cout << angle.value<degree>() << endl;
> cout << angle.value<radian>() << endl;
>
> output :
> 45 deg + pi / 4 rad

This is not possible.

> 90 deg
> pi / 2 rad

You would get 1.57..., not pi/2

> 90
> 1.57079632679

This can be done with quantity<degree::plane_angle>(angle).value() e.g..

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net