+ Reply to Thread
Results 1 to 5 of 5

Determining which side of a semicircle an angle lies.

  1. #1
    Registered User
    Join Date
    05-07-2017
    Location
    Western Australia
    MS-Off Ver
    2011
    Posts
    6

    Determining which side of a semicircle an angle lies.

    Hi all,

    Please help me create an IF statement to solve the problem I have here. I am given an angle (for interest sake it is a wind direction), say 280 degrees. I then have another angle which might be say 060 degrees.

    What I need is a function that can designate "Black" or "Red" determined on what side of the semicircle an angle appears on.

    See the picture below as it'll make more sense what I am trying to describe. The angles can all change to be anywhere around the compass, the only constant is that it's always two semicircles.

    I'm running into problems as the compass goes around 360 degrees so the heading 050 is actually greater than 359 degrees...
    I have tried creating IF statements using the reciprocal of the initial angle but can't make it work perfectly.

    Thanks!
    Attached Images Attached Images

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Determining which side of a semicircle an angle lies.

    If I understand this right, then assuming that A1 has the 280 degree value, and B1 has the 60, give this a try:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    05-07-2017
    Location
    Western Australia
    MS-Off Ver
    2011
    Posts
    6

    Re: Determining which side of a semicircle an angle lies.

    Hi, thanks for your reply!

    Your formula works fine if the numbers are set at 280 degrees and 060 degrees.
    However, the numbers can change - try substituting 280 with 020 degrees - the formula gives erroneous results.
    Any ideas?

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Determining which side of a semicircle an angle lies.

    I tend to solve these kind of problems by referring to the unit circle (see my demo sheet here: https://www.excelforum.com/tips-and-...han-excel.html ). Basically what I see is an attempt to identify which quadrant the angle between the two bearings lies in. You probably need to more carefully define red and black. It looks like black is for quadrants I and II working CCW from the reference angle and red is for quadrants III, and IV. Then I recall from my trig courses way back when the properties of the trig functions in each quadrant and pick a function or functions that will readily tell me which quadrant the angle lies in. In this case, I know that sin() is positive in quadrants I and II, and negative in quadrants III and IV. I would proceed like this:

    1) Take the difference of the two angles to get theta. Note that, if I have thought through this correctly, it should not matter when the bearings are on opposite sides of 360. Theta should still represent the correct angle (though you probably should test several cases to be sure).
    2) Take the sine of theta. Note that, like all other programming languages, Excel performs trig calculations in radians, not degrees.
    3) Test is sine(theta) is positive or negative and assign the correct color.
    3a) You may need to think through the two cases where sine(theta) is exactly 0 and decide which color to assign those cases.

    At this point, I will assume you are able to program that algorithm into the spreadsheet.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    05-07-2017
    Location
    Western Australia
    MS-Off Ver
    2011
    Posts
    6

    Re: Determining which side of a semicircle an angle lies.

    Hi yes your solution seems to have worked thanks!

    SIN((B47−B17)×(PI()÷180))

    B47 contains the angle that creates the semicircles, B17 is the presented other angle.

    I then ran this IF statement on the result; IF(B23<0, "semicircle one", "semicircle two")

    I'm not too fussed on when it's right on the boundary between the two semi circles. It's down to less than 1 degree so for the application of this solve it's not necessary to dig any further. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compare 2 sets of values in side-by-side Stacked Column chart
    By dlaudenschlager in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 03-21-2016, 01:34 PM
  2. [SOLVED] Semicircle distribution in Excel
    By BristolJGM in forum Excel General
    Replies: 6
    Last Post: 10-25-2015, 07:48 PM
  3. [SOLVED] Set Excel 2010 as default program when installed side-by-side with 2013
    By AlvaroSiza in forum Excel General
    Replies: 1
    Last Post: 08-31-2013, 06:45 PM
  4. VBA to copy data from multiple sheets side-by-side into one sheet matching date
    By MHCapcog in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-02-2013, 06:11 PM
  5. Determining the Point and Angle of rotation
    By Ashraf_Robot in forum Excel General
    Replies: 9
    Last Post: 06-12-2012, 02:44 PM
  6. Replies: 0
    Last Post: 04-19-2009, 10:53 PM
  7. Replies: 1
    Last Post: 03-20-2006, 10:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1