Intersection of a circle in 3D with horizontal planes?

248 Views Asked by At

Let's assume that we have two vectors in $\mathbb R ^3$, $v_1$ and $v_2$, such that $v_1 \perp v_2$ and $|v_1|=|v_2|=1$.

Since the two vectors emerge from the origin, they can define a circle in $\mathbb R^3$ that includes both vectors and is perpendicular to their cross product.

Now, the question is how to compute all points on the circle that have a specific $z$-value, or in other words, all points that are formed by intersecting the non-horizontal circle at the origin with a horizontal plane with a specific $z$-value determining its height.

Later addition:

Reading this problem can cause confusion because of me adding specifiers like 'horizontal' without me providing what is the coordinate system we work on. In my system, X is right, Y is front, and Z is up. So saying a 'horizontal' plane means: the plane that is parallel to the X and Y (right and front) axes and is defined by only is Z value as its height.

2

There are 2 best solutions below

0
On BEST ANSWER

Let's write the points of the circle parametrically:

$$ u(t) = \cos(t) v_1 + \sin(t) v_2 $$ where $t$ ranges from $0$ to $2\pi$.

Each of these points (i.e., for any $t$) is a unit vector.

You want to know when these have a particular $z$-value; let's say $z = c$. That's the same as saying that the dot-product of $u(t)$ with the $z$-axis unit vector $e_3 = \pmatrix{0 \\0\\1}$ must be exactly $c$. So let's write that out: \begin{align} c &= u(t) \cdot e_3 \\ &= (\cos(t) v_1 + \sin(t) v_2) \cdot e_3 \\ &= (\cos(t) v_1 \cdot e_3 + \sin(t) v_2 \cdot e_3) \end{align} Now $v_1 \cdot e_3$ is just the $z$-coordinate of $v_1$; similarly for the other dot product. So we have $$ c = z_1 \cos(t) + z_2 \sin(t) $$ Here's where things get a little tricky. If only the right-hand side had the form $$ \cos(b) \cos(t) + \sin(b) \sin(t) $$ we could use the cosine-addition formula to simplify it. But $z_1$ and $z_2$ aren'y necessarily the sine and cosine of any angle. To have that be true, we'd need $z_1^2 + z_2^2 = 1$. So let's fiddle a little: \begin{align} c &= z_1 \cos(t) + z_2 \sin(t) \\ &\\ \frac{c}{\sqrt{z_1^2 + z_2^2}} &= \frac{z_1 \cos(t) + z_2 \sin(t)}{\sqrt{z_1^2 + z_2^2}} &\text{ dividing both sides by the same thing}\\ \frac{c}{\sqrt{z_1^2 + z_2^2}} &= \frac{z_1}{\sqrt{z_1^2 + z_2^2}} \cos(t) + \frac{z_2}{\sqrt{z_1^2 + z_2^2}} \sin(t) &\text{ distributing}\\ \end{align}

Now we have a pair of (somewhat messy) coefficients whose squares sum to one, and we need to find "the angle whose cosine and sine these numbers are".

Fortunately, we're in luck: there's a pretty standard math function, "atan2", that provides just what we need: in general $atan2(y, x)$ [yes, I got the order right!] is the angle $r$ with the property that a ray from the origin in direction $r$ passes through the point $(x, y)$. To put it differently, there's a number $r$ with the property that $x = r \cos(b); y = r \sin(b)$.

Let's let $b = atan2(\frac{z_2}{\sqrt{z_1^2 + z_2^2}}, \frac{z_1}{\sqrt{z_1^2 + z_2^2}})$.

Then we have $$ \cos(b) = \frac{z_1}{\sqrt{z_1^2 + z_2^2}} \\ \sin(b) = \frac{z_1}{\sqrt{z_1^2 + z_2^2}} $$ So we can rewrite a bit more: \begin{align} \frac{c}{\sqrt{z_1^2 + z_2^2}} &= \frac{z_1}{\sqrt{z_1^2 + z_2^2}} \cos(t) + \frac{z_2}{\sqrt{z_1^2 + z_2^2}} \sin(t)\\ &= \cos(b) \cos(t) + \sin(b) \sin(t)\\ &= \cos(b-t) & \text{by the cosine subtraction formula}\\ \end{align} which means that \begin{align} \cos^{-1}\left(\frac{c}{\sqrt{z_1^2 + z_2^2}} \right) = b - t \end{align} so $$ t = b - \cos^{-1}\left(\frac{c}{\sqrt{z_1^2 + z_2^2}} \right) $$ will be one of the two solutions you need.

The nasty thing here is that the inverse cosine of $x$ only provides one of the two angles whose cosine is $x$. To get the other, you negate. So the other $t$-value you want is $$ t = b + \cos^{-1}\left(\frac{c}{\sqrt{z_1^2 + z_2^2}} \right) $$

From these two values of $t$, you can compute $\cos(t)$ and $\sin(t)$ and therefore compute $u(t)$, which is what you needed.

I want to add one more thing: I said to let $$b = atan2(\frac{z_2}{\sqrt{z_1^2 + z_2^2}}, \frac{z_1}{\sqrt{z_1^2 + z_2^2}} $$ but there's a slightly different description of atan2 that lets us simplify a bit: atan2(y, x) is the angle $b$ with the property that a ray from the origin at angle $b$ (counterclockwise from the positive-$x$ direction) passes through the point $(x, y)$. That means that for any positive number $q$, the ray also passes through $(qx, qy)$. So $atan2(y, x)$ is the same as $atan2(qy, qx)$, as long as $q$ is positive. As a consequence, we can replace our formula for $b$ with $$ b = atan2(z_2, z_1) $$ which is certainly simpler to read.

One more thing: atan2 isn't defined at $(0, 0)$ (more precisely, its definition is arbitrary), so it's good that in your setup for this problem, you pointed out that the $z$-components of your two vectors were nonzero.

0
On

The locus of all points in the described circle is given by the vector parametric equation

$ p(t) = v_1 \ \cos t + v_2 \ \sin t \tag{1} $

Since you want to find the points on this circle that have a specified $Z$ value, then you basically want to solve for the value of the parameter $t$ at which

$ z_1 = v_{1z} \ \cos t + v_{2z} \ \sin t \tag{2} $

where $z_1$ is the specified $Z$ level.

This is a simple equation to solve. It can have two, one, or no solutions. In the general case the value of $t$ is computed as follows:

$ t = \alpha \pm \beta \tag{3}$

where

$ \alpha = \text{Atan2}( v_{1z} , v_{2z} ) \tag{4} $

$ \beta = \cos^{-1} \left( \dfrac{ z_1 }{ \sqrt{ v_{1z}^2 + v_{2z}^2 } } \right) \tag{5} $

Note that there will be solutions if and only if

$ | z_1 | \le \sqrt{ v_{1z}^2 + v_{2z}^2 } \tag{6}$

If this condition is satisfied, and equality holds then there will be only one solution. With strict inequality, we will have two solutions. If the inequality is not satisfied, then there are no solutions.

Once the values of $t$ (if any) are found, the $3D$ points can be found from equation $(1)$.