makeRotationAxis method

Matrix4 makeRotationAxis(
  1. Vector3 axis,
  2. num angle
)

Implementation

Matrix4 makeRotationAxis(Vector3 axis, num angle) {
  // Based on http://www.gamedev.net/reference/articles/article1199.asp

  var c = Math.cos(angle).toDouble();
  var s = Math.sin(angle).toDouble();
  var t = 1 - c;
  var x = axis.x, y = axis.y, z = axis.z;
  var tx = t * x, ty = t * y;

  set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y,
      ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);

  return this;
}