I'm currently trying to figure out how to rotate an object at a speed of 160 degrees per second, gradually slowing down until it comes to a stop at a specific angle. For instance, if the target angle is set to 30 degrees, the object should spin quickly and then decelerate, ultimately coming to rest at 30 degrees. I'm struggling to develop the algorithm needed to achieve this effect, which is why I'm seeking assistance.
For now, let's assume that setting the rotation can be done simply by assigning a value to object.Rotation, such as object.Rotation = 30 (degrees). Please feel free to provide a solution in Java, Lua, C++, or JavaScript.
Here's what I have so far (which isn't much):
//Assume wait(1) pauses for 1 second
int angle = 70; //Start with fast rotations that gradually slow down
for (int i = 140; i > .1; i = i - 5) { //Algorithm must work for any angle
for (int a = 0; a < i; a = a + 10) {
object.Rotation = a;
wait(.05);
}
}