Jump to content
  • Advertisement
Sign in to follow this  

Constraints to Jacobian

Recommended Posts

Posted (edited)

I was reading this article:


and it is missing the derivation of a Jacobian.


Can somebody please do the derivation of the Jacobian with two equality constraints for double pendulum?

I want to simulate double pendulum by using force-based approach with system solver, not the iterative approach.

Edited by vlad777

Share this post

Link to post
Share on other sites
Posted (edited)

The author gives an explanation of the Jacobian. The Jacobian rows are the transposed gradients of the scalar constraint functions. In practice the Jacobian is usually found 'by inspection' using that the time derivative of the constraint function has a special form, dC/dt = J*v 

E.g. say you have a simple distance constraint between two particles 

C =| p2 - p1|

dC/dt =  (p2 - p1)/ |p2 - p1| * (v2 - v1) = n * (v2 - v1) , where n = (p2 - p1) / | p2 - p1|

J = ( -n^t n^t )

Going through the time derivative is often way easier than building partial derivatives/gradients...

Edited by Dirk Gregorius

Share this post

Link to post
Share on other sites

I don't know how to do it.

Can you please derive two equality constraints for double pendulum?

Share this post

Link to post
Share on other sites
Posted (edited)

I did. It is the same as I wrote above.

C1 = |p2 - p1| - L

C2 = |p3 - p2| - L

J1 = ( -n1^t | n1^t | 0^t ) where n1 = (p2 - p1) / |p2 - p1|

J2 = ( 0^t | -n2^t | n2^t ) where n2 = (p3 - p2) / |p3 - p2|

Edited by Dirk Gregorius

Share this post

Link to post
Share on other sites
On 6/10/2019 at 6:20 PM, Randy Gaul said:

You mean like this? http://scienceworld.wolfram.com/physics/DoublePendulum.html

This is reduced coordinates using Euler Lagrange equation.

I think it should be done without using angles, just positions.

Just like my example article solves single pendulum just with positions.

BTW what kind of math is this (in my example article)?

Is it vector calculus or analytical mechanics or what, can you please tell me?

Share this post

Link to post
Share on other sites

I am incline to doubt that only video games use these kind of a simulations.

Share this post

Link to post
Share on other sites

I figured it out partially, but it doesn't work for masses other than 1.0

Can you please tell me how to fix this?


        Mx J = new Mx(2, 4);
        Mx Jdot = new Mx(2, 4);
        Mx M = new Mx(4);
        vector Fext = new vector(4);
        vector qdot = new vector(4);
        vector lambda;

                M.data[0, 0] = 1.0 / tp.mass;
                M.data[1, 1] = 1.0 / tp.mass;
                M.data[2, 2] = 1.0 / tp3.mass;
                M.data[3, 3] = 1.0 / tp3.mass;

                Fext.data[0] = 0;
                Fext.data[1] = body.g;
                Fext.data[2] = 0;
                Fext.data[3] = body.g;

                qdot.data[0] = tp.velocity.x;
                qdot.data[1] = tp.velocity.y;
                qdot.data[2] = tp3.velocity.x;
                qdot.data[3] = tp3.velocity.y;

                Jdot.data[0, 0] = tp.velocity.x;
                Jdot.data[0, 1] = tp.velocity.y;
                Jdot.data[1, 0] = tp.velocity.x - tp3.velocity.x;
                Jdot.data[1, 1] = tp.velocity.y - tp3.velocity.y;
                Jdot.data[1, 2] = tp3.velocity.x - tp.velocity.x;
                Jdot.data[1, 3] = tp3.velocity.y - tp.velocity.y;

                J.data[0, 0] = tp.position.x;
                J.data[0, 1] = tp.position.y;
                J.data[1, 0] = tp.position.x - tp3.position.x;
                J.data[1, 1] = tp.position.y - tp3.position.y;
                J.data[1, 2] = tp3.position.x - tp.position.x;
                J.data[1, 3] = tp3.position.y - tp.position.y;

                lambda = Mx.Invert(J * M * !J) * (-Jdot * qdot - J * M * Fext);

                var fvec = !J * lambda;


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!