My current task: To extrude a shape along a MOVING bspline. Each control point on the bspline consists of a position, and an "up" vector
Initially, people using my code will establish their bsplines like this (green dots/lines are the position and upvector, the purple are just interpolations).
The programmers will then expect to be able to move control point's POSITION (but not upvector) and have things render correctly. So here's the same stuff except with the bottom position now moved to distort the spline:
As you can see, the upvector, when it tries to work with this, doesn't stay sane at all. It actually behaves correctly, but then suddenly makes a huge jump, in this case 180 degrees. But if one of the points is offset a little bit perpendicularly, it won't be 180 degrees... illustrated below:
In my BSpline class, the upvector is grabbed like so:
utype GetUpVector(float thePos)
{
vtype aTan=GetTangent(thePos);
float aPos=thePos-floorf(thePos);
int aIPos=(int)floorf(thePos);
utype aUp;
LerpN(aUp,mPoints[_clamp(0,aIPos,mPoints.Size()-1)].mUp,mPoints[_clamp(0,aIPos+1,mPoints.Size()-1)].mUp,aPos);
vtype aLeft=aTan.Cross(aUp);
vtype aResult=aLeft.Cross(aTan);
return aResult.Normal();
}
(Where mPoints is the list of points in the spline, and GetTangent gets basically the direction of the spline at the location).
Can anyone help me figure out what's happening here? How do I get the spline to return an upvector that keeps to the curve of the spline?