Discord
@hash/pendulum
Simulation
2
0
Public

Pendulum

This simulation models single and multiple pendulums by using agents linked together by nearly incompressible springs. Agents are linked to each other using the Networks library.

This simulation generates ideal pendulums swinging in roughly Earth gravity. Different points of the pendulum are assumed to be connected by an incompressible rod. Movement is calculated by finding the total forces acting on each point in the pendulum: gravity and the tension connecting each point.

The different points of the pendulum are linked together by using the Networks Library.

Implementation

Different forces acting on each object are represented by different behaviors. The rods connecting each point of the pendulum are represented as extremely incompressible springs with a very high k-constant.

@hash/physics/spring.rs - calculates the spring forces applied by every neighbor connected to an agent.

@hash/physics/gravity.rs - calculates the purely downward force, at roughly Earth gravity.

@hash/physics/forces.rs - uses Newton's law to convert the forces into movement, based on the time-step specified in globals.json.

Configurations

By changing the initialization behavior in init.json, you can generate different configurations of the pendulum system. Either a single, double, or triple pendulum can be initialized.

The starting position of the triple pendulum causes it to move along all 3 axes, demonstrating the behavior in full 3D space.