Can anyone help me figure out an algorithm here? I feel like this should be easier than it is.
Say you have a source of light at point (x,y).
Say that the cone of light emitted from this light source is 2D when viewed from above (so we don't treat it like a 3D cone, its kind of like a triangle that goes on infinitely).
You know two things:
1) The orientation angle in degrees to which the source is pointing (clockwise from the positive y axis).
2) The sweep of the beam (anything from 0 to 360 degrees), which is evenly distributed around the orientation angle.
You are given a location (a,b) and asked to determine if the beam of light falls on that location. Regardless of distance - this point could be a million points away from (x,y) but if it falls within the cone of the beam then it qualifies as true.
I need an algorithm that can determine whether or not (a,b) is within the sweep of the light source at point (x,y).
My first thought was that you could find the equation for the two lines that describe the 'sweep' and then find out if the point is 'above' or 'below' or 'within' those two lines. But I can't seem to figure out a way to determine the equation for the lines in a GENERIC way (i.e. for all possible orientations and sweeps).
Anyone got any ideas???
Clockwise from the positive y axis is an interesting way of defining the orientation angle. But come to think of it, that's the only thing slightly weird for me.
Polar coordinates are ideal here because you don't care about distance. In polar coordinates, that just means the theta coordinate is between two numbers. I'm going to try and do this based on my own interpretation of the question.
So, you have a fixed point (x,y) which is the source and you want to see if (a,b) is in the sweep. You'd be best translating this situation to seeing if (a-x, b-y) would be in the same sweep centred at the origin.
The orientation angle wouldn't change here. Let's call it t. As polar coordinates measure the angle from the positive x axis counterclockwise, your orientation angle in polar coordinates would be pi/2 - t. -t because your angle is measured in the opposite direction to polar convention.
Let the sweep be s. If it's distributed evenly, the sweep ranges from theta = pi/2 - t - s/2 to pi/2 - s + s/2
All you need to do now is show that (a-x, b-y) if converted to polar form has an angle in between the range given above.