# Intersection between rotating 3D line and 3D line

I am trying to find the intersection between the surface of revolution described by rotating a 3D line $$\vec{r}_1(s)$$ an angle $$\theta$$ around the $$z$$ axis and another 3D line $$\vec{r}_2$$. In parametric form, I know that the solution to this problem is described by the solutions to

$$$$\begin{pmatrix} x_1(s)\cos{\theta} + y_1(s)\sin{\theta} \\ -x_1(s)\sin{\theta} + y_1(s)\cos{\theta}\\ z_1(s) \end{pmatrix} = \begin{pmatrix} x_2(t) \\ y_2(t) \\ z_2(t) \end{pmatrix}$$$$

I don't know how to manipulate the equations to find the values possible values of $$s,t,\theta$$.

I am sure that if $$\vec{r}_1$$ pases through the z-axis, rotating it describes a cone with the z-axis as axis and finding the intersection is straight forward. However, in the case where $$\vec{r}_1(s)$$ doesn't intersect the $$z$$ axis I am no entirely sure of the surface that it describes. It is not necesarrily a cone for example, if $$\vec{r}_2$$ is parallel to the z-axis, the surface is a circular cylinder.

Using cylindrical coordinates, I have found that I have found the following equation for the surface: let $$\vec{q}_1 = \vec{r}_1(0)= (x_1,y_1,z_1)$$ and $$\vec{vq}_1 =\vec{r}_1(1) - \vec{r}_1(0) = (vqx_1,vqy_1,vqz_1)$$:

$$$$\rho^2 = (x_{1}^2 + y_{1}^2) + f(z)^2 (vqx_1^2 + vqy_1^2)$$$$

With $$f(z) = (z - z_1)/(vqz_1)$$

I am not sure how to use that equation. I guess I could substitute $$\rho^2 = x_2^2(t) + y_2^2(t)$$ and $$z = z_2(t)$$ and try to solve for $$t$$ in order to find the intersection but I am not sure this would work.

• These equations are of little use as long as you don't write the functions of $s$ and $t$ explicitly.
– user65203
Commented Mar 29, 2021 at 20:59

This is a comment, just too long to fit in the comment box.

Rotating a line segment $$(x_0, y_0, z_0) - (x_1, y_1, z_1)$$ (where $$z_0 \ne z_1$$) around the $$z$$ axis yields a surface of revolution $$r(z) = \sqrt{ Z_2 z^2 + 2 Z_1 z + Z_0 } \tag{1a}\label{G1a}$$ where \begin{aligned} Z_2 &= \displaystyle \frac{(x_1 - x_0)^2 + (y_1 - y_0)^2}{(z_1 - z_0)^2} \\ Z_1 &= \displaystyle \frac{(x_1 - x_0)(x_0 z_1 - x_1 z_0) + (y_1 - y_0)(y_0 z_1 - y_1 z_0)}{(z_1 - z_0)^2} \\ Z_0 &= \displaystyle \frac{(x_0 z_1 - x_1 z_0)^2 + (y_0 z_1 - y_1 z_0)^2}{(z_1 - z_0)^2} \end{aligned} \tag{1b}\label{G1b}

This is because each point on the line defines the radius for that $$z$$. Parametrising the line using $$0 \le t \le 1$$, \begin{aligned} x(t) &= (1-t) x_0 + t x_1 \\ y(t) &= (1-t) y_0 + t y_1 \\ z(t) &= (1-t) z_0 + t z_1 \\ r(t) &= \sqrt{x(t)^2 + y(t)^2} \\ \end{aligned} and solving $$z(t) = z$$ for $$t$$ yields $$t = \frac{z - z_0}{z_1 - z_0}$$ Substituting this $$t$$ into $$r(t)$$ yields $$\eqref{G1a}$$ and $$\eqref{G1b}$$.

Note that you will be evaluating $$r^2(z) = Z_2 z^2 + 2 Z_1 + Z_0$$, really.

