break circle into sections for heading : <p>I am attempting to break a circle into 3 sections given an angle, this angle determines where the sections will be, for more details on what the sections are search online for aircraft holding patterns.</p>

<p>I'm having trouble getting the logic to work correctly, in the situation where one of the sections spans both sides of 360 degrees. This is what I have so far. both radial and heading are known numbers, in my test case they're 310 and 70 respectively. The code is written in swift.</p>

<pre><code>func setEntryLimits(){
    directHigh = abs((radial+110.0).truncatingRemainder(dividingBy: 360))
    directLow = abs((radial-70.0).truncatingRemainder(dividingBy: 360))

    parallelHigh = abs(radial.truncatingRemainder(dividingBy: 360))
    parallelLow = abs((radial+110.0).truncatingRemainder(dividingBy: 360))

    tearDropHigh = abs((radial-70.0).truncatingRemainder(dividingBy: 360))
    tearDropLow = abs(radial.truncatingRemainder(dividingBy: 360))


    turnHeadingDial()

}

func turnHeadingDial(){
    var heading = value*360
    inbound = radial + 180 

    if(tearDropHigh&gt;360||parallelHigh&gt;360||directHigh&gt;360){
    heading = heading+360
    }

    if(tearDropHigh&lt;tearDropLow){
        let tempT = tearDropLow
        tearDropLow = tearDropHigh
        tearDropHigh = tempT
    }

    if(parallelHigh&lt;parallelLow){
        let tempP = parallelLow
        parallelLow = parallelHigh
        parallelHigh = tempP
    }

    if(directHigh&lt;directLow){
        let tempD = directLow;
        directLow = directHigh;
        directHigh = tempD;
    }

    if(inbound&gt;360){
        inbound = inbound-360
    }

    if(heading&lt;tearDropHigh&amp;&amp;heading&gt;(tearDropLow)){
        entryLabel.setText("Tear Drop")
        test1.setText(String(tearDropHigh))
        test2.setText(String(tearDropLow))
    }
    else if(heading&lt;(parallelHigh)&amp;&amp;heading&gt;parallelLow){
        entryLabel.setText("Parallel")
        test1.setText(String(parallelHigh))
        test2.setText(String(parallelLow))
    }
    else if(heading&lt;(directHigh)&amp;&amp;heading&gt;directLow){
        entryLabel.setText("Direct")
        test1.setText(String(directHigh))
        test2.setText(String(directLow))
    }
    else {
        entryLabel.setText("calc error")
    }
    print(tearDropHigh," -tear- ",tearDropLow," ",parallelHigh," -parallel- ",parallelLow," ",directHigh," -direct- ",directLow)

    headingLabel.setText(String(heading))
}
</code></pre>
