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!
You have $$\begin{aligned} x &= L \\ y &= L \cos \varphi \\ z &= L \sin \varphi \\ \end{aligned}$$ Rotation by $\theta$ around the $y$ axis is $$\begin{aligned} x^\prime &= x \cos \theta + z \sin \theta \\ y^\prime &= y \\ z^\prime &= z \cos \theta - x \sin \theta \\ \end{aligned}$$ It looks like your error is in forgetting one summand in the $z^\prime$ component.
Combining the two you get $$\begin{aligned} x^\prime &= L \cos \theta + L \sin\varphi \sin\theta \\ y^\prime &= L \cos \varphi \\ z^\prime &= L \sin \varphi \cos\theta - L \sin\theta \\ \end{aligned}$$
For example, at $\theta = 90°$, $\sin\theta = 1$ and $\cos\theta = 0$, and $$\begin{aligned} x_{90°} &= L \sin\varphi \\ y_{90°} &= L \cos \varphi \\ z_{90°} &= -L \\ \end{aligned}$$ which is the expected rotated cylinder.
This ninety-degree check is useful when examining ones own rotations. Whenever the result gets flat (like yours with $\theta = 90°$), you know your rotation formulae was incorrect.