Athena: Bezier Curves

Bezier CurveWhen animations are exported from Maya through COLLADA files, they come out in a variety of formats depending on how the animation was implemented, and what is being animated.

One format is the bezier curve, a curve made from four points. Two fo the points are the start and end position, and the other two are control points that describe how it should curve.

Bezier Curve ApplicationSince all three axis can be animated, I made it possible to make a 3-component vector bezier class using the bezier class I created, and just calculate the point coefficients once, passing them to the bezier class to get the position. This of course only works if the time length for curves are the same on all three axis.

I’ve made a sample, it is an Xcode project that uses GLUT to render a 2D bezier and a 3D bezier. The code should work with other IDEs. One thing I should warn is that this bezier class only works when the time step is constant between the control point and it’s respective point.

P0 (0, 0) … keypoint 0
P1 (2, 10) … keypoint 1
C0 (0.666667, 42.6212) … control point 0
C1 (1.33333, 10) … control point 1

T0 = (C0 – P0) -> (2, 42.6212)
T1 = (P1 – C1) -> (2, 0)

The above sample is from the COLLADA forum, as you can see the time step is 2 for both T0 and T1. The same post describes how to calculate the S0 if your time step is not constant.

Athena Bezier Source (Version 1.0.0) (401 downloads)