将表示乌龟位置的向量旋转一个角度Netlogo [英] Rotating a vector denoting turtle position by an angle Netlogo

查看:163
本文介绍了将表示乌龟位置的向量旋转一个角度Netlogo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照以下步骤设置/更新每只海龟的位置:

I set/update each turtle's position as follows:

 set xcor xcor + item 0 vector
 set ycor ycor + item 0 vector

因此,我向当前座席的坐标添加了一个向量.

Therefore I add a vector to the current agent's coordinates.

问题: 我希望将相加的矢量旋转角度x.因此,矢量"vector"应旋转角度x. 该角度应从具有指定偏差的高斯分布中获取.

PROBLEM: I wish to rotate the added vector by angle x. Thus the vector "vector" should be rotated by angle x. The angle should be taken from a Gaussian distribution with a specified deviation.

我正在尝试实现类似于库赞模型的东西. http://www.csim.scu.edu.tw/~chiang/course/ComputerGameAdvance/Collective%20Memory%20and%20Spatial%20Sorting%20in%20Animal%20Groups.pdf

I am trying to achieve something similar to Couzin's model. http://www.csim.scu.edu.tw/~chiang/course/ComputerGameAdvance/Collective%20Memory%20and%20Spatial%20Sorting%20in%20Animal%20Groups.pdf

提前谢谢!

推荐答案

您似乎在这里有两个问题;我将介绍您使用的标题.矩阵扩展允许矩阵相乘,因此一旦有了旋转角,您就可以创建一个标准的旋转矩阵.但是NetLogo中的标准建议是使用更加以乌龟为中心的方法.然后,您需要确定是否使用NetLogo标题约定(北为0度,东为90度,等等.)如果是这样,您可以执行以下操作:

You seem to have two questions here; I'll address the one you used for the title. The matrix extension allows matrix multiplication, so you could just create a standard rotation matrix once you have the ange of rotation. But standard advice in NetLogo would be to use a more turtle-centric approach. Then you need to decide whether to use the NetLogo heading conventions (0 degrees for north, 90 degrees for east, etc.) If so you could do something like this:

to move [#dx #dy]
  let %dist 0
  ask patch 0 0 [set %dist distancexy #dx #dy]
  facexy (xcor + #dx) (ycor + dy)
  let %theta random-rotation
  rt %theta
  jump %dist
end

to-report random-rotation
  report (random-float 360) - 180
end

在这里,随机旋转不是高斯分布的,因为我不确定您的意思.也许是冯·米塞斯(von Mises)的分布?无论如何,您都应作为一个单独的问题进行澄清和提问.

Here the random rotation is not Gaussian distributed because I was not sure what you meant. Perhaps a von Mises distribution? In any case, you should clarify and ask as a separate question.

这篇关于将表示乌龟位置的向量旋转一个角度Netlogo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