2

Get mean heading of neighboring turtles

to-report mean-heading [ headings ]
  let mean-x mean map sin headings
  let mean-y mean map cos headings
  report atan mean-x mean-y
end   

from that answer gets me part way there but I want is each of the headings to be weighted on size of the turtles.

something like

 sum [heading * size] of turtles / sum [size] of turtles

But that would, you know, actually work.

Community
  • 1
  • 1
King-Ink
  • 2,096
  • 12
  • 18

1 Answers1

2

If you accept a turtleset instead of a list of headings, then:

to-report weighted-mean-heading [turts]
  let mean-x mean [size * sin heading] of turts
  let mean-y mean [size * cos heading] of turts
  report atan mean-x mean-y
end   
Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
  • That seems right I have to test it a bit first though. – King-Ink Feb 01 '16 at 20:16
  • Thank you. You have just answered this http://stackoverflow.com/questions/34749916/need-help-on-speeding-up-a-particle-system-or-how-to-ask-turtles-not-to-ask-oth – King-Ink Feb 01 '16 at 20:47