Implementation of the Key Frame System (Hermite position interpolation + squad Quaternary space orientation interpolation)

Source: Internet
Author: User

Let's talk about the low-layer motion control method at work. When designing an animation, an animation generally first designs the Motion Track of the object, and then specifies the motion of the object along the trajectory. The trajectory of an object is a spline, which is provided by user interaction. Assuming that the trajectory of an object is a spatial parameter curve Q (u), we must sample the Q (U) and other intervals to obtain the position of the object in each frame. However, when the parameter U is sampled at intervals, the same interval sampling on the spline cannot be obtained, because the same spacing parameter does not necessarily correspond to the same spacing arc length. Since the arc-length function S = a (u) is a strict addition function of U, S and u are one-to-one relationships. A (u) is an integral equation, which has no analytical solution. We cannot directly express the A-1 (s) Resolution, usually only use the numerical method. This method is described in detail in advanced animation and rendering techniques. The author of this book, Watt, also proposes an approximate calculation method based on the forward difference according to their practices, this is implemented in all algorithms. What kind of items are used to represent our tracks? Splines commonly used in computer-aided geometric design include betiller, B-spline, and β-spline. Each has its own advantages and disadvantages. B-spline is one of the commonly used curves in animation. Its second-order Continuity ensures the smoothness of motion, and the locality ensures that the animation can be adjusted locally. Therefore, it is very suitable for trajectory curves, however, it is not suitable for key frame interpolation. Based on the Hermite function, kochanek introduces two additional parameters into the constrained equation. The obtained spline function is very suitable for the key frame interpolation system. The specific Hermite splines are explained in many ways. They only list the general formulas of the incubation vectors and the incubation vectors. The tensor parameter T is used to control the attention of curves at interpolation points; offset parameter B is used to adjust the relative weight of the source string and the target string. Continuity parameter C is used to control the left and right tangent. These three parameters are suitable for the shape adjustment of the specified curve. Design of the positional Interpolation Curve:Class spline {public: spline (); Virtual ~ Spline (); Public: void addkeypoint (cpoint3d * const pt); void removepoint (cpoint3d * const pt ); // return the point of the arc length being S (0 <= S <= 1) virtual cpoint3d arclengthpoint (double S) = 0; // The Method Based on forward difference approximately virtual cpoint3d arcintervallengthpoint (double S) = 0; // build the segments according to keypoints, whose spline type may be Hermite, // bspline, bezi Er inherited from spline class virtual void buildsegment () = 0; // update these keypoint values when data are changed virtual void updatesplinevalues () = 0; protected: public: static vector <cpoint3d *> m_splinekeypoint; private: spline (const spline & S); spline & operator = (const spline & S) ;}; class hermitespline: Public spline {public: hermitespline (); Virtual ~ Hermitespline (); Public: void setlengths (); // build a table of U against accumulated arclength virtual cpoint3d arclengthpoint (double S); void setintervallengths (); // a method based on forward differences virtual cpoint3d arcintervallengthpoint (double S); Virtual void buildsegment (); Virtual void updatesplinevalues (); Private: /* define the Hermite segment between P1 and P2 (have two keypoints at lea St) construct the segment using four vector (P1, P2, DD1, DS2) */class hermitesegment {public: Virtual ~ Hermitesegment () {}; hermitesegment (const cpoint3d * const P0, const cpoint3d * const P1, const cpoint3d * const P2, const cpoint3d * const P3); Private: hermitesegment (); hermitesegment (const hermitesegment & segment); hermitesegment & operator = (const hermitesegment & segment); Public: // tension [-1, 1] default value is 0.0, float tension () const {return m_tension;} // bias [-1, 1], default Value is 0.0, And the toggle direction float bias () const {return m_bias;} // continuity [-1, 1], default value is 0.0, float continuity () const {return m_continuity;} // curve resolution, default is 10 int resolution () const {return m_resolution;} void settension (float T) {m_tension = T;} void setbias (float B) {m_bias = B;} void setcontinuity (float c) {m_continuity = C;} void setresolut Ion (INT res) {m_resolution = res;} public: Float arclength (float ustart, float uend); cpoint3d getpointonsegment (float U); Private: void setcoef (); float arcintegrand (float U); Private: cpoint3d m_keypoint [4]; float m_coef [4] [3]; float m_bias; float m_tension; float m_continuity; int m_resolution; bool m_coefisvalid;}; vector <double> m_seglength; // For setlengths () vector <double> m_intervalleng Th; // For setintervallengths () Double m_totallength; int m_deltau; public: vector SquadIt is a commonly used construction method that is worth inserting the element of the Quaternary element. In 1995, Kim et al. proposed an analytical method for constructing the unit Quaternary curve. It can promote the curves in R3 to the Quaternary space and construct a unit Quaternary curve similar to that of the original curve. In actual implementation, I used the squad method to interpolation the curve. As shown in the following figure, figure 1 defines four key frames, and figure 2 defines six key frames. Based on the General constructor method of the Quaternary curve with higher-order derivatives in [2] in the document, it is not difficult to clarify the derivative and angular velocity of the Quaternary functions. ^_^ see also: 1. Advanced animation and rendering techniques 2. Kim m j, Kim m s, Shin s y. A general construction scheme for unit quaternion curves with simple high order derivatives. computer Graphics, 1995, 29 (3): 369-376

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.