To calculate the intersection between a surface of revolution described by $$r(z)$$ and an (unrelated to above) line or line segment between points $$(x_A, y_A, z_A)$$ and $$(x_B, y_B, z_B)$$, we parametrise the line (segment) the same way as above, say using $$\lambda$$, \begin{aligned} x(\lambda) = (1 - \lambda) x_A + \lambda x_B \\ y(\lambda) = (1 - \lambda) y_A + \lambda y_B \\ z(\lambda) = (1 - \lambda) z_A + \lambda z_B \\ \end{aligned} and the intersection(s) occur when $$z(\lambda)$$ is within the $$z_0$$ and $$z_1$$, and $$x(\lambda)^2 + y(\lambda)^2 = r^2\bigl(z(\lambda)\bigr)$$ It turns out this has zero, one, or two real algebraic solutions.

First, calculate \begin{aligned} D &= Z_2 (z_B - z_A)^2 - (x_B - x_A)^2 - (y_B - y_A)^2 \\ R &= Z_2 ( (x_A z_B - x_B z_A)^2 + (y_A z_B - y_B z_A)^2 - Z_0 (z_B - z_A)^2 ) \\ ~ &+ Z_1^2 (z_B - z_A)^2 - (x_A y_B - x_B y_A)^2 \\ ~ &+ 2 Z_1 ( (x_B z_A - z_B x_A) (x_B - x_A) + (y_B z_A - y_A z_B)(y_B - y_A) ) \\ ~ &+ Z_0 ( (x_B - x_A)^2 + (y_B - y_A)^2 ) \\ \end{aligned} If $$D = 0$$ or $$R \lt 0$$, there is no intersection. Otherwise, there is one or two real solutions $$\lambda = \frac{S \pm \sqrt{R}}{D}$$ where $$S = x_A (x_B - x_A) + y_A (y_B - y_A) - (Z_1 + Z_2 z_A) (z_B - z_A)$$ Note that $$0 \le \lambda \le 1$$ is on the line segment between the points, $$\lambda \lt 0$$ is before point $$(x_A, y_A, z_A)$$, and $$\lambda \gt 1$$ is after point $$(x_B, y_B, z_B)$$.

• In the case when $z_0 = z_1$ and $z_A = Z_B$, the problem becomes 2D, but the equations are not reduced. Any idea what I could do in that case? Commented Apr 2, 2021 at 1:16

Hint.

Solving

$$\cases{ \cos\theta x_1+\sin\theta y_1 = x_2\\ -\sin\theta x_1 + \cos\theta y_1 = y_2 }$$

for $$\{\sin\theta,\cos\theta\}$$ we have

$$\cases{ \sin\theta = \frac{x_2y_1-x_1 y_2}{x_1^2+y_1^2}\\ \cos\theta = \frac{x_1x_2+y_1y_2}{x_1^2+y_1^2} }$$

so

$$\left(\frac{x_2y_1-x_1 y_2}{x_1^2+y_1^2}\right)^2+\left(\frac{x_1x_2+y_1y_2}{x_1^2+y_1^2}\right)^2 = 1$$

but $$\cases{ (x_1,y_1,z_1) = p_{01}+\lambda_1\vec v_1\\ (x_2,y_2,z_2) = p_{02}+\lambda_2\vec v_2 }$$

so making the pertinent substitutions we get two equations and two unknowns

$$\cases{ \left(\frac{x_2y_1-x_1 y_2}{x_1^2+y_1^2}\right)_{\lambda_1,\lambda_2}^2+\left(\frac{x_1x_2+y_1y_2}{x_1^2+y_1^2}\right)_{\lambda_1,\lambda_2}^2 = 1\\ z_1(\lambda_1) =z_2(\lambda_2) }$$

now depending on $$p_{01},p_{02},\vec v_1,\vec v_2$$ the ruled surface and the line can or cannot intersect. If them do not intersect the system of a quadratic an a linear equation will have not real solutions for $$\lambda_1,\lambda_2$$