# How to know if a vector is in a region created by 2 tangential line from one end of the vector to a circle? 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)

• You need to specify what is given. Also, there are a lot of vectors that are equal to the one in the picture but have a different starting point. Do you care about that? – Vasya May 23 '19 at 3:51
• @Vasya Thanks for the comment. I'm trying to have a general answer for an arbitrary vector and arbitrary circle in XY plan. I have added some more details in the question. – Anh Tran May 23 '19 at 4:10
• Is it $\mathbf u$ that you wish to test? Is $(x_u,y_u)$ the cone’s apes? – amd May 23 '19 at 5:40
• @amd Yes, u is the vector I want to test and $(x_u, y_u)$ is the pointy end. – Anh Tran May 23 '19 at 7:05 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}$$

• Good job, beautiful equation, easy to program. I haven't check out the math yet but looks good so far. – Anh Tran May 24 '19 at 1:43