|
Boost Users : |
Subject: Re: [Boost-users] [Units] Converting from angular_velocity to degrees_per_second
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-12-01 14:43:17
AMDG
On 12/1/2010 11:10 AM, Andrew Hundt wrote:
> I have made my question more specific so it will be easier to answer.
> I need to make a conversion from a general angular_velocity to
> degrees/second.
There's no such thing as a general angular_velocity.
I assume that you mean that you want to convert
from radians/second to degrees/second.
> To illustrate this problem the example boostUnits.cpp:
>
> #include<boost/units/systems/si.hpp>
> #include<boost/units/systems/angle/revolutions.hpp>
> #include<boost/units/systems/angle/degrees.hpp>
> #include<boost/units/conversion.hpp>
> #include<boost/units/pow.hpp>
> #include<iostream>
> #include<iterator>
> #include<algorithm>
>
> int main()
> {
> boost::units::quantity< boost::units::si::angular_velocity>
> m_speed((30.0*boost::units::si::radians_per_second));
> std::cout<< "m_speed: "<< m_speed<< std::endl;
>
> uint32_t result =
> static_cast<uint32_t>(boost::units::quantity<boost::units::si::angular_velocity,uint32_t>(m_speed*boost::units::degree::degrees/boost::units::si::seconds).value());
> std::cout<< " result:"<< result<< std::endl;
>
> return(0);
> }
Try
typedef boost::units::divide_typeof_helper<
boost::units::degree::plane_angle,
boost::units::si::time
>::type degrees_per_second;
static_cast<boost::units::quantity<degrees_per_second> >(m_speed);
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