How to know if a vector is in a region created by 2 tangential line from one end of the vector to a circle?

52 Views Asked by At

Example of what I'm taking about

My question will be clearer looking at the picture. The dash area is the area I want to know if the vector is inside of it or not. With the picture drawn out, the question seems to be trivial but I want to have a mathematical answer. My end goal is to have this problem solve through programming.

Let:

-The circle O(xc, yc) has a radius of R.

-The vector u(a,b) with the starting point of (xu, yu)

1

There are 1 best solutions below

1
On BEST ANSWER

enter image description here

Because triangles OAP and OBP are right,

$$x^2+R^2=OP^2, \mbox{or} $$ $$x=\sqrt{OP^2-R^2}$$

From properties of right triangles:

$$\frac{x}{OP}=\cos\frac{\alpha}{2},$$ where $\alpha$ denotes the angle BPA. Then

$$\cos\frac{\alpha}{2}=\frac{\sqrt{OP^2-R^2}}{OP^2}$$

Because triangles BPO and APO have a side equal to R and share the side OP, then BPO and APO are identical and therefore OP cuts $\alpha$ into two equal angles $\frac{\alpha}{2}$.

Now plot an arbitrary vector $\vec{PC}$ (the coordinates of C are assumed known). The vectors $$\frac{\vec{PC}}{PC} \mbox{ and } \frac{\vec{PO}}{PO}$$ are unit vectors.

Then

$$\frac{\vec{PC}}{PC} \cdot \frac{\vec{PO}}{PO}=\cos\gamma.$$

If $\vec{PC}$ is between the two tangents,

$$\cos\gamma \ge \cos\frac{\alpha}{2},$$ because $\gamma \le \frac{\alpha}{2}$.

Therefore the condition for an arbitrary vector $\vec{PC}$ drawn from P and ending in C, to be between the two tangents, is

$$\frac{\vec{PC}}{PC} \cdot \frac{\vec{PO}}{PO} \ge \frac{\sqrt{OP^2-R^2}}{OP^2}$$.

To ensure the vector does not cross the circle, add these two conditions:

$$OC \ge R$$

and $PC \le PA$, that is

$$PC \le \sqrt{OP^2-R^2}$$