2d rolling ball physics

Talk about computers, hardware, applications, and consumer electronics.
Ice Cold
Posts: 202
Joined: 2008.09.26 (11:49)
Location: Australia
Contact:

Postby mattk210 » 2008.12.29 (00:49)

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.
Last edited by mattk210 on 2008.12.29 (09:40), edited 2 times in total.

User avatar
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:

Postby T3chno » 2008.12.29 (02:30)

You mean like the game, Switchball?
Image

Ice Cold
Posts: 202
Joined: 2008.09.26 (11:49)
Location: Australia
Contact:

Postby mattk210 » 2008.12.29 (04:22)

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.

User avatar
Plus (Size) Member
Posts: 56
Joined: 2008.10.09 (20:40)
NUMA Profile: http://nmaps.net/user/player_03

Postby player_03 » 2009.01.01 (05:27)

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.
Tsukatu wrote:Now, making sure Caps Lock is ON, make sure that Caps Lock is on. Now that Caps Lock is actually on, check again to make sure that Caps Lock is on. Now press the P button. To play, make sure that Caps Lock is on.
Nmaps.net
!Reality

My achievements
My N video

Ice Cold
Posts: 202
Joined: 2008.09.26 (11:49)
Location: Australia
Contact:

Postby mattk210 » 2009.01.02 (22:47)

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 15 guests