Tuesday, December 18, 2018

c++ - simplest way of making a sphere roll in a realistic way


rather than just moving a sphere across a plane, I want to make it roll like a ball. What is the simplest way of doing this? I assume it will have something to do with the circumference of the ball and rotating + moving it at a calculated rate.


What is the relevant maths here?



Answer



The simplest way is to calculate how much ball is moved and rotate the ball that much divided by it's radius!


And the reason: we all know how they calculate PI. imagine a circle with radius of one unit, it's perimeter is 2*PI as shown in this picture:


circle


Now in your case the ball may move in any direction. but it's movement speed is always a 2d vector (note that it's rolling not flying!) and to rotate a ball you need a 2d vector. these 2d vectors have the same value except you need to divide speed vector by sphere diameter.



and as a sidenote, I've assumed that rotating the ball doesn't need any force. if you want a real physical simulation thing get a little more harder than this.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...