# Class: djointuniversal

A universal joint is like a ball and socket joint that constrains an extra degree of rotational freedom. Given axis 1 on body 1, and axis 2 on body 2 that is perpendicular to axis 1, it keeps them perpendicular. In other words, rotation of the two bodies about the direction perpendicular to the two axes will be equal. In the picture, the two bodies are joined together by a cross. Axis 1 is attached to body 1, and axis 2 is attached to body 2. The cross keeps these axes at 90 degrees, so if you grab body 1 and twist it, body 2 will twist as well. A Universal joint is equivalent to a hinge-2 joint where the hinge-2's axes are perpendicular to each other, and with a perfectly rigid connection in place of the suspension. Universal joints show up in cars, where the engine causes a shaft, the drive shaft, to rotate along its own axis. At some point you'd like to change the direction of the shaft. The problem is, if you just bend the shaft, then the part after the bend won't rotate about its own axis. So if you cut it at the bend location and insert a universal joint, you can use the constraint to force the second shaft to rotate about the same angle as the first shaft. Another use of this joint is to attach the arms of a simple virtual creature to its body. Imagine a person holding their arms straight out. You may want the arm to be able to move up and down, and forward and back, but not to rotate about its own axis.

## Hierarchy

    o-+ ode
      o-+ djoint
        o-+ djointuniversal

## Methods:

### Method overview:

- anchor
- angle1
- angle2
- anglerate1
- anglerate2
- axis1
- axis2
- new

new ([djointgroup group])
  returns: (djointuniversal)
  creates a new universaljoint
anchor (djointuniversal,[float x,y,z])
  returns: ([float x1,y1,z1,x2,y2,z2])
  Sets/gets anchor.
angle1 (djointuniversal)
  returns: (float)
  Gets Angle1
angle2 (djointuniversal)
  returns: (float)
  Gets Angle2
anglerate1 (djointuniversal)
  returns: (float)
  Gets Anglerate1
anglerate2 (djointuniversal)
  returns: (float)
  Gets Anglerate2
axis1 (djointuniversal,[float x,y,z])
  returns: ([float x,y,z])
  Set/gets Axis1. Axis 1 and axis 2 should be perpendicular to each other.
axis2 (djointuniversal,[float x,y,z])
  returns: ([float x,y,z])
  Set/gets Axis2. Axis 1 and axis 2 should be perpendicular to each other.

## Inherited Methods:

### From djoint

attach, body1, body2, bounce, bounce2, bounce3, cfm, cfm2, cfm3, delete, feedback, fmax, fmax2, fmax3, fudgefactor, fudgefactor2, fudgefactor3, geom1, geom2, histop, histop2, histop3, lostop, lostop2, lostop3, stopcfm, stopcfm2, stopcfm3, stoperp, stoperp2, stoperp3, velocity, velocity2, velocity3