Quaternion.fromAxis constructor
Constructs a quaternion from an axis
and a rotation angle
.
Implementation
factory Quaternion.fromAxis(List<num> axis, num angle) {
final halfAngle = 0.5 * angle;
final norm = halfAngle.sin() /
(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]).sqrt();
return Quaternion(
halfAngle.cos(), axis[0] * norm, axis[1] * norm, axis[2] * norm);
}