distance joint

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
Isawyou
Posts: 20
Joined: Wed Sep 02, 2015 10:00 pm

distance joint

Post by Isawyou »

hi!
I didn't understand joints, also the code from erin catto GDC 2009
Mat22 Rot1(body1->rotation);
Mat22 Rot2(body2->rotation);

r1 = Rot1 * localAnchor1;
r2 = Rot2 * localAnchor2;

// deltaV = deltaV0 + K * impulse
// invM = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)]
// = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y]
// [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]
Mat22 K1;
K1.col1.x = body1->invMass + body2->invMass; K1.col2.x = 0.0f;
K1.col1.y = 0.0f; K1.col2.y = body1->invMass + body2->invMass;

Mat22 K2;
K2.col1.x = body1->invI * r1.y * r1.y; K2.col2.x = -body1->invI * r1.x * r1.y;
K2.col1.y = -body1->invI * r1.x * r1.y; K2.col2.y = body1->invI * r1.x * r1.x;

Mat22 K3;
K3.col1.x = body2->invI * r2.y * r2.y; K3.col2.x = -body2->invI * r2.x * r2.y;
K3.col1.y = -body2->invI * r2.x * r2.y; K3.col2.y = body2->invI * r2.x * r2.x;

Mat22 K = K1 + K2 + K3;
what he mean by this part :(
vanger
Posts: 13
Joined: Sun Feb 21, 2016 2:34 am

Re: distance joint

Post by vanger »

He computed effective mass matrix (inverse of it) in the usual way. If you have a constraint C on your (generalized) coordinates you can deduce a velocity constraint by differentiation so Cdot = JV, where V is a colums of (generalized) velocities (velocities components and angular velocities in this case) and J is some matrix. We'll call it a Jacobian matrix. The main idea is to change velocities by such forces which do no work. Such forces have the form of JT \lambda, where JT is J transposed.
Lets V1 and V2 are velocities on the current iteration and a next one (sought of).
According to the equations of motion
M(V2 - V1) = F h = JT p,
where h is a time step, p = h \lambda.
So V2 = V1 + Minv JT p.
We still don't know what p is. But we do know that the correct V2 satisfies J V2 = 0. So
J V1 + J Minv JT p = 0.
But J V1 is just a Cdot on a current step. That matrix J Minv JT usually denoted as K. It's inverse can be sought as an effective mass matrix.
And finally p = -Kinv J V1.
Post Reply