def __init__(self, a, b, *args): """a and b are the two bodies to connect, and pivot is the point in world coordinates of the pivot. Because the pivot location is given in world coordinates, you must have the bodies moved into the correct positions already. Alternatively you can specify the joint based on a pair of anchor points, but make sure you have the bodies in the right place as the joint will fix itself as soon as you start simulating the space. That is, either create the joint with PivotJoint(a, b, pivot) or PivotJoint(a, b, anchr1, anchr2). a : `Body` The first of the two bodies b : `Body` The second of the two bodies args : [Vec2d] or [Vec2d,Vec2d] Either one pivot point, or two anchor points """ if len(args) == 1: self._constraint = cp.cpPivotJointNew(a._body, b._body, args[0]) elif len(args) == 2: self._constraint = cp.cpPivotJointNew2(a._body, b._body, args[0], args[1]) else: raise Exception("You must specify either one pivot point or two anchor points") self._ccontents = self._constraint.contents self._pjc = cp.cast(self._constraint, ct.POINTER(cp.cpPivotJoint)).contents self._a = a self._b = b
def __init__(self, a, b, pivot): """Simply allow two objects to pivot about a single point. a and b are the two bodies to connect, and pivot is the point in world coordinates of the pivot. Because the pivot location is given in world coordinates, you must have the bodies moved into the correct positions already.""" self._joint = cp.cpPivotJointNew(a._body, b._body, pivot)