|
Boost Users : |
Subject: Re: [Boost-users] [Units] Can't assign equation
From: Matthias Schabel (boost_at_[hidden])
Date: 2009-01-21 11:50:02
> Why does first work without a conversion and second doesn't? Also,
> how do I get second to work? I assume this will require some type of
> explicit conversion, but wrapping the right-hand side with
> quantity<velocity>(...) doesn't work.
>
> quantity<velocity> nextVelocity(quantity<velocity> old)
> {
> quantity<velocity> first = (pi / 6.0 * pow<3>(particleDiameter) *
> gravity * (densityWater - densityGold)) * deltaTime / particleMass;
> quantity<velocity> second = (pi / 8.0 * densityWater *
> dragCoefficient * old * root<2>(pow<2>(old))) * deltaTime /
> particleMass;
> ...
> }
The second equation is dimensionally incorrect; i.e. the library is
doing what it should be doing : telling you that you've made a mistake
in your equation. In particular, the first equation gives
m^3 (m s^-2) (kg m^-3) s kg^-1 -> m s^-1
while the second gives
(kg m^-3) (m s^-1)^2 s kg^-1 -> m^-1 s^-1
Matthias
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