2D geometry: how to check if a point is at an angle

I have the following geometric problem in 2D:

i has a point from which I use an infinite angle (2D cone), which is given by direction and angle. (the point and direction form a vector, and on each side half of the angle forms a 2D cone)

Now I want to check if another point in 2D is inside this cone or outside.

how can this be achieved? thanks!

+6
geometry 2d point
source share
4 answers

Calculate the vector from the center of the cone to the query point. Normalize a vector of length 1, take the center of the cone vector and normalize it to length 1 as well.
Now take the point product between the vectors. The point product between two normalized vectors is the cosine of the angle between them. Take the arccos ( acos in most languages) of the dot product and you get the angle. Compare this angle to the angle of the cone (half the angle in your description). if it is lower, then the point is inside the cone.

It works in 2D and 3D.

+9
source share

Calculate the direction angle using arctg directions. Select the source from the marked point. Calculate its angle (again through arctg of the normalized vector) and check if it lies within the angular boundaries.

+1
source share

I would say that the best way is to project a point onto a two-dimensional surface perpendicular to the direction of the cones. Then you calculate the orthogonal distance between the same plane and the point. Finally, you know the width of the cone at this height so that you can see if this point is outside this width.

+1
source share

Let the vector from the origin point to the specified point form an angle A with the normal passing through the center. If the angle A is smaller than the cone's polygon, it lies inside outside.

+1
source share

All Articles