CJ AddAngularRow

From Newton Wiki
Revision as of 08:02, 10 June 2019 by WikiSysop (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

So far we have used NewtonUserJointAddLinearRow to limit translations and even some rotations. However, some rotations need another function - NewtonUserJointAddAngularRow.

To understand how this works imagine the following:

  • Position both objects so that their origin is on an arbitary line. The direction of this line is called the pin vector.
  • Define a reference vector for each object that is perpendicular to the pin vector and passes through the objects' origins. You can imagine up-vectors/front-vectors or whatever you prefer.
  • Determine the angle between these two reference vectors as they meet the pin vector (and are superimposed so you are measuring the relative rotation of the two bodies around the pin).
  • This angle is the error angle and must be signed.
  • Pass the angle and the pin values to NewtonUserJointAddAngularRow and Newton will drive the relative angular position, velocity and acceleration to zero. It does this by applying torque to both bodies.
  • Experiment with the sign to make sure the bodies move in the right direction (the wrong sign will blow up the joint).

This will be used in the next section to remove all rotation from the 2D joint.

Links