Aleph0
Aleph0

Reputation: 6084

Converting given quantities to different system of base units

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.

Upvotes: 0

Views: 101

Answers (0)

Related Questions