How Can I Program Target Motion Analysis Considering 360 Degrees?

  • Context: Undergrad 
  • Thread starter Thread starter thomas576
  • Start date Start date
  • Tags Tags
    Trig
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
thomas576
Messages
20
Reaction score
1
im trying to write a program to determine target motion analysis, the problem I am having is determining how to get my computer to understand what side the 2 objects are on. here's an example. say I am 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...

thanks

i know i can explain this better but I am having problems understanding how to approach it myself
 
Last edited:
Mathematics news on Phys.org
Relative_bearing = Bearing - Heading;
if Relative_bearing < 0 then Relative_bearing = relative_bearing + 360;
if Relative_bearing < 180 then side = right; else side = left;