curvy 2.0.0-alpha.7 → 2.0.0-alpha.9

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.
Files changed (39) hide show
  1. package/dist/characteristic/index.mjs +1 -1
  2. package/dist/curve/index.mjs +1 -1
  3. package/dist/interval/index.mjs +1 -1
  4. package/dist/matrix/index.mjs +1 -1
  5. package/dist/path/index.mjs +4 -4
  6. package/dist/polynomial/index.mjs +2 -2
  7. package/dist/shared/{characteristic-D9yZWCym.mjs → characteristic-B0VEB_OA.mjs} +3 -3
  8. package/dist/shared/{characteristic-D9yZWCym.mjs.map → characteristic-B0VEB_OA.mjs.map} +1 -1
  9. package/dist/shared/{cubic-BK8xjSkd.mjs → cubic-NEn7E6V_.mjs} +2 -2
  10. package/dist/shared/{cubic-BK8xjSkd.mjs.map → cubic-NEn7E6V_.mjs.map} +1 -1
  11. package/dist/shared/{interval2d-BMDmeL1M.mjs → interval2d-C0eduE-V.mjs} +2 -2
  12. package/dist/shared/{interval2d-BMDmeL1M.mjs.map → interval2d-C0eduE-V.mjs.map} +1 -1
  13. package/dist/shared/{matrix4x4-qyRufxfs.mjs → matrix4x4-BWmf4lZM.mjs} +3 -3
  14. package/dist/shared/{matrix4x4-qyRufxfs.mjs.map → matrix4x4-BWmf4lZM.mjs.map} +1 -1
  15. package/dist/shared/{quadratic-CWXIRh42.mjs → quadratic-Dlxqo2V1.mjs} +2 -2
  16. package/dist/shared/{quadratic-CWXIRh42.mjs.map → quadratic-Dlxqo2V1.mjs.map} +1 -1
  17. package/dist/shared/{rationalCubic2d-DaFTrUXw.mjs → rationalCubic2d-3S5K69Jy.mjs} +7 -7
  18. package/dist/shared/{rationalCubic2d-DaFTrUXw.mjs.map → rationalCubic2d-3S5K69Jy.mjs.map} +1 -1
  19. package/dist/shared/{rationalCubic2d-BZvT9s5N.mjs → rationalCubic2d-CJY-feGw.mjs} +5 -5
  20. package/dist/shared/{rationalCubic2d-BZvT9s5N.mjs.map → rationalCubic2d-CJY-feGw.mjs.map} +1 -1
  21. package/dist/shared/{vector2-CWU3cPB2.mjs → vector2-CSkaMXvp.mjs} +10 -2
  22. package/dist/shared/vector2-CSkaMXvp.mjs.map +1 -0
  23. package/dist/shared/{vector2.internal-BL8hFl1c.mjs → vector2.internal-DP1nTBdS.mjs} +17 -2
  24. package/dist/shared/{vector2.internal-BL8hFl1c.mjs.map → vector2.internal-DP1nTBdS.mjs.map} +1 -1
  25. package/dist/shared/{vector3-DmMm6pX8.mjs → vector3-CR2LPV03.mjs} +14 -2
  26. package/dist/shared/vector3-CR2LPV03.mjs.map +1 -0
  27. package/dist/shared/{vector4-oqPPp45j.mjs → vector4-PO_7EYd-.mjs} +54 -2
  28. package/dist/shared/{vector4-oqPPp45j.mjs.map → vector4-PO_7EYd-.mjs.map} +1 -1
  29. package/dist/shared/{vector4.internal-BnnTjVIr.mjs → vector4.internal-BJ1QN2Ck.mjs} +55 -15
  30. package/dist/shared/vector4.internal-BJ1QN2Ck.mjs.map +1 -0
  31. package/dist/splines/index.mjs +7 -7
  32. package/dist/vector/index.mjs +3 -3
  33. package/dist/vector/vector2.d.ts +80 -0
  34. package/dist/vector/vector3.d.ts +120 -0
  35. package/dist/vector/vector4.d.ts +184 -0
  36. package/package.json +1 -1
  37. package/dist/shared/vector2-CWU3cPB2.mjs.map +0 -1
  38. package/dist/shared/vector3-DmMm6pX8.mjs.map +0 -1
  39. package/dist/shared/vector4.internal-BnnTjVIr.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"matrix4x4-qyRufxfs.mjs","names":["equals","make","fromRows","fromColumns","setRow","toRows","setColumn","toColumns","determinant","vectorProductLeft","vector2.make","vector2.dot","rowVector","vectorProductRight","columnVector","solveSystem","transpose","reverseRows","reverseColumns","equals","make","fromRows","fromColumns","setRow","toRows","setColumn","toColumns","determinant","matrix2x2.determinant","minor","vector3.components","matrix2x2.make","vectorProductLeft","vector3.make","vector3.dot","vectorProductRight","solveSystem","rowVector","columnVector","transpose","reverseRows","reverseColumns","isMatrix4x4","equals","identity","make","fromRows","fromColumns","setRow","toRows","setColumn","toColumns","determinant","matrix3x3.determinant","minor","vector4.components","matrix3x3.make","vectorProductLeft","vector4.make","vector4.dot","vectorProductRight","multiply","inverse","solveSystem","rowVector","columnVector","transpose","reverseRows","reverseColumns","internal.isMatrix4x4","internal.identity","internal.equals","internal.make","internal.fromRows","internal.fromColumns","internal.setRow","internal.setColumn","internal.determinant","internal.minor","internal.vectorProductLeft","internal.vectorProductRight","internal.multiply","internal.inverse","internal.solveSystem","internal.toRows","internal.toColumns","internal.rowVector","internal.columnVector","internal.transpose","internal.reverseRows","internal.reverseColumns"],"sources":["../../src/dimensions.ts","../../src/matrix/matrix2x2.internal.ts","../../src/matrix/matrix3x3.internal.ts","../../src/matrix/matrix4x4.internal.ts","../../src/matrix/matrix4x4.ts"],"sourcesContent":["import { invariant } from './utils.ts'\n\nexport type TwoDimensionalIndex = 0 | 1\nexport type TwoDimensionalComponent = 'x' | 'y'\n\nexport interface TwoDimensional<out T1, out T2 = T1> {\n readonly x: T1\n readonly y: T2\n\n readonly 0: T1\n readonly 1: T2\n}\n\nexport type ThreeDimensionalIndex = TwoDimensionalIndex | 2\nexport type ThreeDimensionalComponent = TwoDimensionalComponent | 'z'\n\nexport interface ThreeDimensional<out T1, out T2 = T1, out T3 = T2> extends TwoDimensional<T1, T2> {\n readonly z: T3\n readonly 2: T3\n}\n\nexport type FourDimensionalIndex = ThreeDimensionalIndex | 3\nexport type FourDimensionalComponent = ThreeDimensionalComponent | 'w'\n\nexport interface FourDimensional<\n out T1,\n out T2 = T1,\n out T3 = T2,\n out T4 = T3,\n> extends ThreeDimensional<T1, T2, T3> {\n readonly w: T4\n readonly 3: T4\n}\n\nfunction toIndex(input: string | number): number {\n if (typeof input === 'number') {\n invariant(input >= 0 && input <= 3, 'Index out of bounds')\n\n return input\n }\n\n if (input === 'x') {\n return 0\n }\n\n if (input === 'y') {\n return 1\n }\n\n if (input === 'z') {\n return 2\n }\n\n if (input === 'w') {\n return 3\n }\n\n invariant(false, 'Invalid component')\n}\n\nexport const toTwoDimensionalIndex = toIndex as (\n input: TwoDimensionalIndex | TwoDimensionalComponent,\n) => TwoDimensionalIndex\nexport const toThreeDimensionalIndex = toIndex as (\n input: ThreeDimensionalIndex | ThreeDimensionalComponent,\n) => ThreeDimensionalIndex\nexport const toFourDimensionalIndex = toIndex as (\n input: FourDimensionalIndex | FourDimensionalComponent,\n) => FourDimensionalIndex\n","import { toTwoDimensionalIndex } from '../dimensions.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport * as vector2 from '../vector/vector2.internal.ts'\nimport type { Matrix2x2, Matrix2x2Coordinate } from './matrix2x2.ts'\n\nexport const Matrix2x2TypeId: unique symbol = Symbol.for('curvy/matrix2x2')\nexport type Matrix2x2TypeId = typeof Matrix2x2TypeId\n\nclass Matrix2x2Impl extends Pipeable implements Matrix2x2 {\n readonly [Matrix2x2TypeId]: Matrix2x2TypeId = Matrix2x2TypeId\n\n readonly m00: number\n readonly m01: number\n\n readonly m10: number\n readonly m11: number\n\n constructor(m00 = 0, m01 = 0, m10 = 0, m11 = 0) {\n super()\n this.m00 = m00\n this.m01 = m01\n this.m10 = m10\n this.m11 = m11\n }\n\n get [Symbol.toStringTag]() {\n return `Matrix2x2(${this.m00}, ${this.m01}, ${this.m10}, ${this.m11})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return `Matrix2x2(${this.m00}, ${this.m01}, ${this.m10}, ${this.m11})`\n }\n\n [Symbol.hasInstance](m: unknown): m is Matrix2x2 {\n return isMatrix2x2(m)\n }\n}\n\n/** @internal */\nexport const isMatrix2x2 = (m: unknown): m is Matrix2x2 =>\n typeof m === 'object' && m !== null && Matrix2x2TypeId in m\n\n/** @internal */\nexport const equals = dual<\n (b: Matrix2x2) => (a: Matrix2x2) => boolean,\n (a: Matrix2x2, b: Matrix2x2) => boolean\n>(\n 2,\n (a: Matrix2x2, b: Matrix2x2) =>\n epsEquals(a.m00, b.m00) &&\n epsEquals(a.m01, b.m01) &&\n epsEquals(a.m10, b.m10) &&\n epsEquals(a.m11, b.m11),\n)\n\n/** @internal */\nexport const make = (m00 = 0, m01 = m00, m10 = m01, m11 = m10) =>\n new Matrix2x2Impl(m00, m01, m10, m11)\n\n/** @internal */\nexport const fromRows = (v0: Vector2, v1: Vector2) => new Matrix2x2Impl(v0.x, v0.y, v1.x, v1.y)\n\n/** @internal */\nexport const fromColumns = (v0: Vector2, v1: Vector2) => new Matrix2x2Impl(v0.x, v1.x, v0.y, v1.y)\n\n/** @internal */\nexport const setRow = dual<\n (row: Matrix2x2Coordinate, v: Vector2) => (m: Matrix2x2) => Matrix2x2,\n (m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2) => Matrix2x2\n>(3, (m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2) =>\n fromRows(...(toRows(m).with(toTwoDimensionalIndex(row), v) as [Vector2, Vector2])),\n)\n\n/** @internal */\nexport const setColumn = dual<\n (column: Matrix2x2Coordinate, v: Vector2) => (m: Matrix2x2) => Matrix2x2,\n (m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2) => Matrix2x2\n>(3, (m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2) =>\n fromColumns(...(toColumns(m).with(toTwoDimensionalIndex(column), v) as [Vector2, Vector2])),\n)\n\n/** @internal */\nexport const determinant = (m: Matrix2x2): number => m.m00 * m.m11 - m.m01 * m.m10\n\n// (a: Vector2, b: Vector2) => a.x * b.x + a.y * b.y\n\n/*\n * {\n * x: first row dot v -> fr.x\n * y: second row dot v\n * }\n * */\n\n/** @internal */\nexport const vectorProductLeft = dual<\n (v: Vector2) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, v: Vector2) => Vector2\n>(2, (m: Matrix2x2, v: Vector2) =>\n vector2.make(vector2.dot(rowVector(m, 0), v), vector2.dot(rowVector(m, 1), v)),\n)\n\n/** @internal */\nexport const vectorProductRight = dual<\n (v: Vector2) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, v: Vector2) => Vector2\n>(2, (m: Matrix2x2, v: Vector2) =>\n vector2.make(vector2.dot(columnVector(m, 0), v), vector2.dot(columnVector(m, 1), v)),\n)\n\n/** @internal */\nexport const solveSystem = dual<\n (v: Vector2) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, v: Vector2) => Vector2\n>(2, (m: Matrix2x2, v: Vector2) => {\n const inverseDeterminant = 1 / determinant(m)\n\n invariant(\n Number.isFinite(inverseDeterminant),\n 'cannot solve system when coefficient matrix determinant is zero',\n )\n\n return vector2.make(\n determinant(setColumn(m, 0, v)) * inverseDeterminant,\n determinant(setColumn(m, 1, v)) * inverseDeterminant,\n )\n})\n\n/** @internal */\nexport const toRows = (m: Matrix2x2): [Vector2, Vector2] => [\n vector2.make(m.m00, m.m01),\n vector2.make(m.m10, m.m11),\n]\n\n/** @internal */\nexport const toColumns = (m: Matrix2x2): [Vector2, Vector2] => [\n vector2.make(m.m00, m.m10),\n vector2.make(m.m01, m.m11),\n]\n\n/** @internal */\nexport const rowVector = dual<\n (row: Matrix2x2Coordinate) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, row: Matrix2x2Coordinate) => Vector2\n>(2, (m: Matrix2x2, row: Matrix2x2Coordinate) => toRows(m)[toTwoDimensionalIndex(row)])\n\n/** @internal */\nexport const columnVector = dual<\n (column: Matrix2x2Coordinate) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, column: Matrix2x2Coordinate) => Vector2\n>(2, (m: Matrix2x2, column: Matrix2x2Coordinate) => toColumns(m)[toTwoDimensionalIndex(column)])\n\n/** @internal */\nexport const transpose = (m: Matrix2x2) => fromColumns(...toRows(m))\n\n/** @internal */\nexport const reverseRows = (m: Matrix2x2) => {\n const [r0, r1] = toRows(m)\n return fromRows(r1, r0)\n}\n\n/** @internal */\nexport const reverseColumns = (m: Matrix2x2) => {\n const [c0, c1] = toColumns(m)\n return fromColumns(c1, c0)\n}\n","import { toThreeDimensionalIndex } from '../dimensions.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport * as vector3 from '../vector/vector3.internal.ts'\nimport type { Matrix2x2 } from './matrix2x2.ts'\nimport * as matrix2x2 from './matrix2x2.internal.ts'\nimport type { Matrix3x3, Matrix3x3Coordinate } from './matrix3x3.ts'\n\nexport const Matrix3x3TypeId: unique symbol = Symbol.for('curvy/matrix3x3')\nexport type Matrix3x3TypeId = typeof Matrix3x3TypeId\n\nclass Matrix3x3Impl extends Pipeable implements Matrix3x3 {\n readonly [Matrix3x3TypeId]: Matrix3x3TypeId = Matrix3x3TypeId\n\n readonly m00: number\n readonly m01: number\n readonly m02: number\n\n readonly m10: number\n readonly m11: number\n readonly m12: number\n\n readonly m20: number\n readonly m21: number\n readonly m22: number\n\n constructor(m00 = 0, m01 = 0, m02 = 0, m10 = 0, m11 = 0, m12 = 0, m20 = 0, m21 = 0, m22 = 0) {\n super()\n this.m00 = m00\n this.m01 = m01\n this.m02 = m02\n this.m10 = m10\n this.m11 = m11\n this.m12 = m12\n this.m20 = m20\n this.m21 = m21\n this.m22 = m22\n }\n\n get [Symbol.toStringTag]() {\n return `Matrix3x3(${this.m00}, ${this.m01}, ${this.m02}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m20}, ${this.m21}, ${this.m22})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return `Matrix3x3(${this.m00}, ${this.m01}, ${this.m02}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m20}, ${this.m21}, ${this.m22})`\n }\n\n [Symbol.hasInstance](m: unknown): m is Matrix3x3 {\n return isMatrix3x3(m)\n }\n}\n\nexport type { Matrix3x3 }\n\n/** @internal */\nexport const isMatrix3x3 = (m: unknown): m is Matrix3x3 =>\n typeof m === 'object' && m !== null && Matrix3x3TypeId in m\n\n/** @internal */\nexport const equals = dual<\n (b: Matrix3x3) => (a: Matrix3x3) => boolean,\n (a: Matrix3x3, b: Matrix3x3) => boolean\n>(\n 2,\n (a: Matrix3x3, b: Matrix3x3) =>\n epsEquals(a.m00, b.m00) &&\n epsEquals(a.m01, b.m01) &&\n epsEquals(a.m02, b.m02) &&\n epsEquals(a.m10, b.m10) &&\n epsEquals(a.m11, b.m11) &&\n epsEquals(a.m12, b.m12) &&\n epsEquals(a.m20, b.m20) &&\n epsEquals(a.m21, b.m21) &&\n epsEquals(a.m22, b.m22),\n)\n\n/** @internal */\nexport const make = (\n m00 = 0,\n m01 = m00,\n m02 = m01,\n m10 = m02,\n m11 = m10,\n m12 = m11,\n m20 = m12,\n m21 = m20,\n m22 = m21,\n): Matrix3x3 => {\n return new Matrix3x3Impl(m00, m01, m02, m10, m11, m12, m20, m21, m22)\n}\n\n/** @internal */\nexport const fromRows = (v0: Vector3, v1: Vector3, v2: Vector3): Matrix3x3 =>\n new Matrix3x3Impl(v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z)\n\n/** @internal */\nexport const fromColumns = (v0: Vector3, v1: Vector3, v2: Vector3): Matrix3x3 =>\n new Matrix3x3Impl(v0.x, v1.x, v2.x, v0.y, v1.y, v2.y, v0.z, v1.z, v2.z)\n\n/** @internal */\nexport const setRow = dual<\n (row: Matrix3x3Coordinate, v: Vector3) => (m: Matrix3x3) => Matrix3x3,\n (m: Matrix3x3, row: Matrix3x3Coordinate, v: Vector3) => Matrix3x3\n>(3, (m: Matrix3x3, row: Matrix3x3Coordinate, v: Vector3) =>\n fromRows(...(toRows(m).with(toThreeDimensionalIndex(row), v) as [Vector3, Vector3, Vector3])),\n)\n\n/** @internal */\nexport const setColumn = dual<\n (column: Matrix3x3Coordinate, v: Vector3) => (m: Matrix3x3) => Matrix3x3,\n (m: Matrix3x3, column: Matrix3x3Coordinate, v: Vector3) => Matrix3x3\n>(3, (m: Matrix3x3, column: Matrix3x3Coordinate, v: Vector3) =>\n fromColumns(\n ...(toColumns(m).with(toThreeDimensionalIndex(column), v) as [Vector3, Vector3, Vector3]),\n ),\n)\n\n/** @internal */\nexport const determinant = (m: Matrix3x3) =>\n m.m00 * matrix2x2.determinant(minor(m, 0, 0)) -\n m.m01 * matrix2x2.determinant(minor(m, 0, 1)) +\n m.m02 * matrix2x2.determinant(minor(m, 0, 2))\n\n/** @internal */\nexport const minor = dual<\n (row: Matrix3x3Coordinate, column: Matrix3x3Coordinate) => (m: Matrix3x3) => Matrix2x2,\n (m: Matrix3x3, row: Matrix3x3Coordinate, column: Matrix3x3Coordinate) => Matrix2x2\n>(3, (m: Matrix3x3, row: Matrix3x3Coordinate, column: Matrix3x3Coordinate) => {\n const [v0, v1] = toRows(m).toSpliced(toThreeDimensionalIndex(row), 1) as [Vector3, Vector3]\n const columnIndex = toThreeDimensionalIndex(column)\n const [m00, m01] = vector3.components(v0).toSpliced(columnIndex, 1) as [number, number]\n const [m10, m11] = vector3.components(v1).toSpliced(columnIndex, 1) as [number, number]\n\n return matrix2x2.make(m00, m01, m10, m11) as Matrix2x2\n})\n\n/** @internal */\nexport const vectorProductLeft = dual<\n (v: Vector3) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, v: Vector3) => Vector3\n>(2, (m: Matrix3x3, v: Vector3) => {\n const [v0, v1, v2] = toRows(m) as [Vector3, Vector3, Vector3]\n return vector3.make(vector3.dot(v0, v), vector3.dot(v1, v), vector3.dot(v2, v))\n})\n\n/** @internal */\nexport const vectorProductRight = dual<\n (v: Vector3) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, v: Vector3) => Vector3\n>(2, (m: Matrix3x3, v: Vector3) => {\n const [v0, v1, v2] = toColumns(m) as [Vector3, Vector3, Vector3]\n return vector3.make(vector3.dot(v, v0), vector3.dot(v, v1), vector3.dot(v, v2))\n})\n\n/** @internal */\nexport const solveSystem = dual<\n (v: Vector3) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, v: Vector3) => Vector3\n>(2, (m: Matrix3x3, v: Vector3) => {\n const inverseDeterminant = 1 / determinant(m)\n\n invariant(\n Number.isFinite(inverseDeterminant),\n 'cannot solve system when coefficient matrix determinant is zero',\n )\n\n return vector3.make(\n determinant(setColumn(m, 0, v)) * inverseDeterminant,\n determinant(setColumn(m, 1, v)) * inverseDeterminant,\n determinant(setColumn(m, 2, v)) * inverseDeterminant,\n )\n})\n\n/** @internal */\nexport const toRows = (m: Matrix3x3): [Vector3, Vector3, Vector3] => [\n vector3.make(m.m00, m.m01, m.m02),\n vector3.make(m.m10, m.m11, m.m12),\n vector3.make(m.m20, m.m21, m.m22),\n]\n\n/** @internal */\nexport const toColumns = (m: Matrix3x3): [Vector3, Vector3, Vector3] => [\n vector3.make(m.m00, m.m10, m.m20),\n vector3.make(m.m01, m.m11, m.m21),\n vector3.make(m.m02, m.m12, m.m22),\n]\n\n/** @internal */\nexport const rowVector = dual<\n (row: Matrix3x3Coordinate) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, row: Matrix3x3Coordinate) => Vector3\n>(2, (m: Matrix3x3, row: Matrix3x3Coordinate) => toRows(m)[toThreeDimensionalIndex(row)])\n\n/** @internal */\nexport const columnVector = dual<\n (column: Matrix3x3Coordinate) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, column: Matrix3x3Coordinate) => Vector3\n>(2, (m: Matrix3x3, column: Matrix3x3Coordinate) => toColumns(m)[toThreeDimensionalIndex(column)])\n\n/** @internal */\nexport const transpose = (m: Matrix3x3) => fromColumns(...toRows(m))\n\n/** @internal */\nexport const reverseRows = (m: Matrix3x3) => {\n const [v0, v1, v2] = toRows(m)\n return fromRows(v2, v1, v0)\n}\n\n/** @internal */\nexport const reverseColumns = (m: Matrix3x3) => {\n const [v0, v1, v2] = toColumns(m)\n return fromColumns(v2, v1, v0)\n}\n","import { toFourDimensionalIndex } from '../dimensions.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport type { Vector4 } from '../vector/vector4.ts'\nimport * as vector4 from '../vector/vector4.internal.ts'\nimport type { Matrix3x3 } from './matrix3x3.ts'\nimport * as matrix3x3 from './matrix3x3.internal.ts'\nimport type { Matrix4x4, Matrix4x4Coordinate } from './matrix4x4.ts'\n\nexport const Matrix4x4TypeId: unique symbol = Symbol.for('curvy/matrix4x4')\nexport type Matrix4x4TypeId = typeof Matrix4x4TypeId\n\nclass Matrix4x4Impl extends Pipeable implements Matrix4x4 {\n readonly [Matrix4x4TypeId]: Matrix4x4TypeId = Matrix4x4TypeId\n\n readonly m00: number\n readonly m01: number\n readonly m02: number\n readonly m03: number\n\n readonly m10: number\n readonly m11: number\n readonly m12: number\n readonly m13: number\n\n readonly m20: number\n readonly m21: number\n readonly m22: number\n readonly m23: number\n\n readonly m30: number\n readonly m31: number\n readonly m32: number\n readonly m33: number\n\n constructor(\n m00 = 0,\n m01 = m00,\n m02 = m01,\n m03 = m02,\n m10 = m00,\n m11 = m01,\n m12 = m02,\n m13 = m03,\n m20 = m00,\n m21 = m01,\n m22 = m02,\n m23 = m03,\n m30 = m00,\n m31 = m01,\n m32 = m02,\n m33 = m03,\n ) {\n super()\n\n this.m00 = m00\n this.m01 = m01\n this.m02 = m02\n this.m03 = m03\n this.m10 = m10\n this.m11 = m11\n this.m12 = m12\n this.m13 = m13\n this.m20 = m20\n this.m21 = m21\n this.m22 = m22\n this.m23 = m23\n this.m30 = m30\n this.m31 = m31\n this.m32 = m32\n this.m33 = m33\n }\n\n get [Symbol.toStringTag]() {\n return `Matrix4x4(${this.m00}, ${this.m01}, ${this.m02}, ${this.m03}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m13}, ${this.m20}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m30}, ${this.m31}, ${this.m32}, ${this.m33})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return `Matrix4x4(${this.m00}, ${this.m01}, ${this.m02}, ${this.m03}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m13}, ${this.m20}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m30}, ${this.m31}, ${this.m32}, ${this.m33})`\n }\n\n [Symbol.hasInstance](m: unknown): m is Matrix4x4 {\n return isMatrix4x4(m)\n }\n}\n\n/** @internal */\nexport const isMatrix4x4 = (m: unknown): m is Matrix4x4 =>\n typeof m === 'object' && m !== null && Matrix4x4TypeId in m\n\n/** @internal */\nexport const equals = dual<\n (b: Matrix4x4) => (a: Matrix4x4) => boolean,\n (a: Matrix4x4, b: Matrix4x4) => boolean\n>(\n 2,\n (a: Matrix4x4, b: Matrix4x4) =>\n epsEquals(a.m00, b.m00) &&\n epsEquals(a.m01, b.m01) &&\n epsEquals(a.m02, b.m02) &&\n epsEquals(a.m03, b.m03) &&\n epsEquals(a.m10, b.m10) &&\n epsEquals(a.m11, b.m11) &&\n epsEquals(a.m12, b.m12) &&\n epsEquals(a.m13, b.m13) &&\n epsEquals(a.m20, b.m20) &&\n epsEquals(a.m21, b.m21) &&\n epsEquals(a.m22, b.m22) &&\n epsEquals(a.m23, b.m23) &&\n epsEquals(a.m30, b.m30) &&\n epsEquals(a.m31, b.m31) &&\n epsEquals(a.m32, b.m32) &&\n epsEquals(a.m33, b.m33),\n)\n\n/**\n * The 4x4 identity matrix.\n * @internal\n */\nexport const identity: Matrix4x4 = new Matrix4x4Impl(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)\n\n// first four arguments are the top row\n/** @internal */\nexport const make = (\n m00 = 0,\n m01 = m00,\n m02 = m01,\n m03 = m02,\n m10 = m00,\n m11 = m01,\n m12 = m02,\n m13 = m03,\n m20 = m00,\n m21 = m01,\n m22 = m02,\n m23 = m03,\n m30 = m00,\n m31 = m01,\n m32 = m02,\n m33 = m03,\n) =>\n new Matrix4x4Impl(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)\n\n/** @internal */\nexport const fromRows = (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) =>\n new Matrix4x4Impl(\n v0.x,\n v0.y,\n v0.z,\n v0.w,\n v1.x,\n v1.y,\n v1.z,\n v1.w,\n v2.x,\n v2.y,\n v2.z,\n v2.w,\n v3.x,\n v3.y,\n v3.z,\n v3.w,\n )\n\n/** @internal */\nexport const fromColumns = (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) =>\n new Matrix4x4Impl(\n v0.x,\n v1.x,\n v2.x,\n v3.x,\n v0.y,\n v1.y,\n v2.y,\n v3.y,\n v0.z,\n v1.z,\n v2.z,\n v3.z,\n v0.w,\n v1.w,\n v2.w,\n v3.w,\n )\n\n/** @internal */\nexport const setRow = dual<\n (row: Matrix4x4Coordinate, v: Vector4) => (m: Matrix4x4) => Matrix4x4,\n (m: Matrix4x4, row: Matrix4x4Coordinate, v: Vector4) => Matrix4x4\n>(3, (m: Matrix4x4, row: Matrix4x4Coordinate, v: Vector4) =>\n fromRows(\n ...(toRows(m).with(toFourDimensionalIndex(row), v) as [Vector4, Vector4, Vector4, Vector4]),\n ),\n)\n\n/** @internal */\nexport const setColumn = dual<\n (column: Matrix4x4Coordinate, v: Vector4) => (m: Matrix4x4) => Matrix4x4,\n (m: Matrix4x4, column: Matrix4x4Coordinate, v: Vector4) => Matrix4x4\n>(3, (m: Matrix4x4, column: Matrix4x4Coordinate, v: Vector4) =>\n fromColumns(\n ...(toColumns(m).with(toFourDimensionalIndex(column), v) as [\n Vector4,\n Vector4,\n Vector4,\n Vector4,\n ]),\n ),\n)\n\n/** @internal */\nexport const determinant = (m: Matrix4x4) =>\n m.m00 * matrix3x3.determinant(minor(m, 0, 0)) -\n m.m01 * matrix3x3.determinant(minor(m, 0, 1)) +\n m.m02 * matrix3x3.determinant(minor(m, 0, 2)) -\n m.m03 * matrix3x3.determinant(minor(m, 0, 3))\n\n/** @internal */\nexport const minor = dual<\n (row: Matrix4x4Coordinate, column: Matrix4x4Coordinate) => (m: Matrix4x4) => Matrix3x3,\n (m: Matrix4x4, row: Matrix4x4Coordinate, column: Matrix4x4Coordinate) => Matrix3x3\n>(3, (m: Matrix4x4, row: Matrix4x4Coordinate, column: Matrix4x4Coordinate) => {\n const [v0, v1, v2] = toRows(m).toSpliced(toFourDimensionalIndex(row), 1) as [\n Vector4,\n Vector4,\n Vector4,\n ]\n const columnIndex = toFourDimensionalIndex(column)\n const [m00, m01, m02] = vector4.components(v0).toSpliced(columnIndex, 1) as [\n number,\n number,\n number,\n ]\n const [m10, m11, m12] = vector4.components(v1).toSpliced(columnIndex, 1) as [\n number,\n number,\n number,\n ]\n const [m20, m21, m22] = vector4.components(v2).toSpliced(columnIndex, 1) as [\n number,\n number,\n number,\n ]\n\n return matrix3x3.make(m00, m01, m02, m10, m11, m12, m20, m21, m22)\n})\n\n/** @internal */\nexport const vectorProductLeft = dual<\n (v: Vector4) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, v: Vector4) => Vector4\n>(2, (m: Matrix4x4, v: Vector4) => {\n const [v0, v1, v2, v3] = toRows(m) as [Vector4, Vector4, Vector4, Vector4]\n return vector4.make(\n vector4.dot(v0, v),\n vector4.dot(v1, v),\n vector4.dot(v2, v),\n vector4.dot(v3, v),\n )\n})\n\n/** @internal */\nexport const vectorProductRight = dual<\n (v: Vector4) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, v: Vector4) => Vector4\n>(2, (m: Matrix4x4, v: Vector4) => {\n const [v0, v1, v2, v3] = toColumns(m) as [Vector4, Vector4, Vector4, Vector4]\n\n return vector4.make(\n vector4.dot(v, v0),\n vector4.dot(v, v1),\n vector4.dot(v, v2),\n vector4.dot(v, v3),\n )\n})\n\n/** @internal */\nexport const multiply = dual<\n (b: Matrix4x4) => (a: Matrix4x4) => Matrix4x4,\n (a: Matrix4x4, b: Matrix4x4) => Matrix4x4\n>(\n 2,\n (a: Matrix4x4, b: Matrix4x4) =>\n new Matrix4x4Impl(\n a.m00 * b.m00 + a.m01 * b.m10 + a.m02 * b.m20 + a.m03 * b.m30,\n a.m00 * b.m01 + a.m01 * b.m11 + a.m02 * b.m21 + a.m03 * b.m31,\n a.m00 * b.m02 + a.m01 * b.m12 + a.m02 * b.m22 + a.m03 * b.m32,\n a.m00 * b.m03 + a.m01 * b.m13 + a.m02 * b.m23 + a.m03 * b.m33,\n a.m10 * b.m00 + a.m11 * b.m10 + a.m12 * b.m20 + a.m13 * b.m30,\n a.m10 * b.m01 + a.m11 * b.m11 + a.m12 * b.m21 + a.m13 * b.m31,\n a.m10 * b.m02 + a.m11 * b.m12 + a.m12 * b.m22 + a.m13 * b.m32,\n a.m10 * b.m03 + a.m11 * b.m13 + a.m12 * b.m23 + a.m13 * b.m33,\n a.m20 * b.m00 + a.m21 * b.m10 + a.m22 * b.m20 + a.m23 * b.m30,\n a.m20 * b.m01 + a.m21 * b.m11 + a.m22 * b.m21 + a.m23 * b.m31,\n a.m20 * b.m02 + a.m21 * b.m12 + a.m22 * b.m22 + a.m23 * b.m32,\n a.m20 * b.m03 + a.m21 * b.m13 + a.m22 * b.m23 + a.m23 * b.m33,\n a.m30 * b.m00 + a.m31 * b.m10 + a.m32 * b.m20 + a.m33 * b.m30,\n a.m30 * b.m01 + a.m31 * b.m11 + a.m32 * b.m21 + a.m33 * b.m31,\n a.m30 * b.m02 + a.m31 * b.m12 + a.m32 * b.m22 + a.m33 * b.m32,\n a.m30 * b.m03 + a.m31 * b.m13 + a.m32 * b.m23 + a.m33 * b.m33,\n ),\n)\n\n/** @internal */\nexport const inverse = (m: Matrix4x4): Matrix4x4 => {\n const det = determinant(m)\n invariant(det !== 0, 'cannot invert singular matrix')\n\n const inv = 1 / det\n // adjugate is the transpose of the cofactor matrix\n const cof = (row: Matrix4x4Coordinate, col: Matrix4x4Coordinate) => {\n const sign = ((row as number) + (col as number)) % 2 === 0 ? 1 : -1\n return sign * matrix3x3.determinant(minor(m, row, col)) * inv\n }\n\n return new Matrix4x4Impl(\n cof(0, 0),\n cof(1, 0),\n cof(2, 0),\n cof(3, 0),\n cof(0, 1),\n cof(1, 1),\n cof(2, 1),\n cof(3, 1),\n cof(0, 2),\n cof(1, 2),\n cof(2, 2),\n cof(3, 2),\n cof(0, 3),\n cof(1, 3),\n cof(2, 3),\n cof(3, 3),\n )\n}\n\n/** @internal */\nexport const solveSystem = dual<\n (v: Vector4) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, v: Vector4) => Vector4\n>(2, (m: Matrix4x4, v: Vector4) => {\n const inverseDeterminant = 1 / determinant(m)\n\n invariant(\n Number.isFinite(inverseDeterminant),\n 'cannot solve system when coefficient matrix determinant is zero',\n )\n\n return vector4.make(\n determinant(setColumn(m, 0, v)) * inverseDeterminant,\n determinant(setColumn(m, 1, v)) * inverseDeterminant,\n determinant(setColumn(m, 2, v)) * inverseDeterminant,\n determinant(setColumn(m, 3, v)) * inverseDeterminant,\n )\n})\n\n/** @internal */\nexport const toRows = (m: Matrix4x4) =>\n [\n vector4.make(m.m00, m.m01, m.m02, m.m03),\n vector4.make(m.m10, m.m11, m.m12, m.m13),\n vector4.make(m.m20, m.m21, m.m22, m.m23),\n vector4.make(m.m30, m.m31, m.m32, m.m33),\n ] as const\n\n/** @internal */\nexport const toColumns = (m: Matrix4x4) =>\n [\n vector4.make(m.m00, m.m10, m.m20, m.m30),\n vector4.make(m.m01, m.m11, m.m21, m.m31),\n vector4.make(m.m02, m.m12, m.m22, m.m32),\n vector4.make(m.m03, m.m13, m.m23, m.m33),\n ] as const\n\n/** @internal */\nexport const rowVector = dual<\n (row: Matrix4x4Coordinate) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, row: Matrix4x4Coordinate) => Vector4\n>(2, (m: Matrix4x4, row: Matrix4x4Coordinate) => toRows(m)[toFourDimensionalIndex(row)])\n\n/** @internal */\nexport const columnVector = dual<\n (column: Matrix4x4Coordinate) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, column: Matrix4x4Coordinate) => Vector4\n>(2, (m: Matrix4x4, column: Matrix4x4Coordinate) => toColumns(m)[toFourDimensionalIndex(column)])\n\n/** @internal */\nexport const transpose = (m: Matrix4x4) => fromColumns(...toRows(m)) as Matrix4x4\n\n/** @internal */\nexport const reverseRows = (m: Matrix4x4) => {\n const [v0, v1, v2, v3] = toRows(m) as [Vector4, Vector4, Vector4, Vector4]\n return fromRows(v3, v2, v1, v0)\n}\n\n/** @internal */\nexport const reverseColumns = (m: Matrix4x4) => {\n const [v0, v1, v2, v3] = toColumns(m) as [Vector4, Vector4, Vector4, Vector4]\n return fromColumns(v3, v2, v1, v0)\n}\n","import type { FourDimensionalComponent, FourDimensionalIndex } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector4 } from '../vector/vector4.ts'\nimport type { Matrix3x3 } from './matrix3x3.ts'\nimport type { Matrix4x4TypeId } from './matrix4x4.internal.ts'\nimport * as internal from './matrix4x4.internal.ts'\n\n/**\n * A coordinate in a 4x4 matrix.\n *\n * @since 1.0.0\n */\nexport type Matrix4x4Coordinate = FourDimensionalIndex | FourDimensionalComponent\n\n/**\n * A 4x4 matrix.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Matrix4x4 extends Pipeable {\n readonly [Matrix4x4TypeId]: Matrix4x4TypeId\n\n /**\n * The value of the first row and first column.\n */\n readonly m00: number\n /**\n * The value of the first row and second column.\n */\n readonly m01: number\n /**\n * The value of the first row and third column.\n */\n readonly m02: number\n /**\n * The value of the first row and fourth column.\n */\n readonly m03: number\n /**\n * The value of the second row and first column.\n */\n readonly m10: number\n /**\n * The value of the second row and second column.\n */\n readonly m11: number\n /**\n * The value of the second row and third column.\n */\n readonly m12: number\n /**\n * The value of the second row and fourth column.\n */\n readonly m13: number\n /**\n * The value of the third row and first column.\n */\n readonly m20: number\n /**\n * The value of the third row and second column.\n */\n readonly m21: number\n /**\n * The value of the third row and third column.\n */\n readonly m22: number\n /**\n * The value of the third row and fourth column.\n */\n readonly m23: number\n /**\n * The value of the fourth row and first column.\n */\n readonly m30: number\n /**\n * The value of the fourth row and second column.\n */\n readonly m31: number\n /**\n * The value of the fourth row and third column.\n */\n readonly m32: number\n /**\n * The value of the fourth row and fourth column.\n */\n readonly m33: number\n}\n\n/**\n * Checks if a value is a `Matrix4x4`.\n *\n * @param m - The value to check.\n * @returns `true` if the value is a `Matrix4x4`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isMatrix4x4: (m: unknown) => m is Matrix4x4 = internal.isMatrix4x4\n\n/**\n * The 4x4 identity matrix.\n *\n * @since 1.1.0\n */\nexport const identity: Matrix4x4 = internal.identity\n\nexport const equals: {\n /**\n * Checks if two `Matrix4x4` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first matrix.\n * @param b - The second matrix.\n * @returns `true` when each pair of components is within tolerance.\n * @since 1.1.0\n */\n (a: Matrix4x4, b: Matrix4x4): boolean\n /**\n * Checks if two `Matrix4x4` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second matrix.\n * @returns A function that takes the first matrix and returns the comparison result.\n * @since 1.1.0\n */\n (b: Matrix4x4): (a: Matrix4x4) => boolean\n} = internal.equals\n\n/**\n * Creates a new `Matrix4x4` instance.\n *\n * @param m00 - The value of the first row and first column.\n * @param m01 - The value of the first row and second column.\n * @param m02 - The value of the first row and third column.\n * @param m03 - The value of the first row and fourth column.\n * @param m10 - The value of the second row and first column.\n * @param m11 - The value of the second row and second column.\n * @param m12 - The value of the second row and third column.\n * @param m13 - The value of the second row and fourth column.\n * @param m20 - The value of the third row and first column.\n * @param m21 - The value of the third row and second column.\n * @param m22 - The value of the third row and third column.\n * @param m23 - The value of the third row and fourth column.\n * @param m30 - The value of the fourth row and first column.\n * @param m31 - The value of the fourth row and second column.\n * @param m32 - The value of the fourth row and third column.\n * @param m33 - The value of the fourth row and fourth column.\n * @returns A new `Matrix4x4` instance.\n * @since 1.0.0\n */\nexport const make: (\n m00?: number,\n m01?: number,\n m02?: number,\n m03?: number,\n m10?: number,\n m11?: number,\n m12?: number,\n m13?: number,\n m20?: number,\n m21?: number,\n m22?: number,\n m23?: number,\n m30?: number,\n m31?: number,\n m32?: number,\n m33?: number,\n) => Matrix4x4 = internal.make\n\n/**\n * Creates a new `Matrix4x4` instance from four row vectors.\n *\n * @param v0 - The first row vector.\n * @param v1 - The second row vector.\n * @param v2 - The third row vector.\n * @param v3 - The fourth row vector.\n * @returns A new `Matrix4x4` instance.\n * @since 1.0.0\n */\nexport const fromRows: (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) => Matrix4x4 =\n internal.fromRows\n\n/**\n * Creates a new `Matrix4x4` instance from four column vectors.\n *\n * @param v0 - The first column vector.\n * @param v1 - The second column vector.\n * @param v2 - The third column vector.\n * @param v3 - The fourth column vector.\n */\nexport const fromColumns: (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) => Matrix4x4 =\n internal.fromColumns\n\nexport const setRow: {\n /**\n * Sets a row of a `Matrix4x4` to a new vector.\n *\n * @param m - The matrix to modify.\n * @param row - The row to set.\n * @param v - The new vector.\n * @returns A new `Matrix4x4` instance with the specified row set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, row: Matrix4x4Coordinate, v: Vector4): Matrix4x4\n /**\n * Sets a row of a `Matrix4x4` to a new vector.\n *\n * @param row - The row to set.\n * @param v - The new vector.\n * @returns A function that takes a matrix and returns a new `Matrix4x4` instance with the specified row set to the new vector.\n * @since 1.0.0\n */\n (row: Matrix4x4Coordinate, v: Vector4): (m: Matrix4x4) => Matrix4x4\n} = internal.setRow\n\nexport const setColumn: {\n /**\n * Sets a column of a `Matrix4x4` to a new vector.\n *\n * @param m - The matrix to modify.\n * @param column - The column to set.\n * @param v - The new vector.\n * @returns A new `Matrix4x4` instance with the specified column set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, column: Matrix4x4Coordinate, v: Vector4): Matrix4x4\n /**\n * Sets a column of a `Matrix4x4` to a new vector.\n *\n * @param column - The column to set.\n * @param v - The new vector.\n * @returns A function that takes a matrix and returns a new `Matrix4x4` instance with the specified column set to the new vector.\n * @since 1.0.0\n */\n (column: Matrix4x4Coordinate, v: Vector4): (m: Matrix4x4) => Matrix4x4\n} = internal.setColumn\n\n/**\n * Calculates the determinant of a `Matrix4x4`.\n *\n * @param m - The matrix to calculate the determinant of.\n * @returns The determinant of the matrix.\n * @since 1.0.0\n */\nexport const determinant: (m: Matrix4x4) => number = internal.determinant\n\n/**\n * Calculates the minor of a `Matrix4x4` at a given row and column.\n *\n * @param m - The matrix to calculate the minor of.\n * @param row - The row to exclude.\n * @param column - The column to exclude.\n * @returns The minor of the matrix at the given row and column.\n */\nexport const minor: (\n m: Matrix4x4,\n row: Matrix4x4Coordinate,\n column: Matrix4x4Coordinate,\n) => Matrix3x3 = internal.minor\n\nexport const vectorProductLeft: {\n /**\n * Calculates the left vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 2 * 18 + 3 * 19 + 4 * 20\n * // y = 5 * 17 + 6 * 18 + 7 * 19 + 8 * 20\n * // z = 9 * 17 + 10 * 18 + 11 * 19 + 12 * 20\n * // w = 13 * 17 + 14 * 18 + 15 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductLeft(m, v)\n * ```\n * @param m - The matrix to multiply.\n * @param v - The vector to multiply.\n * @returns The resulting vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, v: Vector4): Vector4\n /**\n * Calculates the left vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 2 * 18 + 3 * 19 + 4 * 20\n * // y = 5 * 17 + 6 * 18 + 7 * 19 + 8 * 20\n * // z = 9 * 17 + 10 * 18 + 11 * 19 + 12 * 20\n * // w = 13 * 17 + 14 * 18 + 15 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductLeft(v)(m)\n * ```\n * @since 1.0.0\n */\n (v: Vector4): (m: Matrix4x4) => Vector4\n} = internal.vectorProductLeft\n\nexport const vectorProductRight: {\n /**\n * Calculates the right vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 5 * 18 + 9 * 19 + 13 * 20\n * // y = 2 * 17 + 6 * 18 + 10 * 19 + 14 * 20\n * // z = 3 * 17 + 7 * 18 + 11 * 19 + 15 * 20\n * // w = 4 * 17 + 8 * 18 + 12 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductRight(m, v)\n * ```\n * @since 1.0.0\n */\n (m: Matrix4x4, v: Vector4): Vector4\n /**\n * Calculates the right vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 5 * 18 + 9 * 19 + 13 * 20\n * // y = 2 * 17 + 6 * 18 + 10 * 19 + 14 * 20\n * // z = 3 * 17 + 7 * 18 + 11 * 19 + 15 * 20\n * // w = 4 * 17 + 8 * 18 + 12 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductRight(v)(m)\n * ```\n * @since 1.0.0\n */\n (v: Vector4): (m: Matrix4x4) => Vector4\n} = internal.vectorProductRight\n\nexport const multiply: {\n /**\n * Multiplies two `Matrix4x4` instances. Result is `a · b`.\n *\n * @param a - The left-hand matrix.\n * @param b - The right-hand matrix.\n * @returns The product matrix.\n * @since 1.1.0\n */\n (a: Matrix4x4, b: Matrix4x4): Matrix4x4\n /**\n * Multiplies two `Matrix4x4` instances. Result is `a · b`.\n *\n * @param b - The right-hand matrix.\n * @returns A function that takes the left-hand matrix and returns the product.\n * @since 1.1.0\n */\n (b: Matrix4x4): (a: Matrix4x4) => Matrix4x4\n} = internal.multiply\n\n/**\n * Returns the inverse of a `Matrix4x4`.\n *\n * Throws when the matrix is singular (determinant is zero).\n *\n * @param m - The matrix to invert.\n * @returns The inverse matrix.\n * @since 1.1.0\n */\nexport const inverse: (m: Matrix4x4) => Matrix4x4 = internal.inverse\n\nexport const solveSystem: {\n /**\n * Solves a system of linear equations represented by a `Matrix4x4` and a `Vector4`.\n *\n * @param m - The matrix representing the coefficients of the equations.\n * @param v - The vector representing the constants of the equations.\n * @returns The solution vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, v: Vector4): Vector4\n /**\n * Solves a system of linear equations represented by a `Matrix4x4` and a `Vector4`.\n *\n * @param v - The vector representing the constants of the equations.\n * @returns A function that takes a matrix and returns the solution vector.\n * @since 1.0.0\n */\n (v: Vector4): (m: Matrix4x4) => Vector4\n} = internal.solveSystem\n\n/**\n * Returns the rows of a `Matrix4x4` as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the rows of the matrix.\n * @since 1.0.0\n */\nexport const toRows: (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4] = internal.toRows as (\n m: Matrix4x4,\n) => [Vector4, Vector4, Vector4, Vector4]\n\n/**\n * Returns the columns of a `Matrix4x4` as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the columns of the matrix.\n * @since 1.0.0\n */\nexport const toColumns: (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4] =\n internal.toColumns as (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4]\n\nexport const rowVector: {\n /**\n * Returns a row vector from a `Matrix4x4`.\n *\n * @param m - The matrix to get the row vector from.\n * @param row - The row index.\n * @returns The row vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, row: Matrix4x4Coordinate): Vector4\n /**\n * Returns a row vector from a `Matrix4x4`.\n *\n * @param row - The row index.\n * @returns A function that takes a matrix and returns the row vector.\n * @since 1.0.0\n */\n (row: Matrix4x4Coordinate): (m: Matrix4x4) => Vector4\n} = internal.rowVector\n\nexport const columnVector: {\n /**\n * Returns a column vector from a `Matrix4x4`.\n *\n * @param m - The matrix to get the column vector from.\n * @param column - The column index.\n * @returns The column vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, column: Matrix4x4Coordinate): Vector4\n /**\n * Returns a column vector from a `Matrix4x4`.\n *\n * @param column - The column index.\n * @returns A function that takes a matrix and returns the column vector.\n * @since 1.0.0\n */\n (column: Matrix4x4Coordinate): (m: Matrix4x4) => Vector4\n} = internal.columnVector\n\n/**\n * Transposes a `Matrix4x4`.\n *\n * @param m - The matrix to transpose.\n * @returns The transposed matrix.\n * @since 1.0.0\n */\nexport const transpose: (m: Matrix4x4) => Matrix4x4 = internal.transpose\n\n/**\n * Reverses the rows of a `Matrix4x4`.\n *\n * @param m - The matrix to reverse the rows of.\n * @returns The matrix with the rows reversed.\n * @since 1.0.0\n */\nexport const reverseRows: (m: Matrix4x4) => Matrix4x4 = internal.reverseRows\n\n/**\n * Reverses the columns of a `Matrix4x4`.\n *\n * @param m - The matrix to reverse the columns of.\n * @returns The matrix with the columns reversed.\n * @since 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yCC;;;;;;;;AAStD,MAAa,cAA2CC;;;;;;;;AASxD,MAAa,iBAA8CC"}
