units icon indicating copy to clipboard operation
units copied to clipboard

Support for equivalent units

Open simonvpe opened this issue 6 years ago • 0 comments

The following code calculates the angular acceleration when applying torque to a body with a given rotational inertia. However, the resulting unit [N/(kg*m)] should be convertible to [rad/s^2]. What support is there for this in the library?

using kilogram_meters_squared_t = decltype(1.0_kg * 1.0_sq_m);
using radians_per_second_squared_t = decltype(1.0_rad / 1.0_s / 1.0_s);

const kilogram_meters_squared_t inertia = kilogram_meters_squared_t{1.0};
const newton_meter_t torque = 1.0_Nm;

// Conversion should happen automatically
const radians_per_second_squared_t angular_acc{(torque / inertia).to<float>()};

simonvpe avatar Feb 01 '19 14:02 simonvpe