src/m4.js
function transpose(m, dst) {
  dst = dst || new MatType(16);
  if (dst === m) {
    let t;

    t = m[1];
    m[1] = m[4];
    m[4] = t;

    t = m[2];
    m[2] = m[8];
    m[8] = t;

    t = m[3];
    m[3] = m[12];
    m[12] = t;

    t = m[6];
    m[6] = m[9];
    m[9] = t;

    t = m[7];
    m[7] = m[13];
    m[13] = t;

    t = m[11];
    m[11] = m[14];
    m[14] = t;
    return dst;
  }

  const m00 = m[0 * 4 + 0];
  const m01 = m[0 * 4 + 1];
  const m02 = m[0 * 4 + 2];
  const m03 = m[0 * 4 + 3];
  const m10 = m[1 * 4 + 0];
  const m11 = m[1 * 4 + 1];
  const m12 = m[1 * 4 + 2];
  const m13 = m[1 * 4 + 3];
  const m20 = m[2 * 4 + 0];
  const m21 = m[2 * 4 + 1];
  const m22 = m[2 * 4 + 2];
  const m23 = m[2 * 4 + 3];
  const m30 = m[3 * 4 + 0];
  const m31 = m[3 * 4 + 1];
  const m32 = m[3 * 4 + 2];
  const m33 = m[3 * 4 + 3];

  dst[ 0] = m00;
  dst[ 1] = m10;
  dst[ 2] = m20;
  dst[ 3] = m30;
  dst[ 4] = m01;
  dst[ 5] = m11;
  dst[ 6] = m21;
  dst[ 7] = m31;
  dst[ 8] = m02;
  dst[ 9] = m12;
  dst[10] = m22;
  dst[11] = m32;
  dst[12] = m03;
  dst[13] = m13;
  dst[14] = m23;
  dst[15] = m33;

  return dst;
}
function transpose(m, dst) {
  dst = dst || new MatType(16);
  if (dst === m) {
    let t;

    t = m[1];
    m[1] = m[4];
    m[4] = t;

    t = m[2];
    m[2] = m[8];
    m[8] = t;

    t = m[3];
    m[3] = m[12];
    m[12] = t;

    t = m[6];
    m[6] = m[9];
    m[9] = t;

    t = m[7];
    m[7] = m[13];
    m[13] = t;

    t = m[11];
    m[11] = m[14];
    m[14] = t;
    return dst;
  }

  const m00 = m[0 * 4 + 0];
  const m01 = m[0 * 4 + 1];
  const m02 = m[0 * 4 + 2];
  const m03 = m[0 * 4 + 3];
  const m10 = m[1 * 4 + 0];
  const m11 = m[1 * 4 + 1];
  const m12 = m[1 * 4 + 2];
  const m13 = m[1 * 4 + 3];
  const m20 = m[2 * 4 + 0];
  const m21 = m[2 * 4 + 1];
  const m22 = m[2 * 4 + 2];
  const m23 = m[2 * 4 + 3];
  const m30 = m[3 * 4 + 0];
  const m31 = m[3 * 4 + 1];
  const m32 = m[3 * 4 + 2];
  const m33 = m[3 * 4 + 3];

  dst[ 0] = m00;
  dst[ 1] = m10;
  dst[ 2] = m20;
  dst[ 3] = m30;
  dst[ 4] = m01;
  dst[ 5] = m11;
  dst[ 6] = m21;
  dst[ 7] = m31;
  dst[ 8] = m02;
  dst[ 9] = m12;
  dst[10] = m22;
  dst[11] = m32;
  dst[12] = m03;
  dst[13] = m13;
  dst[14] = m23;
  dst[15] = m33;

  return dst;
}
function transpose ( m , dst ) { dst = dst || new MatType ( 16 ) ; if ( dst === m ) { let t ; t = m [ 1 ] ; m [ 1 ] = m [ 4 ] ; m [ 4 ] = t ; t = m [ 2 ] ; m [ 2 ] = m [ 8 ] ; m [ 8 ] = t ; t = m [ 3 ] ; m [ 3 ] = m [ 12 ] ; m [ 12 ] = t ; t = m [ 6 ] ; m [ 6 ] = m [ 9 ] ; m [ 9 ] = t ; t = m [ 7 ] ; m [ 7 ] = m [ 13 ] ; m [ 13 ] = t ; t = m [ 11 ] ; m [ 11 ] = m [ 14 ] ; m [ 14 ] = t ; return dst ; } const m00 = m [ 0 * 4 + 0 ] ; const m01 = m [ 0 * 4 + 1 ] ; const m02 = m [ 0 * 4 + 2 ] ; const m03 = m [ 0 * 4 + 3 ] ; const m10 = m [ 1 * 4 + 0 ] ; const m11 = m [ 1 * 4 + 1 ] ; const m12 = m [ 1 * 4 + 2 ] ; const m13 = m [ 1 * 4 + 3 ] ; const m20 = m [ 2 * 4 + 0 ] ; const m21 = m [ 2 * 4 + 1 ] ; const m22 = m [ 2 * 4 + 2 ] ; const m23 = m [ 2 * 4 + 3 ] ; const m30 = m [ 3 * 4 + 0 ] ; const m31 = m [ 3 * 4 + 1 ] ; const m32 = m [ 3 * 4 + 2 ] ; const m33 = m [ 3 * 4 + 3 ] ; dst [ 0 ] = m00 ; dst [ 1 ] = m10 ; dst [ 2 ] = m20 ; dst [ 3 ] = m30 ; dst [ 4 ] = m01 ; dst [ 5 ] = m11 ; dst [ 6 ] = m21 ; dst [ 7 ] = m31 ; dst [ 8 ] = m02 ; dst [ 9 ] = m12 ; dst [ 10 ] = m22 ; dst [ 11 ] = m32 ; dst [ 12 ] = m03 ; dst [ 13 ] = m13 ; dst [ 14 ] = m23 ; dst [ 15 ] = m33 ; return dst ; }
Takes the transpose of a matrix.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} The transpose of m.
@memberOf module:twgl/m4
Takes the transpose of a matrix .