Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Perhaps this is trig?

  1. Oct 9, 2006 #1
    im trying to write a program to determine target motion analysis, the problem im having is determining how to get my computer to understand what side the 2 objects are on. heres an example. say im a boat heading 300, so a little north west, and i have a contact on my right side, i need my program to be able to determine that its on my right side, so his possible bearings are 301degrees past 0 though 120 degrees which would be all on my right side. how can i write this to be solved ? with a simple if statement the numbers get skewed because my number set is restart again at 0 (301-359, 0-120). and the kicker of it is i need to be able to solve this problem when my heading is possilby 0-360 degrees.....


    i know i can explain this better but im having problems understanding how to approach it myself
    Last edited: Oct 9, 2006
  2. jcsd
  3. Oct 9, 2006 #2


    User Avatar

    Relative_bearing = Bearing - Heading;
    if Relative_bearing < 0 then Relative_bearing = relative_bearing + 360;
    if Relative_bearing < 180 then side = right; else side = left;
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook