Creates a rotation matrix around given origin [0, 0] by default.

Type signature

(angle?: number, cx?: number, cy?: number) => {
    a: number;
    c: number;
    e: number;
    b: number;
    d: number;
    f: number;
}

Examples

const angle = Math.PI;
const sine = Math.sin(angle);
const cosine = Math.cos(angle);

rotate(angle); // { a: cosine, b: sine, c: -sine, d: cosine, e: 0, f: 0 }
Try in REPL

Questions

  • How to create a rotation matrix?

TypeScript sourceJavaScript source