You are right with your assumption. The problem lies with the tangential force.
But there are two problems with the way you calculate your tangential force:
- What you mentioned, that the force should apply instantaneously.
- The way you calculate your force, the center of rotation changes throughout the simulation.
Both of those can be fixed by decreasing the timestep and increasing the number of iterations, but those are hardware bound, so you will eventually hit the bottom there.
A better way to fix those problems is by using a different model:
Using a conservative force(examples of that are gravity, electrostatic forces, Forces from a rope that connects your object and the center, …) allows the system to correct itself if it starts spiraling(If your object leaves the desired radius, conservative forces will make sure it comes back).
Here an example implementation for gravity:
orthogonalVector = centerPoint - positionVector;
float value = orthogonalVector.value();
float scalar = gravityConstant*centerMass/pow(value, 3);
accelerationVector = scalar*orthogonalVector;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…