From BlenderWiki
While working with any of the Curve objects in Blender (bezier, Ipo Curves), you will run across the BezTriple data type. It's implementation can be somewhat confusing if you are more used to dealing with Blender's Listbase format.
The BezTriple is a struct that contains several elements, including a 3x3 matrix defined in the struct as "vec[3][3]". The "vec" array refers to the data from the three parts of a Bezier point: the actual point and its two handles. Each of the these three elements has, potentially, three associated values, one each for x, y, and z. When dealing with Ipo Curves or other two dimensional curves, the z value is extraneous.
Here is how the values map into the array:
- vec[0][0]=x location of handle 1
- vec[0][1]=y location of handle 1
- vec[0][2]=z location of handle 1
- vec[1][0]=x location of control point
- vec[1][1]=y location of control point
- vec[1][2]=z location of control point
- vec[2][0]=x location of handle 2
- vec[2][1]=y location of handle 2
- vec[2][2]=z location of handle 2
As stated above, when dealing with Ipo Curves, the vec[2][] portion is irrelevant.
A final note on the implementation of BezTriples in Curves is that although a Nurb can contain multiple BezTriples to actually define the curve in space, these multiple instances are not contained in a Listbase. The *bezt pointer in the case of Nurbs points not to a Listbase, but to the first element in a simple array of BezTriples. This is why in the code you will notice implementations first counting the number of points, then working through them by incrementing the *bezt point (bezt++), while decrementing the counter (usually a--).
If the bezt element of Nurbs pointed to a Listbase this sort of thing would not be necessary, as you would simply loop through the Listbase in the common fashion. It is also why you see the entire memory space for the array being copied and pushed around when new BezTriples (points) are added to a curve.
-- harkyman - 12 Jan 2006







![[]](/skins/blender/open.png)
