确定距点特定距离和角度的对象的坐标 [英] Determine coordinates for an object at a specific distance and angle from a point

查看:20
本文介绍了确定距点特定距离和角度的对象的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在二维空间中,我有一个坐标为 x1 和 y1 的对象,它面向特定方向,我们将其称为观察者".开始时,测量对象旋转的角度为 0,因此对象开始时始终面​​向相同的方向.这个角度是由一个叫做 yrot 的变量来测量的.

In a 2d space, I have an object of coordinates x1 and y1 and it is facing a specific direction , we'll call it "viewer". At start, the angle that measures the object rotation is 0, so the object starts always facing the same way. The angle is measured by a variable called yrot.

让 D 是由 sqrt ((x1-x2)^2 + (y1-y2)^2) 确定的与对象的距离,考虑这个距离是已知的.

let D be the distance from the object determined by sqrt ((x1-x2)^2 + (y1-y2)^2), consider this distance known.

现在,知道了观察者坐标、D 距离和 yrot 角,我想确定与观察者对象面部距离为 D 的对象的坐标 x2、y2.

Now, knowing the viewer coordinates, the D distance and the yrot angle I want to determine the coordinates x2, y2 of the object that is at distance D from the viewer object's face.

为了澄清这一点,我将添加一个简单的矩阵来解释我想要的:

To clarify this I will add a simple matrix to explain what I want:

Z 0 0

0 0 0

0 0 V

V 是观察者,V 面向 Z.我只对 V 前面(特定距离处)有一个物体感兴趣.换句话说,假设 Z 与 V 的距离为 D(已知),我只对 Z 是一个物体感兴趣,没有别的.

V is the viewer, V is facing towards Z. I am only interested if there is an object in front of V(at the specific distance). In other words, suppose Z is at distance D(known) from V, I am only interested if Z is an object, nothing else.

我相信所需的坐标是 x2 = x1 (+/-) d* sin yrot;y2 = y1 (+/-) d*cos yrot;我不确定这是否是正确的公式,它似乎不起作用.我也不确定第二个操作数的符号.

I believe the needed coordinates are x2 = x1 (+/-) d* sin yrot; y2 = y1 (+/-) d*cos yrot; I am not sure if this is the correct formula and it doesn't seem to be working. I am also unsure abut the signum of the second operand.

如果有什么不清楚的,请留言,我会尽快回复.

If anything is unclear, please leave comments and I will do my best to answer as fast as possible.

谢谢!

后期||<- 哪里是面向观众的,yrot = 0;[] <- 查看器

Later edit: || <- where is viewer oriented, yrot = 0; [] <- viewer

        = [] <- viewer yrot = 90 degrees. 

这应该澄清yrot是什么.此外,对象可以按我想要的方式旋转(> 2 PI),并且可以顺时针和逆时针旋转.

This should clarify what yrot is. Also, the object can rotate as much as I want to ( > 2 PI) and it can rotate both clock-wise and counter clock wise.

Charles Bretana 的回答似乎几乎正确,我不确定它是否涵盖过度旋转(旋转 > 360 度)和向不同方向旋转.

Charles Bretana's answer seems almost correct, I'm not sure if it covers overrotating(rotating > 360 degrees) and rotating in different directions.

推荐答案

给定一个点 A (ax, ay), 点 B (bx, by) 的坐标,它与 A 在表示的方向上的距离为 d角度 t(其中 t: - pi 并且从正 x 方向逆时针测量),将是:

Given a point A (ax, ay), the coordinates of the point B (bx, by) which is a distance d from A in the direction represented by angle t (where t: - pi < t < + pi and is measured counter clockwise from the positive x direction), would be:

 bx = ax + d*cos(t)
 by = ay + d*sin(t)

我不确定这种方法是否符合您的问题,因为从您的问题中不清楚 yrot 代表什么角度.但是,如果您将 yrot 简单地确定为观察者视线与具有正 X 轴的 B 点之间的角度,则上述方法应该可行.

I'm not exactly sure if this approach matches your question, as It is not clear from your question what angle yrot represents. But if you determine yrot as simply the angle between the viewer's line of sight to the point B with the positive X-Axis, the above should work.

为了覆盖过度旋转,只需将 yRot 减去 2*Pi 直到结果介于 - Pi 和 +Pi 之间

To cover overrotating, just take the yRot and subtract 2*Pi until the result is between - Pi and +Pi

这篇关于确定距点特定距离和角度的对象的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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