Get the parametric equation of a rotated cylinder (with certain slope)

3dgeometryparametrizationsolid of revolutionsolid-geometry

I have a basic question but I have failed in solving it. I have the equation of a cylinder which is $y^2 + z^2 = r^2$ (centered in the x-axis). The parametric equation (dependent on $L$ and $s$) is $(x,y,z) = (L, r\cos(s), r\sin(s))$.

I would like to rotate it certain angle $\theta$ (anticlockwise). Thus I have the new axis from the rotation as: $x=x'*\cos\theta + z'*\sin\theta$, $y=y'$ and $z=r*\sin\theta$. However, when rewriting the equation of the cylinder as $(y')^2 + (-x'*\sin\theta + z'*\cos\theta)^2 = r^2$ and parametrizing, I get: $(x,y,z) = (L, r*\cos(s), z+x'*\tan\theta)$, with $z=r*\sin\theta$. When I plot this, I get a elliptic cylinder.
Does anyone know what am I doing wrong? I need such equation because I will generate multiple cylinders later computationally.

I have followed previous posts such as If I have an oblique cylinder can I trim it in to a rectilinear cylinder? but they actually obtain the elliptic cylinder.

Many thanks!

Best Answer

The algebraic equation of a right circular cylinder with radius $r$ and axis $a$ (a unit vector) is given by

$ (p - p_0)^T (I - a a ^T) (p - p_0) = r^2 $

where $p_0$ is a point on the axis. To find the parametric equation, define a new basis for $\mathbb{R}^3$ having its $z'$-axis along the axis $a$. Let $u_1$ and $u_2$ be unit vectors that perpendicular to $a$ and to each other. Now express $p$ and $p_0$ in this basis as follows. First define the rotation matrix

$R = [u_1, u_2, a]$

Then define $q$ and $q_0$ by

$ p = R q $ and $p_0 = R q_0 $

Plug these into the equation of the cylinder

$ (q - q_0)^T R^T (I - a a ^T ) R (q - q_0) = r^2 $

Now $R^T (I - a a^T ) R = I - (R^T a) (R^T a)^T $

and $R^T a = \begin{bmatrix} 0 \\0 \\ 1 \end{bmatrix} $

Hence, $Q = R^T (I - a a ^T) R = \begin{bmatrix} 1 && 0 && 0 \\ 0 && 1 && 0 \\ 0 && 0 && 0 \end{bmatrix} $

Thus the equation in terms of $q$ reduces to

$ (q_1 - q_{01} )^2 + (q_2 - q_{02})^2 = r^2 $

whose parametrization is

$q_1 = q_{01} + r \cos \theta $

$q_2 = q_{02} + r \sin \theta $

$q_3 = t $

where $t$ is arbitrary.

Finally, the parametrization of $p$ is

$ p = R q = R \begin{bmatrix} q_{01} + r \cos \theta\\ q_{02} + r \sin \theta\\ t \end{bmatrix} $

Related Question