|
This is a basic animation of a coupled oscillator.
The compound circles are represented by the center of gravity (directly in the middle) and the current angle with the x-axis. Two forces are applied. The force induced by the spring and directing towards the point where the spring is fixed, and the gravity force. Because the spring force affects the right circle an angular momentum is induced. I also let the gravity force induce an angular momentum in the right circle. This is not physically correct, because the gravity force is affecting only the center of mass and the object is symmetric around the center, so there should be not torque. But this gives more convincing results, because it helps to control the torque induced by the spring.
Simulation is done by computing, mass and inertia of the object and calculating the forces (gravity and spring) at every time step. The Euler method is used for integration. To improve the result in every time step 10 iterations are done, to get a smoother result. Please note, that the movement is highly dependent on the number of iterations, so the more stable 5th-order Runge-Kutta method should be used for integration instead.
Given the force, the acceleration of the center of gravity is proportional and so the current velocity and the pose can be determined. Also given the force and the point of application one can compute the angular momentum.
I didn't put much effort in the implementation of a correct collision detection and reaction, because this is not the main purpose of the program.
- Press 'k' to double spring constant, 'l' to divide by two.
- Press 'r' to increase the density, 't' to devide by two.
- Press 'i' to increase the iterations, 'o' to devide by two.
- Press '1' and click to set the center of gravity and reset velocity and angle
- Press '2' and click to set the point the spring is fixed and reset velocity
- Press 'c' to deactivate the simple collision reaction
- Adjust the point the spring is fixed with the left mouse button, velocity and angle will NOT be reseted
Click the applet to activate.
|