Commit 5c59a8bd by Jean-Benoist Leger

### separation between root3 and cst_power_biking

parent d31b3a5f
 ... ... @@ -89,23 +89,8 @@ void rv_do_walk( velocityB = distance_AB / time; } double rv_constant_power_biking( parameters_t & parameters, double & velocityA, double & delta_elevation, double & distance_AB) void order3_poly(double & a, double & b, double & c, double & d, double & root3) { double velocityB; double delta_gravitational_potential_energy = parameters.mass * RV_G * delta_elevation; double work_of_rolling_resistance = parameters.mass * RV_G * parameters.Cr * distance_AB; // we write a poly a*vB^3+b*vB^2+c*vB+d // the root is the answer double a = (RV_RHO_AIR*parameters.SCx*distance_AB+2*parameters.mass)/4; double b = a*velocityA; double c = (4*work_of_rolling_resistance+(RV_RHO_AIR*parameters.SCx*distance_AB-2*parameters.mass)*velocityA*velocityA+4*delta_gravitational_potential_energy)/4; double d = c*velocityA - 2*distance_AB*parameters.power; double p = (3*a*c-b*b)/(3*a*a); // velocity^2 double q = (2*b*b*b-9*a*b*c+27*a*a*d)/(27*a*a*a); // velocity^3 double e = -b/(3*a); // velocity ... ... @@ -122,20 +107,40 @@ double rv_constant_power_biking( // computation without using imagnary computation double three_power_ = std::pow(3.0,3.0/2.0); double two_power_ = std::pow(2.0,1.0/3.0); velocityB = (cos(atan2(0,(sqrt(discri)-three_power_*q)/(2*three_power_))/3)*std::pow(sqrt(discri)-three_power_*q,2.0/3.0)-two_power_*two_power_*cos(atan2(0,(sqrt(discri)-three_power_*q)/(2*three_power_))/3)*p)/(two_power_*sqrt(3)*std::pow(abs(sqrt(discri)-three_power_*q),1.0/3.0)); root3 = (cos(atan2(0,(sqrt(discri)-three_power_*q)/(2*three_power_))/3)*std::pow(sqrt(discri)-three_power_*q,2.0/3.0)-two_power_*two_power_*cos(atan2(0,(sqrt(discri)-three_power_*q)/(2*three_power_))/3)*p)/(two_power_*sqrt(3)*std::pow(abs(sqrt(discri)-three_power_*q),1.0/3.0)); } else { // idem but we assume <0 double three_power_ = std::pow(3.0,3.0/2.0); velocityB = -(2*p*cos(atan2(sqrt(-discri)/(2*three_power_),-q/2)/3))/(sqrt(-3*p)); root3 = -(2*p*cos(atan2(sqrt(-discri)/(2*three_power_),-q/2)/3))/(sqrt(-3*p)); } velocityB+=e; root3+=e; if(velocityB<0) velocityB=0; if(isnan(velocityB)) velocityB=0; if(root3<0) root3=0; if(isnan(root3)) root3=0; } double rv_constant_power_biking( parameters_t & parameters, double & velocityA, double & delta_elevation, double & distance_AB) { double velocityB; double delta_gravitational_potential_energy = parameters.mass * RV_G * delta_elevation; double work_of_rolling_resistance = parameters.mass * RV_G * parameters.Cr * distance_AB; // we write a poly a*vB^3+b*vB^2+c*vB+d // the root is the answer double a = (RV_RHO_AIR*parameters.SCx*distance_AB+2*parameters.mass)/4; double b = a*velocityA; double c = (4*work_of_rolling_resistance+(RV_RHO_AIR*parameters.SCx*distance_AB-2*parameters.mass)*velocityA*velocityA+4*delta_gravitational_potential_energy)/4; double d = c*velocityA - 2*distance_AB*parameters.power; order3_poly(a,b,c,d,velocityB); // Now hack // To avoid oscillation starting from 0, we choose the speed half of old and ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!