UNPKG

@js-draw/math

Version:
35 lines (34 loc) 1.54 kB
/** * This package contains general math utilities used by `js-draw`. * These include 2D and 3D vectors, 2D paths, and 3x3 matrices. * * ```ts,runnable,console * import { Vec2, Mat33, Rect2 } from '@js-draw/math'; * * // Example: Rotate a vector 90 degrees about the z-axis * const rotate90Degrees = Mat33.zRotation(Math.PI/2); // π/2 radians = 90 deg * const moveUp = Mat33.translation(Vec2.of(1, 0)); * const moveUpThenRotate = rotate90Degrees.rightMul(moveUp); * console.log(moveUpThenRotate.transformVec2(Vec2.of(1, 2))); * * // Example: Bounding box of some points * console.log(Rect2.bboxOf([ * Vec2.of(1, 2), Vec2.of(3, 4), Vec2.of(-100, 1000), * ])); * ``` * * @packageDocumentation */ export { LineSegment2 } from './shapes/LineSegment2.mjs'; export { Path, stepCurveIndexBy as stepPathIndexBy, compareCurveIndices as comparePathIndices, PathCommandType, } from './shapes/Path.mjs'; export { Rect2 } from './shapes/Rect2.mjs'; export { Parameterized2DShape } from './shapes/Parameterized2DShape.mjs'; export { QuadraticBezier } from './shapes/QuadraticBezier.mjs'; export { Abstract2DShape } from './shapes/Abstract2DShape.mjs'; export { Mat33 } from './Mat33.mjs'; export { Vec2 } from './Vec2.mjs'; export { Vec3 } from './Vec3.mjs'; export { Color4 } from './Color4.mjs'; export * from './rounding/lib.mjs'; // Note: All above exports cannot use `export { default as ... } from "..."` because this // breaks TypeDoc -- TypeDoc otherwise labels any imports of these classes as `default`.