Graph rotation smooth control method and device
By real-time update of the rotation angle and dynamic adjustment of correction parameters, combined with machine learning algorithms, the problems of unsmooth rotation and insensitive response in traditional graphic rotation control methods are solved, and natural smooth and personalized graphic rotation control is achieved, improving user experience and interaction accuracy.
Patent Information
- Application Number
- CN202411143644.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-11-22
AI Technical Summary
Traditional graphic rotation control methods have problems such as poor rotation, inability to adapt to user habits, insensitive rotation speed and path response, resulting in poor user experience and lack of efficient and accurate algorithms and strategies to achieve smooth adsorption and disengagement effects.
Using the graphic rotation smoothing control method, the rotation angle is updated in real time by continuously monitoring the screen touch events, using the interpolation and easing function to achieve smooth adsorption and disengagement, and dynamically adjust the correction parameters according to the user's rotation speed and path, and optimize the rotation with machine learning algorithm Habit.
Achieve natural and smooth rotation effects, improve interaction accuracy and personalization, reduce abruptness, and enhance the ease of use and fun of the application.
Smart Images

Figure CN119002787A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of graphics control, and in particular to a graphics rotation smooth control method and device. Background Art
[0002] In the field of graphic interaction, accurate and natural graphic rotation control has always been the key to improving user experience and enhancing application functions. Traditional graphic rotation control methods often have many shortcomings, such as non-smooth rotation, inability to adapt to user habits, and insensitive response to rotation speed and path. When performing graphic rotation operations on touch devices, users often need to rotate the graphics to a specific angle. When the graphics are rotated to these specific angles, there is a lack of smooth adsorption effect, resulting in a poor user experience. In addition, the rotation angle correction lacks dynamic adaptability and cannot be optimized according to the user's rotation habits, affecting the accuracy of rotation control. In the prior art, there is a lack of efficient and accurate algorithms and strategies, making it difficult to achieve smooth adsorption and detachment effects, and it is also impossible to make adaptive adjustments based on the user's unique operating mode. Summary of the invention
[0003] To solve the above problems, the present invention provides a method and device for smooth control of graphic rotation, which can achieve a natural and smooth rotation effect, adapt to personalized needs and ensure the accuracy of graphic rotation control during the interaction process.
[0004] To achieve the above object, the technical solution adopted by the present invention is:
[0005] A method for smoothly controlling graphic rotation comprises the following steps:
[0006] S1: Continuously monitor the touch events on the screen, obtain the coordinates of the touch point and the touch starting point, and calculate the vector of the finger and the rotation angle of the graphic;
[0007] S2: Update the display position of the graphic on the screen in real time according to the current rotation angle;
[0008] S3: monitor the current rotation angle. When the rotation angle approaches a specific angle and enters the threshold area from outside the threshold area, an interpolator and an easing function are used to achieve smooth adsorption. When the rotation angle moves away from the specific angle and leaves the threshold area from inside the threshold area, an interpolator and an easing function are used to achieve smooth detachment.
[0009] S4: dynamically adjusting the correction parameters of the rotation angle according to the user's rotation speed and rotation path;
[0010] S5: Record and analyze the user's rotation habits and use machine learning algorithms to optimize the rotation correction parameters.
[0011] Furthermore, the method of continuously monitoring the touch events of the screen, obtaining the coordinates of the touch point and the touch starting point, and calculating the vector of the finger and the rotation angle of the graphic comprises the following steps:
[0012] S11: obtaining the plane coordinates of the touch point through the touch screen sensor, obtaining the linear acceleration on the three axes through the accelerometer, obtaining the angular velocity of the device around the three axes through the gyroscope, and filtering the acceleration and angular velocity data;
[0013] S12: according to the influence of screen orientation and resolution, the coordinates of the touch screen are converted into a space consistent with the device coordinate system, and the accelerometer and gyroscope sensor data are calibrated;
[0014] S13: Estimate the touch position and device attitude by combining the measured values of the touch screen coordinates with the position and attitude changes predicted by the accelerometer and gyroscope through the Kalman filter algorithm;
[0015] S14: when a touch event starts, the touch coordinates optimized by the algorithm are recorded as the starting point coordinates, and the touch point coordinates optimized by the algorithm are continuously obtained during the touch process to calculate the vector;
[0016] S15: Calculate the rotation angle of the device based on the gyroscope data, and project the vector of the finger in the coordinate system after the device is rotated. Suppose the rotation angle around the axis measured by the gyroscope is θ g yro, then the rotation matrix is:
[0017]
[0018] Multiply the finger's vector by the rotation matrix, and then use the inverse tangent function to get the rotation angle of the figure.
[0019] Furthermore, in step S13, a complementary filtering algorithm is used to fuse the low-frequency accurate information measured by the accelerometer with the high-frequency dynamic information measured by the gyroscope, and a more accurate attitude estimation is obtained by adjusting the weights.
[0020] Furthermore, the real-time updating of the display position of the graphic on the screen according to the current rotation angle comprises the following steps:
[0021] S21: Based on the initial position of the graphic on the screen, the reference point is rotated according to the geometric features of the graphic as the center point of rotation (x c enter,y c enter);
[0022] S22: Construct the rotation matrix R according to the rotation angle θ of the graph obtained by algorithm optimization
[0023]
[0024] S23: Suppose the graph has multiple vertices, whose original positions are (x v ertex,y v ertex), the vertex position after rotation is (x v ertex r otated`,y v ertex r otated), the calculation formula of the vertex position is:
[0025] x v ertex r otated=(x v ertex-x c enter)cosθ-(y v ertex-y c enter)sinθ+x c entery v ertex r otated=(x v ertex-x c enter)sinθ+(y v ertex-y c enter)cosθ+y c enter;
[0026] S24: Redraw the graphics and display them on the screen based on the calculated new positions of the vertices after rotation, as well as the boundary conditions and clipping of the graphics.
[0027] Further, the monitoring of the current rotation angle, when approaching a specific angle and entering the threshold area from outside the threshold area, using an interpolator and an easing function to achieve smooth adsorption, and when moving away from the specific angle and leaving the threshold area from within the threshold area, using an interpolator and an easing function to achieve smooth separation; comprises the following steps:
[0028] S31: continuously monitoring the current rotation angle of the graphic according to the set specific angle at which the graphic is attached or detached and the threshold area around the specific angle;
[0029] S32: When the rotation angle enters the threshold area from outside the threshold area, a smooth adsorption operation is triggered; when the rotation angle leaves the threshold area from outside the threshold area, a smooth detachment operation is triggered;
[0030] S33: when entering the threshold region, gradually adjusting the rotation angle of the graphic through cubic spline interpolation and sine curve easing function, and when leaving the threshold region, gradually adjusting the rotation angle of the graphic through cubic spline interpolation and sine curve easing function in the opposite direction;
[0031] S34: According to the interpolated rotation angle calculated for each frame, the new positions of the graphic vertices are recalculated according to the method of steps S21-S23, and the graphic is updated to be displayed on the screen.
[0032] Furthermore, the method of dynamically adjusting the correction parameters of the rotation angle according to the rotation speed and rotation path of the user comprises the following steps:
[0033] S41: When the user performs a touch rotation operation on the screen, the rotation angle change a is calculated and recorded by comparing the rotation angles at different time points, and the time interval b is calculated and recorded by the time difference between two adjacent angle measurements, and the rotation speed c is calculated, and the formula is: c=a / b, and multiple points on the rotation path are recorded at the same time;
[0034] S42: evaluating the curvature of the path by calculating the degree of curvature between several adjacent points, and determining the frequency of direction changes of the path by counting the number of times the direction of the path changes;
[0035] S43: performing speed-based adjustment and path-based adjustment according to the established correction parameters;
[0036] S44: Repeat steps S41-S43 within each frame time interval, update the correction parameters in real time and apply them to the correction of the rotation angle.
[0037] Furthermore, the speed-based adjustment and the path-based adjustment are performed according to the established correction parameters; the steps include:
[0038] S431: Perform speed-based adjustment through the established correction parameter k, the expression of the correction parameter is:
[0039]
[0040] Wherein, 1 is the initial value of the correction parameter, a is a coefficient determined based on experience when the rotation speed is fast, b is another coefficient determined based on experience when the rotation speed is slow, c is the rotation speed, and d is the rotation speed threshold value based on the statistical characteristics of the user's historical rotation operation data;
[0041] S432: according to the curvature of the path and the frequency of direction changes, the correction parameter k is increased for high curvature or frequent direction changes; the correction parameter k is decreased for low curvature and stable direction;
[0042] S433: The final corrected rotation angle is the product of the correction parameter and the uncorrected measured rotation angle.
[0043] Furthermore, the recording and analyzing of the user's rotation habits and the use of a machine learning algorithm to optimize the rotation correction parameters include the following steps:
[0044] S51: collecting the starting angle, ending angle, rotation time and a series of coordinate points on the rotation path of each rotation during multiple screen touch rotation operations performed by the user, and collecting the user's operating device information and operating environment information, and pre-processing the collected data;
[0045] S52: extracting features from the collected data, including: an average value, a maximum value, a minimum value of the rotation speed, a curvature feature of the rotation path, and a frequency and amplitude of a change in the rotation direction;
[0046] S53: Divide the data after feature extraction into a training set, a validation set and a test set, determine the number of input layer nodes according to the number of features through a multi-layer perceptron model, determine the number of output layer nodes according to the correction parameters, use the activation function ReLU function for the hidden layer, and determine the activation function of the output layer according to the properties of the correction parameters;
[0047] S54: Use the training set data to train the multi-layer perceptron, define the loss function, use Adam to automatically adjust the model parameters according to the gradient of the loss function, and use small batches for training;
[0048] S55: Adjust the hyperparameters of the number of hidden layers and nodes, learning rate, regularization parameter, and dropout probability. Perform a final evaluation on the trained model using the test set data. Deploy the trained model to actual applications to receive new rotation operation data from users. Regularly retrain and adjust the model using new data.
[0049] Furthermore, it also includes: combining a multi-layer perceptron model with a convolutional neural network model to avoid overfitting by ensemble learning and averaging prediction results.
[0050] A graphics rotation smooth control device comprises a monitoring module, an updating module, an adsorption and separation module and an adaptive optimization module, wherein:
[0051] The monitoring module is used to obtain the location information of the touch point and the posture and motion information of the device through sensor fusion technology;
[0052] The update module is used to calculate the finger's stroke vector and the rotation angle of the graphic to update the display position of the graphic on the screen in real time;
[0053] The adsorption and detachment module is used to monitor the rotation angle. When approaching a specific angle and entering the threshold area from outside the threshold area, an interpolator and an easing function are used to achieve smooth adsorption; when moving away from a specific angle and detaching from the threshold area from within the threshold area, an interpolator and an easing function are used to achieve smooth detachment.
[0054] The adaptive optimization module is used to dynamically adjust the correction parameters of the rotation angle according to the user's rotation speed and rotation path, record and analyze the user's rotation habits, and use a machine learning algorithm to optimize the rotation correction parameters.
[0055] Furthermore, the monitoring module is also used to learn and analyze the image sequence or touch data generated by the touch screen through a convolutional neural network or a recurrent neural network, and output the predicted touch starting point and subsequent movement trajectory through a trained model.
[0056] Furthermore, the adaptive optimization module is used to optimize the rotation correction parameters through a multi-layer perceptron model or a support vector machine model.
[0057] The beneficial effects of the present invention are:
[0058] 1. By achieving smooth adsorption and detachment effects, and dynamically adjusting according to the user's rotation speed and path, users can feel more natural and smooth when operating graphic rotation, reducing abruptness and discomfort.
[0059] 2. Accurately monitoring and calculating the rotation angle can ensure that the rotation of the graphic better matches the user's intention and improve the accuracy and precision of the interaction.
[0060] 3. Record and analyze the user's rotation habits, and use machine learning algorithms to optimize them, so that the graphic rotation control can adapt to the operating styles and preferences of different users, provide a personalized interactive experience, and dynamically adjust the correction parameters to avoid excessive or insufficient rotation of the graphic, so that it can accurately stay at the position or angle expected by the user.
[0061] 4. Smooth, accurate and personalized graphic rotation control can increase the ease of use and fun of the application, attract more users, and improve user satisfaction and loyalty to the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 The present invention is a flow chart of a method for smoothly controlling the rotation of a graphic.
[0063] Figure 2 The present invention is a structural diagram of a graphics rotation smooth control device.
[0064] Figure 3 The invention discloses a logic flow chart of a method and device for smoothly controlling graphic rotation. DETAILED DESCRIPTION
[0065] See also Figure 1 As shown, the present invention relates to a method for smoothly controlling graphic rotation, comprising the following steps:
[0066] S1: Continuously monitor the touch events on the screen, obtain the coordinates of the touch point and the touch starting point, and calculate the vector of the finger and the rotation angle of the graphic;
[0067] S2: Update the display position of the graphic on the screen in real time according to the current rotation angle;
[0068] S3: monitor the current rotation angle. When the rotation angle approaches a specific angle and enters the threshold area from outside the threshold area, an interpolator and an easing function are used to achieve smooth adsorption. When the rotation angle moves away from the specific angle and leaves the threshold area from inside the threshold area, an interpolator and an easing function are used to achieve smooth detachment.
[0069] S4: dynamically adjusting the correction parameters of the rotation angle according to the user's rotation speed and rotation path;
[0070] S5: Record and analyze the user's rotation habits and use machine learning algorithms to optimize the rotation correction parameters.
[0071] Furthermore, the method of continuously monitoring the touch events of the screen, obtaining the coordinates of the touch point and the touch starting point, and calculating the vector of the finger and the rotation angle of the graphic comprises the following steps:
[0072] S11: obtaining the plane coordinates of the touch point through the touch screen sensor, obtaining the linear acceleration on the three axes through the accelerometer, obtaining the angular velocity of the device around the three axes through the gyroscope, and filtering the acceleration and angular velocity data;
[0073] S12: according to the influence of screen orientation and resolution, the coordinates of the touch screen are converted into a space consistent with the device coordinate system, and the accelerometer and gyroscope sensor data are calibrated;
[0074] S13: Estimate the touch position and device attitude by combining the measured values of the touch screen coordinates with the position and attitude changes predicted by the accelerometer and gyroscope through the Kalman filter algorithm;
[0075] S14: when a touch event starts, the touch coordinates optimized by the algorithm are recorded as the starting point coordinates, and the touch point coordinates optimized by the algorithm are continuously obtained during the touch process to calculate the vector;
[0076] S15: Calculate the rotation angle of the device based on the gyroscope data, and project the vector of the finger in the coordinate system after the device is rotated. Suppose the rotation angle around the axis measured by the gyroscope is θ g yro, then the rotation matrix is:
[0077]
[0078] Multiply the finger's vector by the rotation matrix, and then use the inverse tangent function to get the rotation angle of the figure.
[0079] Specifically, the acceleration and angular velocity data are filtered to remove noise and outliers. For touch screen coordinates, the original touch coordinates are converted to actual coordinates in the physical space based on the screen resolution, orientation, and physical size of the device. For sensor calibration, the deviation values of the accelerometer and gyroscope are obtained through prior calibration experiments and removed in subsequent data.
[0080] In step S13, the position and velocity of the touch point are represented by a state vector, the measurement vector is used to describe the vector of measurement data, the state transfer matrix is used to describe the change of position and velocity over time, the measurement matrix associates the position component in the state vector with the measurement value, and the process noise covariance and the measurement noise covariance are determined based on experience or experiments; the state vector at the current moment is predicted by multiplying the state transfer matrix with the state vector at the previous moment, and the covariance matrix at the current moment is predicted by the state transfer matrix, the covariance matrix at the previous moment and the process noise covariance. These two formulas are used to infer the current state and covariance based on the previous state and correlation matrix, and the final step is completed by calculating the Kalman gain, updating the state vector and predicting the covariance matrix update.
[0081] In step S15, for example, the vector of the finger (x, y) is multiplied by the rotation matrix d, and the rotated vector is (dx, dy), then the rotation angle is atan2(dy, dx).
[0082] Furthermore, in step S13, a complementary filtering algorithm is used to fuse the low-frequency accurate information measured by the accelerometer with the high-frequency dynamic information measured by the gyroscope, and a more accurate attitude estimation is obtained by adjusting the weights.
[0083] Specifically, the sampling frequency of the accelerometer and gyroscope is determined by using complementary filtering to perform sensor fusion to obtain touch-related information, and the weight coefficient α of the complementary filtering is defined to balance the contribution of the accelerometer and gyroscope; the angle estimate is initialized. The measurement value (ax, ay, az) is obtained from the accelerometer, and the projection of the gravity direction in the device coordinate system is calculated to obtain the pitch angle θ a cc and roll angle The formula is:
[0084]
[0085] The angular velocity measurement is obtained from the gyroscope, and the angular change Δθ based on the gyroscope is calculated by integrating the angular velocity. g yro.
[0086] Calculate the fused angle θ f used
[0087] θ f used = α*(θ f used prev +Δθ g yro)+(1-α)*θ a cc;
[0088] where θ fuse d prev is the angle obtained by the last fusion. The fused angle is used as the current angle estimate for subsequent calculations and applications. During the process, the weight coefficient α needs to be continuously adjusted and optimized according to the sensor characteristics and system requirements.
[0089] Furthermore, the real-time updating of the display position of the graphic on the screen according to the current rotation angle comprises the following steps:
[0090] S21: Based on the initial position of the graphic on the screen, the reference point is rotated according to the geometric features of the graphic as the center point of rotation (x c enter,y c enter);
[0091] S22: Construct the rotation matrix R according to the rotation angle θ of the graph obtained by algorithm optimization
[0092]
[0093] S23: Suppose the graph has multiple vertices, whose original positions are (x v ertex,y v ertex), the vertex position after rotation is (x v ertex r otated`,y v ertex r otated), the calculation formula of the vertex position is:
[0094] x v ertex r otated=(x v ertex-x c enter)cosθ-(y v ertex-y c enter)sinθ+x c enter
[0095] y v ertex r otated=(x v ertex-x c enter)sinθ+(y vertex-y c enter)cosθ+y c enter;
[0096] S24: Redraw the graphics and display them on the screen based on the calculated new positions of the vertices after rotation, as well as the boundary conditions and clipping of the graphics.
[0097] Specifically, in step S21, first determine the initial position of the graphic in the screen coordinate system. This position is usually determined by taking the upper left corner of the screen as the origin, the right as the positive direction of the x-axis, and the downward as the positive direction of the y-axis. The reference point of the graphic, that is, the center point of rotation, is selected according to the geometric features of the graphic. For example, if the graphic is a rectangle, the center of the rectangle is usually selected; if it is a circle, the center of the circle is selected. In order to accurately calculate the coordinates of the reference point, if the graphic is composed of multiple vertices, it can be obtained by calculating the average value of the coordinates of all vertices.
[0098] In step S22, θ is usually in radians. If the acquired angle is in degrees, it needs to be converted into radians first.
[0099] In step S23, assuming that the graph has n vertices, for each vertex, the formula for calculating the position after rotation is:
[0100]
[0101] That is, the expansion formula in S23 is obtained, and each vertex is calculated accordingly.
[0102] In step S24, after the calculation of the new positions of all vertices is completed, the graphics are redrawn using the new vertex coordinates, which may involve related function calls of the graphics drawing library or graphics engine. When updating the graphics display, the boundary conditions and possible clipping of the graphics also need to be considered. In order to achieve a smooth rotation effect, the frequency of calculation and update needs to be reasonably controlled according to the performance of the system and the refresh rate of the screen. A timer or frame callback mechanism can be used to regularly perform graphics update calculations and displays.
[0103] Further, the monitoring of the current rotation angle, when approaching a specific angle and entering the threshold area from outside the threshold area, using an interpolator and an easing function to achieve smooth adsorption, and when moving away from the specific angle and leaving the threshold area from within the threshold area, using an interpolator and an easing function to achieve smooth separation; comprises the following steps:
[0104] S31: continuously monitoring the current rotation angle of the graphic according to the set specific angle at which the graphic is attached or detached and the threshold area around the specific angle;
[0105] S32: When the rotation angle enters the threshold area from outside the threshold area, a smooth adsorption operation is triggered; when the rotation angle leaves the threshold area from outside the threshold area, a smooth detachment operation is triggered;
[0106] S33: when entering the threshold region, gradually adjusting the rotation angle of the graphic through cubic spline interpolation and sine curve easing function, and when leaving the threshold region, gradually adjusting the rotation angle of the graphic through cubic spline interpolation and sine curve easing function in the opposite direction;
[0107] S34: According to the interpolated rotation angle calculated for each frame, the new positions of the graphic vertices are recalculated according to the method of steps S21-S23, and the graphic is updated to be displayed on the screen.
[0108] Specifically, in step S31, the specific angle at which the graphic is finally adsorbed or detached is determined. This angle can be set according to specific design requirements. For the threshold area, we need to determine an angle range. Assuming that we set the threshold angle to 5 degrees, the threshold area is [specific angle - 5, specific angle + 5]. In each frame or fixed time interval, the current rotation angle of the graphic is accurately obtained, which can be obtained through the previous sensor fusion algorithm and calculation.
[0109] In step S32, the relationship between the rotation angle and the threshold area is continuously compared. When the rotation angle is originally less than [specific angle - threshold angle] and then becomes greater than [specific angle - threshold angle] during continuous monitoring, it is determined as entering the threshold area from outside the threshold area; when the rotation angle is originally greater than [specific angle + threshold angle] and then becomes less than [specific angle - threshold angle] during subsequent continuous monitoring, it is determined as leaving the threshold area from within the threshold area.
[0110] In step S33, according to the angle range of the clear threshold area, and according to the current rotation angle of the determined graphics and the corresponding time, according to the current angle, the target angle and possible intermediate key points, the control point of the cubic spline interpolation is determined, a time variable is set, the initial value is 0, and the time step of each adjustment is determined, and the interpolation progress parameter is initialized at the same time. The value of the sine curve easing function is calculated according to the time variable as sin (k time variable), and k is a coefficient determined according to the expected adjustment speed. Using cubic spline interpolation, the interpolation angle of the current time step is calculated based on the value of the control point and the sine curve easing function, and the calculated interpolation angle is applied to the graphics to update its displayed rotation angle. Increase the time variable to determine whether the adjustment is completed. If not completed, continue to calculate and update the next time step. If completed, end the adjustment process.
[0111] Furthermore, the method of dynamically adjusting the correction parameters of the rotation angle according to the rotation speed and rotation path of the user comprises the following steps:
[0112] S41: When the user performs a touch rotation operation on the screen, the rotation angle change a is calculated and recorded by comparing the rotation angles at different time points, and the time interval b is calculated and recorded by the time difference between two adjacent angle measurements, and the rotation speed c is calculated, and the formula is: c=a / b, and multiple points on the rotation path are recorded at the same time;
[0113] S42: evaluating the curvature of the path by calculating the degree of curvature between several adjacent points, and determining the frequency of direction changes of the path by counting the number of times the direction of the path changes;
[0114] S43: performing speed-based adjustment and path-based adjustment according to the established correction parameters;
[0115] S44: Repeat steps S41-S43 within each frame time interval, update the correction parameters in real time and apply them to the correction of the rotation angle.
[0116] Specifically, in step S44, the correction parameters may be updated in real time within each frame time interval or within a fixed time interval, and applied to the correction of the rotation angle, so as to dynamically adjust the correction effect according to the user's rotation speed and path, and provide a rotation experience that better meets the user's intention.
[0117] Furthermore, the speed-based adjustment and the path-based adjustment are performed according to the established correction parameters; the steps include:
[0118] S431: Perform speed-based adjustment through the established correction parameter k, the expression of the correction parameter is:
[0119]
[0120] Wherein, 1 is the initial value of the correction parameter, a is a coefficient determined based on experience when the rotation speed is fast, b is another coefficient determined based on experience when the rotation speed is slow, c is the rotation speed, and d is the rotation speed threshold value based on the statistical characteristics of the user's historical rotation operation data;
[0121] S432: according to the curvature of the path and the frequency of direction changes, the correction parameter k is increased for high curvature or frequent direction changes; the correction parameter k is decreased for low curvature and stable direction;
[0122] S433: The final corrected rotation angle is the product of the correction parameter and the uncorrected measured rotation angle.
[0123] Specifically, in step S431, when c=d, the correction parameter is not adjusted based on the speed. For the formula when the rotation speed is faster, it means that the final rotation angle is corrected to a greater extent during fast rotation.
[0124] Furthermore, the recording and analyzing of the user's rotation habits and the use of a machine learning algorithm to optimize the rotation correction parameters include the following steps:
[0125] S51: collecting the starting angle, ending angle, rotation time and a series of coordinate points on the rotation path of each rotation during multiple screen touch rotation operations performed by the user, and collecting the user's operating device information and operating environment information, and pre-processing the collected data;
[0126] S52: extracting features from the collected data, including: an average value, a maximum value, a minimum value of the rotation speed, a curvature feature of the rotation path, and a frequency and amplitude of a change in the rotation direction;
[0127] S53: Divide the data after feature extraction into a training set, a validation set and a test set, determine the number of input layer nodes according to the number of features through a multi-layer perceptron model, determine the number of output layer nodes according to the correction parameters, use the activation function ReLU function for the hidden layer, and determine the activation function of the output layer according to the properties of the correction parameters;
[0128] S54: Use the training set data to train the multi-layer perceptron, define the loss function, use Adam to automatically adjust the model parameters according to the gradient of the loss function, and use small batches for training;
[0129] S55: Adjust the hyperparameters of the number of hidden layers and nodes, learning rate, regularization parameter, and dropout probability. Perform a final evaluation on the trained model using the test set data. Deploy the trained model to actual applications to receive new rotation operation data from users. Regularly retrain and adjust the model using new data.
[0130] Specifically, the user's operating environment information is collected, such as light, the way the device is held, etc. However, if it cannot be obtained, it can be abandoned. The preprocessing of the data includes cleaning outliers and standardizing the data so that the algorithm can process it better. The curvature features of the rotation path in the extracted features include the average curvature and the maximum curvature.
[0131] The number of nodes in the output layer should be the same as the number of correction parameters to be predicted. The activation function of the output layer is selected according to the value range and properties of the correction parameters. ReLU is simple to calculate as an activation function and can effectively avoid the gradient vanishing problem. The loss function is defined based on whether it is used for regression problems or classification problems. Adam, as an optimization algorithm, can automatically adjust the parameters of the model according to the gradient of the loss function. Training is performed in small batches, and a batch of data is randomly selected from the training set each time for gradient calculation and parameter update, rather than updating parameters sample by sample, which can improve training efficiency and make the gradient more stable.
[0132] In step S55, by testing different combinations and observing the performance on the validation set, the optimal structure is determined to adjust the number of hidden layers and nodes; try different learning rate values to find a suitable value that can make the model converge quickly and avoid oscillation; adjust the coefficients of L1 and L2 regularization to balance the complexity of the model and the degree of fit to the training data to adjust the regularization parameters; try different Dropout probability values to find the probability that effectively prevents overfitting without losing too much model expression ability. The final evaluation of the trained model is to measure the performance and generalization ability of the model by calculating evaluation indicators such as mean square error, mean absolute error, accuracy, etc. Compare with other benchmark models or previous methods to evaluate the improvement effect of the model. Regularly retraining and adjusting the model with new data is to adapt to possible changes and new patterns in user behavior.
[0133] Furthermore, it also includes: combining a multi-layer perceptron model with a convolutional neural network model to avoid overfitting by ensemble learning and averaging prediction results.
[0134] Specifically, after collecting a large amount of data related to user rotation operations, the data set is divided into a training set, a validation set, and a test set. The number of nodes in the input layer of the multilayer perceptron is determined according to the number of extracted features, the activation function ReLU function is used for the hidden layer, and the number of nodes in the output layer is defined according to the number of correction parameters to be predicted. The convolution layer, pooling layer, and fully connected layer are designed for the image data of the input data, and the convolution kernel size, step size, and pooling method are selected.
[0135] The training set data is used to train the multi-layer perceptron model and the convolutional neural network model respectively. According to the optimization algorithm of the Adam optimizer and the mean square error loss function, the loss on the validation set is monitored during the training process to adjust the hyperparameters. In the test phase, the trained multi-layer perceptron model and the convolutional neural network model are used to predict the new data respectively. The prediction results of the two models are averaged to obtain the final integrated prediction result.
[0136] The integrated prediction results are used as optimized rotation correction parameters for graphic rotation control, and the performance of the integrated model is evaluated by calculating the mean square error using the test set data. According to the evaluation results, if they do not meet expectations, the model structure and hyperparameters are adjusted, and retraining and integration are performed.
[0137] Convolutional neural networks are particularly suitable for processing image data. They can automatically extract features from images and have strong feature learning capabilities. Ensemble learning combines the prediction results of multiple models, which can usually improve the stability and generalization ability of the model. It can take advantage of the advantages of different models and combine them to avoid the overfitting disadvantages of machine learning algorithms to the greatest extent.
[0138] A graphics rotation smooth control device comprises a monitoring module, an updating module, an adsorption and separation module and an adaptive optimization module, wherein:
[0139] The monitoring module is used to obtain the location information of the touch point and the posture and motion information of the device through sensor fusion technology;
[0140] The update module is used to calculate the finger's stroke vector and the rotation angle of the graphic to update the display position of the graphic on the screen in real time;
[0141] The adsorption and detachment module is used to monitor the rotation angle. When approaching a specific angle and entering the threshold area from outside the threshold area, an interpolator and an easing function are used to achieve smooth adsorption; when moving away from a specific angle and detaching from the threshold area from within the threshold area, an interpolator and an easing function are used to achieve smooth detachment.
[0142] The adaptive optimization module is used to dynamically adjust the correction parameters of the rotation angle according to the user's rotation speed and rotation path, record and analyze the user's rotation habits, and use a machine learning algorithm to optimize the rotation correction parameters.
[0143] Furthermore, the monitoring module is also used to learn and analyze the image sequence or touch data generated by the touch screen through a convolutional neural network or a recurrent neural network, and output the predicted touch starting point and subsequent movement trajectory through a trained model.
[0144] Furthermore, the adaptive optimization module is used to optimize the rotation correction parameters through a multi-layer perceptron model or a support vector machine model.
[0145] Specifically, the method for optimizing the rotation correction parameters through the support vector machine model is as follows: collect and preprocess the user's rotation operation data, extract relevant features, and divide them into training set, validation set and test set. Standardize or normalize the extracted features so that the numerical range of the features is within a smaller interval, which is helpful for the training and performance improvement of the support vector machine. Use the Gaussian kernel as the kernel function because it performs better in many cases, and the penalty parameter C is used as the preliminary parameter. Use grid search combined with cross validation to find the optimal parameter combination, and the grid search will traverse the given parameter range and kernel function type. Cross validation further divides the training set into multiple subsets, and one of the subsets is used as the validation set and the remaining subsets as the training set in turn, so as to more comprehensively evaluate the performance of the model under different data partitions. According to the optimal parameters and kernel functions found by grid search and cross validation, the support vector machine model is trained using the training set. The performance of the trained model is evaluated using the validation set and the test set. Perform multiple grid searches and cross validations with different random seeds, and combine multiple results to determine relatively stable optimal parameters to reduce the sensitivity to the selection of parameters and kernel functions.
[0146] The above implementation modes are merely descriptions of the preferred implementation modes of the present invention, and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary engineering and technical personnel in the field shall fall within the protection scope determined by the claims of the present invention.
Claims
1. A method for smoothly controlling graphic rotation, characterized in that: The following steps are involved: S1: Continuously monitor the touch events on the screen, obtain the coordinates of the touch point and the touch starting point, and calculate the vector of the finger and the rotation angle of the graphic; S2: Update the display position of the graphic on the screen in real time according to the current rotation angle; S3: monitor the current rotation angle. When the rotation angle approaches a specific angle and enters the threshold area from outside the threshold area, an interpolator and an easing function are used to achieve smooth adsorption. When the rotation angle moves away from the specific angle and leaves the threshold area from inside the threshold area, an interpolator and an easing function are used to achieve smooth detachment. S4: dynamically adjusting the correction parameters of the rotation angle according to the user's rotation speed and rotation path; S5: Record and analyze the user's rotation habits and use machine learning algorithms to optimize the rotation correction parameters.
2. A method for smoothly controlling graphic rotation according to claim 1, characterized in that: The method continuously monitors the touch events of the screen, obtains the coordinates of the touch point and the touch starting point, and calculates the vector of the finger and the rotation angle of the graphic; The following steps are involved: S11: obtaining the plane coordinates of the touch point through the touch screen sensor, obtaining the linear acceleration on the three axes through the accelerometer, obtaining the angular velocity of the device around the three axes through the gyroscope, and filtering the acceleration and angular velocity data; S12: according to the influence of screen orientation and resolution, the coordinates of the touch screen are converted into a space consistent with the device coordinate system, and the accelerometer and gyroscope sensor data are calibrated; S13: Estimate the touch position and device attitude by combining the measured values of the touch screen coordinates with the position and attitude changes predicted by the accelerometer and gyroscope through the Kalman filter algorithm; S14: when a touch event starts, the touch coordinates optimized by the algorithm are recorded as the starting point coordinates, and the touch point coordinates optimized by the algorithm are continuously obtained during the touch process to calculate the vector; S15: Calculate the rotation angle of the device based on the gyroscope data, and project the vector of the finger in the coordinate system after the device is rotated. Suppose the rotation angle around the axis measured by the gyroscope is θ g yro, then the rotation matrix is: Multiply the finger's vector by the rotation matrix, and then use the inverse tangent function to get the rotation angle of the figure.
3. A graphics rotation smooth control method according to claim 2, characterized in that: In step S13, a complementary filtering algorithm is used to fuse the low-frequency accurate information measured by the accelerometer with the high-frequency dynamic information measured by the gyroscope, and a more accurate attitude estimation is obtained by adjusting the weights.
4. A method for smoothly controlling graphic rotation according to claim 1, characterized in that: The method of updating the display position of the graphic on the screen in real time according to the current rotation angle comprises the following steps: S21: Based on the initial position of the graphic on the screen, the reference point is rotated according to the geometric features of the graphic as the center point of rotation (x c enter,y c enter); S22: Construct the rotation matrix R according to the rotation angle θ of the graph obtained by algorithm optimization S23: Suppose the graph has multiple vertices, whose original positions are (x υ ertex,y υ ertex), the vertex position after rotation is (x υ ertex r otated,y υ ertex r otated), the calculation formula of the vertex position is: x υ ertex r otated=(x υ ertex-x c erter)cosθ-(y υ ertex-y c cnter)sinθ+x c enter y υ ertex r otated=(x υ ertex-x c enter)sinθ+(y υ ertex-y c enter)cosθy c enter; S24: Redraw the graphics and display them on the screen based on the calculated new positions of the vertices after rotation, as well as the boundary conditions and clipping of the graphics.
5. A method for smoothly controlling graphic rotation according to claim 4, characterized in that: The monitoring of the current rotation angle, when approaching a specific angle and entering the threshold area from outside the threshold area, using an interpolator and an easing function to achieve smooth adsorption, and when moving away from the specific angle and leaving the threshold area from within the threshold area, using an interpolator and an easing function to achieve smooth detachment; comprises the following steps: S31: continuously monitoring the current rotation angle of the graphic according to the set specific angle at which the graphic is attached or detached and the threshold area around the specific angle; S32: When the rotation angle enters the threshold area from outside the threshold area, a smooth adsorption operation is triggered; when the rotation angle leaves the threshold area from outside the threshold area, a smooth detachment operation is triggered; S33: when entering the threshold region, gradually adjusting the rotation angle of the graphic through cubic spline interpolation and sine curve easing function, and when leaving the threshold region, gradually adjusting the rotation angle of the graphic through cubic spline interpolation and sine curve easing function in the opposite direction; S34: According to the interpolated rotation angle calculated for each frame, the new positions of the graphic vertices are recalculated according to the method of steps S21-S23, and the graphic is updated to be displayed on the screen.
6. A method for smoothly controlling graphic rotation according to claim 1, characterized in that: The method of dynamically adjusting the correction parameters of the rotation angle according to the rotation speed and rotation path of the user comprises the following steps: S41: When the user performs a touch rotation operation on the screen, the rotation angle change a is calculated and recorded by comparing the rotation angles at different time points, and the time interval b is calculated and recorded by the time difference between two adjacent angle measurements, and the rotation speed c is calculated, and the formula is: c=a / b, and multiple points on the rotation path are recorded at the same time; S42: evaluating the curvature of the path by calculating the degree of curvature between several adjacent points, and determining the frequency of direction changes of the path by counting the number of times the direction of the path changes; S43: performing speed-based adjustment and path-based adjustment according to the established correction parameters; S44: Repeat steps S41-S43 within each frame time interval, update the correction parameters in real time and apply them to the correction of the rotation angle.
7. A method for smoothly controlling graphic rotation according to claim 6, characterized in that: The method of performing speed-based adjustment and path-based adjustment according to the established correction parameters comprises the following steps: S431: Perform speed-based adjustment through the established correction parameter k, the expression of the correction parameter is: Wherein, 1 is the initial value of the correction parameter, a is a coefficient determined based on experience when the rotation speed is fast, b is another coefficient determined based on experience when the rotation speed is slow, c is the rotation speed, and d is the rotation speed threshold value based on the statistical characteristics of the user's historical rotation operation data; S432: according to the curvature of the path and the frequency of direction changes, the correction parameter k is increased for high curvature or frequent direction changes; the correction parameter k is decreased for low curvature and stable direction; S433: The final corrected rotation angle is the product of the correction parameter and the uncorrected measured rotation angle.
8. A method for smoothly controlling graphic rotation according to claim 1, characterized in that: The method of recording and analyzing the user's rotation habits and optimizing the rotation correction parameters using a machine learning algorithm comprises the following steps: S51: collecting the starting angle, ending angle, rotation time and a series of coordinate points on the rotation path of each rotation during multiple screen touch rotation operations performed by the user, and collecting the user's operating device information and operating environment information, and pre-processing the collected data; S52: extracting features from the collected data, including: an average value, a maximum value, a minimum value of the rotation speed, a curvature feature of the rotation path, and a frequency and amplitude of a change in the rotation direction; S53: Divide the data after feature extraction into a training set, a validation set and a test set, determine the number of input layer nodes according to the number of features through a multi-layer perceptron model, determine the number of output layer nodes according to the correction parameters, use the activation function ReLU function for the hidden layer, and determine the activation function of the output layer according to the properties of the correction parameters; S54: Use the training set data to train the multi-layer perceptron, define the loss function, use Adam to automatically adjust the model parameters according to the gradient of the loss function, and use small batches for training; S55: Adjust the hyperparameters of the number of hidden layers and nodes, learning rate, regularization parameter, and dropout probability. Perform a final evaluation on the trained model using the test set data. Deploy the trained model to actual applications to receive new rotation operation data from users. Regularly retrain and adjust the model using new data.
9. A method for smoothly controlling graphic rotation according to claim 8, characterized in that: Also includes: The multi-layer perceptron model is combined with the convolutional neural network model to avoid overfitting by ensemble learning and averaging the prediction results.
10. A graphic rotation smooth control device, characterized in that: It includes monitoring module, updating module, adsorption and separation module and adaptive optimization module, among which: The monitoring module is used to obtain the location information of the touch point and the posture and motion information of the device through sensor fusion technology; The update module is used to calculate the finger's stroke vector and the rotation angle of the graphic to update the display position of the graphic on the screen in real time; The adsorption and detachment module is used to monitor the rotation angle. When approaching a specific angle and entering the threshold area from outside the threshold area, an interpolator and an easing function are used to achieve smooth adsorption; when moving away from a specific angle and detaching from the threshold area from within the threshold area, an interpolator and an easing function are used to achieve smooth detachment. The adaptive optimization module is used to dynamically adjust the correction parameters of the rotation angle according to the user's rotation speed and rotation path, record and analyze the user's rotation habits, and use a machine learning algorithm to optimize the rotation correction parameters.
11. The graphic rotation smooth control device according to claim 10, characterized in that: The monitoring module is also used to learn and analyze the image sequence or touch data generated by the touch screen through a convolutional neural network or a recurrent neural network, and output the predicted touch starting point and subsequent movement trajectory through a trained model.
12. The graphic rotation smooth control device according to claim 10, characterized in that: The adaptive optimization module is used to optimize the rotation correction parameters through a multi-layer perceptron model or a support vector machine model.
