Physics decceleration algorithm needed

I am looking for an algorithm which will calculate the decceleration of a spinning wheel, as in a slot machine. A rough algorithm would be fine, accuracy is not that important. If you have an acceleration algorithm, please share, I might be able to reverse it.TIADaniel
[290 byte] By [dantams] at [2007-9-27 22:54:12]
# 1

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

lossendil at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 2

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

dantams at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 3

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

Ragnvald at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 4
decceleration is the same as acceleration except the direction is different.
thunderBolt at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 5

> > 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)

Abuse at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 6
I think so too
Ragnvald at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 7
Thanks guys, I will try the different solutions that have been proposed.- Daniel
dantams at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 8

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

dantams at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 9
Check out Physics for Game Developers. All the code's in C, but it's still great.
JTeen at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...
# 10
What's the URL to physics for game developers
jmichael73 at 2007-7-7 14:08:45 > top of Java-index,Other Topics,Java Game Development...