i have the following geometrical issue in 2D:
i have a point from which i cast an infinite angle (2D-cone) which is given by a direction and an angle. (the point and the direction form a vector and to each side half of the angle forms the 2D-cone)
now i want to check if another point in 2D is inside this cone or outside.
how can this be achieved? thanks!
Calculate the vector from the center of the cone to the query point. Normalize the vector to be of length 1, Take the center vector of the cone and normalize this as well to the length of 1.
Now take the dot product between the vectors. The dot product between two normalized vectors is the cosinus of the angle between them. Take the arccos (acos
in most languages) of the dot product and you'll get the angle. compare this angle to the cone's angle (half angle in your description). if its lower, then point in question is inside the cone.
This works in 2D and 3D.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With