Skip to content

applyToPoint

Transforms a point by a matrix.

Available since v3.1.5

import { applyToPoint } from '@helpers4/geometry';
// or, from the all-in-one package (same code, one install):
import { applyToPoint } from 'helpers4/geometry';
applyToPoint(m: Matrix, p: Point): Point
ParameterTypeDescription
mMatrixThe matrix
pPointThe point

Point — The transformed point

x’ = a·x + c·y + e, y’ = b·x + d·y + f.

applyToPoint({ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 }, { x: 1, y: 1 }) // => { x: 9, y: 12 }

Any matrix built by translate, scale, rotate or multiply.

applyToPoint(translate(10, 5), { x: 1, y: 1 }) // => { x: 11, y: 6 }

A 2D affine transformation, in the layout of CSS and SVG matrix(a, b, c, d, e, f):

x' = a·x + c·y + e
y' = b·x + d·y + f
interface Matrix {
  a: number;
  b: number;
  c: number;
  d: number;
  e: number;
  f: number;
}

A point in 2D space.

interface Point {
  x: number;
  y: number;
}

View source on GitHub