rotateTo method

bool rotateTo(
  1. Quaternion q,
  2. double step, [
  3. double tolerance = 0.0001
])

Transforms this rotation defined by this quaternion towards the target rotation defined by the given quaternion by the given angular step. The rotation will not overshoot.

Implementation

bool rotateTo(Quaternion q, double step, [double tolerance = 0.0001 ]) {
	final angle = angleTo( q );
	if ( angle < tolerance ) return true;

	final t = math.min( 1, step / angle ).toDouble();
	slerp( q, t );

	return false;
}