如何在 Pygame 中改变向量的角度?
我目前正在尝试编写 Craig Reynolds Boid 模拟的代码。 然而,为了让机器人在避开障碍物的同时保持其行为,我需要能够以给定的角度引导机器人远离障碍物。 有没有办法将 2D 矢量的角度改变一定的角度 theta? 可能有一种使用 pygame 内置功能的快速方法,但我不能确定,因为该网站目前已关闭。然而,任何可行的方法(无论时间或空间复杂性)都会非常有帮助。
I am currently attempting to code the Craig Reynolds Boids simulation.
However, for the boids to maintain their behavior while avoiding obstacles, I need to be able to steer the boid away from the obstacle by a given angle.
Is there any way of changing the angle of a 2D Vector by a certain angle theta?
There might be a quick way using pygame built-in functionality, but I cannot be sure since the website is currently down. However, any way that works (no matter time or space complexity) would be extremely helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
pygame.math.Vector2
可以用pygame.math.Vector2.rotate
或pygame.math.Vector2.rotate_ip
:A
pygame.math.Vector2
can be rotated withpygame.math.Vector2.rotate
orpygame.math.Vector2.rotate_ip
: