Hierarchy

  • Matrix2D

Constructors

  • The constructor function initializes a Matrix2D object with either a default identity matrix, or a provided matrix or Vector2D object.

    Parameters

    • Optional value: number[][] | Vector2D

      The value parameter can be either a 2D array of numbers (number[][]) or an instance of the Vector2D class.

    Returns Matrix2D

Properties

_matrix: number[][]

Accessors

  • get m(): number[][]
  • The function returns a two-dimensional array of numbers.

    Returns number[][]

    The getter method is returning the value of the private variable _matrix, which is a two-dimensional array of numbers.

  • get empty(): number[][]
  • The function returns a 2D array with three empty arrays.

    Returns number[][]

    An empty 2-dimensional array with 3 empty arrays inside.

  • get identity(): number[][]
  • The above function returns a 3x3 identity matrix.

    Returns number[][]

    The method is returning a 2-dimensional array of numbers representing the identity matrix.

Methods

  • The function "toVector" returns a new Vector2D object with the values from the first and second elements of the _matrix array.

    Returns Vector2D

    A new instance of the Vector2D class is being returned. The values of the returned vector are taken from the first column of the matrix.

  • The function takes two 2D matrices as input and returns their sum as a new 2D matrix.

    Parameters

    • matrix1: Matrix2D

      Matrix2D - The first matrix to be added.

    • matrix2: Matrix2D

      The parameter matrix2 is a Matrix2D object.

    Returns Matrix2D

    a new instance of the Matrix2D class, which is created using the result array.

  • The function multiplies two 2D matrices and returns the result as a new Matrix2D object.

    Parameters

    • matrix1: Matrix2D

      A 2D matrix represented by the Matrix2D class.

    • matrix2: Matrix2D

      The parameter matrix2 is a 2D matrix of size 3x3.

    Returns Matrix2D

    a new instance of the Matrix2D class, created using the result array.

  • The function multiplies each element of a 2D matrix by a given value and returns the resulting matrix.

    Parameters

    • matrix: Matrix2D

      The matrix parameter is an instance of the Matrix2D class, which represents a 2D matrix. It contains a property m that is a 2D array representing the matrix elements.

    • value: number

      The value parameter is a number that you want to multiply each element of the matrix by.

    Returns Matrix2D

    a new instance of the Matrix2D class, which is created using the result array.

  • The function multiplies a 2D matrix by a 2D vector and returns the result as a 2D vector.

    Parameters

    • matrix: Matrix2D

      The parameter "matrix" is of type Matrix2D. It represents a 2-dimensional matrix.

    • vector: Vector2D

      The "vector" parameter is a 2D vector, represented by an object of type Vector2D.

    Returns Vector2D

    a Vector2D.

  • The function "rotate" takes an angle in radians and returns a 2D transformation matrix for rotating objects.

    Parameters

    • radians: number

      The "radians" parameter is the angle in radians by which you want to rotate an object.

    Returns Matrix2D

    The code is returning a new instance of a Matrix2D object.

  • The function scales a matrix by a given factor.

    Parameters

    • factor: number

      The factor parameter is a number that represents the scaling factor by which the matrix should be scaled.

    Returns Matrix2D

    the result of multiplying a new instance of Matrix2D by the given factor.

  • The function subtracts two 2D matrices and returns the result as a new Matrix2D object.

    Parameters

    • matrix1: Matrix2D

      Matrix2D - The first matrix to subtract from.

    • matrix2: Matrix2D

      Matrix2D is a class representing a 2D matrix. It has a property m which is a 2D array representing the matrix elements.

    Returns Matrix2D

    a new instance of the Matrix2D class, which is created using the result array.

  • The translate function takes a 2D vector and returns a 2D matrix that represents a translation transformation.

    Parameters

    • vector: Vector2D

      The parameter "vector" is of type Vector2D. It represents a 2D vector with components x and y, and an optional w component.

    Returns Matrix2D

    The method is returning a new instance of the Matrix2D class.

  • The function returns a 2D matrix that scales and flips a vector around the center of a given width and height.

    Parameters

    • width: number

      The width parameter represents the width of the view or the canvas. It is a number that specifies the width in pixels or any other unit of measurement.

    • height: number

      The height parameter represents the height of the view or the canvas. It is used to calculate the centerY value, which is the vertical center of the view.

    Returns Matrix2D

    a Matrix2D object.

Generated using TypeDoc