Dart Documentationbox2d_consoleJoint

Joint class

The base joint class. Joints are used to constrain two bodies together in various fashions. Some joints also feature limits and motors.

class Joint {
  int type;

  Joint _prev;
  Joint _next;

  JointEdge edgeA;
  JointEdge edgeB;

  Body bodyA;
  Body bodyB;

  bool islandFlag;

  bool collideConnected;

  Object userData;

  // Cache here per time step to reduce cache misses.
  final Vector localCenterA;
  final Vector localCenterB;

  num invMassA;
  num invIA;
  num invMassB;
  num invIB;

  Joint(JointDef def) :
    type = def.type,
    _prev = null,
    _next = null,
    bodyA = def.bodyA,
    bodyB = def.bodyB,
    collideConnected = def.collideConnected,
    islandFlag = false,
    userData = def.userData,

    localCenterA = new Vector(),
    localCenterB = new Vector(),
    edgeA = new JointEdge(),
    edgeB = new JointEdge() { }

  // TODO(dominich): use 'is' to create the right type of Joint and remove the
  // *Def.type.
  factory Joint.create(World argWorld, JointDef def) {
    switch(def.type){
      case JointType.MOUSE:
        throw new NotImplementedException();
        //  return new MouseJoint(def);
      case JointType.DISTANCE:
        return new DistanceJoint(def);
      case JointType.PRISMATIC:
        throw new NotImplementedException();
        //  return new PrismaticJoint(def);
      case JointType.REVOLUTE:
        return new RevoluteJoint(def);
      case JointType.WELD:
        throw new NotImplementedException();
        //return new WeldJoint(def);
      case JointType.FRICTION:
        return new FrictionJoint(def);
      case JointType.LINE:
        throw new NotImplementedException();
        //return new LineJoint(def);
      case JointType.GEAR:
        throw new NotImplementedException();
        //return new GearJoint(def);
      case JointType.PULLEY:
        throw new NotImplementedException();
        //return new PulleyJoint(def);
      case JointType.CONSTANT_VOLUME:
        return new ConstantVolumeJoint(argWorld, def);
    }
    return null;
  }

  static void destroy(Joint joint) {
    joint.destructor();
  }

  /**
   * Get the anchor point on bodyA in world coordinates.
   */
  void getAnchorA(Vector argOut) { }

  /**
   * Get the anchor point on bodyB in world coordinates.
   */
  void getAnchorB(Vector argOut) { }

  /**
   * Get the reaction force on body2 at the joint anchor in Newtons.
   */
  void getReactionForce(num inv_dt, Vector argOut) { }

  /**
   * Get the reaction torque on body2 in N*m.
   */
  num getReactionTorque(num inv_dt) { }

  /**
   * Short-cut function to determine if either body is inactive.
   */
  bool get active() {
    return bodyA.active && bodyB.active;
  }

  void initVelocityConstraints(TimeStep step) { }

  void solveVelocityConstraints(TimeStep step) { }

  /**
   * This returns true if the position errors are within tolerance.
   */
  bool solvePositionConstraints(num baumgarte) { }

  /**
   * Override to handle destruction of joint
   */
  void destructor() { }
}

Subclasses

ConstantVolumeJoint, DistanceJoint, FrictionJoint, RevoluteJoint

Constructors

new Joint(JointDef def) #

Joint(JointDef def) :
  type = def.type,
  _prev = null,
  _next = null,
  bodyA = def.bodyA,
  bodyB = def.bodyB,
  collideConnected = def.collideConnected,
  islandFlag = false,
  userData = def.userData,

  localCenterA = new Vector(),
  localCenterB = new Vector(),
  edgeA = new JointEdge(),
  edgeB = new JointEdge() { }

factory Joint.create(World argWorld, JointDef def) #

factory Joint.create(World argWorld, JointDef def) {
  switch(def.type){
    case JointType.MOUSE:
      throw new NotImplementedException();
      //  return new MouseJoint(def);
    case JointType.DISTANCE:
      return new DistanceJoint(def);
    case JointType.PRISMATIC:
      throw new NotImplementedException();
      //  return new PrismaticJoint(def);
    case JointType.REVOLUTE:
      return new RevoluteJoint(def);
    case JointType.WELD:
      throw new NotImplementedException();
      //return new WeldJoint(def);
    case JointType.FRICTION:
      return new FrictionJoint(def);
    case JointType.LINE:
      throw new NotImplementedException();
      //return new LineJoint(def);
    case JointType.GEAR:
      throw new NotImplementedException();
      //return new GearJoint(def);
    case JointType.PULLEY:
      throw new NotImplementedException();
      //return new PulleyJoint(def);
    case JointType.CONSTANT_VOLUME:
      return new ConstantVolumeJoint(argWorld, def);
  }
  return null;
}

