[ODE] Constraint equations and the famous J matrix

Petr Sovis petr_sovis at hotmail.com
Mon Jun 30 05:40:02 2003


Hi,
base dynamic equation system
  A * lambda = b + k1, where lambdai >= 0, bi >= 0, lambda * b = 0
which can solve contacts, has additional conditions when adding positional 
constraints.
Consider equation (J invM JT ) * lambda = (c/dtime - J * (invM * Fext + 
vold/dtime)) + w as only optimized form of the following:

    | 0  |   | invM J1T J2T  |   | v new    |     | Fext + vold/dtime |
    | 0  | - | J1     0    0    | * | lambda1 | =  |   k1                    
|
    | vx |   | J2     0    0     |   | lambda2 |     |   k2                  
   |

( comes from 2 main dynamic equations:
  motion:          JT * lambda + Fext = M * v'
  constraints:     J * v' + k =,>= 0 )

where J1 is J matrix of the positional joints, which comes from J1 * v = k1 
and the J2 is contact matrix - comes from J2 * v >= 0 (contacts vanish if 
objects are separating during evaluation).
so from this i try answer your question:

    J1 * v = k1    // ball&socket, hinge, slider
    vx - J2 * v >= k2  // contacts

so you must fill J1and J2 matrix the way to fulfill these conditions.

for example ball and socket:

J1 matrix has 3 rows and 6 columns,  k1 == 0 (pure without correction):

  v1 + (p - COM1) x w1 == v2 + (p - COM2) * w2     (1.0)  - velocities on 
the objects in point p must be equal
  v1 + (p - COM1) x w1 - v2 - (p - COM2) x w2 == 0  (1.1)


so:
   Object1 linear velocity v1 and angular w1
   Object2 linear velocity v2 and angular w2
   p is point of the anchor

  a is the star matrix (p-COM1)
  b is the star matrix (p-COM2)

   1 0 0 0  -az ay  -1 0 0  0 bz -by
   0 1 0 az 0  -ax  0 -1 0  -bz 0 bx
   0 0 1 -ay ax 0   0 0 -1  by -ax 0

is the J1 matrix for ball & socket constraint

(try multiply this matrix by velocity vector and v1 w1 v2 w2 and you should 
have the (1.1) )

hope, it will help, sorry if i missed something.
Best regards
   Petr Sovis
   Plastic Reality Technologies

P.S. some minuses can be wrong at first sight - left or rigth handed systems 
change things




>From: "Joakim Eriksson" <jme@snowcode.com>
>To: <ode@q12.org>
>Subject: [ODE] Constraint equations and the famous J matrix
>Date: Mon, 30 Jun 2003 13:45:06 +0200
>
>I have been trying to figure out how exactly a constraint system
>works for a while and I just wanted to run this buy you guys.
>Someone here should be able to tell me if I'm on the right track
>and if not what I have missed.
>If nothing else this might help others in my situation because
>I have never seen all this information collected in one place.
>
>So lets start with the equations:
>
>A*lambda=b
>       -1 T
>A = JM  J
>        -1
>b =-(JM  F+c)
>
>So in the abover equations we have:
>lambda = The unknowns we want to find
>J      = The jacobian constraint matrix
>M      = The mass matrix
>F      = External forces that exists in the system
>
>Now for a small example. Say I want to constrain a body
>to a world position. What would I have to do to get that to work?
>                           -1
>First we need to fill in M  so it should look something like:
>A-----
>-B----
>--C---
>---DEF
>---GHI
>---JKL
>
>In the abover ascii drawing A-C is linear inverse mass and D-L is
>rotational inverse mass.
>
>If we ignore joint positional (error) fixing c is 0
>
>But in this abover case what does the J matrix look like?
>From joint.pdf (Good doc BTW) I guess that the J matrix would look
>like this
>
>1-----
>-1----
>--1---
>----QN
>---O-P
>---QM-
>
>Where M-O is the positive (x,y,z) anchor point and P-R is the anchor
>point neged. In otherwords the lower left is a matrix representation
>of a vector cross product with the anchor point.
>
>Is this a correct J matrix for this example or am I way off here?
>
>Cheers
>  Joakim E.
>
>
>
>_______________________________________________
>ODE mailing list
>ODE@q12.org
>http://q12.org/mailman/listinfo/ode

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail