# Class: djointamotor

An angular motor (AMotor) allows the relative angular velocities of two bodies to be controlled. The angular velocity can be controlled on up to three axes, allowing torque motors and stops to be set for rotation about those axes. This is mainly useful in conjunction will ball joints (which do not constrain the angular degrees of freedom at all), but it can be used in any situation where angular control is needed. To use an AMotor with a ball joint, simply attach it to the same two bodies that the ball joint is attached to.

## Hierarchy

    o-+ ode
      o-+ djoint
        o-+ djointamotor

## Methods:

### Method overview:

- angle
- anglerate
- axis
- new
- numaxes
- usermode

new ([djointgroup group])
  returns: (djointamotor)
  creates a new amotorjoint
angle (djointamotor,int anum, [float angle])
  returns: ([float angle])
  Tell the AMotor what the current angle is along axis anum. This function should only be called in user mode, because in this mode the AMotor has no other way of knowing the joint angles. The angle information is needed if stops have been set along the axis, but it is not needed for axis motors. If no angle is passed, it return the current angle for axis anum. In user mode this is simply the value that was set with. In euler mode this is the corresponding euler angle.
anglerate (djointamotor,int anum)
  returns: (float)
  Return the current angle rate for axis anum. In usermode this is always zero, as not enough information is available. In euler mode this is the corresponding euler angle rate.
axis (djointamotor,[int anum,rel, float x,y,z])
  returns: ([int,float x,y,z])

  Sets/gets the AMotor axes. The anum argument selects the axis to change (0,1 or 2). Each axis can have one of three 'relative orientation' modes, selected by rel:

  1. 0: The axis is anchored to the world frame.
  2. 1: The axis is anchored to the first body.
  3. 2: The axis is anchored to the second body.
  The axis vector (x,y,z) is always specified in world coordinates regardless of the setting of rel. There are two GetAMotorAxis functions, one to return the axis and one to return the relative mode. For dAMotorEuler mode:
  1. Only axes 0 and 2 need to be set. Axis 1 will be determined automatically at each time step.
  2. Axes 0 and 2 must be perpendicular to each other.
  3. Axis 0 must be anchored to the first body, axis 2 must be anchored to the second body.
numaxes ([int])
  returns: ([int])
  Sets/gets the number of angular axes that will be controlled by the AMotor. The argument num can range from 0 (which effectively deactivates the joint) to 3. This is automatically set to 3 in eulermode
usermode (djointamotor,[boolean])
  returns: ([boolean])
  If usermode is true, the user directly sets the axes that the AMotor controls. If it is false, eulermode is active which means that the AMotor computes the euler angles corresponding to the relative rotation, allowing euler angle torque motors and stops to be set.

## 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