# Geometry question- is x degrees within plus or minus y degrees of z

This is not at all what I do so please keep it simple. I'm looking for a true/false condition for a php program I'm working on.

The best way for me to describe the question is by example.

I'm given $2$ directions and $2$ angles like

$A=181$ with possible values $0$ to $360$
$B=160$
$x=5$ with possible values $0$ to $180$
$y=10$

What I'm looking for is $A+x \ge B \ge A-y$ which obvious doesn't work.

I'm developing a relationship between wind direction and crosswind conditions for aircraft and this just has me stumpted.

Thanks for the help...

Real world example Runway 350 DFW, my aircraft can handle 20 degrees cross wind from strait. The morning of my flight the briefer indicates winds at 050.True or false can I launch my aircraft?

-
Is A a vector or a number? What then does 181 mean? Same for B, x and y...How do you define "direction" in your question? – DonAntonio Jan 18 '13 at 3:49
They are numbers, compass directions North=360 etc. x, y I call sweep left and right. – ron Jan 18 '13 at 3:57

## 1 Answer

What I'm looking for is $A+x≥B≥A−y$ which obvious doesn't work.

Why not? If the only thing that bothers you is the wraparound, you can write something like this:

d = B - (A - y)
while (d < 0) d += 360
while (d >= 360) d -= 360
reutrn d ≤ x + y


The first line computes the difference between the actual direction and the second limit direction. By normalizing that angle to the range $[0,360)$, the second inequality will hold automatially, as the angle is $\geq0$. Then you can check the first inequality to see whether your direction lies within the allowed sector.

-
It was the wraparound causing the problem. Your absolutely correct. Sincerely appreciated Thank you! – ron Jan 18 '13 at 14:13