Line constraint

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
c0der
Posts: 74
Joined: Sun Jul 08, 2012 11:32 am

Line constraint

Post by c0der »

Hi all,

What is the best way to impose a limit on a line constraint? Currently, I have a distance constraint running alongside it but don't know if that's the best way. Should I add another Jacobian and combine it with the line joint?

Thanks for your help
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Line constraint

Post by Dirk Gregorius »

// Start with position constraint (u is the axis along you measure the separation)
C = ( x2 + r2 - x1 - r1 ) * u1 > min_distance

// Time derivative
dC/dt = ( v2 + w2 x r2 - v1 - w1 x r1 ) * u1 + ( x2 + r2 - x1 - r1 ) * ( w1 x u1 )

// Define s = ( x2 + r2 - x1 - r1 ). This is the vector from anchor 1 to anchor 2

// This yields
dC/dt = [ v2 + w2 x r2 - v1 - w1 x (r1 + s) ] * u1

// Identify Jacobian by inspection
J = ( -u1 | -(r1 + s) x u1 | u1 | r2 x u1 )

This is for a lower limit. For an upper limit simple change the constraint to: C = ( x2 + r2 - x1 - r1 ) * u1 < max_distance
c0der
Posts: 74
Joined: Sun Jul 08, 2012 11:32 am

Re: Line constraint

Post by c0der »

Thanks Dirk. I have the original line constraint working without limits, however I have a question about the behaviour.

Say that body 2 is at the anchor point and body 1 is the fixed body that the line moves with.

Is the anchor point supposed to move with body 2 and that r2 stays fixed while r1 changes?

Given that the definition for one of the constraints is:

C1 = t.u = 0 where u = x1 + r1 - x2 - r2 and t is the illegal axis of movement

Performing the time derivate leaves r1 and r2 fixed while x1, x2 and t are changing with time? Thanks for your help.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Line constraint

Post by Dirk Gregorius »

The limits are essentially two (upper and lower) more new constraints along the free axis. You are essentially measuring the *signed* separation of the anchors along this axis. The first two line constraints block the movement entirely while the linear limit allows for some movement.

Hope that makes sense,
-Dirk

PS
The local levers (r1' and r2') are fixed, but r1 = R1 * r1' and r2 = R2 * r2' indeed vary in time since the body can change its orientation.
Post Reply