0:00:00.000,0:00:03.000
Now let's try out some of these ideas with the flexible rope.
0:00:03.000,0:00:06.000
We'll fix both ends of that rope
0:00:06.000,0:00:11.000
and want to see what the equilibrium shape is going to be
0:00:11.000,0:00:13.000
under the influence of gravity.
0:00:13.000,0:00:18.000
The obvious choice of finite elements is springs.
0:00:18.000,0:00:23.000
Springs of a given rest length, so that the potential energy of each spring
0:00:23.000,0:00:29.000
amounts to 1/2 times the spring constant times the square of the extension of the spring,
0:00:29.000,0:00:34.000
which is the distance between the two endpoints minus the rest length of the string.
0:00:34.000,0:00:40.000
To model the mass of that rope, we attach mass points to these strings.
0:00:40.000,0:00:45.000
Of course, these mass points carry potential energy due to gravity.
0:00:45.000,0:00:50.000
Given the constants that we provide, compute the potential energy of that rope.
0:00:50.000,0:00:55.000
The one end of that rope will be fixed at x = 0, y = 0.
0:00:55.000,0:01:05.000
The other end of that rope will be fixed at x = 1.3 m and y = 0.4 m.
0:01:05.000,0:01:08.000
Our code starts with a random initialization
0:01:08.000,0:01:13.000
and then applies a pretty simplistic strategy to minimize the energy.
0:01:13.000,0:01:16.000
For a certain number of times it's going to pick one of the masses
0:01:16.000,0:01:20.000
and change the position of that mass point by a random vector.
0:01:20.000,0:01:23.000
If the energy decreases, it keeps that new position.
0:01:23.000,0:01:26.000
If it doesn't, it returns to the position before.
0:01:26.000,9:59:59.000
Very simple, but highly inefficient.