math 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +1605 -0
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/color/color.js +136 -0
- package/dist/color/color.js.map +1 -0
- package/dist/color/colorspace.js +43 -0
- package/dist/color/colorspace.js.map +1 -0
- package/dist/color/hsl.js +123 -0
- package/dist/color/hsl.js.map +1 -0
- package/dist/color/index.js +7 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/parse.js +276 -0
- package/dist/color/parse.js.map +1 -0
- package/dist/core/angle.js +43 -0
- package/dist/core/angle.js.map +1 -0
- package/dist/core/euler.js +212 -0
- package/dist/core/euler.js.map +1 -0
- package/dist/core/mat2.js +385 -0
- package/dist/core/mat2.js.map +1 -0
- package/dist/core/mat2d.js +422 -0
- package/dist/core/mat2d.js.map +1 -0
- package/dist/core/mat3.js +749 -0
- package/dist/core/mat3.js.map +1 -0
- package/dist/core/mat4.js +2197 -0
- package/dist/core/mat4.js.map +1 -0
- package/dist/core/polar.js +200 -0
- package/dist/core/polar.js.map +1 -0
- package/dist/core/quat.js +730 -0
- package/dist/core/quat.js.map +1 -0
- package/dist/core/quat2.js +883 -0
- package/dist/core/quat2.js.map +1 -0
- package/dist/core/scalar.js +112 -0
- package/dist/core/scalar.js.map +1 -0
- package/dist/core/spherical.js +248 -0
- package/dist/core/spherical.js.map +1 -0
- package/dist/core/vec2.js +597 -0
- package/dist/core/vec2.js.map +1 -0
- package/dist/core/vec3.js +916 -0
- package/dist/core/vec3.js.map +1 -0
- package/dist/core/vec4.js +573 -0
- package/dist/core/vec4.js.map +1 -0
- package/dist/geometry/circumcircle.js +39 -0
- package/dist/geometry/circumcircle.js.map +1 -0
- package/dist/geometry/index.js +6 -0
- package/dist/geometry/index.js.map +1 -0
- package/dist/geometry/polygon2-decompose.js +411 -0
- package/dist/geometry/polygon2-decompose.js.map +1 -0
- package/dist/geometry/polygon2-triangulate.js +222 -0
- package/dist/geometry/polygon2-triangulate.js.map +1 -0
- package/dist/geometry/quickhull2.js +123 -0
- package/dist/geometry/quickhull2.js.map +1 -0
- package/dist/geometry/quickhull3.js +605 -0
- package/dist/geometry/quickhull3.js.map +1 -0
- package/dist/ik/fabrik2.js +675 -0
- package/dist/ik/fabrik2.js.map +1 -0
- package/dist/ik/fabrik3.js +912 -0
- package/dist/ik/fabrik3.js.map +1 -0
- package/dist/ik/index.js +5 -0
- package/dist/ik/index.js.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/noise/fractal.js +185 -0
- package/dist/noise/fractal.js.map +1 -0
- package/dist/noise/index.js +16 -0
- package/dist/noise/index.js.map +1 -0
- package/dist/noise/perlin2d.js +50 -0
- package/dist/noise/perlin2d.js.map +1 -0
- package/dist/noise/perlin3d.js +72 -0
- package/dist/noise/perlin3d.js.map +1 -0
- package/dist/noise/permutation.js +120 -0
- package/dist/noise/permutation.js.map +1 -0
- package/dist/noise/simplex2d.js +84 -0
- package/dist/noise/simplex2d.js.map +1 -0
- package/dist/noise/simplex3d.js +147 -0
- package/dist/noise/simplex3d.js.map +1 -0
- package/dist/noise/simplex4d.js +149 -0
- package/dist/noise/simplex4d.js.map +1 -0
- package/dist/noise/worley2d.js +50 -0
- package/dist/noise/worley2d.js.map +1 -0
- package/dist/noise/worley3d.js +61 -0
- package/dist/noise/worley3d.js.map +1 -0
- package/dist/random/index.js +9 -0
- package/dist/random/index.js.map +1 -0
- package/dist/random/isaac32.js +164 -0
- package/dist/random/isaac32.js.map +1 -0
- package/dist/random/isaac64.js +215 -0
- package/dist/random/isaac64.js.map +1 -0
- package/dist/random/mulberry32.js +48 -0
- package/dist/random/mulberry32.js.map +1 -0
- package/dist/random/random.js +120 -0
- package/dist/random/random.js.map +1 -0
- package/dist/shapes/box2.js +300 -0
- package/dist/shapes/box2.js.map +1 -0
- package/dist/shapes/box3.js +550 -0
- package/dist/shapes/box3.js.map +1 -0
- package/dist/shapes/circle.js +6 -0
- package/dist/shapes/circle.js.map +1 -0
- package/dist/shapes/frustum.js +662 -0
- package/dist/shapes/frustum.js.map +1 -0
- package/dist/shapes/index.js +25 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/obb3.js +557 -0
- package/dist/shapes/obb3.js.map +1 -0
- package/dist/shapes/plane3.js +267 -0
- package/dist/shapes/plane3.js.map +1 -0
- package/dist/shapes/polygon2.js +451 -0
- package/dist/shapes/polygon2.js.map +1 -0
- package/dist/shapes/raycast3.js +164 -0
- package/dist/shapes/raycast3.js.map +1 -0
- package/dist/shapes/segment2.js +82 -0
- package/dist/shapes/segment2.js.map +1 -0
- package/dist/shapes/sphere.js +23 -0
- package/dist/shapes/sphere.js.map +1 -0
- package/dist/shapes/triangle2.js +79 -0
- package/dist/shapes/triangle2.js.map +1 -0
- package/dist/shapes/triangle3.js +60 -0
- package/dist/shapes/triangle3.js.map +1 -0
- package/dist/src/color/color.d.ts +50 -0
- package/dist/src/color/colorspace.d.ts +15 -0
- package/dist/src/color/hsl.d.ts +28 -0
- package/dist/src/color/index.d.ts +5 -0
- package/dist/src/color/parse.d.ts +15 -0
- package/dist/src/core/angle.d.ts +29 -0
- package/dist/src/core/arrays.d.ts +4 -0
- package/dist/src/core/euler.d.ts +78 -0
- package/dist/src/core/index.d.ts +27 -0
- package/dist/src/core/mat2.d.ts +217 -0
- package/dist/src/core/mat2d.d.ts +218 -0
- package/dist/src/core/mat3.d.ts +295 -0
- package/dist/src/core/mat4.d.ts +667 -0
- package/dist/src/core/polar.d.ts +151 -0
- package/dist/src/core/quat.d.ts +370 -0
- package/dist/src/core/quat2.d.ts +344 -0
- package/dist/src/core/scalar.d.ts +75 -0
- package/dist/src/core/spherical.d.ts +165 -0
- package/dist/src/core/vec2.d.ts +403 -0
- package/dist/src/core/vec3.d.ts +493 -0
- package/dist/src/core/vec4.d.ts +336 -0
- package/dist/src/geometry/circumcircle.d.ts +9 -0
- package/dist/src/geometry/index.d.ts +5 -0
- package/dist/src/geometry/polygon2-decompose.d.ts +25 -0
- package/dist/src/geometry/polygon2-triangulate.d.ts +15 -0
- package/dist/src/geometry/quickhull2.d.ts +10 -0
- package/dist/src/geometry/quickhull3.d.ts +27 -0
- package/dist/src/ik/fabrik2.d.ts +314 -0
- package/dist/src/ik/fabrik3.d.ts +371 -0
- package/dist/src/ik/index.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/noise/fractal.d.ts +95 -0
- package/dist/src/noise/index.d.ts +9 -0
- package/dist/src/noise/perlin2d.d.ts +19 -0
- package/dist/src/noise/perlin3d.d.ts +20 -0
- package/dist/src/noise/permutation.d.ts +22 -0
- package/dist/src/noise/simplex2d.d.ts +19 -0
- package/dist/src/noise/simplex3d.d.ts +20 -0
- package/dist/src/noise/simplex4d.d.ts +24 -0
- package/dist/src/noise/worley2d.d.ts +22 -0
- package/dist/src/noise/worley3d.d.ts +23 -0
- package/dist/src/random/index.d.ts +8 -0
- package/dist/src/random/isaac32.d.ts +62 -0
- package/dist/src/random/isaac64.d.ts +75 -0
- package/dist/src/random/mulberry32.d.ts +43 -0
- package/dist/src/random/random.d.ts +67 -0
- package/dist/src/shapes/box2.d.ts +174 -0
- package/dist/src/shapes/box3.d.ts +213 -0
- package/dist/src/shapes/circle.d.ts +7 -0
- package/dist/src/shapes/frustum.d.ts +147 -0
- package/dist/src/shapes/index.d.ts +20 -0
- package/dist/src/shapes/obb3.d.ts +105 -0
- package/dist/src/shapes/plane3.d.ts +130 -0
- package/dist/src/shapes/polygon2.d.ts +155 -0
- package/dist/src/shapes/raycast3.d.ts +42 -0
- package/dist/src/shapes/segment2.d.ts +34 -0
- package/dist/src/shapes/sphere.d.ts +19 -0
- package/dist/src/shapes/triangle2.d.ts +53 -0
- package/dist/src/shapes/triangle3.d.ts +29 -0
- package/dist/src/time/easing.d.ts +21 -0
- package/dist/src/time/index.d.ts +6 -0
- package/dist/src/time/spring-core.d.ts +15 -0
- package/dist/src/time/spring.d.ts +36 -0
- package/dist/src/time/spring2.d.ts +11 -0
- package/dist/src/time/spring3.d.ts +11 -0
- package/dist/src/time/spring4.d.ts +11 -0
- package/dist/time/easing.js +24 -0
- package/dist/time/easing.js.map +1 -0
- package/dist/time/index.js +11 -0
- package/dist/time/index.js.map +1 -0
- package/dist/time/spring-core.js +48 -0
- package/dist/time/spring-core.js.map +1 -0
- package/dist/time/spring.js +62 -0
- package/dist/time/spring.js.map +1 -0
- package/dist/time/spring2.js +31 -0
- package/dist/time/spring2.js.map +1 -0
- package/dist/time/spring3.js +32 -0
- package/dist/time/spring3.js.map +1 -0
- package/dist/time/spring4.js +32 -0
- package/dist/time/spring4.js.map +1 -0
- package/package.json +90 -12
- package/skills/math/SKILL.md +140 -0
- package/math.coffee +0 -36
- package/math.js +0 -67
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fabrik2.js","sources":["../../src/ik/fabrik2.ts"],"sourcesContent":["import { type Vec2, vec2 } from '../core';\n\n// FABRIK (Forward And Backward Reaching Inverse Kinematics) for 2D chains.\n//\n// The 2D counterpart of `fabrik3`, same shape and same two passes. What differs is the constraint\n// model: with no axis to hinge about, a joint is a wedge - how far the bone may swing clockwise and\n// anticlockwise of a baseline, either the previous bone (`LOCAL`) or a fixed world direction\n// (`GLOBAL`, which pins the bone's absolute heading).\n//\n// The constraint model follows Caliko, the reference implementation accompanying Aristidou &\n// Lasenby (2011), \"FABRIK: A fast, iterative solver for the Inverse Kinematics problem\".\n\n/** What a joint's clockwise and anticlockwise limits are measured from. */\nexport enum ConstraintCoordinateSystem {\n /** The direction of the previous bone, so the limits bound how far this bone may bend. */\n LOCAL = 0,\n /** A fixed world direction, so the limits bound this bone's absolute heading. */\n GLOBAL = 1,\n}\n\n/**\n * How the first bone in a chain is constrained.\n *\n * The first bone has no bone before it, so it is constrained against a direction held on the chain.\n * The `LOCAL_` types only mean anything for a chain in a {@link Structure2}, where\n * {@link solveStructure} resolves them against the bone the chain hangs off.\n */\nexport enum BaseboneConstraintType {\n /** The first bone may point anywhere. */\n NONE = 0,\n /** Constrained against a fixed world direction. */\n GLOBAL_ABSOLUTE = 1,\n /** Constrained against the host bone's direction, so the chain bends relative to what it hangs off. */\n LOCAL_RELATIVE = 2,\n /**\n * Constrained against a direction expressed in the host bone's frame, where **+Y** is the host\n * bone's own direction. (`fabrik3`'s equivalent uses +Z, so a rig ported between the two needs\n * its axes rotated.)\n */\n LOCAL_ABSOLUTE = 3,\n}\n\n/** Which end of a host bone a connected chain hangs off. */\nexport enum BoneConnectionPoint {\n /** The host bone's start - the joint it shares with the bone before it. */\n START = 0,\n /** The host bone's end. */\n END = 1,\n}\n\n/**\n * A joint's rotational limits: a wedge about a baseline.\n *\n * Angles are in radians, and a limit of PI means unconstrained in that direction. Anticlockwise is\n * positive, matching {@link vec2.signedAngle}.\n */\nexport type Joint2 = {\n /** How far the bone may swing clockwise of the baseline, in [0, PI]. */\n clockwise: number;\n /** How far the bone may swing anticlockwise of the baseline, in [0, PI]. */\n anticlockwise: number;\n /** What `clockwise` and `anticlockwise` are measured from. */\n coordinateSystem: ConstraintCoordinateSystem;\n /** The baseline for a `GLOBAL` joint - a world direction. Unit length. Unused when `LOCAL`. */\n globalAxis: Vec2;\n};\n\n/** A single bone: two points, the fixed distance between them, and how it may rotate. */\nexport type Bone2 = {\n /** The joint shared with the previous bone; on the first bone, the base. */\n start: Vec2;\n /** The joint shared with the next bone; on the last bone, the end effector. */\n end: Vec2;\n /** The rest distance between `start` and `end`, preserved by every solve. */\n length: number;\n /** How far this bone may rotate away from the bone before it. */\n joint: Joint2;\n};\n\n/**\n * A chain of bones, from the base (index 0) to the end effector (the last bone's `end`).\n *\n * Allocate one with {@link createChain2}, fill it with {@link addBone} or\n * {@link addConsecutiveBone}, then solve it every frame.\n *\n * `bones[0].joint` is unused - the first bone is governed by the chain's basebone fields instead,\n * so a joint's fields never change meaning with its index.\n */\nexport type Chain2 = {\n /**\n * The bones, base first and end effector last.\n *\n * Neighbours share a point - bone `i`'s end is bone `i + 1`'s start - and the solver keeps it\n * that way, so moving one moves the other.\n */\n bones: Bone2[];\n /** The sum of every bone length - the chain's reach. Maintained by {@link addBone}. */\n length: number;\n /** Where the base of the chain is pinned when `fixedBase` is set. */\n base: Vec2;\n /** Whether `backward` pins the base to `base`. Clear it to let the whole chain drift. Forced on for a chain connected in a structure. */\n fixedBase: boolean;\n /** How the first bone is held; see {@link BaseboneConstraintType}. */\n baseboneConstraintType: BaseboneConstraintType;\n /** The baseline direction, in the space named by `baseboneConstraintType`. Unit length. */\n baseboneAxis: Vec2;\n /** `baseboneAxis` in world space. Equal to it for `GLOBAL_ABSOLUTE`; resolved by {@link solveStructure} otherwise. */\n baseboneWorldAxis: Vec2;\n /** How far the first bone may swing clockwise of the baseline, in [0, PI]. */\n baseboneClockwise: number;\n /** How far the first bone may swing anticlockwise of the baseline, in [0, PI]. */\n baseboneAnticlockwise: number;\n /** The target this chain solves for inside a {@link Structure2} when `useEmbeddedTarget` is set. */\n embeddedTarget: Vec2;\n /**\n * Whether this chain solves for its own `embeddedTarget` instead of the target passed to\n * {@link solveStructure}. Ignored outside a {@link Structure2}.\n */\n useEmbeddedTarget: boolean;\n /** The most iterations {@link solve} will run. */\n maxIterations: number;\n /** {@link solve} stops as soon as the effector is this close to the target. */\n solveDistanceThreshold: number;\n /**\n * How still an iteration must be before {@link solve} treats the chain as stuck.\n *\n * Only consulted on an iteration that fails to beat the best distance so far, and compared\n * against the previous iteration rather than the best - so a solve that is slowly getting worse\n * runs its full budget. That is deliberate: FABRIK often worsens before it improves, and every\n * stricter rule tried here bought fewer iterations at a disproportionate cost in final pose.\n */\n minIterationChange: number;\n /** The distance from the effector to the target after the last {@link solve}. */\n solveDistance: number;\n /** Scratch holding the best pose {@link solve} has seen, four numbers per bone. Grown by {@link addBone}. */\n bestSolution: number[];\n};\n\n/** A chain's attachment to a bone in another chain of the same structure. */\nexport type Connection = {\n /** The index of the host chain in `structure.chains`, or -1 for a chain that hangs off nothing. */\n hostChain: number;\n /** The index of the host bone within that chain. */\n hostBone: number;\n /** Which end of the host bone this chain's base is pinned to. */\n point: BoneConnectionPoint;\n};\n\n/** A set of chains, each optionally hanging off a bone of another. */\nexport type Structure2 = {\n /** Solved in insertion order, so a connected chain always sees its host already posed. */\n chains: Chain2[];\n /** Parallel to `chains`. */\n connections: Connection[];\n};\n\n// the most iterations a solve runs before giving up on reaching the target\nconst DEFAULT_MAX_ITERATIONS = 20;\n\n// how close the effector must get before a solve stops early. in world units, so scale it with the\n// scene - the default suits a chain a few units long\nconst DEFAULT_SOLVE_DISTANCE_THRESHOLD = 0.01;\n\n// how little an iteration may improve the solve distance before it counts as stalled. a constrained\n// chain can reach a pose no further iteration improves on while still short of the threshold, and\n// without this it would burn every remaining iteration going nowhere. two orders of magnitude below\n// the distance threshold, so a solve still closing in on the target is never mistaken for a stalled\n// one\nconst DEFAULT_MIN_ITERATION_CHANGE = 1e-4;\n\n// below this squared length a vector carries no usable direction - 1e-12 in length terms, well above\n// a normalize's noise floor and well below anything meaningful. every test against it also checks\n// for NaN, so a value poisoned upstream takes the same fallback instead of spreading down the chain\nconst DEGENERATE_SQUARED_LENGTH = 1e-24;\n\n/**\n * Normalizes `axis` into `out`, leaving `out` untouched if `axis` has no direction to give.\n *\n * A zero axis cannot be normalized, and storing one turns every constraint that reads it into NaN.\n * `out` always starts as a valid unit vector, so keeping it is the safe fallback.\n */\nfunction setUnitAxis(out: Vec2, axis: Vec2): Vec2 {\n if (!hasDirection(vec2.squaredLength(axis))) return out;\n return vec2.normalize(out, axis);\n}\n\n/**\n * Whether a squared length is a usable magnitude: a real number, and not effectively zero.\n *\n * NaN counts as unusable. A value poisoned upstream then takes the same fallback as a zero-length\n * one, instead of spreading down the chain and leaving it stuck.\n */\nfunction hasDirection(squaredLength: number): boolean {\n if (Number.isNaN(squaredLength)) return false;\n return squaredLength >= DEGENERATE_SQUARED_LENGTH;\n}\n\n/** Creates an unconstrained joint. */\nexport function createJoint2(): Joint2 {\n return {\n clockwise: Math.PI,\n anticlockwise: Math.PI,\n coordinateSystem: ConstraintCoordinateSystem.LOCAL,\n globalAxis: [0, 1],\n };\n}\n\n/** Creates an empty chain with a fixed base at the origin and no basebone constraint. */\nexport function createChain2(): Chain2 {\n return {\n bones: [],\n length: 0,\n base: [0, 0],\n fixedBase: true,\n baseboneConstraintType: BaseboneConstraintType.NONE,\n baseboneAxis: [0, 1],\n baseboneWorldAxis: [0, 1],\n baseboneClockwise: Math.PI,\n baseboneAnticlockwise: Math.PI,\n embeddedTarget: [0, 0],\n useEmbeddedTarget: false,\n maxIterations: DEFAULT_MAX_ITERATIONS,\n solveDistanceThreshold: DEFAULT_SOLVE_DISTANCE_THRESHOLD,\n minIterationChange: DEFAULT_MIN_ITERATION_CHANGE,\n solveDistance: Number.POSITIVE_INFINITY,\n bestSolution: [],\n };\n}\n\n/**\n * Appends a bone spanning `start` to `end`, copying both.\n *\n * The bone's length is taken from the distance between them. When this is the first bone the\n * chain's base is moved to `start`.\n *\n * @param chain the chain to append to\n * @param start the bone's start point\n * @param end the bone's end point\n * @param joint the bone's joint, or a fresh unconstrained one if omitted\n * @returns the appended bone\n */\nexport function addBone(chain: Chain2, start: Vec2, end: Vec2, joint: Joint2 = createJoint2()): Bone2 {\n const bone: Bone2 = {\n start: [start[0], start[1]],\n end: [end[0], end[1]],\n length: vec2.distance(start, end),\n joint,\n };\n\n if (chain.bones.length === 0) {\n chain.base[0] = start[0];\n chain.base[1] = start[1];\n }\n\n chain.bones.push(bone);\n chain.length += bone.length;\n\n // four numbers of best-pose scratch per bone, so `solve` never allocates\n chain.bestSolution.push(0, 0, 0, 0);\n\n return bone;\n}\n\nconst _addConsecutive_end: Vec2 = [0, 0];\n\n/**\n * Appends a bone starting where the chain currently ends, running `length` along `direction`.\n *\n * @param chain the chain to append to, which must already have at least one bone\n * @param direction the direction to extend in, assumed to be unit length\n * @param length the length of the new bone\n * @param joint the bone's joint, or a fresh unconstrained one if omitted\n * @returns the appended bone\n */\nexport function addConsecutiveBone(chain: Chain2, direction: Vec2, length: number, joint: Joint2 = createJoint2()): Bone2 {\n const previous = chain.bones[chain.bones.length - 1];\n\n _addConsecutive_end[0] = previous.end[0] + direction[0] * length;\n _addConsecutive_end[1] = previous.end[1] + direction[1] * length;\n\n return addBone(chain, previous.end, _addConsecutive_end, joint);\n}\n\n/**\n * Prepends a bone at the base end, extending the chain backward.\n *\n * This is what a follower grows with: driven by {@link forward} alone the base end is the tail.\n *\n * `joint` becomes the joint of the bone that was previously first, because that is the junction the\n * new bone creates. The new first bone's own joint is unused, as always.\n *\n * @param chain the chain to prepend to, which must already have at least one bone\n * @param direction the direction the new bone points, from its own start toward the existing chain. Assumed to be unit length\n * @param length the length of the new bone\n * @param joint the joint for the junction this creates, or a fresh unconstrained one if omitted\n * @returns the prepended bone\n */\nexport function addBoneAtBase(chain: Chain2, direction: Vec2, length: number, joint: Joint2 = createJoint2()): Bone2 {\n const first = chain.bones[0];\n\n // the bone that was first now sits at index 1, so it is the one whose joint governs the new\n // junction. its old joint was the unused basebone slot\n first.joint = joint;\n\n const bone: Bone2 = {\n start: [first.start[0] - direction[0] * length, first.start[1] - direction[1] * length],\n end: [first.start[0], first.start[1]],\n length,\n joint: createJoint2(),\n };\n\n chain.bones.unshift(bone);\n chain.length += length;\n\n chain.base[0] = bone.start[0];\n chain.base[1] = bone.start[1];\n\n chain.bestSolution.push(0, 0, 0, 0);\n\n return bone;\n}\n\n/**\n * Sets a joint's limits relative to the previous bone's direction, which is the usual case.\n *\n * @param joint the joint to configure\n * @param clockwise how far the bone may swing clockwise of the previous bone, in radians, clamped to [0, PI]\n * @param anticlockwise how far it may swing anticlockwise, in radians, clamped to [0, PI]\n * @returns the joint\n */\nexport function setLocalJoint(joint: Joint2, clockwise: number, anticlockwise: number): Joint2 {\n joint.coordinateSystem = ConstraintCoordinateSystem.LOCAL;\n joint.clockwise = clampAngle(clockwise);\n joint.anticlockwise = clampAngle(anticlockwise);\n return joint;\n}\n\n/**\n * Sets a joint's limits relative to a fixed world direction, pinning the bone's absolute heading\n * however the bones before it move.\n *\n * @param joint the joint to configure\n * @param axis the world direction the limits are measured from, assumed to be unit length\n * @param clockwise how far the bone may swing clockwise of `axis`, in radians, clamped to [0, PI]\n * @param anticlockwise how far it may swing anticlockwise, in radians, clamped to [0, PI]\n * @returns the joint\n */\nexport function setGlobalJoint(joint: Joint2, axis: Vec2, clockwise: number, anticlockwise: number): Joint2 {\n joint.coordinateSystem = ConstraintCoordinateSystem.GLOBAL;\n joint.clockwise = clampAngle(clockwise);\n joint.anticlockwise = clampAngle(anticlockwise);\n setUnitAxis(joint.globalAxis, axis);\n return joint;\n}\n\n/**\n * Constrains the first bone to a wedge about `axis`.\n *\n * @param chain the chain to configure\n * @param type which space `axis` is expressed in\n * @param axis the baseline direction, assumed to be unit length. Ignored for {@link BaseboneConstraintType.LOCAL_RELATIVE}, which uses the host bone's direction\n * @param clockwise how far the first bone may swing clockwise of the baseline, in radians, clamped to [0, PI]\n * @param anticlockwise how far it may swing anticlockwise, in radians, clamped to [0, PI]\n * @returns the chain\n */\nexport function setBaseboneConstraint(\n chain: Chain2,\n type: BaseboneConstraintType,\n axis: Vec2,\n clockwise: number,\n anticlockwise: number,\n): Chain2 {\n chain.baseboneConstraintType = type;\n chain.baseboneClockwise = clampAngle(clockwise);\n chain.baseboneAnticlockwise = clampAngle(anticlockwise);\n\n setUnitAxis(chain.baseboneAxis, axis);\n vec2.copy(chain.baseboneWorldAxis, chain.baseboneAxis);\n\n return chain;\n}\n\n/**\n * Moves the chain's pinned base, without moving the bones.\n *\n * The next {@link backward} or {@link solve} pulls the chain to it.\n */\nexport function setBaseLocation(chain: Chain2, base: Vec2): Chain2 {\n chain.base[0] = base[0];\n chain.base[1] = base[1];\n return chain;\n}\n\n/**\n * Lays the chain out straight from its base along `direction`, discarding the current pose.\n *\n * A dead-straight chain is the worst starting pose for {@link solve} - see the note there. Bend\n * `direction` slightly between bones instead if the chain will be solved cold.\n */\nexport function straighten(chain: Chain2, direction: Vec2): Chain2 {\n const bones = chain.bones;\n\n let x = chain.base[0];\n let y = chain.base[1];\n\n for (let i = 0; i < bones.length; i++) {\n const bone = bones[i];\n\n bone.start[0] = x;\n bone.start[1] = y;\n\n x += direction[0] * bone.length;\n y += direction[1] * bone.length;\n\n bone.end[0] = x;\n bone.end[1] = y;\n }\n\n return chain;\n}\n\n/**\n * Writes the end effector's position - the last bone's end - into `out`.\n *\n * A chain with no bones has its base as its effector, matching {@link solve}, which treats an empty\n * chain as a supported state rather than an error.\n */\nexport function getEffector(out: Vec2, chain: Chain2): Vec2 {\n const count = chain.bones.length;\n return vec2.copy(out, count === 0 ? chain.base : chain.bones[count - 1].end);\n}\n\n/** Writes the unit direction of bone `index`, from its start toward its end, into `out`. */\nexport function getBoneDirection(out: Vec2, chain: Chain2, index: number): Vec2 {\n const bone = chain.bones[index];\n\n vec2.subtract(out, bone.end, bone.start);\n\n if (!hasDirection(vec2.squaredLength(out))) {\n return vec2.copy(out, UP);\n }\n\n return vec2.normalize(out, out);\n}\n\n/** The angle of bone `index`, in radians, measured counter-clockwise from the +X axis. */\nexport function getBoneAngle(chain: Chain2, index: number): number {\n const bone = chain.bones[index];\n return Math.atan2(bone.end[1] - bone.start[1], bone.end[0] - bone.start[0]);\n}\n\n/** Whether `target` is within reach of the chain's base, so a solve can place the effector exactly on it. */\nexport function isReachable(chain: Chain2, target: Vec2): boolean {\n return vec2.squaredDistance(chain.base, target) <= chain.length * chain.length;\n}\n\n/**\n * The forward pass: snaps the end effector onto `target` and drags the rest of the chain after it.\n *\n * A non-finite target leaves the chain untouched rather than poisoning it.\n *\n * The base is not pinned, so the whole chain moves. Run alone once per frame this is a follower\n * rather than a solver - a rope or tentacle whose head leads. Pair it with {@link backward}, or use\n * {@link solve}, to keep the base put.\n *\n * @param chain the chain to move, mutated in place\n * @param target where the end effector should go\n * @returns the chain\n */\nexport function forward(chain: Chain2, target: Vec2): Chain2 {\n const bones = chain.bones;\n const count = bones.length;\n\n if (count === 0) return chain;\n\n // a non-finite target would be written straight into the effector and spread down the chain\n if (!Number.isFinite(target[0]) || !Number.isFinite(target[1])) return chain;\n\n // snap the effector onto the target. the rest of the pass follows from it\n const effector = bones[count - 1];\n effector.end[0] = target[0];\n effector.end[1] = target[1];\n\n // the outer-to-inner direction of the bone one step further out, which is what a joint on this\n // bone is constrained against on this pass. undefined for the effector itself.\n let hasReference = false;\n\n for (let i = count - 1; i >= 0; i--) {\n const bone = bones[i];\n const start = bone.start;\n const end = bone.end;\n\n // this bone's outer-to-inner direction\n let dx = start[0] - end[0];\n let dy = start[1] - end[1];\n\n const squaredLength = dx * dx + dy * dy;\n\n if (!hasDirection(squaredLength)) {\n // the two ends coincide, so there is no direction to preserve. carry on along the bone\n // further out, or straight up if this is the effector\n dx = hasReference ? _pass_reference[0] : UP[0];\n dy = hasReference ? _pass_reference[1] : UP[1];\n } else {\n const inverseLength = 1 / Math.sqrt(squaredLength);\n dx *= inverseLength;\n dy *= inverseLength;\n }\n\n constrainForward(chain, i, dx, dy, hasReference);\n dx = _pass_direction[0];\n dy = _pass_direction[1];\n\n const x = end[0] + dx * bone.length;\n const y = end[1] + dy * bone.length;\n\n start[0] = x;\n start[1] = y;\n\n // the previous bone shares this point\n if (i > 0) {\n const previousEnd = bones[i - 1].end;\n previousEnd[0] = x;\n previousEnd[1] = y;\n }\n\n _pass_reference[0] = dx;\n _pass_reference[1] = dy;\n hasReference = true;\n }\n\n return chain;\n}\n\n/**\n * The backward pass: pins the base and pushes each bone outward from it. The basebone constraint\n * is applied here.\n *\n * @param chain the chain to move, mutated in place\n * @param base where the base should go, used only when `chain.fixedBase` is set\n * @returns the chain\n */\nexport function backward(chain: Chain2, base: Vec2): Chain2 {\n const bones = chain.bones;\n const count = bones.length;\n\n if (count === 0) return chain;\n if (!Number.isFinite(base[0]) || !Number.isFinite(base[1])) return chain;\n\n if (chain.fixedBase) {\n const start = bones[0].start;\n start[0] = base[0];\n start[1] = base[1];\n }\n\n let hasReference = false;\n\n for (let i = 0; i < count; i++) {\n const bone = bones[i];\n const start = bone.start;\n const end = bone.end;\n\n // this bone's inner-to-outer direction\n let dx = end[0] - start[0];\n let dy = end[1] - start[1];\n\n const squaredLength = dx * dx + dy * dy;\n\n if (!hasDirection(squaredLength)) {\n dx = hasReference ? _pass_reference[0] : UP[0];\n dy = hasReference ? _pass_reference[1] : UP[1];\n } else {\n const inverseLength = 1 / Math.sqrt(squaredLength);\n dx *= inverseLength;\n dy *= inverseLength;\n }\n\n constrainBackward(chain, i, dx, dy);\n dx = _pass_direction[0];\n dy = _pass_direction[1];\n\n // when the base is free, the first bone swings about its end rather than its start\n if (i === 0 && !chain.fixedBase) {\n start[0] = end[0] - dx * bone.length;\n start[1] = end[1] - dy * bone.length;\n }\n\n const x = start[0] + dx * bone.length;\n const y = start[1] + dy * bone.length;\n\n end[0] = x;\n end[1] = y;\n\n if (i < count - 1) {\n const nextStart = bones[i + 1].start;\n nextStart[0] = x;\n nextStart[1] = y;\n }\n\n _pass_reference[0] = dx;\n _pass_reference[1] = dy;\n hasReference = true;\n }\n\n return chain;\n}\n\n/**\n * One full FABRIK iteration - {@link forward} then {@link backward}.\n *\n * @param chain the chain to move, mutated in place\n * @param target where the end effector should go\n * @returns the distance from the effector to `target` afterwards\n */\nexport function iterate(chain: Chain2, target: Vec2): number {\n if (chain.bones.length === 0) return Number.POSITIVE_INFINITY;\n\n forward(chain, target);\n backward(chain, chain.base);\n\n return vec2.distance(chain.bones[chain.bones.length - 1].end, target);\n}\n\n/**\n * Solves the chain for `target`, iterating until it is close enough, stops improving, or runs out\n * of attempts.\n *\n * A constrained chain does not converge monotonically, so the best pose seen is kept and restored.\n *\n * A dead-straight chain is the worst case to solve cold: every direction lies on one line, leaving\n * nothing sideways to bend it with. Give it a slight bend if the first solve matters.\n *\n * @param chain the chain to solve, mutated in place\n * @param target where the end effector should go\n * @returns the distance from the effector to `target`, also stored as `chain.solveDistance`\n */\nexport function solve(chain: Chain2, target: Vec2): number {\n const count = chain.bones.length;\n\n if (count === 0) {\n chain.solveDistance = Number.POSITIVE_INFINITY;\n return chain.solveDistance;\n }\n\n // in case bones were pushed onto the chain directly rather than through addBone\n if (chain.bestSolution.length < count * 4) {\n chain.bestSolution.length = count * 4;\n chain.bestSolution.fill(0);\n }\n\n let best = Number.POSITIVE_INFINITY;\n let previous = Number.POSITIVE_INFINITY;\n\n for (let i = 0; i < chain.maxIterations; i++) {\n const distance = iterate(chain, target);\n\n if (distance < best) {\n best = distance;\n saveSolution(chain);\n\n if (distance <= chain.solveDistanceThreshold) break;\n } else if (Math.abs(distance - previous) < chain.minIterationChange) {\n // ground to a halt - more iterations will not improve on what we already have\n break;\n }\n\n previous = distance;\n }\n\n if (best !== Number.POSITIVE_INFINITY) {\n restoreSolution(chain);\n }\n\n chain.solveDistance = best;\n\n return best;\n}\n\n/** Creates an empty structure. */\nexport function createStructure2(): Structure2 {\n return { chains: [], connections: [] };\n}\n\n/**\n * Adds a chain that hangs off nothing, solving directly for the structure's target.\n *\n * @returns the index of the added chain\n */\nexport function addChain(structure: Structure2, chain: Chain2): number {\n structure.chains.push(chain);\n structure.connections.push({ hostChain: -1, hostBone: 0, point: BoneConnectionPoint.END });\n return structure.chains.length - 1;\n}\n\n/**\n * Adds a chain whose base is pinned to one end of a bone in a chain already in the structure.\n *\n * Add the host first: {@link solveStructure} walks chains in insertion order, so a chain always\n * sees its host already posed.\n *\n * @param structure the structure to add to\n * @param chain the chain to add\n * @param hostChain the index of the chain to hang off\n * @param hostBone the index of the bone within that chain\n * @param point which end of the host bone to attach to\n * @returns the index of the added chain\n */\nexport function connectChain(\n structure: Structure2,\n chain: Chain2,\n hostChain: number,\n hostBone: number,\n point: BoneConnectionPoint,\n): number {\n structure.chains.push(chain);\n structure.connections.push({ hostChain, hostBone, point });\n return structure.chains.length - 1;\n}\n\n/**\n * Solves every chain in the structure.\n *\n * A connected chain has its base moved onto its host bone's connection point and any `LOCAL_`\n * basebone constraint resolved against the host bone's direction first. A chain with\n * `useEmbeddedTarget` set solves for its own `embeddedTarget` instead.\n *\n * @param structure the structure to solve, mutated in place\n * @param target the target for every chain that does not use an embedded target\n */\nexport function solveStructure(structure: Structure2, target: Vec2): void {\n const chains = structure.chains;\n\n for (let i = 0; i < chains.length; i++) {\n const chain = chains[i];\n const connection = structure.connections[i];\n\n if (connection.hostChain >= 0) {\n const host = chains[connection.hostChain];\n const hostBone = host.bones[connection.hostBone];\n\n setBaseLocation(chain, connection.point === BoneConnectionPoint.START ? hostBone.start : hostBone.end);\n\n // being connected IS what fixes this chain's base - a connected chain with a free base\n // would drift away from the host it is supposed to hang off, so the flag is not the\n // caller's to clear here\n chain.fixedBase = true;\n\n const type = chain.baseboneConstraintType;\n\n if (type === BaseboneConstraintType.LOCAL_RELATIVE) {\n // the baseline is the host bone itself, so the chain bends relative to what it hangs off\n getBoneDirection(chain.baseboneWorldAxis, host, connection.hostBone);\n } else if (type === BaseboneConstraintType.LOCAL_ABSOLUTE) {\n // the baseline is expressed in the host bone's frame, so turn it by however far the\n // host bone is turned from straight up\n getBoneDirection(_structure_direction, host, connection.hostBone);\n vec2.rotate(chain.baseboneWorldAxis, chain.baseboneAxis, ORIGIN, vec2.signedAngle(UP, _structure_direction));\n }\n }\n\n solve(chain, chain.useEmbeddedTarget ? chain.embeddedTarget : target);\n }\n}\n\n/* internals */\n\nconst UP: Vec2 = [0, 1];\nconst ORIGIN: Vec2 = [0, 0];\n\nconst _structure_direction: Vec2 = [0, 0];\n\n// the direction the current pass is constraining against - the previous bone's, whichever way the\n// pass is walking - and the constrained result handed back from `constrain*`\nconst _pass_reference: Vec2 = [0, 0];\nconst _pass_direction: Vec2 = [0, 0];\nconst _constrain_baseline: Vec2 = [0, 0];\n\nfunction clampAngle(radians: number): number {\n return radians < 0 ? 0 : radians > Math.PI ? Math.PI : radians;\n}\n\n/**\n * Clamps the direction `(x, y)` into the wedge reaching `clockwise` one way and `anticlockwise` the\n * other from `baseline`. Writes `_pass_direction`.\n */\nfunction constrainToWedge(x: number, y: number, baseline: Vec2, clockwise: number, anticlockwise: number): void {\n _pass_direction[0] = x;\n _pass_direction[1] = y;\n\n if (clockwise >= Math.PI && anticlockwise >= Math.PI) return;\n\n // anticlockwise is positive\n const signed = vec2.signedAngle(baseline, _pass_direction);\n\n if (signed > anticlockwise) {\n vec2.rotate(_pass_direction, baseline, ORIGIN, anticlockwise);\n } else if (signed < -clockwise) {\n vec2.rotate(_pass_direction, baseline, ORIGIN, -clockwise);\n }\n}\n\n/**\n * Constrains a bone's outer-to-inner direction during the forward pass.\n *\n * A `GLOBAL` joint pins this bone's own heading. A `LOCAL` joint limits the bend between two bones,\n * and that angle belongs to the joint between the two, which walking inward is the next bone's.\n *\n * The effector needs none of its own: its pair is clamped when the bone behind it is processed.\n *\n * Writes the result into `_pass_direction`, which starts out holding the unconstrained direction,\n * so a branch that does not apply can simply return.\n */\nfunction constrainForward(chain: Chain2, index: number, x: number, y: number, hasReference: boolean): void {\n // start from the unconstrained direction. each branch below narrows it if it applies\n _pass_direction[0] = x;\n _pass_direction[1] = y;\n\n // a GLOBAL joint pins this bone's heading whatever its neighbours do. this pass works in\n // outer-to-inner directions, so the baseline is flipped to match\n if (index > 0) {\n const joint = chain.bones[index].joint;\n\n if (joint.coordinateSystem === ConstraintCoordinateSystem.GLOBAL) {\n _constrain_baseline[0] = -joint.globalAxis[0];\n _constrain_baseline[1] = -joint.globalAxis[1];\n constrainToWedge(x, y, _constrain_baseline, joint.clockwise, joint.anticlockwise);\n return;\n }\n }\n\n // the wedge shared with the bone one step further out. the end effector has no such bone\n if (!hasReference) return;\n\n const outer = chain.bones[index + 1].joint;\n\n if (outer.coordinateSystem !== ConstraintCoordinateSystem.LOCAL) return;\n if (outer.clockwise >= Math.PI && outer.anticlockwise >= Math.PI) return;\n\n // this pass measures the pair the other way round - from the outer bone back to this one - and a\n // wedge is not symmetric, so the two limits trade places\n constrainToWedge(x, y, _pass_reference, outer.anticlockwise, outer.clockwise);\n}\n\n/**\n * Constrains a bone's inner-to-outer direction during the backward pass.\n *\n * Writes the result into `_pass_direction`, which starts out holding the unconstrained direction,\n * so a branch that does not apply can simply return.\n */\nfunction constrainBackward(chain: Chain2, index: number, x: number, y: number): void {\n // start from the unconstrained direction. each branch below narrows it if it applies\n _pass_direction[0] = x;\n _pass_direction[1] = y;\n\n if (index === 0) {\n if (chain.baseboneConstraintType === BaseboneConstraintType.NONE) return;\n\n constrainToWedge(x, y, chain.baseboneWorldAxis, chain.baseboneClockwise, chain.baseboneAnticlockwise);\n return;\n }\n\n const joint = chain.bones[index].joint;\n\n if (joint.clockwise >= Math.PI && joint.anticlockwise >= Math.PI) return;\n\n const baseline = joint.coordinateSystem === ConstraintCoordinateSystem.GLOBAL ? joint.globalAxis : _pass_reference;\n\n constrainToWedge(x, y, baseline, joint.clockwise, joint.anticlockwise);\n}\n\nfunction saveSolution(chain: Chain2): void {\n const bones = chain.bones;\n const solution = chain.bestSolution;\n\n for (let i = 0; i < bones.length; i++) {\n const bone = bones[i];\n const offset = i * 4;\n\n solution[offset] = bone.start[0];\n solution[offset + 1] = bone.start[1];\n solution[offset + 2] = bone.end[0];\n solution[offset + 3] = bone.end[1];\n }\n}\n\nfunction restoreSolution(chain: Chain2): void {\n const bones = chain.bones;\n const solution = chain.bestSolution;\n\n for (let i = 0; i < bones.length; i++) {\n const bone = bones[i];\n const offset = i * 4;\n\n bone.start[0] = solution[offset];\n bone.start[1] = solution[offset + 1];\n bone.end[0] = solution[offset + 2];\n bone.end[1] = solution[offset + 3];\n }\n}\n"],"names":["vec2.squaredLength","vec2.normalize","vec2.distance","vec2.copy","vec2.subtract","vec2.squaredDistance","vec2.rotate","vec2.signedAngle"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;IACY;AAAZ,CAAA,UAAY,0BAA0B,EAAA;;AAElC,IAAA,0BAAA,CAAA,0BAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA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