Boost logo

Boost Users :

Subject: Re: [Boost-users] Using atan2 in boost::units
From: Brandon Olivares (programmer2188_at_[hidden])
Date: 2010-01-04 16:52:06


On 2010-01-04, Steven Watanabe wrote:
> AMDG
>
> Matthias Schabel wrote:
>> I think we should probably have functions that return angles default
> to radians if not otherwise specified in the system. To my mind, that
> is consistent with the principle of least surprise and is consistent
> with existing library functionality... While the above solution should
> work and is consistent, it requires more understanding of Boost.Units
> than should be necessary for simple use of inverse trigonometric
> functions.
>>
>
> Yeah. That makes sense.
>

I ended up doing something like the following to get it to work. Please let
me know if there is a better way.

template<class Length>
template<class Angle>
physics::cylindrical_coordinate_system::point<Length, Angle>&
point<Length>::to_cylindrical() const
{
static physics::cylindrical_coordinate_system::point<Length, Angle>
cylindrical(
boost::units::sqrt(boost::units::pow<2>(x_) + boost::units::pow<2>(y_)),
static_cast<boost::units::quantity<Angle> >(
boost::units::atan2(
static_cast<boost::units::quantity<boost::units::si::dimensionless> >(
y_.value()),
static_cast<boost::units::quantity<boost::units::si::dimensionless> >(
x_.value()))),
z_
);
return cylindrical;
} // to_cylindrical

I didn't quite understand what you were getting at before. light_second is a
measure of length, so I didn't want to include a measure of angle in it.

Thanks,
Brandon

> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

--
Brandon
www.creatorspiritus.com
Blog and forum discussing living a Christ-centered life
Follow me on Twitter: http://twitter.com/devbanana

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