Class ContactEquation

Non-penetration constraint equation. Tries to make the contactPointA and contactPointB vectors coincide, while keeping the applied force repulsive.

Hierarchy

Constructors

Properties

B: number
G: Vec2

The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

a: number
b: number
bodyA: Body

First body participating in the constraint

bodyB: Body

Second body participating in the constraint

contactPointA: Vec2

Vector from body i center of mass to the contact point.

contactPointB: Vec2

World-oriented vector from body A center of mass to the contact point.

enabled: boolean

Whether this equation is enabled or not. If true, it will be added to the solver.

epsilon: number
firstImpact: boolean

This property is set to true if this is the first impact between the bodies (not persistant contact).

index: number
invC: number
lambda: number
maxBias: number

Cap the constraint violation (G*q) to this value.

maxForce: number

Max force to apply when solving.

maxForceDt: number
minForce: number

Minimum force to apply when solving.

minForceDt: number
multiplier: number

The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

needsUpdate: boolean

Indicates if stiffness or relaxation was changed.

normalA: Vec2

The normal vector, pointing out of body i

offset: number
penetrationVec: Vec2
relativeVelocity: number

Relative velocity.

relaxation: number

The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

restitution: number

The restitution to use (0=no bounciness, 1=max bounciness).

shapeA: Shape

The shape in body i that triggered this contact.

shapeB: Shape
stiffness: number

The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

timeStep: number
DEFAULT_RELAXATION: number = 4

The default relaxation when creating a new Equation.

DEFAULT_STIFFNESS: number = 1e6

The default stiffness when creating a new Equation.

Methods

  • Add constraint velocity to the bodies.

    Parameters

    • deltalambda: number

    Returns void

  • Computes the RHS of the SPOOK equation

    Parameters

    • a: number
    • b: number
    • h: number

    Returns number

  • Computes G*W, where W are the body velocities

    Returns number

  • Computes G*Wlambda, where W are the body velocities

    Returns number

  • Computes G*inv(M)*G'

    Returns number

  • Computes G*inv(M)*f, where M is the mass matrix with diagonal blocks for each body, and f are the forces on the bodies.

    Returns number

  • Computes G*q, where q are the generalized body coordinates

    Returns number

  • Compute the denominator part of the SPOOK equation: C = G*inv(M)*G' + eps

    Parameters

    • eps: number

    Returns number

  • Get the relative velocity along the normal vector.

    Returns number

  • Multiply a jacobian entry with corresponding positions or velocities

    Parameters

    Returns number

  • Returns void