To get every point, loop through the points between
(px - r; py - r) and
(px + r; py + r) where px and py are the player's x and y coordinates and r is the radius of the circle. For each point, do the following:
- Given the point
(x; y) calculate the distance of this point and the player's position (
d = √((x - px)^2 + (y - py)^2)). Save this somewhere because you'll need it.
d is less than or equal to the radius of the circle, then this point is inside the main circle and you can continue. Otherwise just go to the next point.
- Normalize the vector pointing from the player position to the current point using the distance you calculated earlier. The new vector should be
((x - px) / d, (y - py) / d). Then get the dot product of this vector and
(1, 0) to get the cosine of the angle between the (It'll be
(x - px) / d if you did everything correctly).
- The point is inside the cone if the arccosine of the value you get after the dot product is between the angles.
In pseudo code:
getPoint(px, py, angle1, angle2, r) do
output = empty set
for each x between px - r and px + r) do
for each y between py - r and py + r) do
d = sqrt((px - x)^2 + (py - y)^2)
if d > r then
d = acos((x - px) / d)
if d >= angle1 and d <= angle2 then
add (x, y) to output