1
+ {"version":3,"file":"matrix4x4-BWmf4lZM.mjs","names":["equals","make","fromRows","fromColumns","setRow","toRows","setColumn","toColumns","determinant","vectorProductLeft","vector2.make","vector2.dot","rowVector","vectorProductRight","columnVector","solveSystem","transpose","reverseRows","reverseColumns","equals","make","fromRows","fromColumns","setRow","toRows","setColumn","toColumns","determinant","matrix2x2.determinant","minor","vector3.components","matrix2x2.make","vectorProductLeft","vector3.make","vector3.dot","vectorProductRight","solveSystem","rowVector","columnVector","transpose","reverseRows","reverseColumns","isMatrix4x4","equals","identity","make","fromRows","fromColumns","setRow","toRows","setColumn","toColumns","determinant","matrix3x3.determinant","minor","vector4.components","matrix3x3.make","vectorProductLeft","vector4.make","vector4.dot","vectorProductRight","multiply","inverse","solveSystem","rowVector","columnVector","transpose","reverseRows","reverseColumns","internal.isMatrix4x4","internal.identity","internal.equals","internal.make","internal.fromRows","internal.fromColumns","internal.setRow","internal.setColumn","internal.determinant","internal.minor","internal.vectorProductLeft","internal.vectorProductRight","internal.multiply","internal.inverse","internal.solveSystem","internal.toRows","internal.toColumns","internal.rowVector","internal.columnVector","internal.transpose","internal.reverseRows","internal.reverseColumns"],"sources":["../../src/dimensions.ts","../../src/matrix/matrix2x2.internal.ts","../../src/matrix/matrix3x3.internal.ts","../../src/matrix/matrix4x4.internal.ts","../../src/matrix/matrix4x4.ts"],"sourcesContent":["import { invariant } from './utils.ts'\n\nexport type TwoDimensionalIndex = 0 | 1\nexport type TwoDimensionalComponent = 'x' | 'y'\n\nexport interface TwoDimensional<out T1, out T2 = T1> {\n readonly x: T1\n readonly y: T2\n\n readonly 0: T1\n readonly 1: T2\n}\n\nexport type ThreeDimensionalIndex = TwoDimensionalIndex | 2\nexport type ThreeDimensionalComponent = TwoDimensionalComponent | 'z'\n\nexport interface ThreeDimensional<out T1, out T2 = T1, out T3 = T2> extends TwoDimensional<T1, T2> {\n readonly z: T3\n readonly 2: T3\n}\n\nexport type FourDimensionalIndex = ThreeDimensionalIndex | 3\nexport type FourDimensionalComponent = ThreeDimensionalComponent | 'w'\n\nexport interface FourDimensional<\n out T1,\n out T2 = T1,\n out T3 = T2,\n out T4 = T3,\n> extends ThreeDimensional<T1, T2, T3> {\n readonly w: T4\n readonly 3: T4\n}\n\nfunction toIndex(input: string | number): number {\n if (typeof input === 'number') {\n invariant(input >= 0 && input <= 3, 'Index out of bounds')\n\n return input\n }\n\n if (input === 'x') {\n return 0\n }\n\n if (input === 'y') {\n return 1\n }\n\n if (input === 'z') {\n return 2\n }\n\n if (input === 'w') {\n return 3\n }\n\n invariant(false, 'Invalid component')\n}\n\nexport const toTwoDimensionalIndex = toIndex as (\n input: TwoDimensionalIndex | TwoDimensionalComponent,\n) => TwoDimensionalIndex\nexport const toThreeDimensionalIndex = toIndex as (\n input: ThreeDimensionalIndex | ThreeDimensionalComponent,\n) => ThreeDimensionalIndex\nexport const toFourDimensionalIndex = toIndex as (\n input: FourDimensionalIndex | FourDimensionalComponent,\n) => FourDimensionalIndex\n","import { toTwoDimensionalIndex } from '../dimensions.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport * as vector2 from '../vector/vector2.internal.ts'\nimport type { Matrix2x2, Matrix2x2Coordinate } from './matrix2x2.ts'\n\nexport const Matrix2x2TypeId: unique symbol = Symbol.for('curvy/matrix2x2')\nexport type Matrix2x2TypeId = typeof Matrix2x2TypeId\n\nclass Matrix2x2Impl extends Pipeable implements Matrix2x2 {\n readonly [Matrix2x2TypeId]: Matrix2x2TypeId = Matrix2x2TypeId\n\n readonly m00: number\n readonly m01: number\n\n readonly m10: number\n readonly m11: number\n\n constructor(m00 = 0, m01 = 0, m10 = 0, m11 = 0) {\n super()\n this.m00 = m00\n this.m01 = m01\n this.m10 = m10\n this.m11 = m11\n }\n\n get [Symbol.toStringTag]() {\n return `Matrix2x2(${this.m00}, ${this.m01}, ${this.m10}, ${this.m11})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return `Matrix2x2(${this.m00}, ${this.m01}, ${this.m10}, ${this.m11})`\n }\n\n [Symbol.hasInstance](m: unknown): m is Matrix2x2 {\n return isMatrix2x2(m)\n }\n}\n\n/** @internal */\nexport const isMatrix2x2 = (m: unknown): m is Matrix2x2 =>\n typeof m === 'object' && m !== null && Matrix2x2TypeId in m\n\n/** @internal */\nexport const equals = dual<\n (b: Matrix2x2) => (a: Matrix2x2) => boolean,\n (a: Matrix2x2, b: Matrix2x2) => boolean\n>(\n 2,\n (a: Matrix2x2, b: Matrix2x2) =>\n epsEquals(a.m00, b.m00) &&\n epsEquals(a.m01, b.m01) &&\n epsEquals(a.m10, b.m10) &&\n epsEquals(a.m11, b.m11),\n)\n\n/** @internal */\nexport const make = (m00 = 0, m01 = m00, m10 = m01, m11 = m10) =>\n new Matrix2x2Impl(m00, m01, m10, m11)\n\n/** @internal */\nexport const fromRows = (v0: Vector2, v1: Vector2) => new Matrix2x2Impl(v0.x, v0.y, v1.x, v1.y)\n\n/** @internal */\nexport const fromColumns = (v0: Vector2, v1: Vector2) => new Matrix2x2Impl(v0.x, v1.x, v0.y, v1.y)\n\n/** @internal */\nexport const setRow = dual<\n (row: Matrix2x2Coordinate, v: Vector2) => (m: Matrix2x2) => Matrix2x2,\n (m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2) => Matrix2x2\n>(3, (m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2) =>\n fromRows(...(toRows(m).with(toTwoDimensionalIndex(row), v) as [Vector2, Vector2])),\n)\n\n/** @internal */\nexport const setColumn = dual<\n (column: Matrix2x2Coordinate, v: Vector2) => (m: Matrix2x2) => Matrix2x2,\n (m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2) => Matrix2x2\n>(3, (m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2) =>\n fromColumns(...(toColumns(m).with(toTwoDimensionalIndex(column), v) as [Vector2, Vector2])),\n)\n\n/** @internal */\nexport const determinant = (m: Matrix2x2): number => m.m00 * m.m11 - m.m01 * m.m10\n\n// (a: Vector2, b: Vector2) => a.x * b.x + a.y * b.y\n\n/*\n * {\n * x: first row dot v -> fr.x\n * y: second row dot v\n * }\n * */\n\n/** @internal */\nexport const vectorProductLeft = dual<\n (v: Vector2) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, v: Vector2) => Vector2\n>(2, (m: Matrix2x2, v: Vector2) =>\n vector2.make(vector2.dot(rowVector(m, 0), v), vector2.dot(rowVector(m, 1), v)),\n)\n\n/** @internal */\nexport const vectorProductRight = dual<\n (v: Vector2) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, v: Vector2) => Vector2\n>(2, (m: Matrix2x2, v: Vector2) =>\n vector2.make(vector2.dot(columnVector(m, 0), v), vector2.dot(columnVector(m, 1), v)),\n)\n\n/** @internal */\nexport const solveSystem = dual<\n (v: Vector2) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, v: Vector2) => Vector2\n>(2, (m: Matrix2x2, v: Vector2) => {\n const inverseDeterminant = 1 / determinant(m)\n\n invariant(\n Number.isFinite(inverseDeterminant),\n 'cannot solve system when coefficient matrix determinant is zero',\n )\n\n return vector2.make(\n determinant(setColumn(m, 0, v)) * inverseDeterminant,\n determinant(setColumn(m, 1, v)) * inverseDeterminant,\n )\n})\n\n/** @internal */\nexport const toRows = (m: Matrix2x2): [Vector2, Vector2] => [\n vector2.make(m.m00, m.m01),\n vector2.make(m.m10, m.m11),\n]\n\n/** @internal */\nexport const toColumns = (m: Matrix2x2): [Vector2, Vector2] => [\n vector2.make(m.m00, m.m10),\n vector2.make(m.m01, m.m11),\n]\n\n/** @internal */\nexport const rowVector = dual<\n (row: Matrix2x2Coordinate) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, row: Matrix2x2Coordinate) => Vector2\n>(2, (m: Matrix2x2, row: Matrix2x2Coordinate) => toRows(m)[toTwoDimensionalIndex(row)])\n\n/** @internal */\nexport const columnVector = dual<\n (column: Matrix2x2Coordinate) => (m: Matrix2x2) => Vector2,\n (m: Matrix2x2, column: Matrix2x2Coordinate) => Vector2\n>(2, (m: Matrix2x2, column: Matrix2x2Coordinate) => toColumns(m)[toTwoDimensionalIndex(column)])\n\n/** @internal */\nexport const transpose = (m: Matrix2x2) => fromColumns(...toRows(m))\n\n/** @internal */\nexport const reverseRows = (m: Matrix2x2) => {\n const [r0, r1] = toRows(m)\n return fromRows(r1, r0)\n}\n\n/** @internal */\nexport const reverseColumns = (m: Matrix2x2) => {\n const [c0, c1] = toColumns(m)\n return fromColumns(c1, c0)\n}\n","import { toThreeDimensionalIndex } from '../dimensions.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport * as vector3 from '../vector/vector3.internal.ts'\nimport type { Matrix2x2 } from './matrix2x2.ts'\nimport * as matrix2x2 from './matrix2x2.internal.ts'\nimport type { Matrix3x3, Matrix3x3Coordinate } from './matrix3x3.ts'\n\nexport const Matrix3x3TypeId: unique symbol = Symbol.for('curvy/matrix3x3')\nexport type Matrix3x3TypeId = typeof Matrix3x3TypeId\n\nclass Matrix3x3Impl extends Pipeable implements Matrix3x3 {\n readonly [Matrix3x3TypeId]: Matrix3x3TypeId = Matrix3x3TypeId\n\n readonly m00: number\n readonly m01: number\n readonly m02: number\n\n readonly m10: number\n readonly m11: number\n readonly m12: number\n\n readonly m20: number\n readonly m21: number\n readonly m22: number\n\n constructor(m00 = 0, m01 = 0, m02 = 0, m10 = 0, m11 = 0, m12 = 0, m20 = 0, m21 = 0, m22 = 0) {\n super()\n this.m00 = m00\n this.m01 = m01\n this.m02 = m02\n this.m10 = m10\n this.m11 = m11\n this.m12 = m12\n this.m20 = m20\n this.m21 = m21\n this.m22 = m22\n }\n\n get [Symbol.toStringTag]() {\n return `Matrix3x3(${this.m00}, ${this.m01}, ${this.m02}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m20}, ${this.m21}, ${this.m22})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return `Matrix3x3(${this.m00}, ${this.m01}, ${this.m02}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m20}, ${this.m21}, ${this.m22})`\n }\n\n [Symbol.hasInstance](m: unknown): m is Matrix3x3 {\n return isMatrix3x3(m)\n }\n}\n\nexport type { Matrix3x3 }\n\n/** @internal */\nexport const isMatrix3x3 = (m: unknown): m is Matrix3x3 =>\n typeof m === 'object' && m !== null && Matrix3x3TypeId in m\n\n/** @internal */\nexport const equals = dual<\n (b: Matrix3x3) => (a: Matrix3x3) => boolean,\n (a: Matrix3x3, b: Matrix3x3) => boolean\n>(\n 2,\n (a: Matrix3x3, b: Matrix3x3) =>\n epsEquals(a.m00, b.m00) &&\n epsEquals(a.m01, b.m01) &&\n epsEquals(a.m02, b.m02) &&\n epsEquals(a.m10, b.m10) &&\n epsEquals(a.m11, b.m11) &&\n epsEquals(a.m12, b.m12) &&\n epsEquals(a.m20, b.m20) &&\n epsEquals(a.m21, b.m21) &&\n epsEquals(a.m22, b.m22),\n)\n\n/** @internal */\nexport const make = (\n m00 = 0,\n m01 = m00,\n m02 = m01,\n m10 = m02,\n m11 = m10,\n m12 = m11,\n m20 = m12,\n m21 = m20,\n m22 = m21,\n): Matrix3x3 => {\n return new Matrix3x3Impl(m00, m01, m02, m10, m11, m12, m20, m21, m22)\n}\n\n/** @internal */\nexport const fromRows = (v0: Vector3, v1: Vector3, v2: Vector3): Matrix3x3 =>\n new Matrix3x3Impl(v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z)\n\n/** @internal */\nexport const fromColumns = (v0: Vector3, v1: Vector3, v2: Vector3): Matrix3x3 =>\n new Matrix3x3Impl(v0.x, v1.x, v2.x, v0.y, v1.y, v2.y, v0.z, v1.z, v2.z)\n\n/** @internal */\nexport const setRow = dual<\n (row: Matrix3x3Coordinate, v: Vector3) => (m: Matrix3x3) => Matrix3x3,\n (m: Matrix3x3, row: Matrix3x3Coordinate, v: Vector3) => Matrix3x3\n>(3, (m: Matrix3x3, row: Matrix3x3Coordinate, v: Vector3) =>\n fromRows(...(toRows(m).with(toThreeDimensionalIndex(row), v) as [Vector3, Vector3, Vector3])),\n)\n\n/** @internal */\nexport const setColumn = dual<\n (column: Matrix3x3Coordinate, v: Vector3) => (m: Matrix3x3) => Matrix3x3,\n (m: Matrix3x3, column: Matrix3x3Coordinate, v: Vector3) => Matrix3x3\n>(3, (m: Matrix3x3, column: Matrix3x3Coordinate, v: Vector3) =>\n fromColumns(\n ...(toColumns(m).with(toThreeDimensionalIndex(column), v) as [Vector3, Vector3, Vector3]),\n ),\n)\n\n/** @internal */\nexport const determinant = (m: Matrix3x3) =>\n m.m00 * matrix2x2.determinant(minor(m, 0, 0)) -\n m.m01 * matrix2x2.determinant(minor(m, 0, 1)) +\n m.m02 * matrix2x2.determinant(minor(m, 0, 2))\n\n/** @internal */\nexport const minor = dual<\n (row: Matrix3x3Coordinate, column: Matrix3x3Coordinate) => (m: Matrix3x3) => Matrix2x2,\n (m: Matrix3x3, row: Matrix3x3Coordinate, column: Matrix3x3Coordinate) => Matrix2x2\n>(3, (m: Matrix3x3, row: Matrix3x3Coordinate, column: Matrix3x3Coordinate) => {\n const [v0, v1] = toRows(m).toSpliced(toThreeDimensionalIndex(row), 1) as [Vector3, Vector3]\n const columnIndex = toThreeDimensionalIndex(column)\n const [m00, m01] = vector3.components(v0).toSpliced(columnIndex, 1) as [number, number]\n const [m10, m11] = vector3.components(v1).toSpliced(columnIndex, 1) as [number, number]\n\n return matrix2x2.make(m00, m01, m10, m11) as Matrix2x2\n})\n\n/** @internal */\nexport const vectorProductLeft = dual<\n (v: Vector3) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, v: Vector3) => Vector3\n>(2, (m: Matrix3x3, v: Vector3) => {\n const [v0, v1, v2] = toRows(m) as [Vector3, Vector3, Vector3]\n return vector3.make(vector3.dot(v0, v), vector3.dot(v1, v), vector3.dot(v2, v))\n})\n\n/** @internal */\nexport const vectorProductRight = dual<\n (v: Vector3) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, v: Vector3) => Vector3\n>(2, (m: Matrix3x3, v: Vector3) => {\n const [v0, v1, v2] = toColumns(m) as [Vector3, Vector3, Vector3]\n return vector3.make(vector3.dot(v, v0), vector3.dot(v, v1), vector3.dot(v, v2))\n})\n\n/** @internal */\nexport const solveSystem = dual<\n (v: Vector3) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, v: Vector3) => Vector3\n>(2, (m: Matrix3x3, v: Vector3) => {\n const inverseDeterminant = 1 / determinant(m)\n\n invariant(\n Number.isFinite(inverseDeterminant),\n 'cannot solve system when coefficient matrix determinant is zero',\n )\n\n return vector3.make(\n determinant(setColumn(m, 0, v)) * inverseDeterminant,\n determinant(setColumn(m, 1, v)) * inverseDeterminant,\n determinant(setColumn(m, 2, v)) * inverseDeterminant,\n )\n})\n\n/** @internal */\nexport const toRows = (m: Matrix3x3): [Vector3, Vector3, Vector3] => [\n vector3.make(m.m00, m.m01, m.m02),\n vector3.make(m.m10, m.m11, m.m12),\n vector3.make(m.m20, m.m21, m.m22),\n]\n\n/** @internal */\nexport const toColumns = (m: Matrix3x3): [Vector3, Vector3, Vector3] => [\n vector3.make(m.m00, m.m10, m.m20),\n vector3.make(m.m01, m.m11, m.m21),\n vector3.make(m.m02, m.m12, m.m22),\n]\n\n/** @internal */\nexport const rowVector = dual<\n (row: Matrix3x3Coordinate) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, row: Matrix3x3Coordinate) => Vector3\n>(2, (m: Matrix3x3, row: Matrix3x3Coordinate) => toRows(m)[toThreeDimensionalIndex(row)])\n\n/** @internal */\nexport const columnVector = dual<\n (column: Matrix3x3Coordinate) => (m: Matrix3x3) => Vector3,\n (m: Matrix3x3, column: Matrix3x3Coordinate) => Vector3\n>(2, (m: Matrix3x3, column: Matrix3x3Coordinate) => toColumns(m)[toThreeDimensionalIndex(column)])\n\n/** @internal */\nexport const transpose = (m: Matrix3x3) => fromColumns(...toRows(m))\n\n/** @internal */\nexport const reverseRows = (m: Matrix3x3) => {\n const [v0, v1, v2] = toRows(m)\n return fromRows(v2, v1, v0)\n}\n\n/** @internal */\nexport const reverseColumns = (m: Matrix3x3) => {\n const [v0, v1, v2] = toColumns(m)\n return fromColumns(v2, v1, v0)\n}\n","import { toFourDimensionalIndex } from '../dimensions.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport type { Vector4 } from '../vector/vector4.ts'\nimport * as vector4 from '../vector/vector4.internal.ts'\nimport type { Matrix3x3 } from './matrix3x3.ts'\nimport * as matrix3x3 from './matrix3x3.internal.ts'\nimport type { Matrix4x4, Matrix4x4Coordinate } from './matrix4x4.ts'\n\nexport const Matrix4x4TypeId: unique symbol = Symbol.for('curvy/matrix4x4')\nexport type Matrix4x4TypeId = typeof Matrix4x4TypeId\n\nclass Matrix4x4Impl extends Pipeable implements Matrix4x4 {\n readonly [Matrix4x4TypeId]: Matrix4x4TypeId = Matrix4x4TypeId\n\n readonly m00: number\n readonly m01: number\n readonly m02: number\n readonly m03: number\n\n readonly m10: number\n readonly m11: number\n readonly m12: number\n readonly m13: number\n\n readonly m20: number\n readonly m21: number\n readonly m22: number\n readonly m23: number\n\n readonly m30: number\n readonly m31: number\n readonly m32: number\n readonly m33: number\n\n constructor(\n m00 = 0,\n m01 = m00,\n m02 = m01,\n m03 = m02,\n m10 = m00,\n m11 = m01,\n m12 = m02,\n m13 = m03,\n m20 = m00,\n m21 = m01,\n m22 = m02,\n m23 = m03,\n m30 = m00,\n m31 = m01,\n m32 = m02,\n m33 = m03,\n ) {\n super()\n\n this.m00 = m00\n this.m01 = m01\n this.m02 = m02\n this.m03 = m03\n this.m10 = m10\n this.m11 = m11\n this.m12 = m12\n this.m13 = m13\n this.m20 = m20\n this.m21 = m21\n this.m22 = m22\n this.m23 = m23\n this.m30 = m30\n this.m31 = m31\n this.m32 = m32\n this.m33 = m33\n }\n\n get [Symbol.toStringTag]() {\n return `Matrix4x4(${this.m00}, ${this.m01}, ${this.m02}, ${this.m03}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m13}, ${this.m20}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m30}, ${this.m31}, ${this.m32}, ${this.m33})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return `Matrix4x4(${this.m00}, ${this.m01}, ${this.m02}, ${this.m03}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m13}, ${this.m20}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m30}, ${this.m31}, ${this.m32}, ${this.m33})`\n }\n\n [Symbol.hasInstance](m: unknown): m is Matrix4x4 {\n return isMatrix4x4(m)\n }\n}\n\n/** @internal */\nexport const isMatrix4x4 = (m: unknown): m is Matrix4x4 =>\n typeof m === 'object' && m !== null && Matrix4x4TypeId in m\n\n/** @internal */\nexport const equals = dual<\n (b: Matrix4x4) => (a: Matrix4x4) => boolean,\n (a: Matrix4x4, b: Matrix4x4) => boolean\n>(\n 2,\n (a: Matrix4x4, b: Matrix4x4) =>\n epsEquals(a.m00, b.m00) &&\n epsEquals(a.m01, b.m01) &&\n epsEquals(a.m02, b.m02) &&\n epsEquals(a.m03, b.m03) &&\n epsEquals(a.m10, b.m10) &&\n epsEquals(a.m11, b.m11) &&\n epsEquals(a.m12, b.m12) &&\n epsEquals(a.m13, b.m13) &&\n epsEquals(a.m20, b.m20) &&\n epsEquals(a.m21, b.m21) &&\n epsEquals(a.m22, b.m22) &&\n epsEquals(a.m23, b.m23) &&\n epsEquals(a.m30, b.m30) &&\n epsEquals(a.m31, b.m31) &&\n epsEquals(a.m32, b.m32) &&\n epsEquals(a.m33, b.m33),\n)\n\n/**\n * The 4x4 identity matrix.\n * @internal\n */\nexport const identity: Matrix4x4 = new Matrix4x4Impl(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)\n\n// first four arguments are the top row\n/** @internal */\nexport const make = (\n m00 = 0,\n m01 = m00,\n m02 = m01,\n m03 = m02,\n m10 = m00,\n m11 = m01,\n m12 = m02,\n m13 = m03,\n m20 = m00,\n m21 = m01,\n m22 = m02,\n m23 = m03,\n m30 = m00,\n m31 = m01,\n m32 = m02,\n m33 = m03,\n) =>\n new Matrix4x4Impl(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)\n\n/** @internal */\nexport const fromRows = (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) =>\n new Matrix4x4Impl(\n v0.x,\n v0.y,\n v0.z,\n v0.w,\n v1.x,\n v1.y,\n v1.z,\n v1.w,\n v2.x,\n v2.y,\n v2.z,\n v2.w,\n v3.x,\n v3.y,\n v3.z,\n v3.w,\n )\n\n/** @internal */\nexport const fromColumns = (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) =>\n new Matrix4x4Impl(\n v0.x,\n v1.x,\n v2.x,\n v3.x,\n v0.y,\n v1.y,\n v2.y,\n v3.y,\n v0.z,\n v1.z,\n v2.z,\n v3.z,\n v0.w,\n v1.w,\n v2.w,\n v3.w,\n )\n\n/** @internal */\nexport const setRow = dual<\n (row: Matrix4x4Coordinate, v: Vector4) => (m: Matrix4x4) => Matrix4x4,\n (m: Matrix4x4, row: Matrix4x4Coordinate, v: Vector4) => Matrix4x4\n>(3, (m: Matrix4x4, row: Matrix4x4Coordinate, v: Vector4) =>\n fromRows(\n ...(toRows(m).with(toFourDimensionalIndex(row), v) as [Vector4, Vector4, Vector4, Vector4]),\n ),\n)\n\n/** @internal */\nexport const setColumn = dual<\n (column: Matrix4x4Coordinate, v: Vector4) => (m: Matrix4x4) => Matrix4x4,\n (m: Matrix4x4, column: Matrix4x4Coordinate, v: Vector4) => Matrix4x4\n>(3, (m: Matrix4x4, column: Matrix4x4Coordinate, v: Vector4) =>\n fromColumns(\n ...(toColumns(m).with(toFourDimensionalIndex(column), v) as [\n Vector4,\n Vector4,\n Vector4,\n Vector4,\n ]),\n ),\n)\n\n/** @internal */\nexport const determinant = (m: Matrix4x4) =>\n m.m00 * matrix3x3.determinant(minor(m, 0, 0)) -\n m.m01 * matrix3x3.determinant(minor(m, 0, 1)) +\n m.m02 * matrix3x3.determinant(minor(m, 0, 2)) -\n m.m03 * matrix3x3.determinant(minor(m, 0, 3))\n\n/** @internal */\nexport const minor = dual<\n (row: Matrix4x4Coordinate, column: Matrix4x4Coordinate) => (m: Matrix4x4) => Matrix3x3,\n (m: Matrix4x4, row: Matrix4x4Coordinate, column: Matrix4x4Coordinate) => Matrix3x3\n>(3, (m: Matrix4x4, row: Matrix4x4Coordinate, column: Matrix4x4Coordinate) => {\n const [v0, v1, v2] = toRows(m).toSpliced(toFourDimensionalIndex(row), 1) as [\n Vector4,\n Vector4,\n Vector4,\n ]\n const columnIndex = toFourDimensionalIndex(column)\n const [m00, m01, m02] = vector4.components(v0).toSpliced(columnIndex, 1) as [\n number,\n number,\n number,\n ]\n const [m10, m11, m12] = vector4.components(v1).toSpliced(columnIndex, 1) as [\n number,\n number,\n number,\n ]\n const [m20, m21, m22] = vector4.components(v2).toSpliced(columnIndex, 1) as [\n number,\n number,\n number,\n ]\n\n return matrix3x3.make(m00, m01, m02, m10, m11, m12, m20, m21, m22)\n})\n\n/** @internal */\nexport const vectorProductLeft = dual<\n (v: Vector4) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, v: Vector4) => Vector4\n>(2, (m: Matrix4x4, v: Vector4) => {\n const [v0, v1, v2, v3] = toRows(m) as [Vector4, Vector4, Vector4, Vector4]\n return vector4.make(\n vector4.dot(v0, v),\n vector4.dot(v1, v),\n vector4.dot(v2, v),\n vector4.dot(v3, v),\n )\n})\n\n/** @internal */\nexport const vectorProductRight = dual<\n (v: Vector4) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, v: Vector4) => Vector4\n>(2, (m: Matrix4x4, v: Vector4) => {\n const [v0, v1, v2, v3] = toColumns(m) as [Vector4, Vector4, Vector4, Vector4]\n\n return vector4.make(\n vector4.dot(v, v0),\n vector4.dot(v, v1),\n vector4.dot(v, v2),\n vector4.dot(v, v3),\n )\n})\n\n/** @internal */\nexport const multiply = dual<\n (b: Matrix4x4) => (a: Matrix4x4) => Matrix4x4,\n (a: Matrix4x4, b: Matrix4x4) => Matrix4x4\n>(\n 2,\n (a: Matrix4x4, b: Matrix4x4) =>\n new Matrix4x4Impl(\n a.m00 * b.m00 + a.m01 * b.m10 + a.m02 * b.m20 + a.m03 * b.m30,\n a.m00 * b.m01 + a.m01 * b.m11 + a.m02 * b.m21 + a.m03 * b.m31,\n a.m00 * b.m02 + a.m01 * b.m12 + a.m02 * b.m22 + a.m03 * b.m32,\n a.m00 * b.m03 + a.m01 * b.m13 + a.m02 * b.m23 + a.m03 * b.m33,\n a.m10 * b.m00 + a.m11 * b.m10 + a.m12 * b.m20 + a.m13 * b.m30,\n a.m10 * b.m01 + a.m11 * b.m11 + a.m12 * b.m21 + a.m13 * b.m31,\n a.m10 * b.m02 + a.m11 * b.m12 + a.m12 * b.m22 + a.m13 * b.m32,\n a.m10 * b.m03 + a.m11 * b.m13 + a.m12 * b.m23 + a.m13 * b.m33,\n a.m20 * b.m00 + a.m21 * b.m10 + a.m22 * b.m20 + a.m23 * b.m30,\n a.m20 * b.m01 + a.m21 * b.m11 + a.m22 * b.m21 + a.m23 * b.m31,\n a.m20 * b.m02 + a.m21 * b.m12 + a.m22 * b.m22 + a.m23 * b.m32,\n a.m20 * b.m03 + a.m21 * b.m13 + a.m22 * b.m23 + a.m23 * b.m33,\n a.m30 * b.m00 + a.m31 * b.m10 + a.m32 * b.m20 + a.m33 * b.m30,\n a.m30 * b.m01 + a.m31 * b.m11 + a.m32 * b.m21 + a.m33 * b.m31,\n a.m30 * b.m02 + a.m31 * b.m12 + a.m32 * b.m22 + a.m33 * b.m32,\n a.m30 * b.m03 + a.m31 * b.m13 + a.m32 * b.m23 + a.m33 * b.m33,\n ),\n)\n\n/** @internal */\nexport const inverse = (m: Matrix4x4): Matrix4x4 => {\n const det = determinant(m)\n invariant(det !== 0, 'cannot invert singular matrix')\n\n const inv = 1 / det\n // adjugate is the transpose of the cofactor matrix\n const cof = (row: Matrix4x4Coordinate, col: Matrix4x4Coordinate) => {\n const sign = ((row as number) + (col as number)) % 2 === 0 ? 1 : -1\n return sign * matrix3x3.determinant(minor(m, row, col)) * inv\n }\n\n return new Matrix4x4Impl(\n cof(0, 0),\n cof(1, 0),\n cof(2, 0),\n cof(3, 0),\n cof(0, 1),\n cof(1, 1),\n cof(2, 1),\n cof(3, 1),\n cof(0, 2),\n cof(1, 2),\n cof(2, 2),\n cof(3, 2),\n cof(0, 3),\n cof(1, 3),\n cof(2, 3),\n cof(3, 3),\n )\n}\n\n/** @internal */\nexport const solveSystem = dual<\n (v: Vector4) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, v: Vector4) => Vector4\n>(2, (m: Matrix4x4, v: Vector4) => {\n const inverseDeterminant = 1 / determinant(m)\n\n invariant(\n Number.isFinite(inverseDeterminant),\n 'cannot solve system when coefficient matrix determinant is zero',\n )\n\n return vector4.make(\n determinant(setColumn(m, 0, v)) * inverseDeterminant,\n determinant(setColumn(m, 1, v)) * inverseDeterminant,\n determinant(setColumn(m, 2, v)) * inverseDeterminant,\n determinant(setColumn(m, 3, v)) * inverseDeterminant,\n )\n})\n\n/** @internal */\nexport const toRows = (m: Matrix4x4) =>\n [\n vector4.make(m.m00, m.m01, m.m02, m.m03),\n vector4.make(m.m10, m.m11, m.m12, m.m13),\n vector4.make(m.m20, m.m21, m.m22, m.m23),\n vector4.make(m.m30, m.m31, m.m32, m.m33),\n ] as const\n\n/** @internal */\nexport const toColumns = (m: Matrix4x4) =>\n [\n vector4.make(m.m00, m.m10, m.m20, m.m30),\n vector4.make(m.m01, m.m11, m.m21, m.m31),\n vector4.make(m.m02, m.m12, m.m22, m.m32),\n vector4.make(m.m03, m.m13, m.m23, m.m33),\n ] as const\n\n/** @internal */\nexport const rowVector = dual<\n (row: Matrix4x4Coordinate) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, row: Matrix4x4Coordinate) => Vector4\n>(2, (m: Matrix4x4, row: Matrix4x4Coordinate) => toRows(m)[toFourDimensionalIndex(row)])\n\n/** @internal */\nexport const columnVector = dual<\n (column: Matrix4x4Coordinate) => (m: Matrix4x4) => Vector4,\n (m: Matrix4x4, column: Matrix4x4Coordinate) => Vector4\n>(2, (m: Matrix4x4, column: Matrix4x4Coordinate) => toColumns(m)[toFourDimensionalIndex(column)])\n\n/** @internal */\nexport const transpose = (m: Matrix4x4) => fromColumns(...toRows(m)) as Matrix4x4\n\n/** @internal */\nexport const reverseRows = (m: Matrix4x4) => {\n const [v0, v1, v2, v3] = toRows(m) as [Vector4, Vector4, Vector4, Vector4]\n return fromRows(v3, v2, v1, v0)\n}\n\n/** @internal */\nexport const reverseColumns = (m: Matrix4x4) => {\n const [v0, v1, v2, v3] = toColumns(m) as [Vector4, Vector4, Vector4, Vector4]\n return fromColumns(v3, v2, v1, v0)\n}\n","import type { FourDimensionalComponent, FourDimensionalIndex } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector4 } from '../vector/vector4.ts'\nimport type { Matrix3x3 } from './matrix3x3.ts'\nimport type { Matrix4x4TypeId } from './matrix4x4.internal.ts'\nimport * as internal from './matrix4x4.internal.ts'\n\n/**\n * A coordinate in a 4x4 matrix.\n *\n * @since 1.0.0\n */\nexport type Matrix4x4Coordinate = FourDimensionalIndex | FourDimensionalComponent\n\n/**\n * A 4x4 matrix.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Matrix4x4 extends Pipeable {\n readonly [Matrix4x4TypeId]: Matrix4x4TypeId\n\n /**\n * The value of the first row and first column.\n */\n readonly m00: number\n /**\n * The value of the first row and second column.\n */\n readonly m01: number\n /**\n * The value of the first row and third column.\n */\n readonly m02: number\n /**\n * The value of the first row and fourth column.\n */\n readonly m03: number\n /**\n * The value of the second row and first column.\n */\n readonly m10: number\n /**\n * The value of the second row and second column.\n */\n readonly m11: number\n /**\n * The value of the second row and third column.\n */\n readonly m12: number\n /**\n * The value of the second row and fourth column.\n */\n readonly m13: number\n /**\n * The value of the third row and first column.\n */\n readonly m20: number\n /**\n * The value of the third row and second column.\n */\n readonly m21: number\n /**\n * The value of the third row and third column.\n */\n readonly m22: number\n /**\n * The value of the third row and fourth column.\n */\n readonly m23: number\n /**\n * The value of the fourth row and first column.\n */\n readonly m30: number\n /**\n * The value of the fourth row and second column.\n */\n readonly m31: number\n /**\n * The value of the fourth row and third column.\n */\n readonly m32: number\n /**\n * The value of the fourth row and fourth column.\n */\n readonly m33: number\n}\n\n/**\n * Checks if a value is a `Matrix4x4`.\n *\n * @param m - The value to check.\n * @returns `true` if the value is a `Matrix4x4`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isMatrix4x4: (m: unknown) => m is Matrix4x4 = internal.isMatrix4x4\n\n/**\n * The 4x4 identity matrix.\n *\n * @since 1.1.0\n */\nexport const identity: Matrix4x4 = internal.identity\n\nexport const equals: {\n /**\n * Checks if two `Matrix4x4` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first matrix.\n * @param b - The second matrix.\n * @returns `true` when each pair of components is within tolerance.\n * @since 1.1.0\n */\n (a: Matrix4x4, b: Matrix4x4): boolean\n /**\n * Checks if two `Matrix4x4` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second matrix.\n * @returns A function that takes the first matrix and returns the comparison result.\n * @since 1.1.0\n */\n (b: Matrix4x4): (a: Matrix4x4) => boolean\n} = internal.equals\n\n/**\n * Creates a new `Matrix4x4` instance.\n *\n * @param m00 - The value of the first row and first column.\n * @param m01 - The value of the first row and second column.\n * @param m02 - The value of the first row and third column.\n * @param m03 - The value of the first row and fourth column.\n * @param m10 - The value of the second row and first column.\n * @param m11 - The value of the second row and second column.\n * @param m12 - The value of the second row and third column.\n * @param m13 - The value of the second row and fourth column.\n * @param m20 - The value of the third row and first column.\n * @param m21 - The value of the third row and second column.\n * @param m22 - The value of the third row and third column.\n * @param m23 - The value of the third row and fourth column.\n * @param m30 - The value of the fourth row and first column.\n * @param m31 - The value of the fourth row and second column.\n * @param m32 - The value of the fourth row and third column.\n * @param m33 - The value of the fourth row and fourth column.\n * @returns A new `Matrix4x4` instance.\n * @since 1.0.0\n */\nexport const make: (\n m00?: number,\n m01?: number,\n m02?: number,\n m03?: number,\n m10?: number,\n m11?: number,\n m12?: number,\n m13?: number,\n m20?: number,\n m21?: number,\n m22?: number,\n m23?: number,\n m30?: number,\n m31?: number,\n m32?: number,\n m33?: number,\n) => Matrix4x4 = internal.make\n\n/**\n * Creates a new `Matrix4x4` instance from four row vectors.\n *\n * @param v0 - The first row vector.\n * @param v1 - The second row vector.\n * @param v2 - The third row vector.\n * @param v3 - The fourth row vector.\n * @returns A new `Matrix4x4` instance.\n * @since 1.0.0\n */\nexport const fromRows: (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) => Matrix4x4 =\n internal.fromRows\n\n/**\n * Creates a new `Matrix4x4` instance from four column vectors.\n *\n * @param v0 - The first column vector.\n * @param v1 - The second column vector.\n * @param v2 - The third column vector.\n * @param v3 - The fourth column vector.\n */\nexport const fromColumns: (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) => Matrix4x4 =\n internal.fromColumns\n\nexport const setRow: {\n /**\n * Sets a row of a `Matrix4x4` to a new vector.\n *\n * @param m - The matrix to modify.\n * @param row - The row to set.\n * @param v - The new vector.\n * @returns A new `Matrix4x4` instance with the specified row set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, row: Matrix4x4Coordinate, v: Vector4): Matrix4x4\n /**\n * Sets a row of a `Matrix4x4` to a new vector.\n *\n * @param row - The row to set.\n * @param v - The new vector.\n * @returns A function that takes a matrix and returns a new `Matrix4x4` instance with the specified row set to the new vector.\n * @since 1.0.0\n */\n (row: Matrix4x4Coordinate, v: Vector4): (m: Matrix4x4) => Matrix4x4\n} = internal.setRow\n\nexport const setColumn: {\n /**\n * Sets a column of a `Matrix4x4` to a new vector.\n *\n * @param m - The matrix to modify.\n * @param column - The column to set.\n * @param v - The new vector.\n * @returns A new `Matrix4x4` instance with the specified column set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, column: Matrix4x4Coordinate, v: Vector4): Matrix4x4\n /**\n * Sets a column of a `Matrix4x4` to a new vector.\n *\n * @param column - The column to set.\n * @param v - The new vector.\n * @returns A function that takes a matrix and returns a new `Matrix4x4` instance with the specified column set to the new vector.\n * @since 1.0.0\n */\n (column: Matrix4x4Coordinate, v: Vector4): (m: Matrix4x4) => Matrix4x4\n} = internal.setColumn\n\n/**\n * Calculates the determinant of a `Matrix4x4`.\n *\n * @param m - The matrix to calculate the determinant of.\n * @returns The determinant of the matrix.\n * @since 1.0.0\n */\nexport const determinant: (m: Matrix4x4) => number = internal.determinant\n\n/**\n * Calculates the minor of a `Matrix4x4` at a given row and column.\n *\n * @param m - The matrix to calculate the minor of.\n * @param row - The row to exclude.\n * @param column - The column to exclude.\n * @returns The minor of the matrix at the given row and column.\n */\nexport const minor: (\n m: Matrix4x4,\n row: Matrix4x4Coordinate,\n column: Matrix4x4Coordinate,\n) => Matrix3x3 = internal.minor\n\nexport const vectorProductLeft: {\n /**\n * Calculates the left vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 2 * 18 + 3 * 19 + 4 * 20\n * // y = 5 * 17 + 6 * 18 + 7 * 19 + 8 * 20\n * // z = 9 * 17 + 10 * 18 + 11 * 19 + 12 * 20\n * // w = 13 * 17 + 14 * 18 + 15 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductLeft(m, v)\n * ```\n * @param m - The matrix to multiply.\n * @param v - The vector to multiply.\n * @returns The resulting vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, v: Vector4): Vector4\n /**\n * Calculates the left vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 2 * 18 + 3 * 19 + 4 * 20\n * // y = 5 * 17 + 6 * 18 + 7 * 19 + 8 * 20\n * // z = 9 * 17 + 10 * 18 + 11 * 19 + 12 * 20\n * // w = 13 * 17 + 14 * 18 + 15 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductLeft(v)(m)\n * ```\n * @since 1.0.0\n */\n (v: Vector4): (m: Matrix4x4) => Vector4\n} = internal.vectorProductLeft\n\nexport const vectorProductRight: {\n /**\n * Calculates the right vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 5 * 18 + 9 * 19 + 13 * 20\n * // y = 2 * 17 + 6 * 18 + 10 * 19 + 14 * 20\n * // z = 3 * 17 + 7 * 18 + 11 * 19 + 15 * 20\n * // w = 4 * 17 + 8 * 18 + 12 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductRight(m, v)\n * ```\n * @since 1.0.0\n */\n (m: Matrix4x4, v: Vector4): Vector4\n /**\n * Calculates the right vector product of a `Matrix4x4` and a `Vector4`.\n *\n * @example\n * ```ts\n * import * as Matrix4x4 from 'curvy/matrix4x4'\n * import * as Vector4 from 'curvy/vector4'\n *\n * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\n * const v = Vector4.make(17, 18, 19, 20)\n *\n * // Result:\n * // x = 1 * 17 + 5 * 18 + 9 * 19 + 13 * 20\n * // y = 2 * 17 + 6 * 18 + 10 * 19 + 14 * 20\n * // z = 3 * 17 + 7 * 18 + 11 * 19 + 15 * 20\n * // w = 4 * 17 + 8 * 18 + 12 * 19 + 16 * 20\n * const result = Matrix4x4.vectorProductRight(v)(m)\n * ```\n * @since 1.0.0\n */\n (v: Vector4): (m: Matrix4x4) => Vector4\n} = internal.vectorProductRight\n\nexport const multiply: {\n /**\n * Multiplies two `Matrix4x4` instances. Result is `a · b`.\n *\n * @param a - The left-hand matrix.\n * @param b - The right-hand matrix.\n * @returns The product matrix.\n * @since 1.1.0\n */\n (a: Matrix4x4, b: Matrix4x4): Matrix4x4\n /**\n * Multiplies two `Matrix4x4` instances. Result is `a · b`.\n *\n * @param b - The right-hand matrix.\n * @returns A function that takes the left-hand matrix and returns the product.\n * @since 1.1.0\n */\n (b: Matrix4x4): (a: Matrix4x4) => Matrix4x4\n} = internal.multiply\n\n/**\n * Returns the inverse of a `Matrix4x4`.\n *\n * Throws when the matrix is singular (determinant is zero).\n *\n * @param m - The matrix to invert.\n * @returns The inverse matrix.\n * @since 1.1.0\n */\nexport const inverse: (m: Matrix4x4) => Matrix4x4 = internal.inverse\n\nexport const solveSystem: {\n /**\n * Solves a system of linear equations represented by a `Matrix4x4` and a `Vector4`.\n *\n * @param m - The matrix representing the coefficients of the equations.\n * @param v - The vector representing the constants of the equations.\n * @returns The solution vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, v: Vector4): Vector4\n /**\n * Solves a system of linear equations represented by a `Matrix4x4` and a `Vector4`.\n *\n * @param v - The vector representing the constants of the equations.\n * @returns A function that takes a matrix and returns the solution vector.\n * @since 1.0.0\n */\n (v: Vector4): (m: Matrix4x4) => Vector4\n} = internal.solveSystem\n\n/**\n * Returns the rows of a `Matrix4x4` as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the rows of the matrix.\n * @since 1.0.0\n */\nexport const toRows: (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4] = internal.toRows as (\n m: Matrix4x4,\n) => [Vector4, Vector4, Vector4, Vector4]\n\n/**\n * Returns the columns of a `Matrix4x4` as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the columns of the matrix.\n * @since 1.0.0\n */\nexport const toColumns: (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4] =\n internal.toColumns as (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4]\n\nexport const rowVector: {\n /**\n * Returns a row vector from a `Matrix4x4`.\n *\n * @param m - The matrix to get the row vector from.\n * @param row - The row index.\n * @returns The row vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, row: Matrix4x4Coordinate): Vector4\n /**\n * Returns a row vector from a `Matrix4x4`.\n *\n * @param row - The row index.\n * @returns A function that takes a matrix and returns the row vector.\n * @since 1.0.0\n */\n (row: Matrix4x4Coordinate): (m: Matrix4x4) => Vector4\n} = internal.rowVector\n\nexport const columnVector: {\n /**\n * Returns a column vector from a `Matrix4x4`.\n *\n * @param m - The matrix to get the column vector from.\n * @param column - The column index.\n * @returns The column vector.\n * @since 1.0.0\n */\n (m: Matrix4x4, column: Matrix4x4Coordinate): Vector4\n /**\n * Returns a column vector from a `Matrix4x4`.\n *\n * @param column - The column index.\n * @returns A function that takes a matrix and returns the column vector.\n * @since 1.0.0\n */\n (column: Matrix4x4Coordinate): (m: Matrix4x4) => Vector4\n} = internal.columnVector\n\n/**\n * Transposes a `Matrix4x4`.\n *\n * @param m - The matrix to transpose.\n * @returns The transposed matrix.\n * @since 1.0.0\n */\nexport const transpose: (m: Matrix4x4) => Matrix4x4 = internal.transpose\n\n/**\n * Reverses the rows of a `Matrix4x4`.\n *\n * @param m - The matrix to reverse the rows of.\n * @returns The matrix with the rows reversed.\n * @since 1.0.0\n */\nexport const reverseRows: (m: Matrix4x4) => Matrix4x4 = internal.reverseRows\n\n/**\n * Reverses the columns of a `Matrix4x4`.\n *\n * @param m - The matrix to reverse the columns of.\n * @returns The matrix with the columns reversed.\n * @since 1.0.0\n */\nexport const reverseColumns: (m: Matrix4x4) => Matrix4x4 = internal.reverseColumns\n"],"mappings":";;;;;;AAkCA,SAAS,QAAQ,OAAgC;CAC/C,IAAI,OAAO,UAAU,UAAU;EAC7B,UAAU,SAAS,KAAK,SAAS,GAAG,sBAAsB;EAE1D,OAAO;;CAGT,IAAI,UAAU,KACZ,OAAO;CAGT,IAAI,UAAU,KACZ,OAAO;CAGT,IAAI,UAAU,KACZ,OAAO;CAGT,IAAI,UAAU,KACZ,OAAO;CAGT,UAAU,OAAO,oBAAoB;;AAGvC,MAAa,wBAAwB;AAGrC,MAAa,0BAA0B;AAGvC,MAAa,yBAAyB;;;AC1DtC,MAAa,kBAAiC,OAAO,IAAI,kBAAkB;AAG3E,IAAM,gBAAN,cAA4B,SAA8B;CACxD,CAAU,mBAAoC;CAE9C;CACA;CAEA;CACA;CAEA,YAAY,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG;EAC9C,OAAO;EACP,KAAK,MAAM;EACX,KAAK,MAAM;EACX,KAAK,MAAM;EACX,KAAK,MAAM;;CAGb,KAAK,OAAO,eAAe;EACzB,OAAO,aAAa,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI;;CAGtE,KAAK,OAAO,IAAI,6BAA6B,IAAI;EAC/C,OAAO,aAAa,KAAK,IAAI,IAAI,KAAK,IAAI,I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AAa,cACXC;AAEF,MAAa,SAoBTC;AAEJ,MAAa,YAoBTC;;;;;;;;AASJ,MAAa,cAAwCC;;;;;;;;;AAUrD,MAAa,QAIIC;AAEjB,MAAa,oBA8CTC;AAEJ,MAAa,qBA2CTC;AAEJ,MAAa,WAkBTC;;;;;;;;;;AAWJ,MAAa,UAAuCC;AAEpD,MAAa,cAkBTC;;;;;;;;AASJ,MAAa,SAAiEC;;;;;;;;AAW9E,MAAa,YACXC;AAEF,MAAa,YAkBTC;AAEJ,MAAa,eAkBTC;;;;;;;;AASJ,MAAa,YAAyCC;;;;;;;;AAStD,MAAa,cAA2CC;;;;;;;;AASxD,MAAa,iBAA8CC"}
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
2
- import { $ as equals$3, At as isMonotonic$2, Ct as equals$2, Dt as isDecreasing$2, Et as fromVector$2, Ft as solve$2, G as antiderivative$3, It as solveInverse$2, J as asMonotonic$3, K as asDecreasing$3, Lt as toInverseSolver$2, Mt as make$2, Nt as monotonicity$2, Ot as isIncreasing$2, Pt as range$2, Q as domain$3, Rt as toSolver$2, St as domain$2, Tt as fromPoints$2, X as curvature$1, Y as coefficients$3, Z as derivative$3, _t as asDecreasing$2, at as isMonotonic$3, bt as coefficients$2, ct as make$3, dt as roots$1, et as extreme$1, ft as solve$3, gt as antiderivative$2, ht as toSolver$3, it as isIncreasing$3, jt as length$2, kt as isLinearPolynomial$1, lt as monotonicity$3, mt as toInverseSolver$3, nt as fromVector$3, ot as isQuadraticPolynomial$1, pt as solveInverse$3, q as asIncreasing$3, rt as isDecreasing$3, st as length$3, tt as fromPoints$3, ut as range$3, vt as asIncreasing$2, wt as fromPointSlope$1, xt as derivative$2, yt as asMonotonic$2 } from "./cubic-BK8xjSkd.mjs";
2
+ import { $ as equals$3, At as isMonotonic$2, Ct as equals$2, Dt as isDecreasing$2, Et as fromVector$2, Ft as solve$2, G as antiderivative$3, It as solveInverse$2, J as asMonotonic$3, K as asDecreasing$3, Lt as toInverseSolver$2, Mt as make$2, Nt as monotonicity$2, Ot as isIncreasing$2, Pt as range$2, Q as domain$3, Rt as toSolver$2, St as domain$2, Tt as fromPoints$2, X as curvature$1, Y as coefficients$3, Z as derivative$3, _t as asDecreasing$2, at as isMonotonic$3, bt as coefficients$2, ct as make$3, dt as roots$1, et as extreme$1, ft as solve$3, gt as antiderivative$2, ht as toSolver$3, it as isIncreasing$3, jt as length$2, kt as isLinearPolynomial$1, lt as monotonicity$3, mt as toInverseSolver$3, nt as fromVector$3, ot as isQuadraticPolynomial$1, pt as solveInverse$3, q as asIncreasing$3, rt as isDecreasing$3, st as length$3, tt as fromPoints$3, ut as range$3, vt as asIncreasing$2, wt as fromPointSlope$1, xt as derivative$2, yt as asMonotonic$2 } from "./cubic-NEn7E6V_.mjs";
3
3
  //#region src/polynomial/linear.ts
