Re: X-Axis jump, about 1,4mm February 18, 2014 06:29AM |
Registered: 9 years ago Posts: 578 |
Re: X-Axis jump, about 1,4mm February 18, 2014 07:39AM |
Registered: 9 years ago Posts: 14,639 |
Quote
} else
{
v = sqrt(-u);
u = v/k;
}
Quote
} else
{
u = sqrt(-u);
v = u * k;
}
Re: X-Axis jump, about 1,4mm February 18, 2014 08:16AM |
Registered: 9 years ago Posts: 578 |
if(u >= 0.0)
{
u = sqrt(u);
v = k*u;
} else
{
v = sqrt(-u);// u must be negative to get here, surely? - this is what I changed to "v=1.0" in my naive fix
u = v/k;
}
surely the program wouldn't get into that else clause unless u is negative?Quote
dc42
The values of u and v are never negative on entry.
Re: X-Axis jump, about 1,4mm February 18, 2014 08:26AM |
Registered: 9 years ago Posts: 14,639 |
u = 2.0*acceleration*distance/(k*k - 1); if(u >= 0.0)
if(dCross < 0.0 || dCross > distance) { // With the acceleration available, it is not possible // to satisfy u and v within the distance; reduce the greater of u and v // to get ones that work and flag the fact. // The result is two velocities that can just be accelerated // or decelerated between over the distance to get // from one to the other. result = change; float temp = 2.0 * acceleration * distance; if (v > u) { // Accelerating, reduce v v = sqrt((u * u) + temp); dCross = distance; } else { // Decelerating, reduce u u = sqrt((v * v) + temp); dCross = 0.0; } }
Re: X-Axis jump, about 1,4mm February 18, 2014 08:37AM |
Registered: 9 years ago Posts: 578 |
Re: X-Axis jump, about 1,4mm February 18, 2014 09:33AM |
Registered: 9 years ago Posts: 2,472 |
Re: X-Axis jump, about 1,4mm February 18, 2014 10:02AM |
Registered: 9 years ago Posts: 578 |
Re: X-Axis jump, about 1,4mm February 20, 2014 10:38AM |
Registered: 9 years ago Posts: 48 |
float dCross = 0.5*(0.5*(v*v - u*u)/acceleration + distance); if(dCross < 0.0) { // With the acceleration available, it is not possible // to satisfy u and v within the distance; reduce u and v // proportionately to get ones that work and flag the fact. // The result is two velocities that can just be accelerated // or decelerated between over the distance to get // from one to the other. // dCross < 0 implies that abs(u) > abs(v); we need to reduce u u = sqrt(2*acceleration*distance + v*v); dCross = 0; result = change; } else if(dCross > distance) { // dCross > distance implies that abs(u) < abs(v); we need to reduce v v = sqrt(2*acceleration*distance + u*u); dCross = distance; result = change; }