2
我正在調查netlogo的植絨模型。它具有以下奇怪的代碼。這段代碼做什麼數學? 如果我在數學符號中看到這個,我會理解這一點。我想這是如何在netlogo中實現三角函數的?Netlogo植絨型號代碼說明
to heading
turn-towards average-heading max-align-turn
end
to-report average-heading
let x-component sum [dx] of flock
let y-component sum [dy] of flock
ifelse x-component = 0 and y-component = 0
[ report heading ]
[ report atan x-component y-component ]
end
to turn-towards [new-heading max-turn]
turn-at-most (subtract-headings new-heading heading) max-turn
end
to turn-at-most [turn max-turn]
ifelse abs turn > max-turn
[ ifelse turn > 0
[ rt max-turn ]
[ lt max-turn ] ]
[ rt turn ]
end
所以這給出了一個平均標題? – Newguy
對不起。是的,這給出了平均標題, –
好的,謝謝。這段代碼似乎實現了循環數量的意思?我錯過了atan的論點 – Newguy