Static Methods

void destroy(Joint joint) #

static void destroy(Joint joint) {
  joint.destructor();
}

Properties

final bool active #

Short-cut function to determine if either body is inactive.

bool get active() {
  return bodyA.active && bodyB.active;
}

Body bodyA #

Body bodyA;

Body bodyB #

Body bodyB;

bool collideConnected #

bool collideConnected;

JointEdge edgeA #

JointEdge edgeA;

JointEdge edgeB #

JointEdge edgeB;

num invIA #

num invIA;

num invIB #

num invIB;

num invMassA #

num invMassA;

num invMassB #

num invMassB;

bool islandFlag #

bool islandFlag;

final Vector localCenterA #

final Vector localCenterA;

final Vector localCenterB #

final Vector localCenterB;

final Type runtimeType #

inherited from Object

A representation of the runtime type of the object.

external Type get runtimeType;

int type #

int type;

Object userData #

Object userData;

Operators

bool operator ==(other) #

inherited from Object

The equality operator.

The default behavior for all Objects is to return true if and only if this and other are the same object.

If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.

bool operator ==(other) => identical(this, other);

Methods

void destructor() #

Override to handle destruction of joint

void destructor() { }

void getAnchorA(Vector argOut) #

Get the anchor point on bodyA in world coordinates.

void getAnchorA(Vector argOut) { }

void getAnchorB(Vector argOut) #

Get the anchor point on bodyB in world coordinates.

void getAnchorB(Vector argOut) { }

void getReactionForce(num inv_dt, Vector argOut) #

Get the reaction force on body2 at the joint anchor in Newtons.

void getReactionForce(num inv_dt, Vector argOut) { }

num getReactionTorque(num inv_dt) #

Get the reaction torque on body2 in N*m.

num getReactionTorque(num inv_dt) { }

int hashCode() #

inherited from Object

Get a hash code for this object.

All objects have hash codes. Hash codes are guaranteed to be the same for objects that are equal when compared using the equality operator ==. Other than that there are no guarantees about the hash codes. They will not be consistent between runs and there are no distribution guarantees.

If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.

external int hashCode();

void initVelocityConstraints(TimeStep step) #

void initVelocityConstraints(TimeStep step) { }

new Joint(JointDef def) #

Joint(JointDef def) :
  type = def.type,
  _prev = null,
  _next = null,
  bodyA = def.bodyA,
  bodyB = def.bodyB,
  collideConnected = def.collideConnected,
  islandFlag = false,
  userData = def.userData,

  localCenterA = new Vector(),
  localCenterB = new Vector(),
  edgeA = new JointEdge(),
  edgeB = new JointEdge() { }

factory Joint.create(World argWorld, JointDef def) #

factory Joint.create(World argWorld, JointDef def) {
  switch(def.type){
    case JointType.MOUSE:
      throw new NotImplementedException();
      //  return new MouseJoint(def);
    case JointType.DISTANCE:
      return new DistanceJoint(def);
    case JointType.PRISMATIC:
      throw new NotImplementedException();
      //  return new PrismaticJoint(def);
    case JointType.REVOLUTE:
      return new RevoluteJoint(def);
    case JointType.WELD:
      throw new NotImplementedException();
      //return new WeldJoint(def);
    case JointType.FRICTION:
      return new FrictionJoint(def);
    case JointType.LINE:
      throw new NotImplementedException();
      //return new LineJoint(def);
    case JointType.GEAR:
      throw new NotImplementedException();
      //return new GearJoint(def);
    case JointType.PULLEY:
      throw new NotImplementedException();
      //return new PulleyJoint(def);
    case JointType.CONSTANT_VOLUME:
      return new ConstantVolumeJoint(argWorld, def);
  }
  return null;
}

noSuchMethod(String name, List args) #

inherited from Object

noSuchMethod is invoked when users invoke a non-existant method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod. If noSuchMethod returns a value, that value becomes the result of the original invocation.

The default behavior of noSuchMethod is to throw a noSuchMethodError.

external Dynamic noSuchMethod(String name, List args);

const Object() #

inherited from Object

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

const Object();

bool solvePositionConstraints(num baumgarte) #

This returns true if the position errors are within tolerance.

bool solvePositionConstraints(num baumgarte) { }

void solveVelocityConstraints(TimeStep step) #

void solveVelocityConstraints(TimeStep step) { }

String toString() #

inherited from Object

Returns a string representation of this object.

external String toString();