Four years ago, I watched my son Ridit, in class V at that time, experimenting with cloth and soft-body simulations in Blender. At that time he was deeply interested in learning how modern graphics tools simulate physical behaviour such as cloth, smoke, and rigid body dynamics.
One of his experiments is captured in this video:
Watching him explore Blender’s simulation tools sparked a thought in my mind:
Could I reproduce a simplified cloth simulation myself using code?
Years later, while exploring scientific computing with Julia, I decided to attempt exactly that.
The result is a small but interesting Verlet-integration based cloth simulation written entirely in Julia.
Why Verlet Integration?
In physics simulations used in games and graphics engines, Verlet integration is very popular because:
• It is simple
• It is numerically stable
• It does not explicitly require velocity storage
Many cloth simulators in early game engines relied on this technique.
The basic idea is:
$$
x_{new} = x_{current} + (x_{current} - x_{previous}) + a\Delta t^2
$$
Where:
(x_{current}) → current position
(x_{previous}) → previous position
(a) → acceleration (gravity, wind etc.)
Representing Cloth as a Grid
A cloth can be represented as a grid of particles connected by constraints.
Each particle stores:
Current position
Previous position
Neighbouring particles are connected by distance constraints that maintain the cloth structure.
o---o---o---o
| | | |
o---o---o---o
| | | |
o---o---o---o
Some particles are pinned so the cloth does not fall entirely.
The Julia Implementation
Below is the Julia program that simulates the cloth.
And here is the video if we run this application.
What the Simulation Does
The simulation includes:
1. Gravity
gravity = [0.0,-9.8]
Every particle experiences downward acceleration.
2. Wind Force
wind = [2*sin(0.05*step),0.0]
A sinusoidal wind creates cloth fluttering.
3. Constraint Relaxation
Multiple iterations enforce distance constraints so the cloth maintains its shape.
for k in 1:6
satisfy_constraints()
end
This technique is commonly used in Position Based Dynamics.
Visual Result
The script generates an animated GIF showing a cloth hanging from the top row while wind and gravity deform it dynamically.
Even with a few dozen lines of code, we get a convincing physical effect.
What Makes Julia Interesting for Graphics Simulation
Working with Julia gives several advantages:
• Fast numerical computation
• Simple array operations
• Easy prototyping for physics simulations
• Smooth transition from mathematics to implementation
This makes it attractive for engineers exploring scientific computing, graphics, and simulation together.
A Personal Reflection
This small experiment reminded me of the moment I watched my son exploring cloth simulation in Blender years ago.
Back then he was experimenting visually.
Today I tried to rebuild the physics underneath that visual tool.
Sometimes inspiration in engineering does not come from textbooks — it comes from watching curiosity in the next generation.
And that curiosity often pushes us to explore deeper layers of science and software.
