Skip to content

identity

The matrix that changes nothing.

Available since v3.1.5

import { identity } from '@helpers4/geometry';
// or, from the all-in-one package (same code, one install):
import { identity } from 'helpers4/geometry';
identity(): Matrix

Matrix — { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }

The identity leaves every point where it is.

applyToPoint(identity(), { x: 3, y: 4 }) // => { x: 3, y: 4 }

Multiplying by the identity returns the same transformation.

multiply(identity(), translate(5, 0)) // => translate(5, 0)

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;
}

View source on GitHub