矢量增量和在未知区域中移动
我需要一些数学帮助,但我似乎找不到答案,任何文档链接将不胜感激。
这是我的情况,我不知道我在这个迷宫中的哪里,但我需要四处走动并找到回到起点的路。我正在考虑实现一个路径点列表,其中包含从 0,0 开始偏移的位置。这是一个二维笛卡尔平面。
我被赋予了 2 个属性,我的平移速度从 0-1 以及我的旋转速度从 -1 到 1。-1 是非常左的,+1 是非常右的。这些是速度而不是角度,所以这就是我的问题所在。如果我的平移速度为 0,并且为 0.2,我将不断地以低速向右转向。
如何计算给定这两个变量的偏移量?每次我迈出“一步”时我都可以存储它。
我只需要计算出给定平移和旋转速度的 x 和 y 项的偏移量。以及到达这些点的旋转。
任何帮助表示赞赏。
I was in need of a little math help that I can't seem to find the answer to, any links to documentation would be greatly appreciated.
Heres my situation, I have no idea where I am in this maze, but I need to move around and find my way back to the start. I was thinking of implementing a waypoint list of places i've been offset from my start at 0,0. This is a 2D cartesian plane.
I've been given 2 properties, my translation speed from 0-1 and my rotation speed from -1 to 1. -1 is very left and +1 is very right. These are speed and not angles so thats where my problem lies. If I'm given 0 as a translation speed and 0.2 I will continually turn to my right at a slow speed.
How do I figure out the offsets given these 2 variables? I can store it every time I take a 'step'.
I just need to figure out the offsets in x and y terms given the translations and rotation speeds. And the rotation to get to those points.
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题在几点上不清楚,所以我必须做出一些假设:
鉴于此,存在精确解。首先是简单的部分:
其中 omega 是角速度。行进的距离(可能沿着曲线)是
,曲线的半径是
(当角速度接近零时,这会变得很大——我们稍后会处理这个问题。)如果角度(在开始时)区间)为零,定义为指向+x方向,那么区间内的平移很容易,我们将其称为 deta_x_0 和 delta_y_0:
因为我们希望能够处理非常小的 delta_angle并且半径非常大,我们将展开 sin 和 cos,并且仅当角速度接近零时才使用它:
但角度通常不等于零,因此我们必须旋转这些位移:
Your question is unclear on a couple of points, so I have to make some assumptions:
Given that, there is an exact solution. First the easy part:
Where omega is the angular velocity. The distance traveled (maybe along a curve) is
and the radius of the curve is
(This gets huge when angular velocity is near zero-- we'll deal with that in a moment.) If angle (at the beginning of the interval) is zero, defined as pointing in the +x direction, then the translation in the interval is easy, and we'll call it deta_x_0 and delta_y_0:
Since we want to be able to deal with very small delta_angle and very large radius, we'll expand sin and cos, and use this only when angular velocity is close to zero:
But angle generally isn't equal to zero, so we have to rotate these displacements:
您可以分两个阶段进行。首先计算出方向的变化以获得新的方向向量,然后使用这个新方向计算出新的位置。类似于
您在每一步中存储当前
角度
的位置。 (d_x
,d_y
) 是当前方向向量,omega
是您拥有的旋转速度。delta_t
显然是你的时间步长,v
是你的速度。将其分为两个不同的阶段可能太天真了。我不确定我是否真的考虑过太多,也没有测试过它,但如果它有效,请告诉我!
You could do it in two stages. First work out the change of direction to get a new direction vector and then secondly work out the new position using this new direction. Something like
where you store your current
angle
out at each step. (d_x
,d_y
) is the current direction vector andomega
is the rotation speed that you have.delta_t
is obviously your timestep andv
is your speed.This may be too naive to split it up into two distinct stages. I'm not sure I haven't really thought it through too much and haven't tested it but if it works let me know!