Calculate point on circle where tangent line is parallel to a given vector

746 Views Asked by At

Given a circle around a given point with a given radius and a vector perpendicular to the plane on which the circle lies, how can I calculate the point on the circle where the tangent line is parallel to a given vector?

This is for a Blender Python plugin.

1

There are 1 best solutions below

4
On BEST ANSWER

Given $C = (a, b)$ and radius $r$, you want to find a point $(u, v)$ on the circle with the tangent at $(u, v)$ parallel to $(p, q)$.

The vector perpendicular to $(p, q)$ is $(-q, p)$. So the point you want is

$$ (u, v) = (a, b) \pm \frac{r}{\sqrt{q^2 + p^2}} (-q, p). $$

(The reason for the plus-or-minus is that there are two points on the circle whose tangents are parallel to $(p, q)$. Note, too, that this fails if $(p, q) = (0, 0)$, but that's reasonable -- for that case, any point on the circle is a solution.)

In 3D:

$$ \newcommand{\bn}{{\mathbf n}} \newcommand{\bt}{{\mathbf t}} \newcommand{\bh}{{\mathbf h}} \newcommand{\bk}{{\mathbf k}} $$ Given a circle-center $C = (a, b, c)$ and radius $r$, and a normal vector $\bn$ to the plane containing the circle, you want to find a point $(u, v, w)$ on the circle with the tangent at $(u, v, w)$ parallel to $\bt = (p, q, s)$.

First of all, this isn't always possible. If, for instance, $\bt$ and $\bn$ are parallel, it simply can't be done. The requirement is that $\bt \cdot \bn = 0$, so I'm going to assume that.

Now: let $$ \bh = \bt \times \bn $$ and $$ \bk = \frac{1}{\|\bh\|}\bh. $$ Then your desired circle-point is $$ P = C \pm r \bk. $$ because it's distance $r$ from $C$ (since $\bk$ is a unit vector), and the displacement from $C$, namely $r\bk$, is in the plane normal to $\bn$, hence this is a point of the circle. And the tangent to the circle there is perpendicular to the radius vector, i.e., perpendicular to $\bk$, and also perpendicular to $\bn$ (the normal to the plane of the circle), hence it must be proportional to $\bn \times \bk $, which is proportional to $\bn \times \bh = \bn \times (\bt \times \bn)$, which is proportional to $\bt$, and we're done.