# Please Explain: Find the inaccuracy in simple vector equation to find out if laser hits an object.

Discussion in 'Geometry and Trigonometry' started by nico7s, Aug 24, 2021.

1. ### nico7s

Joined:
Aug 24, 2021
Messages:
1
0
Hello Community of this math forum!

I would really appreciate answers to my question since I am new here too.

I recently had a coding interview where a laser is pointed from the position P1 in the normalized direction D1. The goal is simply to calculate if the laser hits P2 within a radius. Now I think there are many solutions to the problem but a simple but inaccurate one is the following:
I calculate the length L1 between the 2 positions P1 and P2. Then I just go from P1 with D1 by L1 to get P3 and see if P3 is P2. Should work fine but what if P2 is not a point but has a radius. Sure you can just check if the length between P3 and P2 is smaller than the radius, but there is one problem:
If you make the tangent line from P1 to the circle of P2 with its radius you see that the Length between P3 and P2 is bigger than the radius although the laser is touching the radius. I hope I explained it properly. I attached an image to help explain the problem.

Now what I want to calculate is the inaccuracy to include that in the calculation if I hit the object. In the Image the inaccuracy is if the radius is half the distance with P2 (10/0) 0.18! With the radius = distance its 4.14.
Now I am not a math genius like many of you are I think. I tried to find a good solution myself but I did not manage. So if on of you could help me out with this in my opinion quite interesting problem I would really appreciate the effort!

Thanks!

nico7s, Aug 24, 2021
2. ### nycmathguy

Joined:
Jun 27, 2021
Messages:
5,386
422
To get a faster reply, join any of the following:

mathhelpforum.com

mathhelpboard.com

mathforums.com

freemathhelp.com

nycmathguy, Aug 28, 2021