Motion Simulation of Elastic Pendulum in ImGui C++
The following article defines the equation of motion for the mass hanging on the spring. The equations (differential equations) are solved by the Runge Kuttsa method, which I discussed in one of my precious articles. The equations of motion are solved while the simulation is running. The solution (system state) is generated in each simulation step.
The dynamic system which we are going to simulate can not be considered as an extension of the vertical spring—mass system with gravity.
The elastic pendulum or called also the spring pendulum is a physical system where the mass is connected to a spring. The mass can move in 2D (for simulation purposes).
System motion is composed of a simple pendulum and a one-dimensional spring-mass system. See below for the model of the system.
The motion of the discussed pendulum is classified as chaotic and the motion of the system /mass is highly determined by initial conditions.
We describe the motion of an elastic pendulum by coupled ordinary differential equations (Lagrangian equations) which I solved using the Runge-Kutta method.
The mathematical details of the discussed system you will find in my previous article.
Please consider the motion of the mass and how the initial conditions affect the mass motion. A small difference in initial condition affects considerable changes in the whole system behavior (a feature of the chaotic system)
Bearing in mind our discussion I prepared some simulations for the initial condition which give you the impression of the system running, Please enjoy and apply your ideas.
The implementation of the solution I deployed in C++ with the visualization in ImGui. The introduction to the C++ ImGui and information on how to compile and build programs you will find in one of my previous articles.
The source code you will find on my GitHub.
Thank you for reading.