|
Boost : |
Subject: [boost] [interest] Is there interest in planar angle library ?
From: Matus Chochlik (chochlik_at_[hidden])
Date: 2014-06-17 16:12:51
Hi,
I would like to gauge interest in adding a very lightweight library
implementing a class for handling planar angles and related operations to
Boost.
The library sources and several examples of usage can be found here:
https://github.com/matus-chochlik/angle
It does not conform to Boost conventions yet, nor is there any
documentation, but the library is very simple to use:
There is a template angles::angle<T> representing planar angles, using type
T to store the angle value in radians. Conversions for 10 common angle
units are included and new units can easily be added. The library also
implements construction functions and user-defined literal operators
allowing to specify angles in various units and also implements overloads
of functions like sin, cos, etc.
The only external header that this library includes is standard `cmath`.
Here follow some examples of usage:
using namespace angles;
for(angle<double> a; a < 4_turns; a += 45_deg)
{
std::cout << a.to<unit::degree>() << std::endl;
}
for(angle<double> a=-quarters(2); a <= quarters(2); a += gradians(50))
{
std::cout << a.to<unit::turn>() << std::endl;
}
for(angle<double> a; a < turns(1); a += degrees(15))
{
std::cout << sin(a) << std::endl;
}
assert(turns(1) == quarters(4));
assert(degrees(90) == gradians(100));
assert(degrees(45) == quarters(0.5));
assert(degrees(2) == minutes(120));
assert(minutes(4) == seconds(240));
assert(degrees(1) == seconds(3600));
assert(turns(0.5) == gradians(200));
assert(pi(1) == quarters(2));
assert( 3_o_clock == 90_deg);
assert( 6_o_clock == 200_gon);
assert( 7_o_clock == 210_deg);
assert( 9_o_clock == 300_gon);
assert(11_o_clock == 1_turns - 30_deg);
assert(12_o_clock == 2_pi);
Please let me know if you are interested in the 'Boostification' of this
library or if you have any ideas on how it could be improved.
Best regards,
Matus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk