Need “Is the point in the pie?” I have the following,


*

*direction_angle 

*pie_angle 

*position_x 

*position_y 

*pie_radius


Which denotes, 

For a given point, what formula can I use to know if the point inside the pie, or not?
 A: Let 


*

*$\alpha_d$ = direction_angle

*$\alpha_p$ = pie_angle

*$(x_p, y_p)$ = position_x and position_y

*$r_p$ = pie_radius


To check whether a given point $P = (x, y)$ is contained in the pie, you can translate the point so that the pie center is at the origin:
$(x_t, y_t) = (x-x_p, y-y_p)$
Then you can check whether the translated point is to far away from the origin. That is, whether it is contained in the "full circle" of the pie, disregarding the pie angle. Therefore, you can simply check whether the distance of the translated point to the origin is not greater than the radius. 
Additionally, you have to check the angle. You can compute the angle $\alpha_t$ of the vector $(x_t, y_t)$ to the x-axis, which is simply $acos(x_t / ||(x_t, y_t)||)$. In most programming languages, this angle can easily be computed as atan2(yt,xt). This angle has to be between the starting angle of the pie, and the end angle of the pie. 
So to be contained in the pie, the conditions


*

*$\sqrt{x_t^2 + y_t^2} \le r_p$

*$\alpha_d - \alpha_p / 2 \le \alpha_t$

*$\alpha_t < \alpha_d + \alpha_p / 2$


must hold.
A: Computational way 
See also this question.
I have been recently programming a similar script to solve this. Although I used only polygons - not archs. I don't know the precise formula, but a simple ($\neq$ simple computations) idea is to create a segment from the given point to the $y$-axis parallel to $x$-axis and then count the number of intersections of this segment with the boundary of your object. Let's note the number where the segment intersects with the boundary $n$. Now if


*

*$n$ is odd, that is $n = 2k+1$, for $k \in \mathbb{N}$ you can say, that the point is inside the object,

*$n$ is even, that is $n = 2l$ for $l \in \mathbb{N}$ you can say, that the poing is outside the object.


Note A
This is not a good general idea, since If you'd try it for an object with part of boundary parallel to $x$-axis and a the given point would lie on this part, you would get infinitely number $n$.
Mathematical way
Let's say we have a arbitrary circle in the $\mathbb{R}^2$, with the center in $[x_0, y_0]$ and radius $r$, then the equation for the circle is:
$$
(x-x_0)^2 + (y-y_0)^2 = r^2
$$
It is good too write this e.g. for $x_0 = 0 = y_0, r=1$, then you would see, that for points within the circle it is true:
\begin{align*}
P &= [p_0,p_1] \in \mathbb{R}^2\text{ lays inside the circle } \Leftrightarrow \\
  &(p_0 - x_0)^2 + (p_1 - y_0)^2 < r^2
\end{align*}
If you want to consider the boundary then substitute $<$ with $\leq$.
I assume, that the you are given is some interval, e.g. $\left[0,\frac{\pi}{3}\right]$, because otherwise, lets say if you had $60^\circ$, that would not make sense, which $60^\circ$ out of $360^\circ$ you should consider. Have a look at this picture:

We now, how to determine, whether a $P$ is inside the circle. To determine, whether it is in the angle $\angle CAC'$ we can tell by two other inequalities. Basically $P$ is inside the $P$ iff:


*

*$P$ is inside the circle $\checkmark$

*$P$ is above the line $\overline{AC}$

*$P$ is under the line $\overline{AC'}$


Now we need to find $\overline{AC}$ and $\overline{AC'}$ I'll show it for the first one. Arbitrary line in $\mathbb{R}^2$:
$$
y= k\cdot (x-a) + b
$$
Note that we can rewrite this equation as $y = k\cdot x + b - ka$ and with $d = b-ka$ we have $y=k\cdot x + d$. But for our purpose is the first form better.
From differential calculus we know, that $\tan(\angle CAC') = k$. Now we just need to shift the lines accordingly. That is easy, since we have the center $[x_0,y_0]=[2,3]$. So, now just put it together:
\begin{align*}
\overline{AC}: y_1 &= \tan(0)\cdot (x-2) + 3 = 3\\
\overline{AC'}: y_2 &= \tan(60)\cdot (x-2) + 3 = \sqrt{3}\cdot (x -2) + 3
\end{align*}
