# Building my own Delphi Physics Engine part V

Today I felt inspired (after parts I, II, III and IV) and I tried to do a cloth simulation in the Thundax Physics Engine. There are a lot of things to do, but at least I can start simulating different components very fast without too much implementation. I saw one amazing implementation of the "processing cloth" in JRC313.com. Even though the applet is written in JavaScript, the performance is quite impressive and it's a nice work.

but, How it works?
"Every line in the cloth simulation is technically called a constraint and every point is a point mass (an object with no dimension, just location and mass). All the constraints do is control the distance between each point mass. If two points move too far apart, it will pull them closer. If two points are too close together, it will push them apart. The cloth is really then just a collection of constraints and point masses in a never ending struggle."

using Relaxation in simple linear systems:
In the case of this cloth simulation all I needed to do was try satisfying the constraints as fast as I can. For things like simple rope simulations it may be necessary to satisfy several times (maybe 4 or 5). The more times you satisfy, the more rigid the constraint becomes. This process is known as relaxation and is amazing!. The displacement will then be of the form y(t) = Ae − t / Tcos(μt − δ). The constant T is called the relaxation time of the system and the constant μ is the quasi-frequency. (Wikipedia).

In the following videos you'll be able to check the performance of the simulated cloth. I took advantage of my previous bridge (spring + particles) and I've concatenated a series of bridges to set up a virtual cloth. Now the movement is quite astonishing:

In the second video I'm showing one of the new features for the next release: "the cutting tool". I still need to think about it, but for simple objects it could be simple to cut an object and see its reaction, like in the next video:

You can download the last version of the executable file here: thundax Balls demo v1.52. And maybe in a near future you'll be able to see something similar to the Puzzler for iPhone.

Other interesting video about physics and games is Crayon Physics from Petri Purho:

I hope you enjoy the videos!

1. Really nice Jordi, to see and to read.
Thanks,

Vincent

2. Hi Vincent,

It´s really nice having readers like you commenting my work! I'm trying to get round to publishing more often as I have a lot of interesting stuff that needs to be published!.

Jordi.