API Docs for: 0.7.1
Show:

ContactEquation Class

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

Constructor

`ContactEquation`

(
• `bodyA`
• `bodyB`
)

Parameters:

• `bodyA` Body
• `bodyB` Body

Methods

`addToWlambda`

(
• `deltalambda`
)

Add constraint velocity to the bodies.

Parameters:

• `deltalambda` Number

`computeB`

() Number

Computes the RHS of the SPOOK equation

Number:

`computeGiMf`

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

Number:

`computeGiMGt`

() Number

Computes G*inv(M)*G'

Number:

`computeGq`

() Number

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

Number:

`computeGW`

() Number

Computes G*W, where W are the body velocities

Number:

`computeGWlambda`

() Number

Computes G*Wlambda, where W are the body velocities

Number:

`computeInvC`

(
• `eps`
)
Number

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

Parameters:

• `eps` Number

Number:

`gmult`

() Number

Multiply a jacobian entry with corresponding positions or velocities

Number:

`update`

()

Compute SPOOK parameters .a, .b and .epsilon according to the current parameters. See equations 9, 10 and 11 in the SPOOK notes.

Properties

`bodyA`

Body

First body participating in the constraint

`bodyB`

Body

Second body participating in the constraint

`contactPointA`

Array

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

`contactPointB`

Array

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.

`firstImpact`

Boolean

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

`G`

Array

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

`maxForce`

Number

Max force to apply when solving.

`minForce`

Number

Minimum force to apply when solving.

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

Array

The normal vector, pointing out of body i

`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

The shape in body j that triggered this contact.

`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.