2D Cone Segment Intersection

I would like to know if there is a way to determine if a cone intersects with a (finite) line segment. A cone is actually a circle located at point P (x, y) with a field of view in theta degrees and radius r:

Illustration

I am trying to do this in C #, but I have no idea how to do this, so now I am doing this:

  1. Check if the line intersects with a circle;
  2. If a line segment intersects a circle, then I check each point of the line using the function I found here .

But I do not think this is the best way to do this. Does anyone have an idea?

For more information, I need this function to make some kind of simple vision simulator.

+3
3

. as (x, y) (r, ), r - , - , ( 0).

, P (x, y) = 0 , (r1, ang1) (r2, ang2), , ( ) , :

r1 <= r
r2 <= r

ang1 <= theta
ang2 <= theta

r - , theta - , , .

(x, y) ( ) , wiki, .

, - , : http://mathforum.org/dr.math/faq/formulas/faq.polar.html

R = p sec(ang - omega)

p omega :

p = r1 * cos(ang1-omega) = r2*cos(ang2-omega)

cos(x-y) = cos(x)*cos(y) + sin(x)*sin(y),

[r1*cos(ang1) - r2*cos(ang2)] * cos(omega) =  [r2*sin(ang2) - r1*sin(ang1)] * sin(omega)

, tan(omega) = sin(omega)/cos(omega) arctan ( tan), omega. , , p.

, - (R, ang) ,

R <= r
0 <= ang <= theta
min{ang1, ang2} <= ang <= max{ang1, ang2}

( r , theta - , ang1 - P1, ang2 - P2).

Rcos(ang-omega) = p

cos (ang-omega) , [min {ang1, ang2}, max {ang1, ang2}].

, .

.

+2

Google / , , . - , .

0

, :

S1, - S2. - C1, - C2, - O.

Z- , (O S1) C1.

Z- (O S2) C1. , C1, . , C2 C1.

, .

3D . googled . , :)

The quick google 'cone line crossing' got all kinds of hits. The basic idea is to form a plane from the beginning of the cone and the start and end point of the line. After that, you can take the angle between this plane and the normal of the cone. If this angle is less than the angle of propagation on the cone, you have an intersection.

0
source

Source: https://habr.com/ru/post/1745826/