 # Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-01-07 05:23:34

"David B. Held" <dheld_at_[hidden]> wrote in message
news:btgjns\$do1\$1_at_sea.gmane.org...
> "Andy Little" <andy_at_[hidden]> wrote in message
> news:btgigm\$bfq\$1_at_sea.gmane.org...
> >
> > "Daniel Frey" <daniel.frey_at_[hidden]> wrote
> >
> > > > Speed s = 2 m / s;
> > [...]
> > q_velocity::m_div_s s(2);
>
> If I had to choose between the two, I'd pick the first one, hands down.
> Why? Well, it all goes back to expressing the solution in the language
> of the problem domain. Granted, this is an extreme (ab)use of
> operator overloading, but if it lets us write expressions that almost
> look natural, why shouldn't we take advantage?

{
const double& tip_r = rotordialog.m_outer_dia/2000.0L;
const double rr = r/1000;
const double& tsr = rotordialog.m_tsr;
const double& ellipticality = rotordialog.m_ellipticality;
const double& Vin_y= rotordialog.m_vw;
const double dr = get_dr()/1000.0L;
const double dt = 1.0L;

// could simplify to vout_y = vin_y*(1/3 + ellipticality *(2/3 -
sqrt(1-r^2/R^2))
const double Vout_y = Vin_y * ((rr < tip_r)
?1.0L-((2.0L/3.0L)*(1.0L - ellipticality) +
(ellipticality * sqrt(1.0L - (rr*rr)/(tip_r*tip_r))))
:1.0L-((2.0L/3.0L)*(1.0L - ellipticality)) );
const double Vb_y = (Vin_y + Vout_y)/2.0L;
const double mass = Vb_y * 2 * PI * (rr) * rotordialog.m_rho_air * dr;
const double Fb_y = mass * (Vin_y - Vout_y)/dt;
double Vout_x=0;
double oldVout_x=0;
const double cl = rotordialog.m_cl;
const double drag_coeff = rotordialog.m_cd/cl;
for (int i =0;i < 1000;++i){
const double Vb_x = Vout_x/2.0L + Vin_y * tsr * (rr/tip_r);
const double beta = atan2(Vb_y,Vb_x);
const double sinbeta = sin(beta);
const double cosbeta = cos(beta);
const double Lift = Fb_y/(cosbeta + drag_coeff * sinbeta);
const double Fb_x = Lift * (sinbeta - drag_coeff * cosbeta);
oldVout_x = Vout_x;
Vout_x= Fb_x/mass;
if ( abs(Vout_x - oldVout_x) < 0.0001L * Vin_y){
double chord = Lift /
((Vb_x * Vb_x + Vb_y * Vb_y) *0.5* rotordialog.m_rho_air* cl *dr *
return chord_omega(chord * 1000,beta - rotordialog.m_alpha *
0.017453293L);
}
}
return chord_omega(0,0);//fail
}

Feel free to recode in your 'problem domain' with m and s my friend. I'll
take my syntax .

BTW what about performance? Or doesnt that matter?

regards
Andy Little