A rough algorithm ?
if (speed > 0.0)
speed -= deceleration;
wheelAngle += speed;
With deceleration proportional to axis' friction :
small decelaration for a ball bearing
high deceleration for a stone wheel on a wooden axis
Thanks, I already had a similar algorithm. Probably I shouldn't have asked for a rough algorithm after all.
I had in mind an algorithm which would slow down more realistically, i.e. decrease in velocity first very little, then larger and larger, in a curve, not linear. It is needed to simulate the wheel of a slot machine.
- Daniel
> realistically, i.e. decrease in velocity first very
> little, then larger and larger, in a curve, not
-Or even more realistcly: First a lot, then smaller and smaller, in a curve...
;-)if(speed > 0.0)
{
speed /= decFactor; // = 0.99 (between 0 and 1, close to 1)
speed -= decConst; // = whatever positive value
}
else
speed = 0.0;
angle += speed;
> > realistically, i.e. decrease in velocity first very
> > little, then larger and larger, in a curve, not
> -Or even more realistcly: First a lot, then smaller
> and smaller, in a curve...
> ;-)> if(speed > 0.0)
> {
> speed /= decFactor; // = 0.99 (between 0 and 1,
> 1, close to 1)
>speed -= decConst; // = whatever positive value
> }
> else
>speed = 0.0;
> angle += speed;
>
>
i think you meant
speed *=decFactor; // = 0.99 (between 0 and 1, close to 1)
> > if(speed > 0.0)
> > {
> > speed /= decFactor; // = 0.99 (between 0 and 1,
> > 1, close to 1)
> >speed -= decConst; // = whatever positive value
> > }
> > else
> >speed = 0.0;
> > angle += speed;
> >
> >
>
> i think you meant
> speed *=decFactor; // = 0.99 (between 0 and 1,
> close to 1)
>
I found that speed *= decFactor where 0.9 < decFactor < 1.0 gives an inward curve, whereas speed *= decFactor where decFactor > 1.0 and decConst > (decFactor - 1.0) gives an outward curve, which is what I wanted. This would actually also be achieved by the first proposal speed /= decFactor; // = 0.99 (between 0 and 1, close to 1). I will use speed *= 1.099;
speed -= (0.1 * initialSpeed);
as it gives a beautiful outward curve.