# Tube plots?

**URL:** <https://discourse.julialang.org/t/tube-plots/65999>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [August 7, 2021, 8:30pm UTC](https://discourse.julialang.org/t/tube-plots/65999 "2021-08-07T20:30:52Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [October 6, 2023, 8:00pm UTC](https://discourse.julialang.org/t/tube-plots/65999/18 "2023-10-06T20:00:05Z")

</div>

**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:

```julia
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](https://discourse.julialang.org/t/drawing-a-tubular-path-with-meshes-jl-blog-post/104203/2), as well as a link to examples.

---

_[View the full topic](https://discourse.julialang.org/t/tube-plots/65999)._
