Advertisement
Marlingaming

Radar IFF System 2

Feb 11th, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. local Radar_Data = {}--Distance,Azimuth,Elevation,
  2. local Radar_Targets = {}--X,Y,Z,Identified?, Time last Seen
  3. local Heading = 0
  4. local GPS = {0,0,0}
  5. local Tags = {}-- ID, X, Y, Z, Time last sent
  6. function draw()
  7. GPS = {input.getNumber(1),input.getNumber(2),input.getNumber(3)}
  8. end
  9.  
  10. function FixHeading()
  11. compass_input = input.getNumber(whatever input channel)
  12. pi2 = math.pi*2
  13. Heading = math.fmod ((compass_input+1.25)*pi2, pi2)
  14. end
  15.  
  16. function Concert(D,A,E,I)
  17. local ID = Radar_Targets[I][4]
  18. local Y = math.sin(-1*(A/180))*D
  19. local Z = math.sin(E/180)*D
  20. local X = math.sqrt(D^2 - Y^2 - Z^2)
  21. Radar_Targets[I] = {X,Y,Z,ID,0}
  22. end
  23.  
  24. function Identify(ID)
  25. local Distance
  26. for i = 1, #Tags do
  27. Distance = math.sqrt(math.pwr((Radar_Targets[ID][1] - Tags[i][1]),2) + math.pwr((Radar_Targets[ID][2] - Tags[i][3]),2) + math.pwr((Radar_Targets[ID][3] - Tags[i][4]),2))
  28. if Distance < 50 then Radar_Targets[ID][4] = Tags[i][1] end
  29. end
  30. if Radar_Targets[ID][4] == nil then Radar_Targets[ID][4] = -1 end
  31. end
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement