How to perform smooth, inertial rotation on mobile devices?

Hello everyone. I’m implementing a search system similar to those in most games, where users browse objects by swiping and rotating them on a mobile screen. However, I also need to achieve precise control over the object’s rotation when the user swipes slowly, and a rapid swipe that causes the object to rotate so quickly that it continues rotating a short distance even after the user stops swiping (like inertia). Furthermore, I need the object to land at a few fixed angles after stopping, which is very difficult to achieve. If my description is confusing, you can refer to the “No Boring Weather” app on iOS; I’m trying to replicate its operation. Currently, I’ve implemented rotation based on swipes and a small amount of inertia, but the results are poor. Does anyone have suggestions for a better implementation? Thanks in advance. Below is a partial implementation of mine.1.Receive the move event and location of the touch input to set the relative rotation of the corresponding object.

2.Then accept the released event of the touch input and add timeline control inertia.

3.I need a possible implementation of rotation to a specified angle, but I require it to rotate to the nearest integer multiple of 72.