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

Joined
Aug 24, 2021
Messages
1
Reaction score
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.
Problem1.jpg


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!
 
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.
View attachment 319

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!

To get a faster reply, join any of the following:

mathhelpforum.com

mathhelpboard.com

mathforums.com

freemathhelp.com
 

Members online

No members online now.

Forum statistics

Threads
2,521
Messages
9,844
Members
697
Latest member
RicoCullen
Back
Top