Options
All
  • Public
  • Public/Protected
  • All
Menu

Mat provides static function for matrix operations. It's not yet optimized but good enough to use.

Hierarchy

  • Mat

Index

Methods

Static add

  • Matrix additions. Matrices should have the same rows and columns.

    Parameters

    • a: GroupLike

      a group of Pt

    • b: GroupLike | number[][] | number

      a scalar number, an array of numeric arrays, or a group of Pt

    Returns Group

    a group with the same rows and columns as a and b

Static multiply

  • Matrix multiplication

    Parameters

    • a: GroupLike

      a Group of M Pts, each with K dimensions (M-rows, K-columns)

    • b: GroupLike | number[][] | number

      a scalar number, an array of numeric arrays, or a Group of K Pts, each with N dimensions (K-rows, N-columns) -- or if transposed is true, then N Pts with K dimensions

    • Default value transposed: boolean = false

      (Only applicable if it's not elementwise multiplication) If true, then a and b's columns should match (ie, each Pt should have the same dimensions). Default is false.

    • Default value elementwise: boolean = false

      if true, then the multiplication is done element-wise. Default is false.

    Returns Group

    If not elementwise, this will return a group with M Pt, each with N dimensions (M-rows, N-columns).

Static reflectAt2DMatrix

  • Get a matrix to reflect a point along a line. For use in transform2D

    Parameters

    • p1: PtLike

      second end point to define the reflection line

    • p2: PtLike

    Returns Pt[]

Static rotate2DMatrix

  • rotate2DMatrix(cosA: number, sinA: number): GroupLike

Static rotateAt2DMatrix

  • Get a matrix to rotate a point from an origin point. For use in transform2D

    Parameters

    • cosA: number
    • sinA: number
    • at: PtLike

    Returns GroupLike

Static scale2DMatrix

  • scale2DMatrix(x: number, y: number): GroupLike

Static scaleAt2DMatrix

Static shear2DMatrix

  • shear2DMatrix(tanX: number, tanY: number): GroupLike

Static shearAt2DMatrix

Static transform2D

  • Transform a 2D point given a 2x3 or 3x3 matrix

    Parameters

    • pt: PtLike

      a Pt to be transformed

    • m: GroupLike | number[][]

      2x3 or 3x3 matrix

    Returns Pt

    a new transformed Pt

Static translate2DMatrix

  • translate2DMatrix(x: number, y: number): GroupLike

Static transpose

  • transpose(g: GroupLike | number[][], defaultValue?: number | boolean, useLongest?: boolean): Group
  • Same as zip function

    Parameters

    • g: GroupLike | number[][]
    • Default value defaultValue: number | boolean = false
    • Default value useLongest: boolean = false

    Returns Group

Static zip

  • zip(g: GroupLike | number[][], defaultValue?: number | boolean, useLongest?: boolean): Group
  • Zip a group of Pt. eg, [[1,2],[3,4],[5,6]] => [[1,3,5],[2,4,6]]

    Parameters

    • g: GroupLike | number[][]

      a group of Pt

    • Default value defaultValue: number | boolean = false

      a default value to fill if index out of bound. If not provided, it will throw an error instead.

    • Default value useLongest: boolean = false

      If true, find the longest list of values in a Pt and use its length for zipping. Default is false, which uses the first item's length for zipping.

    Returns Group

Static zipSlice

  • zipSlice(g: GroupLike | number[][], index: number, defaultValue?: number | boolean): Pt
  • Zip one slice of an array of Pt. Imagine the Pts are organized in rows, then this function will take the values in a specific column.

    Parameters

    • g: GroupLike | number[][]

      a group of Pt

    • index: number
    • Default value defaultValue: number | boolean = false

      a default value to fill if index out of bound. If not provided, it will throw an error instead.

    Returns Pt

Generated using TypeDoc