Dart Documentationbox2d_htmlManifold

Manifold class

A manifold for two touching convex shapes. Box2D has support for many kinds of contact, such as clip pont versus plain with radius and point versus point with radius (as with circles).

class Manifold {
  /** The points of contact. */
  final List<ManifoldPoint> points;

  /**
   * The meaning of the localNormal depends on the type of this manifold. The
   * different meanings (or lack thereof) are outlined below.
   * Circles: not used.
   * faceA: The normal on polygonA.
   * faceB: The normal on polygonB.
   */
  final Vector localNormal;

  /**
   * The meaning of the localPoint depends on the type of this manifold. The
   * different meanings (or lack thereof) are outlined below.
   * Circles: The local center of circleA.
   * faceA: The center of faceA.
   * faceB: The center of faceB.
   */
  final Vector localPoint;

  /** The type of manifold. See [ManifoldType]. */
  int type;

  /** The number of manifold points. */
  int pointCount;

  /**
   * Creates a manifold with 0 points. It's point array should be full of
   * already instantiated ManifoldPoints.
   */
  Manifold() :
      points = new List<ManifoldPoint>(Settings.MAX_MANIFOLD_POINTS),
      localNormal = new Vector(),
      localPoint = new Vector(),
      pointCount = 0 {
    for (int i = 0; i < Settings.MAX_MANIFOLD_POINTS; ++i)
      points[i] = new ManifoldPoint();
  }

  /**
   * Creates a new manifold that is a copy of the given manifold.
   */
  Manifold.copy(Manifold other) :
      points = new List<ManifoldPoint>(Settings.MAX_MANIFOLD_POINTS),
      localNormal = new Vector.copy(other.localNormal),
      localPoint = new Vector.copy(other.localPoint),
      pointCount = other.pointCount,
      type = other.type {
    for (int i = 0; i < Settings.MAX_MANIFOLD_POINTS; ++i)
      points[i] = new ManifoldPoint.copy(other.points[i]);
  }

  /**
   * Sets this manifold to be a copy of the given manifold.
   */
  void setFrom(Manifold other) {
    for (int i = 0; i < other.pointCount; ++i)
      points[i].setFrom(other.points[i]);

    type = other.type;
    localNormal.setFrom(other.localNormal);
    localPoint.setFrom(other.localPoint);
    pointCount = other.pointCount;
  }
}

Constructors

new Manifold() #

Creates a manifold with 0 points. It's point array should be full of already instantiated ManifoldPoints.

Manifold() :
    points = new List<ManifoldPoint>(Settings.MAX_MANIFOLD_POINTS),
    localNormal = new Vector(),
    localPoint = new Vector(),
    pointCount = 0 {
  for (int i = 0; i < Settings.MAX_MANIFOLD_POINTS; ++i)
    points[i] = new ManifoldPoint();
}

new Manifold.copy(Manifold other) #

Creates a new manifold that is a copy of the given manifold.

Manifold.copy(Manifold other) :
    points = new List<ManifoldPoint>(Settings.MAX_MANIFOLD_POINTS),
    localNormal = new Vector.copy(other.localNormal),
    localPoint = new Vector.copy(other.localPoint),
    pointCount = other.pointCount,
    type = other.type {
  for (int i = 0; i < Settings.MAX_MANIFOLD_POINTS; ++i)
    points[i] = new ManifoldPoint.copy(other.points[i]);
}

Properties

final Vector localNormal #

The meaning of the localNormal depends on the type of this manifold. The different meanings (or lack thereof) are outlined below. Circles: not used. faceA: The normal on polygonA. faceB: The normal on polygonB.

final Vector localNormal;

final Vector localPoint #

The meaning of the localPoint depends on the type of this manifold. The different meanings (or lack thereof) are outlined below. Circles: The local center of circleA. faceA: The center of faceA. faceB: The center of faceB.

final Vector localPoint;

int pointCount #

The number of manifold points.

int pointCount;

final List<ManifoldPoint> points #

The points of contact.

final List<ManifoldPoint> points;

final Type runtimeType #

inherited from Object

A representation of the runtime type of the object.

external Type get runtimeType;

int type #

The type of manifold. See ManifoldType.

int type;

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

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();

new Manifold() #

Creates a manifold with 0 points. It's point array should be full of already instantiated ManifoldPoints.

Manifold() :
    points = new List<ManifoldPoint>(Settings.MAX_MANIFOLD_POINTS),
    localNormal = new Vector(),
    localPoint = new Vector(),
    pointCount = 0 {
  for (int i = 0; i < Settings.MAX_MANIFOLD_POINTS; ++i)
    points[i] = new ManifoldPoint();
}

new Manifold.copy(Manifold other) #

Creates a new manifold that is a copy of the given manifold.

Manifold.copy(Manifold other) :
    points = new List<ManifoldPoint>(Settings.MAX_MANIFOLD_POINTS),
    localNormal = new Vector.copy(other.localNormal),
    localPoint = new Vector.copy(other.localPoint),
    pointCount = other.pointCount,
    type = other.type {
  for (int i = 0; i < Settings.MAX_MANIFOLD_POINTS; ++i)
    points[i] = new ManifoldPoint.copy(other.points[i]);
}

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();

void setFrom(Manifold other) #

Sets this manifold to be a copy of the given manifold.

void setFrom(Manifold other) {
  for (int i = 0; i < other.pointCount; ++i)
    points[i].setFrom(other.points[i]);

  type = other.type;
  localNormal.setFrom(other.localNormal);
  localPoint.setFrom(other.localPoint);
  pointCount = other.pointCount;
}

String toString() #

inherited from Object

Returns a string representation of this object.

external String toString();