Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Equation

Base class for constraint equations.

Hierarchy

Index

Constructors

  • new Equation(bodyA: Body, bodyB: Body, minForce?: number, maxForce?: number): Equation
  • Constructor for an Equation

    Parameters

    • bodyA: Body

      First body participating in the equation

    • bodyB: Body

      Second body participating in the equation

    • Optional minForce: number

      Minimum force to apply. Default: -Number.MAX_VALUE

    • Optional maxForce: number

      Maximum force to apply. Default: Number.MAX_VALUE

    Returns Equation

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

enabled: boolean

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

epsilon: number
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.

offset: number
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.

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

  • addToWlambda(deltalambda: number): void
  • Add constraint velocity to the bodies.

    Parameters

    • deltalambda: number

    Returns void

  • computeB(a: number, b: number, h: number): number
  • Computes the RHS of the SPOOK equation

    Parameters

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

    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

  • computeGiMGt(): number
  • Computes G*inv(M)*G'

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

    Returns number

  • computeGq(): number
  • Computes G*q, where q are the generalized body coordinates

    Returns number

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

    Parameters

    • eps: number

    Returns number

  • gmult(G: Vec2, vi: Vec2, wi: number, vj: Vec2, wj: number): number
  • Multiply a jacobian entry with corresponding positions or velocities

    Parameters

    Returns number

  • update(): void
  • Returns void