Hanson algorithm to represent a tubular surface, given its directrice line
This algorithm ensures the continuity of a moving othonormal frame along the directrice.
Let \gamma(t) = (x(t), y(t), z(t)) be the directrice parameterization with respect to the standard orthonormal frame, \mathcal{F}=(O; (e_1, e_2, e_3)).
Denote by q(θ; w) the unit quaternion that defines the rotation about the unit vector w, with an angle θ. It is represented by the 4-vector (\cos(\theta/2), \sin(\theta/2)w).
To this unit quaternion corresponds the rotation, of matrix:
M= Rotations.UnitQuaternion(cos(θ/2, (sin(θ/2)*w)...))
Let τ(t) be the unit tangent vector field along the curve. The vector field of unit quaternions
Q(t) =q(\theta(t), w(t)), with \theta(t)=\arccos(e_1 \cdot \tau(t)), and w=(e_1 \times \tau(t))/||e_1 \times \tau(t)||, associated to the directrice, represents a path in the group of rotations, i.e. a field of orthonormal bases consisting in the columns of rotation matrices.
The first column of such a matrix is the unit tangent vector, \tau(t), and the last two, the orthonormal vectors denoted n_1(t), n_2(t), which define the tube parametrization:
S(u,v)=γ(u) + r\cos(v) * n₁(u) + r\sin(v) * n₂(u), \:\: (u, v)\in[a,b]\times[0, 2\pi]
r is the tube radius.
The function implementing this algorithm is posted on this thread:
https://discourse.julialang.org/t/drawing-a-tubular-path-with-meshes-jl-blog-post/104203/2, as well as a link to examples.