Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
It was the wraparound causing the problem. Your absolutely correct. Sincerely appreciated Thank you! –  ron Jan 18 '13 at 14:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.