I want to find the equations for a solid oblique cylinder centered on the origin.
What's this equation?
Work I've Done So Far
Suppose the cylinder has radius $R$ and height $h$.
First, I found the equation for a regular solid cylinder centered on the origin.
$$\begin{align} x^2 + y^2 &\leq R^2 \\ -\frac{h}{2}\leq z &\leq \frac{h}{2} \end{align} $$
So then I tried to make a cylinder slanted.
And looking top down the cylinder moves
So, then I reasoned that I could just substitute these new values in. My equation for a solid oblique cylinder would be
$$\begin{align} (x-h\cos(\alpha))^2 + y^2 &\leq R^2 \\ 0\leq z &\leq h \sin(\alpha) \end{align} $$
But this is not centered on the origin. Using my diagram above, the center has $y=0$, and then the average of $(0,0)$ and $(2R + h\cos(\alpha),h\sin(\alpha)$. Then the center is
$$\mathbf{r}_{center}=\left(R + \frac{h}{2}\cos(\alpha),0,\frac{h}{2}\sin(\alpha)\right)$$
So the oblique cylinder centered on the COM is
$$\begin{align} \left(x-\left(R+\frac{h}{2}\cos(\alpha)\right)\right)^2 + y^2 &\leq R^2 \\ -\frac{h \sin(\alpha)}{2}\leq z &\leq \frac{h \sin(\alpha)}{2} \end{align} $$
But this also seems wrong to me because I think the $x$ coordinate of the center of a thin cross section of the cylinder should vary with height and my formula has no $z$.
So another possibility might be
$$\begin{align} \left(x-\left(\frac{z}{2}\cos(\alpha)\right)\right)^2 + y^2 &\leq R^2 \\ -\frac{h \sin(\alpha)}{2}\leq z &\leq \frac{h \sin(\alpha)}{2} \end{align} $$
This one seems reasonable because (1) the center of the circle would vary with height and (2) it reduces to the regular cylinder when $\alpha = 90^{\circ}$.
$\endgroup$ 115 Answers
$\begingroup$Ordinary Cylinder
An ordinary solid cylinder looks like this:
An the equations look like this
$$\begin{align} x^2 + y^2 \leq R^2 \\ |z| \leq \frac{h}{2} \end{align} $$
Oblique Cylinder
An oblique cylinder looks like this:
I will show how to derive the equations an oblique cylinder that is sheared in the $xz$ plane. Importantly, the height of the oblique cylinder should not change because that will change the volume. Therefore, the range of $z$ should remain the same.
A horizontal shear mapping is as follows:
$$\begin{bmatrix} x'\\ z'\\ \end{bmatrix} =\ \begin{bmatrix} 1 & m \\ 0 & 1\\ \end{bmatrix} \begin{bmatrix} x\\ z\\ \end{bmatrix} = \begin{bmatrix} x + mz\\ z \end{bmatrix} $$
This transformation can be seen using Python:
Notice the height between the bottom and top remains the same. This is the transformation we want. However, it is not stated in terms of $\alpha$, the angle from the vertical. It's stated in terms of the distance of the top point from the original spot, i.e. $m$ (see the picture above).
Now consider the following:
In this example, $\alpha_2 > \alpha_1$, so consequently, $cos(\alpha_2) < \cos(\alpha_1)$, which you can see in this side-by-side comparison.
Call the verticals for each triangle $A_1,A_2$, the horizontals $O_1,O_2$ and the hypotenuses $H_1$ and $H_2$.
Currently, $H_1 = H_2$ but we want $A_1 = A_2$. So we should normalize the adjacent sides to be the same length. This can be done as follows:
$$\begin{align} A^2 + O^2 & = H^2 \\ \frac{A^2}{A^2} + \frac{O^2}{A^2} &= \frac{H^2}{A^2} \\ 1 + \tan^2(\alpha) & = \sec^2(\alpha) \end{align} $$which is the common trig identity. So if we set $m = \tan(\alpha)$, we end up getting this instead
Notice the heights are now the same, which means for different angles the height will be constant as desired. Thus, the transformation should be
$$\begin{bmatrix} x'\\ z'\\ \end{bmatrix} =\ \begin{bmatrix} 1 & \tan(\alpha) \\ 0 & 1\\ \end{bmatrix} \begin{bmatrix} x\\ z\\ \end{bmatrix} = \begin{bmatrix} x + z\tan(\alpha)\\ z \end{bmatrix} $$
So, the equation of the cylinder would be
$$\begin{align} (x-z\tan(\alpha))^2 + y^2 \leq R^2 \\ |z| \leq \frac{h}{2} \end{align} $$
This is the set of formulas Math Lover provided, so they were correct. However, I found their intuition for why $\tan$ was used lacking so I wanted to supplement.
Using $m=\sin$ vs $m=\tan$
In the comments, there was some discussion of whether $\sin$ or $\tan$ should be used for $m$. In this Python code, you can clearly see that $\sin$ wouldn't make sense.
See how even though $\alpha = 90^{\circ}$, $\sin(\alpha)$ doesn't stretch the cylinder waaaay out like we would expect.
However, notice for $\tan$, even at $\alpha = 85^\circ$, the stretch becomes very pronounced
Also, notice how the norm of the vertical sides for the $\tan$ output become enormous, which is also what you would expect, but it does not for the $\sin$ output.
This can also be seen in 3D here.
With $\sin$ at $\alpha = 90^\circ$,
Notice, this is the maximum possible slant and we can easily imagine a substantially more slanted cylinder.
With $\tan$ at $\alpha = 85^\circ$,
Why it is $x-z\tan(\alpha)$ not $x+z\tan(\alpha)$
If you use $x+z\tan(\alpha)$, that means the center of the top circle of the cylinder would be $x = -\frac{h}{2}\tan(\alpha)$, which is negative for $0\leq \alpha \leq 90^\circ$.
This would produce$$\begin{bmatrix} x'\\ z'\\ \end{bmatrix} =\ \begin{bmatrix} 1 & -\tan(\alpha) \\ 0 & 1\\ \end{bmatrix} \begin{bmatrix} x\\ z\\ \end{bmatrix} = \begin{bmatrix} x - z\tan(\alpha)\\ z \end{bmatrix} $$
and lead to the following cylinder
This is what None suggested and, as you can see, the cylinder here would be flipped from the desired cylinder with positive $x$ for positive $z$.
$\endgroup$ $\begingroup$Equation of the right cylinder along z axis is
$x^2 + y^2 \le R^2$
between $-\frac{h}{2}\le z \le \frac{h}{2}$
Now you keep the point of the cylinder at the origin fixed and make it oblique along the x axis keeping both bases parallel to the XY plane,
(i) The x coordinate of the center will shift farther away from z axis as the value of |z| increases
(ii) The y coordinate of the center will remain the same.
The coordinate of the center at z will be $(z.tan\alpha, 0,z)$ where $\alpha$ is the angle between z-axis and axis of the cylinder.
The equation of the cylinder will be $(x-z.tan\alpha)^2 + y^2 \le R^2$.
If we want the oblique cylinder to have the same volume, $-\frac{h}{2}\le z \le \frac{h}{2}$ remains the same.
EDIT:
added pictures of initial position and oblique cylinder slanted towards x-axis.
$\endgroup$ 2 $\begingroup$A right circular cylinder of radius $R$ and height $h$ centered at origin with cylinder axis on the $z$ axis fulfills$$\left\lbrace ~ \begin{aligned} x^2 + y^2 &\le R^2 \\ \lvert z \rvert &\le \frac{h}{2} \\ \end{aligned} \right . \tag{1}\label{None1}$$
If we want to apply a shear mapping to the $x z$ plane that slants the $x$ axis by angle $\varphi$ ($-90° \lt \varphi \lt +90°$), we perform a change in variables$$\left\lbrace ~ \begin{aligned} x^\prime &= x + z \tan\varphi \\ y^\prime &= y \\ z^\prime &= z \\ \end{aligned} \right . \tag{2}\label{None2}$$
If we have a line segment between $(0, 0, -s)$ and $(0, 0, +s)$ in the original coordinate system, with $0 \lt s \in \mathbb{R}$, the shear mapping would move its endpoints to $(-s \tan\varphi, 0, -s)$ and $(s \tan\varphi, 0, s)$, respectively. Therefore, its length would change from $2 s$ to $2\sqrt{(s \tan \varphi)^2 + s^2}$.
For the line segment to have a stretched length $h$, we need to solve$$h = 2 \sqrt{(s \tan\varphi)^2 + s^2} = 2 s \sqrt{1 + (\tan\varphi)^2} \tag{3a}\label{None3a}$$for $s$. This is simple:$$s = \frac{h}{2 \sqrt{1 + (\tan\varphi)^2}} \tag{3b}\label{None3b}$$However, because$$\frac{1}{\sqrt{1 + (\tan\varphi)^2}} = \cos\varphi \quad \text{ for} \quad -90° \lt \varphi \lt +90°$$$\eqref{None3b}$ is actually equivalent to$$s = \frac{h}{2}\cos(\varphi) \tag{4}\label{None4}$$
Therefore, the equation for an oblique (shear-mapped) cylinder with $x$ axis sheared by angle $\varphi$ on the $xz$ plane, height along cylinder axis $h$, centered at origin, is$$\left\lbrace ~ \begin{aligned} (x - z \tan\varphi)^2 + y^2 &\le R^2 \\ \lvert z \rvert &\le \frac{h}{2} \cos\varphi \\ \end{aligned} \right. \tag{5}\label{None5}$$
$\endgroup$ 3 $\begingroup$Comment
- If three parameters are allowed then $ (x,y,z) $$$= ( a \cos \theta \cos u - v \sin u, b \sin \theta, a \cos \theta \sin u + v \cos u) $$
cylinder radius = a
- In oblique ( non-Cartesian ) coordinates it has the form of a right circular cylinder.
The equation of the original upright cylinder is
$ r^T Q r = r_0^2 $
where
$r = [x, y, z]^T $ and
$Q = \begin{bmatrix} 1 && 0 && 0 \\ 0 && 1 && 0 \\ 0 && 0 && 0 \end{bmatrix}$
and $r_0$ is the radius of the cylinder.
Now all you have to do is apply a sheer transformation to the points on this cylinder by an angle $\alpha$ measured from $z$ axis, and pointing in the positive $x$ axis, the sheer transformation matrix is given by:
$S = \begin{bmatrix} 1 && 0 && \tan \alpha \\ 0 && 1 && 0 \\ 0 && 0 && 1 \end{bmatrix} $
So that the image of $r $ is $r' = S r$, from which we can write $r = S^{-1} r'$
Substitute this into the equation of the upright cylinder, and remove the primes from the variable names ($r'$ to $ r$) you get
$ r^T S^{-T} Q S^{-1} r = r_0^2 $
And this is the equation of the oblique cylinder.
$\endgroup$ 1