Hey
I'm dealing with ribbons following the shape of multiple spline segments. It's straightforward to compute the direction at any point along the spline. However the ribbon also got a flat shape and I'm struggling with finding a way to compute the angle of the ribbon in the plane perpendicular to the direction.
To illustrate what I mean here's a piece of code that almost worked:
float3x3 rotMtxFromSpline;
rotMtxFromSpline[1] = normalize(splineDir);
rotMtxFromSpline[0] = normalize(cross(float3(1, 0, 0), rotMtxFromSpline[1]));
rotMtxFromSpline[2] = cross(rotMtxFromSpline[0], rotMtxFromSpline[1]);
// Rotate rotMtxFromSpline[0] in the rotMtxFromSpline[0]-rotMtxFromSpline[2]-plane to align with float3(0, 0, 1) dir
rotMtxFromSpline[0] = normalize(dot(rotMtxFromSpline[0], float3(0, 0, 1)) * rotMtxFromSpline[0] + dot(rotMtxFromSpline[2], float3(0, 0, 1)) * rotMtxFromSpline[2]);
rotMtxFromSpline[2] = cross(rotMtxFromSpline[0], rotMtxFromSpline[1]);
The problem with this code is when the spline segment becomes perpendicular to (0,0,1)-dir as the orientation switch from one side to the other very easily.
The approach above is kind of a global approach and I'm thinking if there's a way to append some info to each spline segment to remedy the issue.
Anyhow I wanted to post this question in case anyone had a similar problem that they solved or maybe anyone know some web resource dealing with this issue?
Thanks!