public void DoRotateAroundOrigin(Vector2 mousePosition) { if (isRotating) { Quaternion activeRotationQuaternion; if (TurntableEnabled) { var delta = mousePosition - rotationStartPosition; // scale it to device units delta /= TrackBallController.TrackBallRadius / 2; var zRotation = Matrix4X4.CreateFromAxisAngle(Vector3.UnitZ.Transform(world.RotationMatrix), delta.X); var screenXRotation = Matrix4X4.CreateFromAxisAngle(Vector3.UnitX, -delta.Y); activeRotationQuaternion = new Quaternion(zRotation * screenXRotation); } else { activeRotationQuaternion = TrackBallController.GetRotationForMove(TrackBallController.ScreenCenter, TrackBallController.TrackBallRadius, rotationStartPosition, mousePosition, false); } rotationStartPosition = mousePosition; world.RotateAroundPosition(mouseDownWorldPosition, activeRotationQuaternion); Invalidate(); } }