CodeBase - Swinging pendulum

Return to the CodeBase listing

Category: Math / Physics

Version: 1.0

0
0

Information

Uploaded: 12th Jan 2004 16:19

Modified: 12th Jan 2004 17:04

Author:  Ianx

Summary

Following on from my "bouncing balls" codebase entry, here's another simulation: A swinging pendulum.

Full Description

This is a sample for representing a swigning pendulum in Dark Basic. The actual coding is pretty simple. As with most exercises like this, the tricky part is figuring out how to represent the physics in code. In this case we create a small cube, then add a limb for the pendulum's shaft and another limb for the weight. This means we can simply rotate the cube according to the correct formula for a pendulum and the shaft & weight will rotate with it.<br /> The final code is fairly short but does give a good representation of a pendulum - it moves quite realistically. The parameters as set in the sample code will cause the pendulum to swing in a complete circle for a while then gradually slow down and come to rest.

Comments

No comments yet.