.. role:: clio-static
   :class: clio-flag clio-flag-static


####
Mat4
####

.. js:class:: cee.Mat4

   An immutable 4x4 matrix
   
   Matrices are stored internally as a one dimensional array for performance reasons.
   
   The mapping of matrix elements to indices of this internal array is as follows:
   
   
   ::
   
        | m00  m01  m02  m03 |     | 0  4   8  12 | 
        | m10  m11  m12  m13 |     | 1  5   9  13 | 
        | m20  m21  m22  m23 |     | 2  6  10  14 | 
        | m30  m31  m32  m33 |     | 3  7  11  15 | 
   
   This is consistent with the way matrices are represented in WebGL. To exemplify, translation values are stored in elements 12,13,14; see figure below
   
   
   ::
   
        | 1  0  0 Tx |
        | 0  1  0 Ty |
        | 0  0  1 Tz |
        | 0  0  0  1 |
   
   From the OpenGL red book (page 68)   v' = M\*v
   
   
   ::
   
        | X'|   | 1  0  0 Tx |   | X |
        | Y'|   | 0  1  0 Ty |   | Y |
        | Z'| = | 0  0  1 Tz | * | Z |
        | 1 |   | 0  0  0  1 |   | 1 |
   
   Note that this class is immutable.
   
   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.Mat4.constructor`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~cee.Mat4.equals`
   * :js:meth:`~cee.Mat4.getAsArray`
   * :js:meth:`~cee.Mat4.getInverse`
   * :js:meth:`~cee.Mat4.getRowCol`
   * :js:meth:`~cee.Mat4.isIdentity`
   * :js:meth:`~static cee.Mat4.fromArray`
   * :js:meth:`~static cee.Mat4.fromCoordSystemAxes`
   * :js:meth:`~static cee.Mat4.fromElements`
   * :js:meth:`~static cee.Mat4.fromRotation`
   * :js:meth:`~static cee.Mat4.fromScaling`
   * :js:meth:`~static cee.Mat4.fromTranslation`
   * :js:meth:`~static cee.Mat4.multiply`
   * :js:meth:`~static cee.Mat4.translatePostMultiply`
   * :js:meth:`~static cee.Mat4.translatePreMultiply`
   
   



.. rst-class:: kind-group kind-constructors

.. rubric:: Constructors
   :class: kind-group-title


.. js:method:: cee.Mat4.constructor

      .. rst-class:: sig-pretty-signature
      
         | Mat4(): :js:class:`Mat4 <cee.Mat4>`
      
      Creates the matrix. Default is an identity matrix.
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. rst-class:: kind-group kind-methods

.. rubric:: Methods
   :class: kind-group-title


.. js:method:: cee.Mat4.equals

      .. rst-class:: sig-pretty-signature
      
         | equals(**other**\ : :js:class:`Mat4 <cee.Mat4>`\ ): *boolean*
      
      Returns true if the matrices are equal
      
      **Parameters**
      
      
         **other**\ : :js:class:`Mat4 <cee.Mat4>`
      
      
      **Returns**\ : *boolean*
      



.. js:method:: cee.Mat4.getAsArray

      .. rst-class:: sig-pretty-signature
      
         | getAsArray(): *ArrayLike*
      
      Returns a reference to the internal array storing the matrix values.
      
      The array will be ordered as follows:
      
      
      ::
      
           | m00  m01  m02  m03 |     | 0  4   8  12 | 
           | m10  m11  m12  m13 |     | 1  5   9  13 | 
           | m20  m21  m22  m23 |     | 2  6  10  14 | 
           | m30  m31  m32  m33 |     | 3  7  11  15 | 
      
      **Returns**\ : *ArrayLike*
      



.. js:method:: cee.Mat4.getInverse

      .. rst-class:: sig-pretty-signature
      
         | getInverse(): :js:class:`Mat4 <cee.Mat4>`
      
      Returns this inverse of this matrix.
      
      If this matrix is not invertible, returns a zero matrix.
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: cee.Mat4.getRowCol

      .. rst-class:: sig-pretty-signature
      
         | getRowCol(**row**\ : *number*\ , **col**\ : *number*\ ): *number*
      
      Returns the value at the given row and column
      
      **Parameters**
      
      
         **row**\ : *number*
      
         **col**\ : *number*
      
      
      **Returns**\ : *number*
      



.. js:method:: cee.Mat4.isIdentity

      .. rst-class:: sig-pretty-signature
      
         | isIdentity(): *boolean*
      
      Returns true if the matrix is an identity matrix
      
      **Returns**\ : *boolean*
      



