Calculate center of circle tangent to two lines in space 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:


*

*Calculate $\vec{PR}$

*Calculate $a=\arccos{\frac{\vec{QP}\bullet\vec{QR}}{\left|\vec{QP}\right|\cdot\left|\vec{QR}\right|}}$

*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 :-)
 A: Another way to solve this, if you know the radius $r$, is to offset the two tangent lines by that amount and find where they intersect. That would be the center of the circle.
Here is an example with GeoGebra (of course)

The dark black lines are the original lines, and the light gray lines are offset by one radius. Where they intersect is the center of the corner radius (red).
A: What you want is the tangent, tangent, radius algorithm. One way to handle this is as follows:


*

*Measure the angle $\alpha = \widehat{RQP}$. This is done using the cross product and dot product from the coordinates of the points.

*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}}$$

*Numerically create a vector of length $s$ along $QR$ and rotate it by $\frac{\alpha}{2}$ to find point $A$.



A: I would suggest something like this to find the center of your circle: Since you know the coordinates of $P$ and $Q$, you can find a normalized vector that is perpendicular to $\vec{QP}$, using the inner product. You also said that $PQ$ is a tangent line meaning, the vector $\vec{PO}$ is perpendicular to $\vec{PQ}$. Given the fact you can calculate a vector perpendicular to $PQ$ means you only have to travel along this vector over a lenght of your (known) radius. If you start in $P$ you will end up exactly at the center of your cirlce.
A: There is no unique solution to this problem. There are infinitely many circles which will be tangent to the two given lines. The centre's of these circles, as pointed in the solution given, will be on the angle bisector. See the animation below:

A: 
Consider the given circle with the radius $r_1$
as a scaled version 
of the inscribed circle of 
the given $\triangle ABC$
with the inradius $r$. 
Then we have a scaling factor
\begin{align}
k&=\frac {r_1}r
,
\end{align} 
and the center of the given circle is
\begin{align}
I_1&=B+k\cdot\vec{BI}
.
\end{align}
Reminder: the center of the inscribed circle
in terms of the points $A,B,C$ and side lengths $a,b,c$
is found as
\begin{align}
I&=\frac{a\,A+b\,B+c\,C}{a+b+c}
,
\end{align}
and the tangential points of the incircle
\begin{align}
A_t&=\tfrac12\cdot(B+C)+\frac{b-c}{2a}\cdot(B-C)
,\\
C_t&=\tfrac12\cdot(A+B)+\frac{a-b}{2c}\cdot(A-B)
.
\end{align}
