API Docs for: 0.4.0
Show:

Equation Class

Base class for constraint equations.

Constructor

Equation

(
  • bi
  • bj
  • minForce
  • maxForce
)

Parameters:

  • bi Body

    First body participating in the equation

  • bj Body

    Second body participating in the equation

  • minForce Number

    Minimum force to apply. Default: -1e6

  • maxForce Number

    Maximum force to apply. Default: 1e6

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

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.

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.