0

I'm trying to use boost-unit for one of my projects. In this project several quantities like velocity, accelaration, angular velocity are represented with SI-System base units. (m/s, m/s^2, rad/s^2)

The user uses a GUI Interface to plot these quantities. Let's say an angular velocity. The GUI should allow the user to dynamically change the base units, where he has the options:

Lengths: m, cm, mm

Time: s, ms, min, h

Angle: rad, deg

In order to use boost-unit for my project I need a generic function converting a quantity like 5*m*s^-2*rad to 5*1000/M_PI*180*mm*s^2*deg.

But I'm completely lost what might be the best approach to write this function.

I think it has to be something like:

template<typename H1, typename H2, typename U, typename V>
quantity<V> convert(const quantity<U>& quantity);

Where H1 and H2 are of type homogeneous_system, that can be build by make_system.

Aleph0
  • 5,816
  • 4
  • 29
  • 80
  • 1
    Have a look at examples [ConversionFactor](http://www.boost.org/doc/libs/1_61_0/doc/html/boost_units/Examples.html#boost_units.Examples.ConversionFactor) and [RuntimeUnits](http://www.boost.org/doc/libs/1_61_0/doc/html/boost_units/Examples.html#boost_units.Examples.RuntimeUnits) (from boost doc). – Jarod42 Jul 06 '16 at 17:07
  • Hello. Many thanks for this hint. The documentation is so lengthy, that I didn't saw the forest for the trees. I think that it might be the solution for what I'm looking, but there is still a part missing. Given a `quantity` I need to know what powers of base units `T` is composed of. For example `quantity` gives me the powers 1 and -2 for `rad` and 'seconds'. I guess the missing part should be implemented as a generic function in 'T'. – Aleph0 Jul 07 '16 at 06:24
  • I think `io.hpp` has to accomplish the same job of getting the powers of exponents. But I really don't want to dive in this template metaprogramming stuff on my own. – Aleph0 Jul 07 '16 at 06:55

0 Answers0