An animation speed control method, device, equipment and storage medium
By equally dividing the time process interval and generating a lookup table, the problems of large computational load and low efficiency in animation speed control in existing technologies are solved, and fast and accurate animation speed control is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NINGBO NINGSHU SAFETY TECHNOLOGY CO LTD
- Filing Date
- 2022-11-24
- Publication Date
- 2026-07-03
AI Technical Summary
Existing technologies using cubic Bézier curves for animation speed control involve large computational loads and heavy real-time computational burdens. The number of calculations increases significantly, especially when accuracy requirements are increased, leading to low computational efficiency.
By equally dividing the preset time process interval, a lookup table is generated to record the mapping relationship between time process parameters and indirect variable parameters. The lookup table is used to quickly narrow down the range of target indirect variable parameters and reduce the amount of calculation.
It improves the computational efficiency of animation speed control, reduces the number of calculations, and enhances the speed and accuracy of real-time calculations.
Smart Images

Figure CN115719396B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of animation technology, and in particular to an animation speed control method, apparatus, device, and storage medium. Background Technology
[0002] In the fields of visualization and animation, the speed control of an animation is typically achieved using animation curves, most commonly a special cubic Bézier curve. For this animation control curve, the animation begins when the time parameter x = 0 and ends when x = 1, indicating which part of the animation has progressed as the time parameter x changes. By adjusting control points P1 and P2 on the curve, the slope of the curve can be controlled, thereby controlling the rhythm of the animation and achieving animation control. When using an animation controller, it is necessary to quickly calculate the y-value at any x given control points P1 and P2, where y represents the movement control parameter of the animation.
[0003] Existing techniques can indeed find the required solution using the binary search method, but they suffer from high computational cost and excessive burden on real-time operations. Calculations suggest that, under normal circumstances, with a precision of 0.0001, the time complexity is approximately O(log₂n), with n = 10000, requiring an average of 13.2 calculations. Furthermore, the number of calculations increases by 3.3 for every order of magnitude increase in precision requirement. While these number of calculations may seem insignificant to a computer, the inherent complexity of the formula and the frequent use of computation in animation control necessitate minimizing the number of calculations to achieve faster and more direct results. Therefore, improving computational speed remains a pressing issue. Summary of the Invention
[0004] In view of this, the purpose of this invention is to provide an animation speed control method, apparatus, device, and storage medium that can create a lookup table through pre-calculation and quickly narrow down the range of indirect variable parameters corresponding to the current time process parameters based on the lookup table, thereby improving computational efficiency. The specific solution is as follows:
[0005] In a first aspect, this application provides an animation speed control method, including:
[0006] The preset time process interval is equally divided to obtain a preset number of time process segments, and the indirect variable parameters corresponding to the time process parameters at both ends of each time process segment are determined respectively.
[0007] By recording the mapping relationship between the time process parameters and the indirect variable parameters, a corresponding lookup table is generated, and the lookup table is used to find the two indirect variable parameters that correspond to the time process parameters at both ends of the target time process segment where the current time process parameter is located.
[0008] From the parameter range corresponding to the two indirect variable parameters, a target indirect variable parameter that satisfies a preset target condition is determined; the preset target condition is that the difference between the time process parameter corresponding to the target indirect variable parameter and the current time process parameter is less than or equal to a preset difference threshold.
[0009] The current motion control parameters corresponding to the target indirect variable parameters are determined based on the cubic Bézier curve, and the speed of the target animation is controlled using the current time process parameters and the current motion control parameters.
[0010] Optionally, the step of using the lookup table to find two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located includes:
[0011] Based on the time process parameters in the lookup table and the number of segments corresponding to the time process segments, create data item serial numbers that correspond to the time process parameters respectively;
[0012] The sequence numbers of the two data items corresponding to the current time process parameters are determined based on the current time process parameters and the number of segments corresponding to the time process segments.
[0013] The two indirect variable parameters are determined from the lookup table using the two data item numbers.
[0014] Optionally, the step of using the lookup table to find two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located includes:
[0015] Use the lookup table to find the time process parameters at both ends of the target time process segment corresponding to the current time process parameter;
[0016] Based on the mapping relationship between the time process parameters and the indirect variable parameters recorded in the lookup table, determine the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment.
[0017] Optionally, determining the target indirect variable parameters that satisfy the preset target conditions from the parameter range corresponding to the two indirect variable parameters includes:
[0018] Determine whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies a preset coverage condition; the preset coverage condition is that the product of the number of segments and the preset difference threshold is greater than or equal to the preset coverage threshold.
[0019] If not, then perform a bisection operation within the parameter range corresponding to the two indirect variable parameters until the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter is less than or equal to the preset difference threshold, and then determine the indirect variable parameter after the current bisection as the target indirect variable parameter.
[0020] Optionally, performing the bisection operation within the parameter range corresponding to the two indirect variable parameters includes:
[0021] Perform a derivative operation on the cubic Bézier curve to obtain a cubic Bézier derivative curve;
[0022] A bisection operation is performed on the cubic Bézier derivative curve within the parameter range corresponding to the two indirect variable parameters.
[0023] Optionally, after determining whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies the preset coverage condition, the method further includes:
[0024] If so, then determine the first difference and the second difference between the time process parameters at both ends of the target time process segment and the current time process parameter, respectively;
[0025] Determine the target time process parameter corresponding to the minimum difference between the first difference and the second difference, and determine the indirect variable parameter corresponding to the target time process parameter as the target indirect variable parameter.
[0026] Optionally, after determining whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies the preset coverage condition, the method further includes:
[0027] If so, then the two indirect variable parameters are interpolated using a preset interpolation rule to obtain the target indirect variable parameters.
[0028] Secondly, this application provides an animation speed control device, comprising:
[0029] The interval division module is used to equally divide a preset time process interval to obtain a corresponding preset number of time process segments, and to determine the indirect variable parameters corresponding to the time process parameters at both ends of each time process segment.
[0030] The parameter lookup module is used to generate a corresponding lookup table by recording the mapping relationship between the time process parameters and the indirect variable parameters, and to use the lookup table to find the two indirect variable parameters that correspond to the time process parameters at both ends of the target time process segment where the current time process parameter is located.
[0031] The target parameter determination module is used to determine the target indirect variable parameter that satisfies the preset target condition from the parameter range corresponding to the two indirect variable parameters; the preset target condition is that the difference between the time process parameter corresponding to the target indirect variable parameter and the current time process parameter is less than or equal to a preset difference threshold.
[0032] The animation speed control module is used to determine the current movement control parameters corresponding to the target indirect variable parameters based on the cubic Bézier curve, and to control the speed of the target animation using the current time process parameters and the current movement control parameters.
[0033] Thirdly, this application provides an electronic device, comprising:
[0034] Memory, used to store computer programs;
[0035] A processor for executing the computer program to implement the aforementioned animation speed control method.
[0036] Fourthly, this application provides a computer-readable storage medium for storing a computer program that, when executed by a processor, implements the aforementioned animation speed control method.
[0037] In this application, a preset time process interval is equally divided to obtain a preset number of time process segments, and indirect variable parameters corresponding to the time process parameters at both ends of each time process segment are determined. A corresponding lookup table is generated by recording the mapping relationship between the time process parameters and the indirect variable parameters, and the lookup table is used to find two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located. Target indirect variable parameters that meet preset target conditions are determined from the parameter range corresponding to the two indirect variable parameters. The preset target conditions are that the difference between the time process parameter corresponding to the target indirect variable parameter and the current time process parameter is less than or equal to a preset difference threshold. The current movement control parameter corresponding to the target indirect variable parameter is determined based on a cubic Bézier curve, and the target animation is speed controlled using the current time process parameter and the current movement control parameter. Therefore, this application divides the preset time process interval equally and pre-calculates the indirect variable parameters corresponding to the time process parameters. Then, it creates a lookup table based on the mapping relationship between the time process parameters and the indirect variable parameters. The lookup table is used to search for the current time process parameters, which quickly narrows down the range of the indirect variable parameters corresponding to the current time process parameters, reduces the amount of calculation, and improves the calculation efficiency. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0039] Figure 1 This is a flowchart of an animation speed control method disclosed in this application;
[0040] Figure 2 This is a flowchart of a specific animation speed control method disclosed in this application;
[0041] Figure 3 This is a flowchart of a specific animation speed control method disclosed in this application;
[0042] Figure 4 This is a schematic diagram of a cubic Bézier curve disclosed in this application;
[0043] Figure 5 This is a schematic diagram of the structure of an animation speed control device disclosed in this application;
[0044] Figure 6This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] Existing technologies can indeed find the required solution using the bisection method, but they suffer from high computational complexity and excessive burden in real-time operations. Calculations show that, under normal circumstances, when the computational precision is 0.0001, an average of 13.2 calculations are required, and the number of calculations increases by 3.3 for every order of magnitude increase in precision requirement. To address this, this application provides an animation speed control method that can create a lookup table through pre-calculation, quickly narrowing down the range of indirect variable parameters corresponding to the current time process parameters, thereby improving computational efficiency.
[0047] See Figure 1 As shown, an embodiment of the present invention discloses an animation speed control method, including:
[0048] Step S11: Divide the preset time process interval equally to obtain a preset number of time process segments, and determine the indirect variable parameters corresponding to the time process parameters at both ends of each time process segment.
[0049] In this embodiment, the preset time process interval is x∈[0,1]. A number of time process segments is defined, and the preset time process interval is divided equally to obtain a corresponding number of time process segments. The indirect variable parameters corresponding to the time process parameters at both ends of each time process segment are calculated using the relationship between the time process parameter x and the indirect variable parameter t. The relationship between the time process parameter x and the indirect variable parameter t is as follows:
[0050] x t =P0x(1-t) 3 +3P1xt(1-t) 2 +3P2xt 2 (1-t)+P3xt 3 , t∈[0,1]
[0051] Where x represents the time process parameter, t represents the indirect variable parameter, P0 represents the starting point coordinates, P1 and P2 represent the control point coordinates, and P3 represents the ending point coordinates. For example, if the number of segments is 100, the preset time process interval x∈[0,1] is divided into 100 equal parts, resulting in a corresponding number of time process segments. The time process parameters at both ends of each time process segment are x=0, 0.01, 0.02...0.99, 1. The indirect variable parameter corresponding to each time process parameter is calculated using the relationship between the time process parameter x and the indirect variable parameter t.
[0052] In this embodiment, for ease of calculation, the number of fragments can be set to a positive integer, preferably an easily calculated number, such as a power of ten. For every tenfold increase in the number of fragments, the expected number of calculations in real-time computation decreases by 3.3 times. When the number of fragments is 1000, the expected number of calculations is reduced by approximately 10 times. Generally, setting the number of fragments to 100 or 1000 is recommended, as this can result in a significant speed improvement.
[0053] Step S12: Generate a corresponding lookup table by recording the mapping relationship between the time process parameters and the indirect variable parameters, and use the lookup table to find the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located.
[0054] In this embodiment, after obtaining the time process parameters and the corresponding indirect variable parameters, a lookup table is generated to record the mapping relationship between the time process parameters and the indirect variable parameters. For example, after obtaining the indirect variable parameter t when the time process parameters x = 0.01, 0.02...0.99, and x = 0, t = 0 and x = 1, t = 1, a lookup table is generated. Since the time process parameter x and the indirect variable parameter t of the linearized cubic Bézier curve follow a linear relationship, that is, when t = t1, x = x1, when t = t2, x = x2, and when t1 < t2, x1 < x2, if the time process parameter x to be solved satisfies x > x1 and x < x2, then t must be within the interval [t1, t2]. It is understandable that the lookup table can be used to find the range of x that is adjacent to the current time process parameter, that is, the time process parameters at both ends of the target time process segment. At the same time, the lookup table can also be used to locate the approximate range of the corresponding indirect variable parameter t. Then, within this range, the target indirect variable parameter that meets the preset target conditions can be determined, thereby reducing the amount of calculation.
[0055] Step S13: Determine the target indirect variable parameter that meets the preset target condition from the parameter range corresponding to the two indirect variable parameters; the preset target condition is that the difference between the time process parameter corresponding to the target indirect variable parameter and the current time process parameter is less than or equal to the preset difference threshold.
[0056] In this embodiment, in the prior art, for a known current time process parameter, a bisection is directly performed on the indirect variable parameter t∈[0,1] until the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter is less than or equal to a preset difference threshold. The indirect variable parameter after the current bisection can then be used as an approximate solution for the current time process parameter, i.e., the target indirect variable parameter. However, this application pre-calculates the correspondence between the time process parameter and the indirect variable parameter and generates a lookup table. The lookup table is used to find the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located, thereby quickly narrowing the calculation range. Simultaneously, by comparing the number of time process segments with the preset difference threshold, the target indirect variable parameter can be determined either by performing a bisection within the parameter range corresponding to the two indirect variable parameters, or by directly determining the target indirect variable parameter without performing a bisection. The preset difference threshold can be set according to the user's performance requirements; the higher the performance requirements, the smaller the preset difference threshold.
[0057] Step S14: Determine the current motion control parameters corresponding to the target indirect variable parameters based on the cubic Bézier curve, and use the current time process parameters and the current motion control parameters to control the speed of the target animation.
[0058] In this embodiment, speed control of an animation typically requires the use of animation curves, most commonly a special cubic Bézier curve. Generalized Bézier curves cannot meet the needs of animation control, while linearized Bézier curves generally refer to those that exhibit a linear relationship where the time progression parameter x increases as the indirect variable parameter t increases. This linearized Bézier curve starts at P0(0, 0) and ends at P3(1, 1), with the two intermediate control points P1 and P2 satisfying that the abscissa x is greater than 0 and less than 1. Here, x = 0 indicates the start of the animation, and x = 1 indicates the end of the animation. The formula for a cubic Bézier curve is as follows:
[0059] B(t)=P0(1-t) 3 +3P1t(1-t) 2 +3P2t 2 (1-t)+P3t 3 , t∈[0,1]
[0060] Where t represents the indirect variable parameter, P0 represents the starting point coordinates, P1 and P2 represent the control point coordinates, P3 represents the ending point coordinates, and B(t) represents the animation movement control parameter. It can be understood that this special linearized cubic Bézier curve allows us to first determine the target indirect variable parameter t using the currently known time progression parameter x, and then use the cubic Bézier curve and the target indirect variable parameter t to solve for y. y is the animation movement control parameter B(t), which describes how much y needs to move as the time progression parameter x changes, thus achieving control over the target animation. For example, if the target animation controls the movement distance, the distance y needs to move depends on the time progression parameter x; if the target animation controls the gradation, the gradation degree y needs to be controlled as the time progression parameter x changes.
[0061] Therefore, this application divides the preset time process interval equally and pre-calculates the indirect variable parameters corresponding to the time process parameters. Then, it creates a lookup table based on the mapping relationship between the time process parameters and the indirect variable parameters. The lookup table is used to search for the current time process parameters, which quickly narrows down the range of the indirect variable parameters corresponding to the current time process parameters, reduces the amount of calculation, and improves the calculation efficiency.
[0062] As can be seen from the previous embodiment, this application describes how to generate a lookup table through pre-calculation, which can be used to quickly narrow down the range of indirect variable parameters corresponding to the current time process parameters. Therefore, this application will now describe in detail how to use the lookup table to find the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameters are located.
[0063] See Figure 2 As shown, this embodiment of the invention discloses a process for determining two indirect variable parameters, including:
[0064] Step S21: Based on the time process parameters in the lookup table and the number of segments corresponding to the time process segments, create data item serial numbers corresponding to the time process parameters respectively.
[0065] In this embodiment, the time process parameters in the lookup table are multiplied by the number of segments corresponding to the time process segments, thereby associating the index of each data item in the lookup table with the time process parameters. For example, if the time process parameters in the lookup table are 0, 0.1, 0.2...0.9, 1, and the number of segments corresponding to the time process parameters is 10, then the indexes of the data items corresponding to the time process parameters are 0, 1, 2...9, 10, respectively. In this way, by associating the indexes of the data items in the lookup table with the time process parameters, the position of the currently needed time process parameter in the lookup table can be quickly determined.
[0066] Step S22: Determine the sequence numbers of the two data items corresponding to the current time process parameters based on the current time process parameters and the number of segments corresponding to the time process segments.
[0067] In this embodiment, given the current time process parameters, the current time process parameters are multiplied by the number of segments corresponding to the time process segment, and the result is rounded down to determine the first data item number. Then, the next adjacent number is used as the second data item number, or the second data item number is determined by rounding up the result of the multiplication. The formula for determining the data item number is as follows:
[0068] index = floor(x * b)
[0069] Where `index` represents the data item number, `x` represents the current time process parameter, `b` represents the number of segments corresponding to the time process parameter, and `floor` represents the floor function. For example, if the current time process parameter `x` is 0.625 and the number of segments `b` corresponding to the time process parameter is 10, then the first data item number is 6, and the second data item number is 7.
[0070] Step S23: Use the two data item numbers to determine the two corresponding indirect variable parameters from the lookup table.
[0071] In this embodiment, after determining the two data item indices index and index+1, the two indirect variable parameters t corresponding to the two data item indices can be determined from the lookup table based on the two data item indices. index and t index+1 .
[0072] In this embodiment, in addition to determining the two indirect variable parameters by creating data item serial numbers as described above, the step of using a lookup table to find the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located may include using the lookup table to find the time process parameters at both ends of the target time process segment corresponding to the current time process parameter; and determining the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment based on the mapping relationship between the time process parameters and the indirect variable parameters recorded in the lookup table. It can be understood that when the current time process parameter is known, the time process parameters at both ends of the target time process segment where the current time process parameter is located can be determined from the lookup table, and then the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment can be determined using the correspondence between the time process parameters and the indirect variable parameters. For example, if the current time process parameter is 0.625 and the number of segments corresponding to the time process segment is 10, then the target time process segment where the current time process parameter 0.625 is located in the lookup table is [0.6, 0.7]. The indirect variable parameters when the time process parameter is 0.6 and the indirect variable parameters when the time process parameter is 0.7 are determined by using the mapping relationship between the time process parameter and the indirect variable parameter recorded in the lookup table.
[0073] Therefore, on the one hand, this application can establish a correlation between time process parameters and data item numbers by creating data item indices corresponding to time process parameters in a lookup table, thereby quickly finding the range of indirect variable parameters corresponding to the current time process parameter using the data item indices. On the other hand, this application can first determine the time process parameters at both ends of the target time process segment where the current time process parameter is located, and quickly determine the two corresponding indirect variable parameters through the mapping relationship between the time process parameters and indirect variable parameters recorded in the lookup table. In this way, both methods can quickly narrow down the range of indirect variable parameters corresponding to the current time process parameter by using the lookup table, reducing the amount of computation and improving the computation speed.
[0074] As described in the previous embodiment, this application describes how to use a lookup table to find two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located. Therefore, this application will now describe in detail how to determine the target indirect variable parameter that satisfies the preset target conditions from the parameter range corresponding to the two indirect variable parameters. See [link to relevant documentation]. Figure 3 As shown, this embodiment of the invention discloses a process for determining target indirect variable parameters, including:
[0075] Step S31: Determine whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies the preset coverage condition; the preset coverage condition is that the product of the number of segments and the preset difference threshold is greater than or equal to the preset coverage threshold.
[0076] In this embodiment, it is necessary to first determine whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies the preset coverage condition. For example, if the number of segments corresponding to the time process segment is 100 and the preset difference threshold is 0.1, then the product of the two is 10, which is greater than the preset coverage threshold of 1, and the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies the preset coverage condition; if the number of segments corresponding to the time process segment is 10 and the preset difference threshold is 0.001, then the product of the two is 0.01, which is less than the preset coverage threshold of 1, and the relationship between the number of segments corresponding to the time process segment and the preset difference threshold does not satisfy the preset coverage condition.
[0077] Step S32: If not, perform a bisection operation within the parameter range corresponding to the two indirect variable parameters until the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter is less than or equal to the preset difference threshold. Then, determine the indirect variable parameter after the current bisection as the target indirect variable parameter.
[0078] In this embodiment, when the relationship between the number of segments corresponding to a time process segment and a preset difference threshold does not meet the preset coverage condition, a bisection operation needs to be performed within the parameter range corresponding to the two indirect variable parameters. This allows the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter to gradually approach the preset difference threshold. When the difference is less than or equal to the preset difference threshold, the bisection operation stops, and the indirect variable parameter after the current bisection is determined as the target indirect variable parameter. It should be noted that for the bisection method, if the two indirect variable parameters are t... index and t index+1 Then perform a bisection on t. index and t index+1Half of the sum is determined as the indirect variable parameter after the current bisection. It is then determined whether the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter is less than or equal to a preset difference threshold. If yes, the indirect variable parameter after the current bisection is determined as the target indirect variable parameter. If no, it is determined whether the time process parameter corresponding to the indirect variable parameter after the current bisection is greater than the current time process parameter. If yes, the bisection operation continues within the range of indirect variables corresponding to the left of the indirect variable parameter after the current bisection; if no, the bisection operation continues within the range of indirect variables corresponding to the right of the indirect variable parameter after the current bisection. This continues until the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter is less than or equal to the preset difference threshold. Finally, the indirect variable parameter after the current bisection is determined as the target indirect variable parameter.
[0079] In this embodiment, performing the bisection operation within the parameter range corresponding to the two indirect variable parameters may include performing a derivative operation on the cubic Bézier curve to obtain a cubic Bézier derivative curve; and performing the bisection operation on the cubic Bézier derivative curve within the parameter range corresponding to the two indirect variable parameters. Considering that although this application uses the time process parameter x to solve for the indirect variable parameter t, the actual goal is to solve for the movement control parameter y, and in actual use, although t is a necessary intermediate value for evaluation, it is not actually retrieved in the application. Therefore, if this application uses a preset difference threshold to limit the accuracy of t, it cannot truly obtain a smooth curve. Instead, the accuracy of the relationship between the movement control parameter y and the time process parameter x should be used to measure whether an accurate value has been found. Therefore, when using the bisection method, this application limits the accuracy of the derivative of the cubic Bézier curve, and the formula for this derivative is as follows:
[0080] B(t)′=P0(6t-3-3t 2 )+3P1(1-4t+3t 2 )+3P2(2t-3t 2 )+3P3t 2 , t∈[0,1]
[0081] Where t represents the indirect variable parameter, P0 represents the starting point coordinates, P1 and P2 represent the control point coordinates, P3 represents the ending point coordinates, and B(t) represents the animation movement control parameter. It is understandable that when using the same method to calculate the time progression parameter to approximate accuracy, the derivative of the cubic Bézier curve should be applied to more reasonably describe the relationship between the movement control parameter y and the time progression parameter x, thus making the final value smoother.
[0082] Step S33: If so, determine the first difference and the second difference between the time process parameters at both ends of the target time process segment and the current time process parameter.
[0083] Step S34: Determine the target time process parameter corresponding to the minimum difference between the first difference and the second difference, and determine the indirect variable parameter corresponding to the target time process parameter as the target indirect variable parameter.
[0084] In this embodiment, if the relationship between the number of segments corresponding to a time process segment and the preset difference threshold already meets the preset coverage condition, it indicates that the difference between the time process parameters at both ends of the target time process segment and the current time process parameter is less than the preset difference threshold. Therefore, further calculation using the bisection method is unnecessary. Instead, the first and second differences between the time process parameters at both ends of the target time process segment and the current time process parameter can be compared. The minimum difference is selected, and the time process parameter corresponding to the minimum difference is taken as the target time process parameter. The indirect variable parameter corresponding to the target time process parameter is then determined as the target indirect variable parameter. This eliminates the need for the bisection method, reducing computational load and improving computational speed.
[0085] In this embodiment, in addition to determining the target indirect variable parameter by directly comparing the difference as described above, it may also include performing an interpolation operation on the two indirect variable parameters using a preset interpolation rule if the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies a preset coverage condition, in order to obtain the target indirect variable parameter. For example... Figure 4 As shown, this illustrates the relationship between the time progression parameter x and the indirect variable parameter t in a Bézier curve with control points P1(0.4, 0) and P2(0.6, 1). If the current time progression parameter x = 0.6789312, the number of time progression segments is 10, and the preset difference threshold is 0.1, the target time progression segment containing the current time progression parameter can be found in the lookup table as [0.6, 0.7], and the corresponding range of the indirect variable parameter is [t]. 0.6 , t 0.7 Linear interpolation can yield a more accurate target indirect variable parameter than using a lookup table directly. The linear interpolation formula is as follows:
[0086] t = t 0.6 *(0.7-x)+t 0.7 *(x-0.6)
[0087] Where t represents the target indirect variable parameter, x represents the current time process parameter, and t 0.6 The indirect variable parameter t represents the value of the time progression parameter as 0.6. 0.7This represents the indirect variable parameter when the time progression parameter is 0.7. In this way, the bisection operation is unnecessary; the target indirect variable parameter can be obtained through a single linear interpolation, reducing computational load and improving computational speed.
[0088] Therefore, this application determines whether the relationship between the number of segments corresponding to a time process segment and a preset difference threshold satisfies a preset coverage condition. On the one hand, if the condition is not met, a bisection operation can be performed within the range corresponding to the two indirect variable parameters to obtain the target indirect variable parameter. In this case, by narrowing the execution range of the bisection, the computational load is reduced. On the other hand, if the condition is met, the target indirect variable parameter can be determined directly without performing a bisection, or the target indirect variable parameter can be determined by a single linear interpolation, which can also reduce the computational load and improve the computational speed.
[0089] See Figure 5 As shown, an embodiment of the present invention discloses an animation speed control device, comprising:
[0090] The interval division module 11 is used to equally divide the preset time process interval to obtain a corresponding preset number of time process segments, and to determine the indirect variable parameters corresponding to the time process parameters at both ends of each time process segment.
[0091] The parameter lookup module 12 is used to generate a corresponding lookup table by recording the mapping relationship between the time process parameters and the indirect variable parameters, and to use the lookup table to find the two indirect variable parameters that correspond to the time process parameters at both ends of the target time process segment where the current time process parameter is located.
[0092] The target parameter determination module 13 is used to determine the target indirect variable parameter that satisfies the preset target condition from the parameter range corresponding to the two indirect variable parameters; the preset target condition is that the difference between the time process parameter corresponding to the target indirect variable parameter and the current time process parameter is less than or equal to a preset difference threshold.
[0093] The animation speed control module 14 is used to determine the current movement control parameters corresponding to the target indirect variable parameters based on the cubic Bézier curve, and to use the current time process parameters and the current movement control parameters to control the speed of the target animation.
[0094] Therefore, this application divides the preset time process interval equally and pre-calculates the indirect variable parameters corresponding to the time process parameters. Then, it creates a lookup table based on the mapping relationship between the time process parameters and the indirect variable parameters. The lookup table is used to search for the current time process parameters, which quickly narrows down the range of the indirect variable parameters corresponding to the current time process parameters, reduces the amount of calculation, and improves the calculation efficiency.
[0095] In some specific embodiments, the parameter lookup module 12 may specifically include:
[0096] The sequence number creation unit is used to create data item sequence numbers corresponding to the time process parameters based on the time process parameters in the lookup table and the number of segments corresponding to the time process segments;
[0097] The sequence number determination unit is used to determine the sequence numbers of two data items corresponding to the current time process parameters based on the current time process parameters and the number of segments corresponding to the time process segments;
[0098] The first parameter determination unit is used to determine the corresponding two indirect variable parameters from the lookup table using the two data item numbers.
[0099] In some specific embodiments, the parameter lookup module 12 may specifically include:
[0100] The parameter lookup unit is used to use the lookup table to find the time process parameters at both ends of the target time process segment corresponding to the current time process parameter;
[0101] The second parameter determination unit is used to determine the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment, based on the mapping relationship between the time process parameters and the indirect variable parameters recorded in the lookup table.
[0102] In some specific embodiments, the target parameter determination module 13 may specifically include:
[0103] A condition determination unit is used to determine whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies a preset coverage condition; the preset coverage condition is that the product of the number of segments and the preset difference threshold is greater than or equal to the preset coverage threshold.
[0104] The third parameter determination unit is used to perform a bisection operation within the parameter range corresponding to the two indirect variable parameters if no, until the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter is less than or equal to the preset difference threshold, and then determine the indirect variable parameter after the current bisection as the target indirect variable parameter.
[0105] In some specific embodiments, the animation speed control device may specifically include:
[0106] The curve differentiation unit is used to perform derivative operations on the cubic Bézier curve to obtain the cubic Bézier derivative curve;
[0107] The bisection execution unit is used to perform a bisection operation on the cubic Bézier derivative curve within the parameter range corresponding to the two indirect variable parameters.
[0108] In some specific embodiments, after the condition determination unit, the system may further include:
[0109] The difference determination unit is used to determine, if so, a first difference and a second difference between the time process parameters at both ends of the target time process segment and the current time process parameter, respectively;
[0110] The third parameter determination unit is used to determine the target time process parameter corresponding to the minimum difference between the first difference and the second difference, and to determine the indirect variable parameter corresponding to the target time process parameter as the target indirect variable parameter.
[0111] In some specific embodiments, after the condition determination unit, the system may further include:
[0112] The fourth parameter determination unit is used to perform interpolation operations on the two indirect variable parameters using a preset interpolation rule if the condition is met, so as to obtain the target indirect variable parameter.
[0113] Furthermore, embodiments of this application also disclose an electronic device, Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0114] Figure 6This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the animation speed control method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0115] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0116] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0117] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the animation speed control method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0118] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed animation speed control method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0119] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0120] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0121] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0122] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0123] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An animation speed control method, characterized in that, include: The preset time process interval is equally divided to obtain a preset number of time process segments, and the indirect variable parameters corresponding to the time process parameters at both ends of each time process segment are determined respectively. By recording the mapping relationship between the time process parameters and the indirect variable parameters, a corresponding lookup table is generated, and the lookup table is used to find the two indirect variable parameters that correspond to the time process parameters at both ends of the target time process segment where the current time process parameter is located. From the parameter range corresponding to the two indirect variable parameters, a target indirect variable parameter that satisfies a preset target condition is determined; the preset target condition is that the difference between the time process parameter corresponding to the target indirect variable parameter and the current time process parameter is less than or equal to a preset difference threshold. The current motion control parameters corresponding to the target indirect variable parameters are determined based on the cubic Bézier curve, and the speed of the target animation is controlled by the current time process parameters and the current motion control parameters. The step of determining the target indirect variable parameters that satisfy the preset target conditions from the parameter range corresponding to the two indirect variable parameters includes: Determine whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies a preset coverage condition; the preset coverage condition is that the product of the number of segments and the preset difference threshold is greater than or equal to the preset coverage threshold. If not, then perform a bisection operation within the parameter range corresponding to the two indirect variable parameters until the difference between the time process parameter corresponding to the indirect variable parameter after the current bisection and the current time process parameter is less than or equal to the preset difference threshold, and then determine the indirect variable parameter after the current bisection as the target indirect variable parameter; If so, it indicates that the difference between the time process parameters at both ends of the target time process segment and the current time process parameter is less than the preset difference threshold.
2. The animation speed control method according to claim 1, characterized in that, The step of using the lookup table to find the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located includes: Based on the time process parameters in the lookup table and the number of segments corresponding to the time process segments, create data item serial numbers that correspond to the time process parameters respectively; The sequence numbers of the two data items corresponding to the current time process parameters are determined based on the current time process parameters and the number of segments corresponding to the time process segments. The two indirect variable parameters are determined from the lookup table using the two data item numbers.
3. The animation speed control method according to claim 1, characterized in that, The step of using the lookup table to find the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment where the current time process parameter is located includes: Use the lookup table to find the time process parameters at both ends of the target time process segment corresponding to the current time process parameter; Based on the mapping relationship between the time process parameters and the indirect variable parameters recorded in the lookup table, determine the two indirect variable parameters corresponding to the time process parameters at both ends of the target time process segment.
4. The animation speed control method according to claim 1, characterized in that, The step of performing a bisection operation within the parameter range corresponding to the two indirect variable parameters includes: Perform a derivative operation on the cubic Bézier curve to obtain a cubic Bézier derivative curve; A bisection operation is performed on the cubic Bézier derivative curve within the parameter range corresponding to the two indirect variable parameters.
5. The animation speed control method according to claim 1, characterized in that, After determining whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies the preset coverage condition, the method further includes: If so, then determine the first difference and the second difference between the time process parameters at both ends of the target time process segment and the current time process parameter, respectively; Determine the target time process parameter corresponding to the minimum difference between the first difference and the second difference, and determine the indirect variable parameter corresponding to the target time process parameter as the target indirect variable parameter.
6. The animation speed control method according to claim 1, characterized in that, After determining whether the relationship between the number of segments corresponding to the time process segment and the preset difference threshold satisfies the preset coverage condition, the method further includes: If so, then the two indirect variable parameters are interpolated using a preset interpolation rule to obtain the target indirect variable parameters.
7. An animation speed control device, characterized in that, The animation speed control device is used to implement the animation speed control method as described in any one of claims 1 to 6, and the animation speed control device includes: The interval division module is used to equally divide a preset time process interval to obtain a corresponding preset number of time process segments, and to determine the indirect variable parameters corresponding to the time process parameters at both ends of each time process segment. The parameter lookup module is used to generate a corresponding lookup table by recording the mapping relationship between the time process parameters and the indirect variable parameters, and to use the lookup table to find the two indirect variable parameters that correspond to the time process parameters at both ends of the target time process segment where the current time process parameter is located. The target parameter determination module is used to determine the target indirect variable parameter that satisfies the preset target condition from the parameter range corresponding to the two indirect variable parameters; the preset target condition is that the difference between the time process parameter corresponding to the target indirect variable parameter and the current time process parameter is less than or equal to a preset difference threshold. The animation speed control module is used to determine the current movement control parameters corresponding to the target indirect variable parameters based on the cubic Bézier curve, and to control the speed of the target animation using the current time process parameters and the current movement control parameters.
8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the animation speed control method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the animation speed control method as described in any one of claims 1 to 6.