Boost logo

Boost Users :

Subject: [Boost-users] [Units] Can't assign equation
From: Daniel Dilts (diltsman_at_[hidden])
Date: 2009-01-21 10:57:34


 I'm using Boost.Units in a program for school to make certain that my
equations are consistent (and that I didn't screw them up entering
them). In the next Velocity equation, first get assigned with no
problems, second causes a compiler error that I believe is saying that
the constructor for quantity<velocity> is explicit.

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.

const quantity<dimensionless> pi =
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798;
const quantity<time> deltaTime = .1 * second;
const quantity<length> particleDiameter = .001 * meter;
const quantity<dimensionless> dragCoefficient = 0.5;
const quantity<dimensionless> specificGravityGold = 19.32;
const quantity<acceleration> gravity = 9.80665 * meters_per_second_squared;
const quantity<length> initialHeight = 0 * meters;
const quantity<time> initialTime = 0 * seconds;
const quantity<velocity> initialVelocity = root<2>(4.0/3 *
specificGravityGold * gravity * particleDiameter / dragCoefficient);
const quantity<mass_density> densityWater = 1000 * kilograms_per_cubic_meter;
const quantity<mass_density> densityGold = 19300 * kilograms_per_cubic_meter;
const quantity<mass> particleMass = 4.0 / 3.0 * pi *
pow<3>(particleDiameter / 2.0) * densityGold;

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;
    ...
}


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