Comments on: Line Constraint http://www.codezealot.org/archives/348 Development blog and open source repository by William Bittle Fri, 26 Dec 2014 01:32:52 +0000 hourly 1 http://wordpress.org/?v=4.0.1 By: c0der http://www.codezealot.org/archives/348#comment-50206 Sat, 05 Jan 2013 01:53:19 +0000 http://www.codezealot.org/?p=348#comment-50206 Thanks William, that does clear things up.

I have managed to implement the 3D version, with two restricted tangent axis, thereby ending up with a 2×2 matrix. The only difference is for 3D, you need to build an orthogonal basis from the supplied legal axis of movement and derive a second constraint identical to the one you derived.

]]>
By: William http://www.codezealot.org/archives/348#comment-50160 Fri, 04 Jan 2013 14:09:27 +0000 http://www.codezealot.org/?p=348#comment-50160 Yeah this is one of the more difficult parts to understand. Basically, to perform the derivative, we need to know how u is defined (in terms of what? A single body? Both bodies? Is it fixed?). Since we are doing pair-wise constraints we know that we want to have u in terms of both of the bodies so that their relative motion is constrained. We can define the position constraint using the initial relative position vector of the two bodies relative to the anchor point (this is why we still have to supply an anchor).
Take a look at this image:

If either body moves (in this case I move only body b), we can’t recompute u, since the constraint would always be satisfied. That means that we compute u once, when the constraint is created, from the initial positions of the bodies. But if we are doing that, why can’t we just supply an axis rather than compute it? The answer is, we can, because the creator of the constraint could do the same thing if they just positioned the bodies appropriately upon creation of the constraint. So if I were to position b in the second position in my image above initially, I could make the constraint use (1, 0) as the axis rather than (8, 6).

I hope that clears things up a bit,
William

]]>
By: c0der http://www.codezealot.org/archives/348#comment-50068 Thu, 03 Jan 2013 12:59:50 +0000 http://www.codezealot.org/?p=348#comment-50068 Thanks William. I am having trouble with some parts of the derivation.

I understand as follows:

We have u initially as the relative position between the two bodies, which is transformed with one of the bodies.

t is always perpendicular to u

In your code, you are using the specified legal axis, and the tangent axis, and additionally, the relative position.

So since you have the original equation as

C = t.u = t.(xa + ra – xb – rb)
dC/dt = t.(va + Cross(wa,ra) – vb – Cross(wb,rb)) + Cross(wb,t).u

and u = xa + ra – xb – rb

Where do you incorporate the specified axis in the equation as you do in the code? All I see is t vectors in your derivation and the relative position u, and not the actual legal axis of movement.

I understand that even if we specify the legal axis upon initialisation, this axis and the tangent vector to this axis can change with the movement of one of the bodies.

Contrary to a revolute joint, where the relative position is always zero, we are saying the relative position between the two bodies can be non-zero only if the tangent vector is perpendicular to this relative position vector.

Thanks for your help

]]>
By: William http://www.codezealot.org/archives/348#comment-49990 Wed, 02 Jan 2013 13:52:02 +0000 http://www.codezealot.org/?p=348#comment-49990 The u vector should be the locally transformed world axis (and normalized) passed to the joint. So you should be able to specify the axis of the joint (but using the center of masses is fine). You will also need the local tangent of that vector as well. You will also need an anchor point for the joint. This will allow you to compute the r vectors for both bodies (we need the r vectors so we can determine if the bodies have deviated from the tangent).

The local axis and tangent should be computed on initialization. Then in each iteration we transform those into world coordinates using the rotation matrix (only) of the body that we fixed the axis with.

One thing that may be tricky is solving the system. The b vector is going to be (which I didn’t expand in the post):

b = -Jv
b = [ tT ra x t -tT -(rb + u) x t ] * [ va wa vb wb ]T
b = tT * va + (ra x t) * wa - tT * vb - ((rb + u) x t) * wb

Where u and t are the world space axis and tangent of the joint that we have from initialization.

You can look at my (ignore the motor and limit stuff and focus on the joint constructor and initialization)

William

]]>
By: c0der http://www.codezealot.org/archives/348#comment-49968 Wed, 02 Jan 2013 07:44:52 +0000 http://www.codezealot.org/?p=348#comment-49968 Hi William,

I have a a body at (-20,0,0) and an immovable body at (0,41,0). The world anchor point is at (-20,0,0). Therefore the initial world u vector should be along the line connecting the two body’s center points? I am having trouble getting the simulation correct and trying the 2D case first.

Also, at each frame I have Cross(wa, t) in the velocity equation, therefore the tangent vector should change with body A and be fixed relative to body B.

Thanks for your help

]]>