How to set new turtles direction from average of 2 angles in netlogo -
i need help on how write formula using netlogo. (refer figure per attached) i'm trying set new heading agent calculate average of 2 angles between leader's heading , agent's heading. new heading agent should alter 27. below code use, not work way want:
to change-heading allow nearby-leaders turtles [leader? ] if any? nearby-leaders in-radius vision [turn-towards average-heading-towards-leaders max-cohere-turn ] end to-report average-heading-towards-leaders allow nearby-leaders turtles [leader? ] study average-heading ([heading] of one-of nearby-leaders ) heading end to-report average-heading [a b] study (a - (subtract-headings b) / 2) mod 360 end
really need advice on this, help.
it sidesteps trig works
to-report average-heading[a b] allow h (a - (subtract-headings b) / 2) mod 360 allow s (a + b) / 2 ifelse h < s [report h][report s] ] end
in code
to-report average-heading-towards-leaders study average-heading ([heading] of one-of nearby-leaders turtles [leader? ] ) heading end
mark ii
netlogo
No comments:
Post a Comment