transpose method

Mat3 transpose([
  1. Mat3? target
])

Transpose the matrix @param target Optional. Where to store the result. @return The target Mat3, or a new Mat3 if target was omitted.

Implementation

Mat3 transpose([Mat3? target]) {
  target ??= Mat3();
  final M = elements;
  final T = target.elements;
  double tmp;

  //Set diagonals
  T[0] = M[0];
  T[4] = M[4];
  T[8] = M[8];

  tmp = M[1];
  T[1] = M[3];
  T[3] = tmp;

  tmp = M[2];
  T[2] = M[6];
  T[6] = tmp;

  tmp = M[5];
  T[5] = M[7];
  T[7] = tmp;

  return target;
}