I have a Bezier curve defined as follows:
public Vector3 Evaluate(int segment, float t)
{
float oneMinusT = 1 - t;
var p0 = points[segment];
var p1 = p1Points[segment];
var p2 = p2Points[segment];
var p3 = points[segment + 1];
return oneMinusT * oneMinusT * oneMinusT * p0 + 3 * oneMinusT * oneMinusT * t * p1 + 3 * oneMinusT * t * t * p2 + t * t * t * p3;
}
public Vector3 EvaluateDerivative(int segment, float t)
{
float oneMinusT = 1 - t;
var p0 = points[segment];
var p1 = p1Points[segment];
var p2 = p2Points[segment];
var p3 = points[segment + 1];
return 3 * oneMinusT * oneMinusT * (p1 - p0) + 6 * oneMinusT * t * (p2 - p1) + 3 * t * t * (p3 - p2);
}
public Vector3 EvaluateSecondDerivative(int segment, float t)
{
float oneMinusT = 1 - t;
var p0 = points[segment];
var p1 = p1Points[segment];
var p2 = p2Points[segment];
var p3 = points[segment + 1];
return 6 * oneMinusT * (p2 - 2 * p1 + p0) + 6 * t * (p3 - 2 * p2 + p1);
}
Basically, someone chooses the points along the spline (the points array above), intermediate points are then calculated automatically to keep the spline smooth (p1Points and p2Points).
If one was to choose points with equal increases in t, the resulting points would obviously have varying distances, because the space between 2 control points is mapped to [0...1] on t. I need to reparametrize this curve so that, given some parameter x, equal increases in x result in equal distances travelled along the curve. I barely passed my math courses in college, so ...