Part II of our of our journey in having an object move along a Bezier curve, and moving towards re-parametrizing the curve, we first need to understand a very important aspect of a specific attribute of a Bezier curve and that is computing its tangents via its first derivative.
By using the form on my first post on Beziers,
we can easily observe the first derivative is obtained as follows
which in turn can be reduced to
lastly, giving us
local pbx = pax + 6*t*(p3.x-p2.x)*(1-t)
local pcx = pax + pbx + 3*(p4.x-p3.x)*(t*t);
local pay = 3*(p2.y-p1.y)*((1-t) *(1-t));
local pby = pay + 6*t*(p3.y-p2.y)*(1-t)
local pcy = pay + pby + 3*(p4.y-p3.y)*(t*t);
And why is this important? Because when you want to do text on a path, move the text object along the path, (as well as an object that you want to be perpendicular to the curve) it needs to project away from it. Thus the Y direction is perpendicular to the curve.
Here is an image of the tangents of a curve at a given t, perpendicular to the curve. You can also see the parametrization not being equal in the corner cases of the curve.
