How to calculate the spiral around a curve? I have a curve given by a set of points and want to build a spiral around it (like this).

I tried it by
STEP 1:
calculated the vector of each step by
$$v_n = \left<x_n,y_n,z_n\right> - \left<x_{n-1},y_{n-1},z_{n-1}\right>$$
STEP 2:
I assumed a vector/plane of the rotating trajectory as
$$ w_n = \left<\cos(i),1,\sin(i)\right>$$
where $i$ represents the intervals and increases by the point number.
And calculated the perpendicular vector to find the spiral points by
$$X = v_y \cdot w_z - v_z \cdot w_y $$
$$Y = v_z \cdot w_x - v_x \cdot w_z $$
$$Z = v_x \cdot w_y - v_y \cdot w_x $$
And, of course, I normalized the scale.
The spiral is formed, but I have discontinuity or deformation at sharp angles (probably because the vector direction is changed). It is not a matter of smoothness, as the spiral changes its direction to rotate in the opposite direction.
Where did I do wrong?

Probably your steps are too large.  You are rotating a full radian between steps.  If you use finer steps in both directions you will improve things.  If you just divide $i$ by $10$ in the $w$ equation the pitch will increase by a factor $10$.  Maybe you should interpolate $10$ steps between your $v$ points, then divide $i$ by $10$ in $w$.  The most challenging points are those where the axis of the helix bends most.  You need the steps in your helix rather small by comparison with that scale.
