# Angles, searches and headaches!

**URL:** <https://forum.kirupa.com/t/angles-searches-and-headaches/236477>\
**Category:** flash\
**Created:** [August 21, 2007, 10:04am UTC](https://forum.kirupa.com/t/angles-searches-and-headaches/236477 "2007-08-21T10:04:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dazhall](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@dazhall](https://forum.kirupa.com/u/dazhall)\
**Post date:** [August 21, 2007, 10:04am UTC](https://forum.kirupa.com/t/angles-searches-and-headaches/236477/1 "2007-08-21T10:04:58Z")

</div>

Hi All,  
I’m trying to search an array based on two angles. The array contains the LeftSideAngle and RightSideAngle. The search is entered in degrees, and there is a further field called variance, also in degrees. The idea being that you can then enter say 90°, with a variance of 90° and the search will return all matches with a LeftSideAngle\>=45 and RightSideAngle\<=135 (90° ± 90° on each side).

Now the problem comes when the LeftSideAngle\>180, as the search will span the 360/0 point. E.g. Search = 0° and Variance = 270°, LeftSideAngle\>=225 and RightSideAngle\<=135. I’ve had a go at creating an if statement to handle it, but i’m admitting defeat! Here’s what I’ve got:

```auto

if (LeftWallAngle>=180) {
    if ((Unit.LeftWallAngle>=LeftWallAngle || Unit.LeftWallAngle<=RightWallAngle) && Unit.LeftWallAngle<=360 && Unit.LeftWallAngle>=0) {
        leftTrue = true;
    }
    if (Unit.RightWallAngle>=LeftWallAngle && Unit.RightWallAngle<=360 && Unit.RightWallAngle>=0) {
        rightTrue = true;
    }
    
} else if (LeftWallAngle<=180) {
    if (Unit.LeftWallAngle>=LeftWallAngle && Unit.LeftWallAngle<=RightWallAngle) {
        leftTrue = true;
    }
    if (Unit.RightWallAngle>=LeftWallAngle && Unit.RightWallAngle<=RightWallAngle) {
        rightTrue = true;
    }
}

```

There’s so many ifs it’s got me lost! Any help is, as always, much appreciated!

Thanks!

Darren.