4
4
  var linear_exports = /* @__PURE__ */ __exportAll({
5
5
  antiderivative: () => antiderivative$1,
@@ -345,4 +345,4 @@ const curvature = curvature$1;
345
345
  //#endregion
346
346
  export { solveInverse$1 as _, make as a, solve as c, isIncreasing$1 as d, isMonotonic$1 as f, solve$1 as g, range$1 as h, isMonotonic as i, solveInverse as l, make$1 as m, isDecreasing as n, quadratic_exports as o, linear_exports as p, isIncreasing as r, range as s, derivative as t, isDecreasing$1 as u };
347
347
 
348
- //# sourceMappingURL=quadratic-CWXIRh42.mjs.map
348
+ //# sourceMappingURL=quadratic-Dlxqo2V1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"quadratic-CWXIRh42.mjs","names":["internal.isLinearPolynomial","equals","internal.equals","make","internal.make","fromVector","internal.fromVector","internal.fromPointSlope","fromPoints","internal.fromPoints","solve","internal.solve","toSolver","internal.toSolver","solveInverse","internal.solveInverse","toInverseSolver","internal.toInverseSolver","monotonicity","internal.monotonicity","isMonotonic","internal.isMonotonic","isIncreasing","internal.isIncreasing","isDecreasing","internal.isDecreasing","asMonotonic","internal.asMonotonic","asIncreasing","internal.asIncreasing","asDecreasing","internal.asDecreasing","coefficients","internal.coefficients","derivative","internal.derivative","antiderivative","internal.antiderivative","domain","internal.domain","range","internal.range","length","internal.length","internal.isQuadraticPolynomial","internal.equals","internal.make","internal.fromVector","internal.fromPoints","internal.solve","internal.toSolver","internal.solveInverse","internal.toInverseSolver","internal.coefficients","internal.derivative","internal.roots","internal.extreme","internal.monotonicity","internal.isMonotonic","internal.isIncreasing","internal.isDecreasing","internal.asMonotonic","internal.asIncreasing","internal.asDecreasing","internal.antiderivative","internal.domain","internal.range","internal.length","internal.curvature"],"sources":["../../src/polynomial/linear.ts","../../src/polynomial/quadratic.ts"],"sourcesContent":["import type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPolynomialTypeId } from './linear.internal.ts'\nimport * as internal from './linear.internal.ts'\nimport type { GuaranteedMonotonicity } from './monotonicity.ts'\nimport type { QuadraticPolynomial } from './quadratic.ts'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits.ts'\n\n/**\n * A linear polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. The runtime value carries no trait data — `Traits` only flows\n * through the type system to enable tighter return types on operations like\n * `solveInverse`.\n *\n * @since 1.0.0\n */\nexport interface LinearPolynomial<out Traits = unknown> extends Pipeable {\n readonly [LinearPolynomialTypeId]: LinearPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n}\n\n/**\n * Checks if a value is a `LinearPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `LinearPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPolynomial: (v: unknown) => v is LinearPolynomial = internal.isLinearPolynomial\n\nexport const equals: {\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: LinearPolynomial, b: LinearPolynomial): boolean\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: LinearPolynomial): (a: LinearPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `LinearPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number) => LinearPolynomial = internal.make\n\n/**\n * Creates a new `LinearPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector2) => LinearPolynomial = internal.fromVector\n\n/**\n * Creates a new `LinearPolynomial` instance from a point and slope.\n *\n * @param p - The point on the line.\n * @param slope - The slope of the line.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPointSlope: (p: Vector2, slope: number) => LinearPolynomial =\n internal.fromPointSlope\n\n/**\n * Creates a new `LinearPolynomial` instance from two points.\n *\n * @param p1 - The first point.\n * @param p2 - The second point.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPoints: (p1: Vector2, p2: Vector2) => LinearPolynomial = internal.fromPoints\n\nexport const solve: {\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param p - The linear polynomial to solve.\n * @param x - The value of x to solve for.\n * @returns The result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (p: LinearPolynomial, x: number): number\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param x - The value of x to solve for.\n * @returns A function that takes a `LinearPolynomial` and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (x: number): (p: LinearPolynomial) => number\n} = internal.solve\n\n/**\n * Converts a linear polynomial to a solver function.\n *\n * @param p - The linear polynomial to convert.\n * @returns A function that takes a value of x and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\nexport const toSolver: (p: LinearPolynomial) => (x: number) => number = internal.toSolver\n\n// The implementation always runs the same `c1 === 0 ? Solution.none : ...`\n// branch. For `Monotonic`-branded polynomials the empty branch is provably\n// unreachable, but TS can't see that — the cast pairs the type-level promise\n// with the runtime brand check.\nexport const solveInverse: {\n /**\n * Solves a monotonic linear polynomial for a given value of y. Because the\n * polynomial is strictly monotonic, the inverse always has exactly one\n * solution — wrapped in `Solution.One`.\n *\n * @param p - The monotonic linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: LinearPolynomial<T>, y: number): Solution.One<number>\n /**\n * Solves a linear polynomial for a given value of y. Returns `Solution.none`\n * for constant polynomials (no inverse).\n *\n * @param p - The linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 1.0.0\n */\n <T>(p: LinearPolynomial<T>, y: number): Solution.AtMostOne<number>\n /** @since 1.0.0 */\n (y: number): {\n <T extends Monotonic>(p: LinearPolynomial<T>): Solution.One<number>\n <T>(p: LinearPolynomial<T>): Solution.AtMostOne<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Converts a linear polynomial to an inverse solver function.\n *\n * @param p - The linear polynomial to convert.\n * @since 1.0.0\n */\nexport const toInverseSolver: (p: LinearPolynomial) => (y: number) => Solution.AtMostOne<number> =\n internal.toInverseSolver\n\n/**\n * Finds the roots of a linear polynomial.\n *\n * @param p - The linear polynomial to find the roots of.\n * @since 1.0.0\n */\nexport const root: (p: LinearPolynomial) => Solution.AtMostOne<number> = (p) =>\n internal.solveInverse(p, 0)\n\n/**\n * Calculates the monotonicity of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @returns The guaranteed monotonicity of the polynomial.\n * @since 1.0.0\n */\nexport const monotonicity: (p: LinearPolynomial) => GuaranteedMonotonicity = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `LinearPolynomial<T>` to\n * `LinearPolynomial<T & Monotonic>` when the polynomial is strictly monotonic.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'increasing'` or `'decreasing'`.\n * @since 2.0.0\n */\nexport const isMonotonic: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Monotonic> =\n internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Increasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'increasing'`.\n * @since 2.0.0\n */\nexport const isIncreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Increasing> =\n internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Decreasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'decreasing'`.\n * @since 2.0.0\n */\nexport const isDecreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Decreasing> =\n internal.isDecreasing\n\n/**\n * Asserts that the linear polynomial is monotonic, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When `monotonicity(p)` is `'constant'`.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Monotonic> =\n internal.asMonotonic\n\n/**\n * Asserts that the linear polynomial is increasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Increasing` brand.\n * @throws When `monotonicity(p)` is not `'increasing'`.\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Increasing> =\n internal.asIncreasing\n\n/**\n * Asserts that the linear polynomial is decreasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Decreasing` brand.\n * @throws When `monotonicity(p)` is not `'decreasing'`.\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Decreasing> =\n internal.asDecreasing\n\n/**\n * Returns the polynomial's coefficients as a tuple `[c0, c1]`.\n *\n * @param p - The linear polynomial.\n * @returns The coefficients in monomial order.\n * @since 2.0.0\n */\nexport const coefficients: (p: LinearPolynomial) => readonly [number, number] =\n internal.coefficients\n\n/**\n * Calculates the derivative of a linear polynomial.\n *\n * @param p - The linear polynomial to differentiate.\n * @returns The derivative of the linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: LinearPolynomial) => number = internal.derivative\n\nexport const antiderivative: {\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param p - The linear polynomial to integrate.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the linear polynomial.\n * @since 1.0.0\n */\n (p: LinearPolynomial, constant?: number): QuadraticPolynomial\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a `LinearPolynomial` and returns the antiderivative of the polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: LinearPolynomial) => QuadraticPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param range - The range to check against.\n * @returns The domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (p: LinearPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param range - The range to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (range: Interval): (p: LinearPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param domain - The domain to check against.\n * @returns The range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): Closed\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param domain - The domain to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => Closed\n} = internal.range\n\nexport const length: {\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param p - The linear polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The length of the linear polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): number\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a `LinearPolynomial` and returns the length of the polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => number\n} = internal.length\n","import type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport type { CubicPolynomial } from './cubic.ts'\nimport type { LinearPolynomial } from './linear.ts'\nimport type { Monotonicity } from './monotonicity.ts'\nimport * as internal from './quadratic.internal.ts'\nimport type { QuadraticPolynomialTypeId } from './quadratic.internal.circular.ts'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits.ts'\n\n/**\n * A quadratic polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. Refinements may be parameterized by an `Interval` — a quadratic is\n * monotonic on an interval that avoids its extremum, even though it is not\n * monotonic globally.\n *\n * @since 1.0.0\n */\nexport interface QuadraticPolynomial<out Traits = unknown> extends Pipeable {\n readonly [QuadraticPolynomialTypeId]: QuadraticPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n /**\n * The coefficient of the x^2 term.\n */\n readonly c2: number\n}\n\n/**\n * Checks if a value is a `QuadraticPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `QuadraticPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticPolynomial: (v: unknown) => v is QuadraticPolynomial =\n internal.isQuadraticPolynomial\n\nexport const equals: {\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: QuadraticPolynomial, b: QuadraticPolynomial): boolean\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: QuadraticPolynomial): (a: QuadraticPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `QuadraticPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @param c2 - The coefficient of the x^2 term. Defaults to 1.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number, c2?: number) => QuadraticPolynomial = internal.make\n\n/**\n * Creates a new `QuadraticPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector3) => QuadraticPolynomial = internal.fromVector\n\n/**\n * Creates a new `QuadraticPolynomial` that interpolates the three given\n * points, treating each `Vector2` as an `(x, y)` pair. The three input `x`\n * values must be distinct.\n *\n * @param p0 - The first point.\n * @param p1 - The second point.\n * @param p2 - The third point.\n * @returns The unique quadratic polynomial passing through the three points.\n * @since 2.0.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticPolynomial =\n internal.fromPoints\n\nexport const solve: {\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to solve for.\n * @returns The result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param x - The x value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.solve\n\n/**\n * Creates a solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes an x value and returns the result of the polynomial at that x value.\n */\nexport const toSolver: (p: QuadraticPolynomial) => (x: number) => number = internal.toSolver\n\nexport const solveInverse: {\n /**\n * Solves a monotonic quadratic polynomial for a given y value. Because the\n * polynomial is strictly monotonic (either globally, or over the interval\n * the `Monotonic` brand was attached for), the inverse has at most one\n * solution.\n *\n * @param p - The monotonic quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns Zero or one solutions.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostOne<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param p - The quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns The solutions to the polynomial at the given y value.\n * @since 1.0.0\n */\n <T>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostTwo<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param y - The y value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the\n * solutions. Tightens to `Solution.AtMostOne<number>` for monotonic inputs.\n * @since 1.0.0\n */\n (y: number): {\n <T extends Monotonic>(p: QuadraticPolynomial<T>): Solution.AtMostOne<number>\n <T>(p: QuadraticPolynomial<T>): Solution.AtMostTwo<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Creates an inverse solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes a y value and returns the solutions to the polynomial at that y value.\n */\nexport const toInverseSolver: (\n p: QuadraticPolynomial,\n) => (y: number) => Solution.AtMostTwo<number> = internal.toInverseSolver\n\n/**\n * Returns the polynomial's coefficients as a tuple `[c0, c1, c2]`.\n *\n * @param p - The quadratic polynomial.\n * @returns The coefficients in monomial order.\n * @since 2.0.0\n */\nexport const coefficients: (p: QuadraticPolynomial) => readonly [number, number, number] =\n internal.coefficients\n\n/**\n * Computes the derivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The derivative of the polynomial as a linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: QuadraticPolynomial) => LinearPolynomial = internal.derivative\n\n/**\n * Finds the roots of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The roots of the polynomial as a tuple of solutions.\n * @since 1.0.0\n */\nexport const roots: (p: QuadraticPolynomial) => Solution.AtMostTwo<number> = internal.roots\n\n/**\n * Finds the extreme point of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The extreme point of the polynomial as a solution.\n * @since 1.0.0\n */\nexport const extreme: (p: QuadraticPolynomial) => Vector2 | null = internal.extreme\n\nexport const monotonicity: {\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width — the question is\n * undefined at a single point.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the monotonicity over.\n * @returns The monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i?: Interval): Monotonicity\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width.\n *\n * @param i - The interval to compute the monotonicity over.\n * @returns A function that takes a quadratic polynomial and returns the\n * monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => Monotonicity\n} = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `QuadraticPolynomial<T>` to\n * `QuadraticPolynomial<T & Monotonic>` when the polynomial is strictly\n * monotonic over the given interval (or globally, when no interval is given).\n *\n * @param p - The quadratic polynomial to check.\n * @param i - Optional interval over which to check monotonicity.\n * @returns `true` when monotonicity is `'increasing'` or `'decreasing'`.\n * @since 2.0.0\n */\nexport const isMonotonic: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Monotonic>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Monotonic>\n} = internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Increasing>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Increasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Increasing>\n} = internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Decreasing>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Decreasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Decreasing>\n} = internal.isDecreasing\n\n/**\n * Asserts that the quadratic polynomial is monotonic, throwing on failure.\n *\n * @param p - The quadratic polynomial to assert against.\n * @param i - Optional interval over which to check monotonicity.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When the polynomial is not monotonic over the given (or global) interval.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Monotonic> = internal.asMonotonic\n\n/**\n * Asserts that the quadratic polynomial is increasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Increasing> = internal.asIncreasing\n\n/**\n * Asserts that the quadratic polynomial is decreasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Decreasing> = internal.asDecreasing\n\nexport const antiderivative: {\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, constant?: number): CubicPolynomial\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a quadratic polynomial and returns the antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: QuadraticPolynomial) => CubicPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param p - The quadratic polynomial.\n * @param range - The range to compute the domain over.\n * @returns The domain of the polynomial over the range.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param range - The range to compute the domain over.\n * @returns A function that takes a quadratic polynomial and returns the domain of the polynomial over the range.\n * @since 1.0.0\n */\n (range: Interval): (p: QuadraticPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param p - The quadratic polynomial.\n * @param domain - The domain to compute the range over.\n * @returns The range of the polynomial over the domain.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, domain: Interval): Closed\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param domain - The domain to compute the range over.\n * @returns A function that takes a quadratic polynomial and returns the range of the polynomial over the domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: QuadraticPolynomial) => Closed\n} = internal.range\n\nexport const length: {\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the length over.\n * @returns The length of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i: Interval): number\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param i - The interval to compute the length over.\n * @returns A function that takes a quadratic polynomial and returns the length of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => number\n} = internal.length\n\nexport const curvature: {\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to compute the curvature at.\n * @returns The curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param x - The x value to compute the curvature at.\n * @returns A function that takes a quadratic polynomial and returns the curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.curvature\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,qBAA4DA;AAEzE,MAAaC,WAoBTC;;;;;;;;;AAUJ,MAAaC,SAAuDC;;;;;;;;AASpE,MAAaC,eAA+CC;;;;;;;;;AAU5D,MAAa,iBACXC;;;;;;;;;AAUF,MAAaC,eAA6DC;AAE1E,MAAaC,UAkBTC;;;;;;;;AASJ,MAAaC,aAA2DC;AAMxE,MAAaC,iBAyBTC;;;;;;;AAQJ,MAAaC,oBACXC;;;;;;;AAQF,MAAa,QAA6D,MACxEF,eAAsB,GAAG,EAAE;;;;;;;;AAS7B,MAAaG,iBAAgEC;;;;;;;;;AAU7E,MAAaC,gBACXC;;;;;;;;AASF,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,iBACXC;;;;;;;;;AAUF,MAAaC,gBACXC;;;;;;;;;AAUF,MAAaC,iBACXC;;;;;;;;;AAUF,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,eAA8CC;AAE3D,MAAaC,mBAkBTC;AAEJ,MAAaC,WAkBTC;AAEJ,MAAaC,UAkBTC;AAEJ,MAAaC,WAkBTC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACnTJ,MAAa,wBACXC;AAEF,MAAa,SAoBTC;;;;;;;;;;AAWJ,MAAa,OAAuEC;;;;;;;;AASpF,MAAa,aAAkDC;;;;;;;;;;;;AAa/D,MAAa,aACXC;AAEF,MAAa,QAkBTC;;;;;;;AAQJ,MAAa,WAA8DC;AAE3E,MAAa,eAkCTC;;;;;;;AAQJ,MAAa,kBAEoCC;;;;;;;;AASjD,MAAa,eACXC;;;;;;;;AASF,MAAa,aAA2DC;;;;;;;;AASxE,MAAa,QAAgEC;;;;;;;;AAS7E,MAAa,UAAsDC;AAEnE,MAAa,eAsBTC;;;;;;;;;;;AAYJ,MAAa,cAGTC;;;;;;AAOJ,MAAa,eAGTC;;;;;;AAOJ,MAAa,eAGTC;;;;;;;;;;AAWJ,MAAa,cAG6BC;;;;;;AAO1C,MAAa,eAG8BC;;;;;;AAO3C,MAAa,eAG8BC;AAE3C,MAAa,iBAkBTC;AAEJ,MAAa,SAkBTC;AAEJ,MAAa,QAkBTC;AAEJ,MAAa,SAkBTC;AAEJ,MAAa,YAkBTC"}
1
+ {"version":3,"file":"quadratic-Dlxqo2V1.mjs","names":["internal.isLinearPolynomial","equals","internal.equals","make","internal.make","fromVector","internal.fromVector","internal.fromPointSlope","fromPoints","internal.fromPoints","solve","internal.solve","toSolver","internal.toSolver","solveInverse","internal.solveInverse","toInverseSolver","internal.toInverseSolver","monotonicity","internal.monotonicity","isMonotonic","internal.isMonotonic","isIncreasing","internal.isIncreasing","isDecreasing","internal.isDecreasing","asMonotonic","internal.asMonotonic","asIncreasing","internal.asIncreasing","asDecreasing","internal.asDecreasing","coefficients","internal.coefficients","derivative","internal.derivative","antiderivative","internal.antiderivative","domain","internal.domain","range","internal.range","length","internal.length","internal.isQuadraticPolynomial","internal.equals","internal.make","internal.fromVector","internal.fromPoints","internal.solve","internal.toSolver","internal.solveInverse","internal.toInverseSolver","internal.coefficients","internal.derivative","internal.roots","internal.extreme","internal.monotonicity","internal.isMonotonic","internal.isIncreasing","internal.isDecreasing","internal.asMonotonic","internal.asIncreasing","internal.asDecreasing","internal.antiderivative","internal.domain","internal.range","internal.length","internal.curvature"],"sources":["../../src/polynomial/linear.ts","../../src/polynomial/quadratic.ts"],"sourcesContent":["import type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPolynomialTypeId } from './linear.internal.ts'\nimport * as internal from './linear.internal.ts'\nimport type { GuaranteedMonotonicity } from './monotonicity.ts'\nimport type { QuadraticPolynomial } from './quadratic.ts'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits.ts'\n\n/**\n * A linear polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. The runtime value carries no trait data — `Traits` only flows\n * through the type system to enable tighter return types on operations like\n * `solveInverse`.\n *\n * @since 1.0.0\n */\nexport interface LinearPolynomial<out Traits = unknown> extends Pipeable {\n readonly [LinearPolynomialTypeId]: LinearPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n}\n\n/**\n * Checks if a value is a `LinearPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `LinearPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPolynomial: (v: unknown) => v is LinearPolynomial = internal.isLinearPolynomial\n\nexport const equals: {\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: LinearPolynomial, b: LinearPolynomial): boolean\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: LinearPolynomial): (a: LinearPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `LinearPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number) => LinearPolynomial = internal.make\n\n/**\n * Creates a new `LinearPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector2) => LinearPolynomial = internal.fromVector\n\n/**\n * Creates a new `LinearPolynomial` instance from a point and slope.\n *\n * @param p - The point on the line.\n * @param slope - The slope of the line.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPointSlope: (p: Vector2, slope: number) => LinearPolynomial =\n internal.fromPointSlope\n\n/**\n * Creates a new `LinearPolynomial` instance from two points.\n *\n * @param p1 - The first point.\n * @param p2 - The second point.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPoints: (p1: Vector2, p2: Vector2) => LinearPolynomial = internal.fromPoints\n\nexport const solve: {\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param p - The linear polynomial to solve.\n * @param x - The value of x to solve for.\n * @returns The result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (p: LinearPolynomial, x: number): number\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param x - The value of x to solve for.\n * @returns A function that takes a `LinearPolynomial` and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (x: number): (p: LinearPolynomial) => number\n} = internal.solve\n\n/**\n * Converts a linear polynomial to a solver function.\n *\n * @param p - The linear polynomial to convert.\n * @returns A function that takes a value of x and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\nexport const toSolver: (p: LinearPolynomial) => (x: number) => number = internal.toSolver\n\n// The implementation always runs the same `c1 === 0 ? Solution.none : ...`\n// branch. For `Monotonic`-branded polynomials the empty branch is provably\n// unreachable, but TS can't see that — the cast pairs the type-level promise\n// with the runtime brand check.\nexport const solveInverse: {\n /**\n * Solves a monotonic linear polynomial for a given value of y. Because the\n * polynomial is strictly monotonic, the inverse always has exactly one\n * solution — wrapped in `Solution.One`.\n *\n * @param p - The monotonic linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: LinearPolynomial<T>, y: number): Solution.One<number>\n /**\n * Solves a linear polynomial for a given value of y. Returns `Solution.none`\n * for constant polynomials (no inverse).\n *\n * @param p - The linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 1.0.0\n */\n <T>(p: LinearPolynomial<T>, y: number): Solution.AtMostOne<number>\n /** @since 1.0.0 */\n (y: number): {\n <T extends Monotonic>(p: LinearPolynomial<T>): Solution.One<number>\n <T>(p: LinearPolynomial<T>): Solution.AtMostOne<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Converts a linear polynomial to an inverse solver function.\n *\n * @param p - The linear polynomial to convert.\n * @since 1.0.0\n */\nexport const toInverseSolver: (p: LinearPolynomial) => (y: number) => Solution.AtMostOne<number> =\n internal.toInverseSolver\n\n/**\n * Finds the roots of a linear polynomial.\n *\n * @param p - The linear polynomial to find the roots of.\n * @since 1.0.0\n */\nexport const root: (p: LinearPolynomial) => Solution.AtMostOne<number> = (p) =>\n internal.solveInverse(p, 0)\n\n/**\n * Calculates the monotonicity of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @returns The guaranteed monotonicity of the polynomial.\n * @since 1.0.0\n */\nexport const monotonicity: (p: LinearPolynomial) => GuaranteedMonotonicity = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `LinearPolynomial<T>` to\n * `LinearPolynomial<T & Monotonic>` when the polynomial is strictly monotonic.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'increasing'` or `'decreasing'`.\n * @since 2.0.0\n */\nexport const isMonotonic: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Monotonic> =\n internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Increasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'increasing'`.\n * @since 2.0.0\n */\nexport const isIncreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Increasing> =\n internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Decreasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'decreasing'`.\n * @since 2.0.0\n */\nexport const isDecreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Decreasing> =\n internal.isDecreasing\n\n/**\n * Asserts that the linear polynomial is monotonic, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When `monotonicity(p)` is `'constant'`.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Monotonic> =\n internal.asMonotonic\n\n/**\n * Asserts that the linear polynomial is increasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Increasing` brand.\n * @throws When `monotonicity(p)` is not `'increasing'`.\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Increasing> =\n internal.asIncreasing\n\n/**\n * Asserts that the linear polynomial is decreasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Decreasing` brand.\n * @throws When `monotonicity(p)` is not `'decreasing'`.\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Decreasing> =\n internal.asDecreasing\n\n/**\n * Returns the polynomial's coefficients as a tuple `[c0, c1]`.\n *\n * @param p - The linear polynomial.\n * @returns The coefficients in monomial order.\n * @since 2.0.0\n */\nexport const coefficients: (p: LinearPolynomial) => readonly [number, number] =\n internal.coefficients\n\n/**\n * Calculates the derivative of a linear polynomial.\n *\n * @param p - The linear polynomial to differentiate.\n * @returns The derivative of the linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: LinearPolynomial) => number = internal.derivative\n\nexport const antiderivative: {\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param p - The linear polynomial to integrate.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the linear polynomial.\n * @since 1.0.0\n */\n (p: LinearPolynomial, constant?: number): QuadraticPolynomial\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a `LinearPolynomial` and returns the antiderivative of the polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: LinearPolynomial) => QuadraticPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param range - The range to check against.\n * @returns The domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (p: LinearPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param range - The range to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (range: Interval): (p: LinearPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param domain - The domain to check against.\n * @returns The range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): Closed\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param domain - The domain to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => Closed\n} = internal.range\n\nexport const length: {\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param p - The linear polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The length of the linear polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): number\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a `LinearPolynomial` and returns the length of the polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => number\n} = internal.length\n","import type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport type { CubicPolynomial } from './cubic.ts'\nimport type { LinearPolynomial } from './linear.ts'\nimport type { Monotonicity } from './monotonicity.ts'\nimport * as internal from './quadratic.internal.ts'\nimport type { QuadraticPolynomialTypeId } from './quadratic.internal.circular.ts'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits.ts'\n\n/**\n * A quadratic polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. Refinements may be parameterized by an `Interval` — a quadratic is\n * monotonic on an interval that avoids its extremum, even though it is not\n * monotonic globally.\n *\n * @since 1.0.0\n */\nexport interface QuadraticPolynomial<out Traits = unknown> extends Pipeable {\n readonly [QuadraticPolynomialTypeId]: QuadraticPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n /**\n * The coefficient of the x^2 term.\n */\n readonly c2: number\n}\n\n/**\n * Checks if a value is a `QuadraticPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `QuadraticPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticPolynomial: (v: unknown) => v is QuadraticPolynomial =\n internal.isQuadraticPolynomial\n\nexport const equals: {\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: QuadraticPolynomial, b: QuadraticPolynomial): boolean\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: QuadraticPolynomial): (a: QuadraticPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `QuadraticPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @param c2 - The coefficient of the x^2 term. Defaults to 1.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number, c2?: number) => QuadraticPolynomial = internal.make\n\n/**\n * Creates a new `QuadraticPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector3) => QuadraticPolynomial = internal.fromVector\n\n/**\n * Creates a new `QuadraticPolynomial` that interpolates the three given\n * points, treating each `Vector2` as an `(x, y)` pair. The three input `x`\n * values must be distinct.\n *\n * @param p0 - The first point.\n * @param p1 - The second point.\n * @param p2 - The third point.\n * @returns The unique quadratic polynomial passing through the three points.\n * @since 2.0.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticPolynomial =\n internal.fromPoints\n\nexport const solve: {\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to solve for.\n * @returns The result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param x - The x value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.solve\n\n/**\n * Creates a solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes an x value and returns the result of the polynomial at that x value.\n */\nexport const toSolver: (p: QuadraticPolynomial) => (x: number) => number = internal.toSolver\n\nexport const solveInverse: {\n /**\n * Solves a monotonic quadratic polynomial for a given y value. Because the\n * polynomial is strictly monotonic (either globally, or over the interval\n * the `Monotonic` brand was attached for), the inverse has at most one\n * solution.\n *\n * @param p - The monotonic quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns Zero or one solutions.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostOne<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param p - The quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns The solutions to the polynomial at the given y value.\n * @since 1.0.0\n */\n <T>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostTwo<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param y - The y value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the\n * solutions. Tightens to `Solution.AtMostOne<number>` for monotonic inputs.\n * @since 1.0.0\n */\n (y: number): {\n <T extends Monotonic>(p: QuadraticPolynomial<T>): Solution.AtMostOne<number>\n <T>(p: QuadraticPolynomial<T>): Solution.AtMostTwo<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Creates an inverse solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes a y value and returns the solutions to the polynomial at that y value.\n */\nexport const toInverseSolver: (\n p: QuadraticPolynomial,\n) => (y: number) => Solution.AtMostTwo<number> = internal.toInverseSolver\n\n/**\n * Returns the polynomial's coefficients as a tuple `[c0, c1, c2]`.\n *\n * @param p - The quadratic polynomial.\n * @returns The coefficients in monomial order.\n * @since 2.0.0\n */\nexport const coefficients: (p: QuadraticPolynomial) => readonly [number, number, number] =\n internal.coefficients\n\n/**\n * Computes the derivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The derivative of the polynomial as a linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: QuadraticPolynomial) => LinearPolynomial = internal.derivative\n\n/**\n * Finds the roots of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The roots of the polynomial as a tuple of solutions.\n * @since 1.0.0\n */\nexport const roots: (p: QuadraticPolynomial) => Solution.AtMostTwo<number> = internal.roots\n\n/**\n * Finds the extreme point of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The extreme point of the polynomial as a solution.\n * @since 1.0.0\n */\nexport const extreme: (p: QuadraticPolynomial) => Vector2 | null = internal.extreme\n\nexport const monotonicity: {\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width — the question is\n * undefined at a single point.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the monotonicity over.\n * @returns The monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i?: Interval): Monotonicity\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width.\n *\n * @param i - The interval to compute the monotonicity over.\n * @returns A function that takes a quadratic polynomial and returns the\n * monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => Monotonicity\n} = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `QuadraticPolynomial<T>` to\n * `QuadraticPolynomial<T & Monotonic>` when the polynomial is strictly\n * monotonic over the given interval (or globally, when no interval is given).\n *\n * @param p - The quadratic polynomial to check.\n * @param i - Optional interval over which to check monotonicity.\n * @returns `true` when monotonicity is `'increasing'` or `'decreasing'`.\n * @since 2.0.0\n */\nexport const isMonotonic: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Monotonic>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Monotonic>\n} = internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Increasing>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Increasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Increasing>\n} = internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Decreasing>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Decreasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Decreasing>\n} = internal.isDecreasing\n\n/**\n * Asserts that the quadratic polynomial is monotonic, throwing on failure.\n *\n * @param p - The quadratic polynomial to assert against.\n * @param i - Optional interval over which to check monotonicity.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When the polynomial is not monotonic over the given (or global) interval.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Monotonic> = internal.asMonotonic\n\n/**\n * Asserts that the quadratic polynomial is increasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Increasing> = internal.asIncreasing\n\n/**\n * Asserts that the quadratic polynomial is decreasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Decreasing> = internal.asDecreasing\n\nexport const antiderivative: {\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, constant?: number): CubicPolynomial\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a quadratic polynomial and returns the antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: QuadraticPolynomial) => CubicPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param p - The quadratic polynomial.\n * @param range - The range to compute the domain over.\n * @returns The domain of the polynomial over the range.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param range - The range to compute the domain over.\n * @returns A function that takes a quadratic polynomial and returns the domain of the polynomial over the range.\n * @since 1.0.0\n */\n (range: Interval): (p: QuadraticPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param p - The quadratic polynomial.\n * @param domain - The domain to compute the range over.\n * @returns The range of the polynomial over the domain.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, domain: Interval): Closed\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param domain - The domain to compute the range over.\n * @returns A function that takes a quadratic polynomial and returns the range of the polynomial over the domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: QuadraticPolynomial) => Closed\n} = internal.range\n\nexport const length: {\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the length over.\n * @returns The length of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i: Interval): number\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param i - The interval to compute the length over.\n * @returns A function that takes a quadratic polynomial and returns the length of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => number\n} = internal.length\n\nexport const curvature: {\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to compute the curvature at.\n * @returns The curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param x - The x value to compute the curvature at.\n * @returns A function that takes a quadratic polynomial and returns the curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.curvature\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,qBAA4DA;AAEzE,MAAaC,WAoBTC;;;;;;;;;AAUJ,MAAaC,SAAuDC;;;;;;;;AASpE,MAAaC,eAA+CC;;;;;;;;;AAU5D,MAAa,iBACXC;;;;;;;;;AAUF,MAAaC,eAA6DC;AAE1E,MAAaC,UAkBTC;;;;;;;;AASJ,MAAaC,aAA2DC;AAMxE,MAAaC,iBAyBTC;;;;;;;AAQJ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{ a as make, i as magnitude, n as cross } from "./vector2-CWU3cPB2.mjs";
4
- import { n as transpose } from "./vector4-oqPPp45j.mjs";
3
+ import { a as make, i as magnitude, n as cross } from "./vector2-CSkaMXvp.mjs";
4
+ import { n as transpose } from "./vector4-PO_7EYd-.mjs";
5
5
  import { l as scaleShift, m as unitOpen, p as unit, t as biunit, u as size } from "./interval-CqC3ZIqj.mjs";
6
6
  import { a as match, i as map, o as none, s as one, t as clip } from "./solution-UKGK826h.mjs";
7
- import { A as GL32_X1, B as GL32_X5, C as GL32_W4, D as GL32_W8, E as GL32_W7, F as GL32_X14, H as GL32_X7, I as GL32_X15, L as GL32_X2, M as GL32_X11, N as GL32_X12, O as GL32_W9, P as GL32_X13, R as GL32_X3, S as GL32_W3, T as GL32_W6, U as GL32_X8, V as GL32_X6, W as GL32_X9, _ as GL32_W12, a as isIncreasing$6, b as GL32_W15, c as range, d as solveInverse, f as subdivide$2, g as GL32_W11, h as GL32_W10, i as isDecreasing$6, j as GL32_X10, k as GL32_X0, l as roots, m as GL32_W1, n as derivative$5, o as isMonotonic$6, p as GL32_W0, s as make$1, u as solve$8, v as GL32_W13, w as GL32_W5, x as GL32_W2, y as GL32_W14, z as GL32_X4 } from "./cubic-BK8xjSkd.mjs";
8
- import { _ as solveInverse$1, a as make$3, c as solve$10, d as isIncreasing$7, f as isMonotonic$7, g as solve$9, h as range$1, i as isMonotonic$8, l as solveInverse$2, m as make$2, n as isDecreasing$8, r as isIncreasing$8, s as range$2, t as derivative$6, u as isDecreasing$7 } from "./quadratic-CWXIRh42.mjs";
9
- import { i as maxDistance, r as make$4, t as fromVectors } from "./interval2d-BMDmeL1M.mjs";
10
- import { i as cubicBezier, t as apply } from "./characteristic-D9yZWCym.mjs";
7
+ import { A as GL32_X1, B as GL32_X5, C as GL32_W4, D as GL32_W8, E as GL32_W7, F as GL32_X14, H as GL32_X7, I as GL32_X15, L as GL32_X2, M as GL32_X11, N as GL32_X12, O as GL32_W9, P as GL32_X13, R as GL32_X3, S as GL32_W3, T as GL32_W6, U as GL32_X8, V as GL32_X6, W as GL32_X9, _ as GL32_W12, a as isIncreasing$6, b as GL32_W15, c as range, d as solveInverse, f as subdivide$2, g as GL32_W11, h as GL32_W10, i as isDecreasing$6, j as GL32_X10, k as GL32_X0, l as roots, m as GL32_W1, n as derivative$5, o as isMonotonic$6, p as GL32_W0, s as make$1, u as solve$8, v as GL32_W13, w as GL32_W5, x as GL32_W2, y as GL32_W14, z as GL32_X4 } from "./cubic-NEn7E6V_.mjs";
8
+ import { _ as solveInverse$1, a as make$3, c as solve$10, d as isIncreasing$7, f as isMonotonic$7, g as solve$9, h as range$1, i as isMonotonic$8, l as solveInverse$2, m as make$2, n as isDecreasing$8, r as isIncreasing$8, s as range$2, t as derivative$6, u as isDecreasing$7 } from "./quadratic-Dlxqo2V1.mjs";
9
+ import { i as maxDistance, r as make$4, t as fromVectors } from "./interval2d-C0eduE-V.mjs";
10
+ import { i as cubicBezier, t as apply } from "./characteristic-B0VEB_OA.mjs";
11
11
  //#region src/curve/linear2d.internal.ts
12
12
  const LinearCurve2dTypeId = Symbol("curvy/curve/linear2d");
13
13
  /** @internal */
@@ -906,4 +906,4 @@ const approximateAsCubicCurves = approximateAsCubicCurves$1;
906
906
  //#endregion
907
907
  export { solve$6 as C, linear2d_exports as S, solveAtY$6 as T, solve$4 as _, boundingBox$2 as a, boundingBox$6 as b, fromPolynomials$2 as c, solveAtX$2 as d, solveAtY$2 as f, quadratic2d_exports as g, length$2 as h, solve as i, length as l, boundingBox$4 as m, fromBezierPoints as n, cubic2d_exports as o, derivative as p, rationalCubic2d_exports as r, fromCoefficients as s, approximateAsCubicCurves as t, solve$2 as u, solveAtX$4 as v, solveAtX$6 as w, length$4 as x, solveAtY$4 as y };
908
908
 
909
- //# sourceMappingURL=rationalCubic2d-DaFTrUXw.mjs.map
909
+ //# sourceMappingURL=rationalCubic2d-3S5K69Jy.mjs.map