Up until now, I've been using unrotateable objects in my physics sims - like N, everything sort of just slides around, and collision is handled with simple projection. Now I want to implement a rolling ball as a character, how can I do this? As in you have control over the spin of the ball clockwise and counterclockwise instead of just controlling thrust in a direction, and movement against the geometry is somehow calculated from there.
EDIT: I have managed to fake this by just applying movement normally, and calculating rotation based on velocity. It's not ideal, but it's OK. I probably should have tried that before posting here. So if someone could show me a fairly simple "real" solution that would be nice but I no longer need it.
2d rolling ball physics
-
- Ice Cold
- Posts: 202
- Joined: 2008.09.26 (11:49)
- Location: Australia
- Contact:
Last edited by mattk210 on 2008.12.29 (09:40), edited 2 times in total.
- Cross-Galactic Train Conducter
- Posts: 2354
- Joined: 2008.09.27 (00:31)
- NUMA Profile: http://nmaps.net/user/T3chno
- MBTI Type: ENTJ
- Location: foam hands
- Contact:
You mean like the game, Switchball?

-
- Ice Cold
- Posts: 202
- Joined: 2008.09.26 (11:49)
- Location: Australia
- Contact:
sort of, but in 2d. But in switchball the orientation of the ball is not particularly relevant, I need the ball to actually rotate accurately as it rolls along.
- Plus (Size) Member
- Posts: 56
- Joined: 2008.10.09 (20:40)
- NUMA Profile: http://nmaps.net/user/player_03
To keep track of how fast the ball is rolling, you'll have to keep track of its angular acceleration.
Angular acceleration = torque / rotational inertia
Rotational inertia = 2/5 * Mass * Radius^2
Torque = Radius * Force perpendicular to radius = Radius * Force * sin( angle between radius and applied force )
On horizontal ground, this would be Radius * Horizontal force, though that isn't good for much more than testing.
Of course, you aren't calculating something in the real world. You can put the mass and radius in whatever units you like, and the only thing that really matters is calculating the torque.
Essentially, just multiply the force by the sine of the angle between the force and radius and multiply that by a constant. Play with the constant's value until the ball seems to be spinning properly. That should be faster than doing all the math.
Hopefully this helps.
Angular acceleration = torque / rotational inertia
Rotational inertia = 2/5 * Mass * Radius^2
Torque = Radius * Force perpendicular to radius = Radius * Force * sin( angle between radius and applied force )
On horizontal ground, this would be Radius * Horizontal force, though that isn't good for much more than testing.
Of course, you aren't calculating something in the real world. You can put the mass and radius in whatever units you like, and the only thing that really matters is calculating the torque.
Essentially, just multiply the force by the sine of the angle between the force and radius and multiply that by a constant. Play with the constant's value until the ball seems to be spinning properly. That should be faster than doing all the math.
Hopefully this helps.
-
- Ice Cold
- Posts: 202
- Joined: 2008.09.26 (11:49)
- Location: Australia
- Contact:
Ah, thanks, that's what I'm looking for. I'm using the "force" you refer to as the velocity of the ball projected along the vector of the geometry it's against, and that works great.
Who is online
Users browsing this forum: No registered users and 4 guests