.. js:method:: static cee.Mat4.fromArray

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | fromArray(**array**\ : *ArrayLike*\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Returns a matrix initialized with the values in the passed array
      
      The array must be ordered as follows:
      
      
      ::
      
           | m00  m01  m02  m03 |     | 0  4   8  12 | 
           | m10  m11  m12  m13 |     | 1  5   9  13 | 
           | m20  m21  m22  m23 |     | 2  6  10  14 | 
           | m30  m31  m32  m33 |     | 3  7  11  15 | 
      
      **Parameters**
      
      
         **array**\ : *ArrayLike*
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.fromCoordSystemAxes

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | fromCoordSystemAxes(**xAxis**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **yAxis**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **zAxis**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Returns a rotation matrix that will align the global X, Y and Z axes with the specified axes.
      
      Note that at least one axis must be specified and all specified axes must be normalized. If two or three axes are specified, they must be orthogonal to each other.
      
      **Parameters**
      
      
         **xAxis**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
            Orientation of x axis
      
      
         **yAxis**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
            Orientation of y axis
      
      
         **zAxis**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
            Orientation of z axis
      
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.fromElements

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | fromElements(**m00**\ : *number*\ , **m01**\ : *number*\ , **m02**\ : *number*\ , **m03**\ : *number*\ , **m10**\ : *number*\ , **m11**\ : *number*\ , **m12**\ : *number*\ , **m13**\ : *number*\ , **m20**\ : *number*\ , **m21**\ : *number*\ , **m22**\ : *number*\ , **m23**\ : *number*\ , **m30**\ : *number*\ , **m31**\ : *number*\ , **m32**\ : *number*\ , **m33**\ : *number*\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Returns a transformation matrix containing the given element values
      
      
      ::
      
           | m00  m01  m02  m03 |  
           | m10  m11  m12  m13 |  
           | m20  m21  m22  m23 |  
           | m30  m31  m32  m33 |  
      
      **Parameters**
      
      
         **m00**\ : *number*
      
         **m01**\ : *number*
      
         **m02**\ : *number*
      
         **m03**\ : *number*
      
         **m10**\ : *number*
      
         **m11**\ : *number*
      
         **m12**\ : *number*
      
         **m13**\ : *number*
      
         **m20**\ : *number*
      
         **m21**\ : *number*
      
         **m22**\ : *number*
      
         **m23**\ : *number*
      
         **m30**\ : *number*
      
         **m31**\ : *number*
      
         **m32**\ : *number*
      
         **m33**\ : *number*
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.fromRotation

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | fromRotation(**axis**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **angle**\ : *number*\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Returns a transformation matrix containing only rotation, specified as a rotation around the given axis
      
      **Parameters**
      
      
         **axis**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **angle**\ : *number*
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.fromScaling

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | fromScaling(**scale**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Returns a transformation matrix containing only the given scaling
      
      
      ::
      
           | Sx 0  0  0 |
           | 0  Sy 0  0 |
           | 0  0  Sz 0 |
           | 0  0  0  1 |
      
      **Parameters**
      
      
         **scale**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.fromTranslation

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | fromTranslation(**trans**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Returns a transformation matrix containing only the given translation
      
      Will set m03 to x, m13 to y, and m23 to z, resulting in the following matrix
      
      
      ::
      
           | 1  0  0 Tx |
           | 0  1  0 Ty |
           | 0  0  1 Tz |
           | 0  0  0  1 |
      
      **Parameters**
      
      
         **trans**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.multiply

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | multiply(**matrices**\ : :js:class:`Mat4 <cee.Mat4>`\ []): :js:class:`Mat4 <cee.Mat4>`
      
      Multiplies given matrices.
      
      **Parameters**
      
      
         **matrices**\ : :js:class:`Mat4 <cee.Mat4>`\ []
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.translatePostMultiply

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | translatePostMultiply(**M**\ : :js:class:`Mat4 <cee.Mat4>`\ , **tv**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Adds translation to the given matrix M by post-multiplying it with a matrix containing the given translation tv.
      
      This has the effect of performing the multiplication M' = M x T
      
      **Parameters**
      
      
         **M**\ : :js:class:`Mat4 <cee.Mat4>`
      
         **tv**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: static cee.Mat4.translatePreMultiply

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | translatePreMultiply(**M**\ : :js:class:`Mat4 <cee.Mat4>`\ , **tv**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): :js:class:`Mat4 <cee.Mat4>`
      
      Adds translation to the given matrix M by pre-multiplying it with a matrix containing the given translation tv.
      
      This has the effect of performing the multiplication M' = T x M
      
      **Parameters**
      
      
         **M**\ : :js:class:`Mat4 <cee.Mat4>`
      
         **tv**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      




