UNPKG

constraint-solver-js

Version:

2D rigid body constraint solver written in typescript.

38 lines (37 loc) 843 B
/** * Represents a solution */ export class SolverSolution { constructor(x, solved, msg) { this.x = x; this._solved = solved; this.msg = msg; } /** * Get solution's X Vector. */ getX() { return this.x; } /** * @returns boolean indicating if the solver found a solution */ solved() { return this._solved; } /** * @returns solver's message. */ message() { return this.msg; } static success(x) { return new SolverSolution(x, true, "Solution achived"); } static timeOut(x) { return new SolverSolution(x, false, "No solution found. Solver timed out"); } static maxIterReached(x) { return new SolverSolution(x, false, "No solution found. Max number of iteratios reached"); } }