what is verlets?

Blitz3D Forums/Blitz3D Programming/what is verlets?

Akat(Posted 2003) [#1]
what is verlets those people talking about? something similar to vertex?


sswift(Posted 2003) [#2]
Imagine you have a single vertex which has simple physics applied to it. Wind, gravity, bounce, friction.

Now imagine you have a lot of these verlets. Eight of them. At the corners of a box.

Now imagine you have connected them with stiff rods. These rods can move in any direction but constrain each verlet to be a certain distance from the other verlet it's connected to.

To use verlets, you create the verlets, and then define which verlets are connected to one another, storing the distance apart which they should try to remain.

Then you do your basic physics on each verlet by itself, moving it however it WANTS to move, ignoring the connections to the other verlets, but colliding it with objects it wants to collide with.

Once you've done this, you do a "relaxation phase". You do several loops, each time looping through all the verlets and trying to move them towards the verlets they are connected to so that they are the right distance from their neighbors. So if verlet A is connected to verlet's B and C, you would move it in the direction of B so that it is the right distance from B, and then you would move it in the direction of C so it is the right distance from C. If you do this several times, then you will converge on a correct solution.

The side effect of all this is that MAGICALLY, your objects will rotate as they are supposed to when they hit something, and they will even bounce as a whole even though you're only simulating the bouncing of individual verlets.


There's one last thing you need to know about verlets and that is that instead of storing a direction and velocity for each, you store the velcoity in the positions of the verlets. But I forget how this works. Someone else will need to describe that. This special way of storing the velocity by storing two positions keeps the physics more stable.


_PJ_(Posted 2003) [#3]

special way of storing the velocity by storing two positions keeps the physics more stable.


Since time passes with every loop, the difference between position (BEFORE) and position (AFTER) can help determine speed, direction and therefore velocity
(is this on the right track?)


sswift(Posted 2003) [#4]
I guess that's all they're doing. I wasn't quite sure if I had it right and I didn't want to go off spouting nonsense. :-)

So I guess what you do is at the start of each frame, store the verlet's position in CURRENTFRAME, and then at the end of each frame, store CURRENTFRAME in LASTFRAME. Then each frame you take CURRENTFRAME-LASTFRAME and that tells you the difference between the verlet's position between where it was and where it now is. And that tells you it's position and velocity. And because the two are combined in this way it's very difficult for position and velocity to get out of synch with one another.


Bouncer(Posted 2003) [#5]
Actually there's no such thing as "verlets". I don't know who invented that word anyway??... It's only the integration method that is called Verlet integration... it's an option for traditional methods like Euler integration.

So actually they are just talking about particles connected by springs.


Miracle(Posted 2003) [#6]
Yeah, but "verlets" is such a fun word to say.


Bot Builder(Posted 2003) [#7]
I dunno who invented using "verlets" I know it wasn't me because I remember thinking it was a wierd but good way of describing them. More sophesticated than particles. Anyway, the first time I heard it was from Miracle/DMC in the Advanced 3d forum.


Ricky Smith(Posted 2003) [#8]
Be what they may, that was a great explanation sswift !


sswift(Posted 2003) [#9]
"So actually they are just talking about particles connected by springs."

Actually they're stick constraints, not springs. IF you want to get TECHNICAL, Mr. They're Not Verlets. :-)


Codemonger(Posted 2003) [#10]
Long live Verlets !!! and the guy who invented them.


Akat(Posted 2003) [#11]
or when vertex / vertices + ODE = verlets??


RexRhino(Posted 2003) [#12]
OK, so I have created my own physics library, but it only works on individual points (I was simulating space ships, so this was all I needed)...

To make this a "vertlet" library, all I have to do is create some function to orient my vertlets so they are a specific distance from each of the other vertlets it is linked to?

Would this work????:

1. Calculate my points using my standard physics library.

2. For each point in my object, I check the distance to it's linked points.

3. Lets say I am out of range between point A, and point B. I would point A at B (they are pivots), determine the difference between how far apart they are, and how far apart they should be, and then move point A forward the amount of the distance?

This all seems extremly simple. Most of the vertlet explainations I have seen have gone into some pretty deep calculus, and this I could do with some simple algebra and trig. Am I misunderstanding something? I haven't began my own ragdoll and rigid body stuff because I thought it was too complex. If this is how it works (and it would work that way quickly), then I see no reason not to write my own.


sswift(Posted 2003) [#13]
"3. Lets say I am out of range between point A, and point B. I would point A at B (they are pivots), determine the difference between how far apart they are, and how far apart they should be, and then move point A forward the amount of the distance?"


Well you could do that, but there's much MUCH less computationally expensive ways to do that:


1. PositionA - PositionB = Vector pointing from B to A.
2. Calculate length of vector.
3. Divide vector by vector's length, making Vector's length = 1.
4. Multiply vector by distance which you want A to be from B.
5. Place A at (B + Vector).


Also, you completely ignored the whole storing the positions instead of the velocities. This is probably important for stability in this sort of system. It's easy to convert each frame from the position stuff to a speed and velocity and then back to a position though.

Why convert back and forth? Well, one reason is that when a collision occurs, the velocity of that verlet is automatically reduced or even inverted by the neccessary amount.

Other than that, yeah you've pretty much got the idea. You just need to do step 3 for each verlet connected to each verlet, for all verlets, and do that a few times each frame to relax the object.


There's a lot of times when people who are knowledgeable about math start using calculus for stuff when they don't need to. It's cause they've been trained that way and it's easier to express concepts like calculating a value with a loop over time to other people who know calculus, I guess. I don't know calculus myself. It's frustrating to read a lot of articles on game development when they start using calculus.


_PJ_(Posted 2003) [#14]
Wasnt Verlet the name of the guy that invented ...well... Verlets?


Rob(Posted 2003) [#15]
Yes. His name was Verlet Varlet.


Akat(Posted 2003) [#16]
what if bouy floating on the wavvy ocean - also using verlets


Rob(Posted 2003) [#17]
Akat, you don't need verlets for simple things like boats and floating objects in general. The power of verlets is when you need to roll something over or have collision interaction with another set of verlets.

If you look at the driver demo on the blitz cd you can see that by just checking the wheels of a car and using align to vector, you get a great result. Same for a Bouy floating on an ocean.

So using verlet calculations with string constraints is overkill for simple things.


Bot Builder(Posted 2003) [#18]
Actually, verlets are pretty well suied for buoys/boats. Id wouldn't be hard to write a little verlet physics, add a loop that checks if verlet's under water, and move upwards. People keep on thinking that verlet calculations are expensive. Halos' demos are slow because he made a really bad implementation of constraints, creating and freeing temporary pivots for EACH constraint, and then Using blitz rotation/pointing/movement commands to correct. Oh well. A bouy could be 1 particle.3 particles, or four. Depends on how much you want it to do. It would be good for boats, cause it would have realistic collision with land instead of blitz entity collisions. With alot more work, you coud get boat-boat working.


Akat(Posted 2003) [#19]
any demo?


Bot Builder(Posted 2003) [#20]
gheh. I could right one if you like. no promises of course. I might have alot of non-blitz work pretty soon. I was thinking about writing an example of this anyway. Also, I'd need to email it to someone who has webspace as I don't. Anyone have some good quad waves algorithms I can work with? I tried writing one a while back, but It didn't work out to well. I'd also need a bouy model to make it pretty, but for now I could use a sphere and a cylinder.

I admit that verlet physics may be overkill in simple situations like these, but it may induce that extra level of detail that makes a game really good. You could also add a verlet string down from the bouy to the sea floor. which isn't actually very slow. the main slow thing in verlet is alot of constraints, and a string only needs one per verlet. Also, it may in the end actually save time, as you might have had to debug a system that moves the bouy in a way simply using aligntovector and nothing else. what if a boat hit the bouy? you'd have to write specialized code to handle it. what if one bouy hit another bouy? more specialized code.