# CJ Simple kinematic

Sometimes you may want to dictate the movement of an object instead of applying forces. This can be useful for movements that are complex to specify with forces but easy as formulae, or to force a heavy object such as a door to move and push away anything in its path. This is a kinematic approach instead of the usual dymanics approach. For this to work you need a way of specifying position at each iteration and let Newton work out the required forces. This can be done with a joint.

## Construction

This is mostly the same as the 2D joints but now we have a position variable - mPosition which gets initialised with the object's position when this constructor is called:

```JointKinematic::JointKinematic(IrrNewtonBody* kpBody0)
{
mpBody0=kpBody0->GetBody();

dMatrix matrix0;
NewtonBodyGetMatrix(mpBody0, &matrix0);
mPosition=matrix0.m_posit;

mpJoint=NewtonConstraintCreateUserJoint(mspWorld, 6, SubmitConstraints, mpBody0, 0);
NewtonJointSetUserData (mpJoint, (void*) this);
}
```

## Position

Before each call to UpdateWorld() you need to specify the desired position of the object by calling this function:

```void JointKinematic::SetPosition(dVector kPosition)
{
mPosition=kPosition;
}
```

## SubmitConstraints

The constraint code simply fixes the position of the object in each axis according to mPosition:

```void JointKinematic::LocalSubmitConstraints(const NewtonJoint* kpJoint)
{
dMatrix matrix0;
NewtonBodyGetMatrix(mpBody0, &matrix0);

dVector pin0(1.0,0.0,0.0);
dVector pin1(0.0,1.0,0.0);
dVector pin2(0.0,0.0,1.0);