## How can I make a rigid joint?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

### How can I make a rigid joint?

The easies way to amke a rijid joint is to take teh code for teh hinge and add the extra degree of freedon.

Code: Select all
`CustomRigid::CustomRigid(const dVector& pivot, NewtonBody* child, NewtonBody* parent)    :NewtonCustomJoint(6, child, parent) {    dVector pin;    dMatrix matrix;    // use front vector of child matrix as pin    NewtonBodyGetMatrix (child, &matrix);    // calculate the two local matrix of the pivot point    CalculateLocalMatrix (pivot, matrix.m_front, m_localMatrix0, m_localMatrix1); } void CustomRigid::SubmitConstrainst () {    dMatrix matrix0;    dMatrix matrix1;    // calculate the position of the pivot point and the Jacobian direction vectors, in global space.    CalculateGlobalMatrix (m_localMatrix0, m_localMatrix1, matrix0, matrix1);    // Restrict the movement on the pivot point along all tree orthonormal direction    NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit, &matrix1.m_posit, &matrix0.m_front);    NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit, &matrix1.m_posit, &matrix0.m_up);    NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit, &matrix1.m_posit, &matrix0.m_right);    // get a point along the pin axis at some reasonable large distance from the pivot    dVector q0 (matrix0.m_posit + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH));    dVector q1 (matrix1.m_posit + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH));    // two constraints row perpendicular to the pin vector    NewtonUserJointAddLinearRow (m_joint, &q0, &q1, &matrix0.m_up);    NewtonUserJointAddLinearRow (m_joint, &q0, &q1, &matrix0.m_right);    // now get the this ankle point    dVector r0 (matrix0.m_posit + matrix0.m_up.Scale(MIN_JOINT_PIN_LENGTH));    dVector r1 (matrix1.m_posit + matrix1.m_up.Scale(MIN_JOINT_PIN_LENGTH));    NewtonUserJointAddLinearRow (m_joint, &r0, &r1, &matrix0.m_right);  }`

Bear in mind that Newton is a numerical approximation of a rigid body simulator, so a rigid joint will not be completely rigid.
If the rigid joint is not meant to be destroyed during the life time of the simulation, you should consider compound collision instead.
Julio Jerez
Moderator Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles