setFromAxisAngle method

Quaternion setFromAxisAngle(
  1. Vector3 axis,
  2. double angle
)

Implementation

Quaternion setFromAxisAngle(Vector3 axis, double angle) {
  // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm

  // assumes axis is normalized

  final halfAngle = angle / 2, s = math.sin(halfAngle);

  _x = axis.x * s;
  _y = axis.y * s;
  _z = axis.z * s;
  _w = math.cos(halfAngle);

  onChangeCallback();

  return this;
}