rotate function

List<double> rotate(
  1. List<double> out,
  2. List<double> a,
  3. double rad
)

Rotates a mat2 by the given angle

@param {mat2} out the receiving matrix @param {ReadonlyMat2} a the matrix to rotate @param {Number} rad the angle to rotate the matrix by @returns {mat2} out

Implementation

List<double> rotate(List<double> out, List<double> a, double rad) {
  final a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
  final s = math.sin(rad);
  final c = math.cos(rad);
  out[0] = a0 * c + a2 * s;
  out[1] = a1 * c + a3 * s;
  out[2] = a0 * -s + a2 * c;
  out[3] = a1 * -s + a3 * c;
  return out;
}