top of page
Search

Computer Animation Toolkit

huyuxin

During school class computer animation, we implemented several frequently used animation toolkit in C++.


The first set of toolkit is Drawing Cubic Polynomial Splines. We implemented Catmull-Rom Splines, Hermite Splines, and B-Splines. For Catmull-Rom Splines, we used three approaches to draw curves: Bernstein Polynomial, De-Casteljau, and Matrix Method. Hermite Spline is similar to Catmull-Rom Spline, but it guarantees 2nd order derivative is continuous. Comparing to CR spline and Hermite Spline, BSpline is more powerful. It is 2nd-order derivative continuous, and each control point only affects curves it directly controls and curves that are next to it, means it has local control ability.


The second set of toolkit is Rotation. We have implemented rotation matrix,  Euler Angles and Quaternion. Euler Angles consists of different rotation orders: ZYX, XYZ, YZX, XZY, ZXY, YXZ. Euler Angles is easy to understand, however it has the problem of Gimble Lock. For instance, let's assume the coordinate system is constructed using right hand rule, x is pointing out of screen, y is rightward, and z is upward. Using Euler Angle in order of YZX (Pitch-Yaw-Roll), if we rotate around Z (yaw) by a random degree, and then rotate around Y (pitch) by 90 degrees, and then rotate around X (roll) by a random degree, we find that the first rotation around Z does not affect the final result anymore, because it is exactly the same as rotation around X, which means we lost 1 degree of freedom. So we introduced another rotation representation to solve Gimble Lock problem, which is called Quaternion. Quaternion allows rotation around any vector of any angles, and we can use Spherical Linear Interpolation to combine 2 Quaternions.


The third set of toolkit is Body Kinematics. We implemented both Forward Kinematics and Inverse Kinematics. Forward Kinematics use local rotation information of every joint to determine their global positions using chain rule from root joint. Inverse Kinematics is more complicated, there is a nullspace in solution. I only implemented Limb-based IK and CCD based IK. The pseudo inverse solver is not included in this video demo.


The fourth set of toolkit is Particles. I implemented a basic particle system to simulate fireworks. Each particle has a vector of 1*6 to store its' current dynamic information: [vx, vy, vz, ax, ay, az]. a is acceleration, and it can be calculated by Newton's Second Law: a = F/m. Then we use Euler's Integration to get the velocity: v(t) = v(t-delta) + a*delta.


The last set of toolkit is behavior controller.


Here is a video demo of the animation toolkit.


Click Here to see the video on Tencent.

16 views0 comments

Recent Posts

See All

Comments


© 2023 by Andi Banks. Proudly created with Wix.com

  • githubIcon
  • LinkedIn
bottom of page