Module @js-draw/math - v1.25.0

This package contains general math utilities used by js-draw. These include 2D and 3D vectors, 2D paths, and 3x3 matrices.

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),
]));

@js-draw/math

A library with math utilities used by js-draw.

Namespaces

Vec2
Vec3

Enumerations

PathCommandType

Classes

Abstract2DShape
Color4
LineSegment2
Mat33
Parameterized2DShape
Path
QuadraticBezier
Rect2

Interfaces

CubicBezierPathCommand
LinePathCommand
MoveToPathCommand
PathCurveIndex
PathIntersectionResult
QuadraticBezierPathCommand
Vec3

Type Aliases

Mat33Array
PathCommand
Point2

Functions

comparePathIndices
stepPathIndexBy
toRoundedString
OpenSource licenses