Determine if a point is within a section of an octagon I've been looking at other answers on this Exchange, such as this one. My math is fairly average, but working in Cartesian planes seems so long ago...
My question is this: how to determine which section of the octagon a point falls in? Points that fall within the radius of $x^2 + y^2 = 15^2$ can be discounted, but this constraint can be ignored safely for now. This will be implemented in a programming language, but the reason I posted it here is because it's not an implementation question -- once I understand the math, I can implement it just fine on my own.
Here's what I'm working with: (I can't post images because I don't have 10 reputation, which I can't get because I don't know enough math yet to comment or answer other questions! What a paradox.)

http://i.imgur.com/AGJeiC1.jpg
The difference between 48.6 and 48.7 is probably caused by the rounding error in the slopes... to divide the circle into 8 pieces, I created lines with slopes of 0.415x and 2.412x which is only 4 sig figs of the calculated slope for angles of 22.5 and 67.5 degrees. (Maybe there's an obvious irrational for these that I'm missing?)
I'm not sure if it's easier to determine if the point is in the triangle formed by the segments I drew in between the points where the lines cross the circle, or if the area bounded by two lines and the edge of the circle is easier to work with. It doesn't matter either way in the end, though.
I feel like I should know how to solve this, but it's just not coming to me. Any and all help is greatly appreciated!
 A: There's a fairly easy way of determining whether a given point falls within a given triangle.
Given any three noncolinear points $A, B, C$ in a plane, any point $P$ in the plane can be expressed as a linear combination of $A, B$ and $C$ whose coefficients add up to 1: $P=aA + bB + cC, a+b+c=1$.
Then the point P is within the triangle if all three coefficients are positive (and by necessity less than 1). It is on an edge of the triangle if one coefficient is zero, and on a vertex if two are (obviously, as then you get e.g. $P=A$).
Finding the coefficients for a given point P boils down to solving a system of 3 linear equations in three unknowns: 
$ aA_x + bB_x + cC_x = P_x $
$ aA_y + bB_y + cC_y = P_y $
$ a + b + c = 1 $
Equivalently a, b, c can be determined by applying  the inverse of a 3×3 matrix to the vector $(P_x, P_y, 1)$. (Sorry, my MathJax skills aren't up to matrices)
As you're doing this computationally, you can precalculate the inverse matrix for each of your 8 triangles and just do the matrix multiplication for any point - and see if the a,b,c that come out are all positive.
A: Here's an alternative to my own earlier answer, given all we need is the direction of the point from the origin.
Number the segments from 0 to 7, starting at the one pointing to the East and proceeding anticlockwise. Denote the x- and y- coordinates of your point by $x$ and $y$.
Now if $x$ is closer to 0 than $y$ is: take $a = \arctan(|x/y|)$ and see if $a < \pi/8$. If so the point is in segment 2 (if $y > 0$) or 6 (if $y < 0$). Otherwise go to the end to choose between segments 1,3,5,7.
If $y$ is closer to 0 than $x$ is: take $a = \arctan(|y/x|)$ and see if this is $<\pi/8$. If so, the point is in segment 0 (if $x > 0$) or 4 (if $x < 0$).
Otherwise the point must be in segment 1 (if $x > 0, y > 0$), 3 ($x < 0, y > 0$), 5 ($x < 0, y < 0$), or 7 ($x > 0, y < 0$).
We're just using arctangent to find the angle between the point and the x / y axes, to find out whether we're in an even-numbered (perpendicular) segment or an odd-numbered  (diagonal) one, then using simple reasoning on x and y to determine which.
My initial draft of this answer just involved $|y/x|$, but then I realised this would lead to nasty overflows when $|x| << |y|$.
A: http://en.wikipedia.org/wiki/Point_in_polygon should provide quite a general solution to your problem. It requires pre-calculating all vertices coordinates.
In your specific, highly symmetric problem you can do opposite: keep a single side of the octagon (say, the top one) and rotate your point around the octagon's centre 7 times by $\frac \pi 8$ to see if it is always on the inner side of the side (that is, below the line $x=127$). If so, the point is inside the octagon.
You can also quickly accept points which are close enough to the origin (say, $x^2 + y^2 \lt 110^2$) or discard those too far apart from it (say, $x^2 + y^2 \gt 130^2$).
