# Equation of a Curve Along the Surface of a Cylinder?

I find myself with a cylinder of radius r, positioned along the x-axis, with equation y^2 + z^2 = r^2.

If I have two arbitrary points which lie on the surface of such a cylinder, is there a"two-point formula" which would give me some equation of a curve (which also curves along the surface of the cylinder) connecting the two points?

I envision an equation similar to the two-point equation of a line in 2D or 3D, but I do not know if such an equation is possible or makes sense.

My use case is wanting to render a curve connecting two points laying on such a cylinder, in a program I am writing in Python. I would like to render this curve but also understand the underlying mathematics.

Thank you in advance.

• There are infinitely many of such curves. Are you looking for one with the shortest path? – Dylan Dec 10 '17 at 5:38
• Hi, thank you for replying. I am looking for the shortest curve that connects the two points along the surface of the cylinder. If an insect were walking from one point on the surface of a cylinder to another point on the surface taking the shortest path, is there an equation that defines that segment? – kreeser1 Dec 10 '17 at 5:42

## 1 Answer

You can convert the problem into cylindrical coordinates $(x,y,z)\mapsto (x,\theta,r)$

$$x = x, \ y = r\cos\theta, \ z = r\sin\theta$$

The constant surface $r = r_0$ in this coordinates system is somewhat equivalent to a "plane" in traditional Cartesian, in that any point on the surface is only dependent on two coordinates $(x,\theta)$

Suppose our two points are described by $(x_1,\theta_1)$ and $(x_2,\theta_2)$, then the shortest path between them is the linear parametrization (equivalent to defining a line in Cartesian space)

$$x(t) = x_1(1-t) + x_2t$$ $$\theta(t) = \theta_1(1-t) + \theta_2t$$

where the angles are picked so that $|\theta_2-\theta_1|\le \pi$

• Thank you for your help Dylan, I appreciate the insight. – kreeser1 Dec 10 '17 at 7:13