Linear Algebra – Calculate Center of Circle Tangent to Two Lines in Space

circleslinear algebravectors

Good afternoon everyone!
I am facing a problem which is straining my memory of linear algebra. I have:

  • Three points with known coordinates, forming a triangle in space. Let the coordinates be R(top), P(left bottom) and Q(right bottom) (only rough positions)
  • I'm not interested in the triangle as such, but in its two lines QP and QR
  • These lines are tangent to a circle of known radius (basically I'm trying to smooth the angle via a radius, like in CAD)

I need the equation of the circle, so I can pick any point I want between P and R to smooth out the angle. The angle is <180°, so there should exist one solution (correct me if I'm wrong)

I found an image which illustrates my problem:

You can see my points R,P,Q, aswell as my circle which is tangent to both rays originating in Q. Please note, that PQ does not necessarily have to be horizontal and that the angle $\alpha$ is not always 50°. My goal is to calculate the origin O and thus the complete equation of my circle in the form $\vec{r}(t)=\vec{c}+r\cdot\cos{\varphi}\cdot\vec{a}+r\cdot\sin{\varphi}\cdot\vec{b}$

Plan I have made so far:

  1. Calculate $\vec{PR}$
  2. Calculate $a=\arccos{\frac{\vec{QP}\bullet\vec{QR}}{\left|\vec{QP}\right|\cdot\left|\vec{QR}\right|}}$
  3. Calculate $b=\frac{\pi}{2}-a$

From here on it gets tricky. I know, that the origin is on the ray seperating the angle in Q in exact half. If I project that ray on my line $\vec{PQ}$, will I end up in the exact middle? Couldn't I just do something like "rotate $\frac{\vec{PR}}{2}$ around an axis through P by b degrees ccw, where the axis is perpendicular to the triangles plane"

I start to get lost here.

  • The perpendicular vector would be $\vec{QP}\times\vec{QR}$, wouldn't it?
  • The German Wikipedia suggests for rotating via an rotation-matrix $R_{\hat{n}}(\alpha)\vec{x}=\hat{n}(\hat{n}\cdot\vec{x})+\cos\left(\alpha\right)(\hat{n}\times\vec{x})\times\hat{n}+\sin\left(\alpha\right)(\hat{n}\times\vec{x})$ where $\vec{n}$ is the unity-normal-vector around which to rotate. Can I use this formula?
  • How do I finally compile my circle-equation?

Edit: And yes, I have seen this, but it didn't help 🙂

Best Answer

What you want is the tangent, tangent, radius algorithm. One way to handle this is as follows:

  1. Measure the angle $\alpha = \widehat{RQP}$. This is done using the cross product and dot product from the coordinates of the points.
  2. Construct the bisector of the angle and note that if the radius is known as $h$ the distance from the vertex to the circle center $QA$ is $$s=\frac{h}{\sin \frac{\alpha}{2}}$$
  3. Numerically create a vector of length $s$ along $QR$ and rotate it by $\frac{\alpha}{2}$ to find point $A$.

TTR