makeRotationAxis method

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

Implementation

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

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

  setValues(
      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;
}