API Docs for: 0.7.1
Show:

# Equation Class

Base class for constraint equations.

## Constructor

### `Equation`

(
• `bodyA`
• `bodyB`
• `minForce`
• `maxForce`
)

#### Parameters:

• `bodyA` Body

First body participating in the equation

• `bodyB` Body

Second body participating in the equation

• `minForce` Number

Minimum force to apply. Default: -Number.MAX_VALUE

• `maxForce` Number

Maximum force to apply. Default: Number.MAX_VALUE

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

### `DEFAULT_RELAXATION`

Number static

The default relaxation when creating a new Equation.

Default: 4

### `DEFAULT_STIFFNESS`

Number static

The default stiffness when creating a new Equation.

Default: 1e6

### `enabled`

Boolean

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

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

### `relativeVelocity`

Number

Relative velocity.

### `relaxation`

Number

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

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