Angular Verlet?

Started by
4 comments, last by lusinho 22 years, 2 months ago
Hi, Ever since reading "Advanced Character Physics" from Thomas Jakobsen (http://www.gdconf.com/archives/proceedings/2001/jakobsent.doc) I''ve been playing around with the Verlet integration method he describes. These are the equations he uses: new_pos = 2 * current_pos - old_pos + accel * dt^2 old_pos = current_pos This works fine for particle type objects, and for shaped objects he uses a group of particles with constraints. However I''m not convinced of the advantages of modeling objects with groups of particles so I decided to try and find an angular version of the verlet algorithm described above. My first guess was something like: new_rot = current_rot * current_rot * old_rot^(-1) * accel_mat * dt^2 But what is accel_mat? It needs to be a matrix so that the result is also a matrix. I tried converting the angular acceleration vector into a matrix by using an axis angle representation, but that didn''t seem to work. I''ve looked around for answers but all the verlet algorithms I can find only handle position coordinates. Maybe this algorithm can''t be used for angular motion? I would appreciate if someone could help me with this problem. Thanks, lusinho
Advertisement
> Maybe this algorithm can''t be used for angular motion?

I suspect so. A major problem will be that the units are very different: angular acceleration, like velocity, can be represented by a vector. But there''s no way to do this for rotations: you need either quaternions or matrices, with four or nine elements. In addition the laws of angular motion are more complex than those of linear motion. E.g. for linear motion you use something like

Pos'' = Pos + vel * time

The equivalent rotational equation is

Q'' = Q + t/2 * Q * w

where Q is the rotation quaternion and w the angular velocity.
John BlackburneProgrammer, The Pitbull Syndicate

Thanks johnb. I was wondering where you got the quaternion equivalent for that equation?

Your answer got me thinking.
In terms of matrices the equivalent to

new_pos = pos + vel * deltatime

is

new_Rot = Rot + Rdot * deltatime

where Rdot is the time derivative of R.
To calculate Rdot we must construct a matrix with the angular velocity vector and multiply it by the Rotation matrix like so:

w_mat =
[ 0 -w.z w.y ]
[w.z 0 -w.x]
[-w.y w.x 0 ]

Rdot = w_mat * R

I got all of this from Baraffs paper (http://www-2.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf).

The linear term velocity is also the time derivative of pos. So in the verlet equations when acceleration is mentioned we could consider that as the second time derivative for the position (or orientation).
With that in mind I re-wrote my angular verlet equation:

new_rot = current_rot * current_rot * old_rot^(-1) + R_dot_dot * dt^2

To calculate R_dot_dot we can use the derivative rules to get the result from Rdot:

R_dot_dot = w_mat_dot * R + w_mat * Rdot

w_mat_dot is actually the angular acceleration vector in matrix form and we already know Rdot, so the final equation comes to:

R_dot_dot = w_mat_dot * R + w_mat * w_mat * R

So, I decided to give this one a try.

Unfortunately, it doesn''t seem to work either!

Any other comments, suggestions or ideas?
> Thanks johnb. I was wondering where you got the quaternion
> equivalent for that equation?

Initially from Baraff''s Siggraph notes, as well as from other places. We have the printed version of these, and I don''t know how they compare to those you can find online.

> Rdot = w_mat * R

Yes, that''s the matrix equivalent of Qdot = 1/2 Q w.

> new_rot = current_rot * current_rot * old_rot^(-1) + R_dot_dot * dt^2

> R_dot_dot = w_mat_dot * R + w_mat * Rdot

> Unfortunately, it doesn''t seem to work either!

I''m not suprised. The trick of turning w into a matrix to work out Rdot is a perculiarity of this calculation. I dn''t know how valid it is to extend it in such a way. Without it or some similar trick you are left with two incompatible data types.

Another complication is that the Verlet technique works because the relationship between position, velocity and acceleration is linear. E.g. In the high-school dynamics equations

x = ut + 1/2 at^2
x = 1/2 (u + v) t
v = u + at

if t is fixed all the other terms (x, a, u, v) are linearly related, making it simple to derive Verlet integration from them. But the equation relating rotation and angular velocity is non-linear and so cannot be manipulated the same way.
John BlackburneProgrammer, The Pitbull Syndicate
theta = omega0*t + 1/2*alpha*t^2
omega^2 = omega0^2 + 2*alpha*theta
omega = omega0 + alpha*t

alpha = angular acc
omega = angular vel
theta = displacment angle

so
x = x0+cos(theta)*scale
y = y0+sin(theta)*scale


omega = v/r

v = linear vel
r = circle radius
You''re right johnb. The quaternion equation is in fact in Baraff''s paper, I just didn''t pay much attention to that part as at the time I was not very interested in quaternions.

To koji187, I dont''t really understand what you are trying to say.

This topic is closed to new replies.

Advertisement