Class GSSolver

Iterative Gauss-Seidel constraint equation solver.

Hierarchy

Constructors

Properties

equationSortFunction?: ((a, b) => number)

Type declaration

    • (a, b): number
    • Function that is used to sort all equations before each solve.

      Parameters

      Returns number

equations: Equation[]

Current equations in the solver.

frictionIterations: number

Number of solver iterations that are used to approximate normal forces used for friction (F_friction = mu * F_normal). These friction forces will override any other friction forces that are set. If you set frictionIterations = 0, then this feature will be disabled.

Use only frictionIterations > 0 if the approximated normal force (F_normal = mass * gravity) is not good enough. Examples of where it can happen is in space games where gravity is zero, or in tall stacks where the normal force is large at bottom but small at top.

Default

0
iterations: number

The max number of iterations to do when solving. More gives better results, but is more expensive.

tolerance: number

The error tolerance, per constraint. If the total error is below this limit, the solver will stop iterating. Set to zero for as good solution as possible, but to something larger than zero to make computations faster.

Default

1e-7
type: 1 = Solver.GS

The type of solver.

usedIterations: number

The number of iterations that were made during the last solve. If .tolerance is zero, this value will always be equal to .iterations, but if .tolerance is larger than zero, and the solver can quit early, then this number will be somewhere between 1 and .iterations.

GS: 1

Gauss-Seidel solver.

Methods

  • Add an equation to be solved.

    Parameters

    Returns void

  • Add equations. Same as .addEquation, but this time the argument is an array of Equations

    Parameters

    Returns void

  • Removes all currently added equations

    Returns void

  • Removes an equation

    Parameters

    Returns void

  • Method to be implemented in each subclass

    Parameters

    Returns void

  • Sort all equations using the .equationSortFunction. Should be called by subclasses before solving.

    Returns void