API Docs for: 0.4.0
Show:

ContactEquation Class

Non-penetration constraint equation. Tries to make the ri and rj vectors the same point.

Constructor

ContactEquation

(
  • bi
  • bj
)

Parameters:

Methods

addToWlambda

(
  • deltalambda
)

Add constraint velocity to the bodies.

Parameters:

  • deltalambda Number

computeB

() Number

Computes the RHS of the SPOOK equation

Returns:

Number:

computeC

(
  • eps
)
Number

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

Parameters:

  • eps Number

Returns:

Number:

computeGiMf

() Number

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

Returns:

Number:

computeGiMGt

() Number

Computes Ginv(M)G'

Returns:

Number:

computeGq

() Number

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

Returns:

Number:

computeGW

() Number

Computes G*W, where W are the body velocities

Returns:

Number:

computeGWlambda

() Number

Computes G*Wlambda, where W are the body velocities

Returns:

Number:

updateSpookParams

(
  • timeStep
)

Update SPOOK parameters .a, .b and .eps according to the given time step. See equations 9, 10 and 11 in the SPOOK notes.

Parameters:

  • timeStep Number

Properties

bi

Body

First body participating in the constraint

bj

Body

Second body participating in the constraint

firstImpact

Boolean

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.

ni

Array

The normal vector, pointing out of body i

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.

ri

Array

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

rj

Array

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

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.