Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🌌 Double Pendulum Simulation (Glowscript)

Created by Maximillian DeMarr
Last major update: 2025-05-21

Interactive 3D simulation of a double pendulum built using GlowScript. This project simulates real-time motion based on Lagrangian mechanics and Euler integration.

🔗 Live Demo

👉 Click here to launch the simulation in your browser

Screenshot 2025-05-24 020948


🎮 Instructions

  • Click "Running" to pause or play the simulation.
  • Use the Simulation Step dropdown to adjust precision (larger steps run faster, less accurately).
  • Drag masses to reposition them manually (pause first for best results).
  • Right-click + drag to rotate the view, and use your scroll wheel to zoom.
  • Toggle Show Graphs for energy tracking (note: high detail may reduce performance).
  • If motion becomes erratic, increase Damping or reload the page.

📊 Physics Overview

The system is modeled using the Euler-Lagrange equations, with angular accelerations derived symbolically and solved numerically using the forward Euler method.

⚠️ This project defines positions in the following way. This is opposite to the conventional vertical orientation, due to how Glowscript handles axes.

$$x=\cos(\theta) \quad y=\sin(\theta)$$

🧮 Energy Equations

Kinetic Energy:

$$T = \frac{1}{2}m_1(\ell_1^2 \dot{\theta}_1^2) + \frac{1}{2}m_2\left(\ell_1^2 \dot{\theta}_1^2 + \ell_2^2 \dot{\theta}_2^2 + 2\ell_1\ell_2\dot{\theta}_1\dot{\theta}_2\cos\Delta\theta \right)$$

Potential Energy:

$$V = -m_1g\ell_1\cos\theta_1 - m_2g\left(\ell_1\cos\theta_1 + \ell_2\cos\theta_2 \right)$$

🔁 Angular Accelerations

$$\ddot{\theta}_1 = \frac{m_2g\sin\theta_2\cos\Delta\theta - m_2\ell_2\dot{\theta}_2^2\sin\Delta\theta - (m_1+m_2)g\sin\theta_1}{\ell_1(m_1 + m_2\sin^2\Delta\theta)}$$ $$\ddot{\theta}_2 = \frac{(m_1+m_2)(\ell_1\dot{\theta}_1^2\sin\Delta\theta - g\sin\theta_2 + g\sin\theta_1\cos\Delta\theta)} {\ell_2(m_1 + m_2\sin^2\Delta\theta)}$$

where

$$\Delta\theta = \theta_1 - \theta_2.$$

🧮 Related Tools

This repo uses:


🧑‍💻 Author

Maximillian DeMarr
Built with curiosity, calculus, and caffeine ☕.
For inquiries or collaborations, feel free to reach out!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages