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

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

问题描述

在二维空间中,我有坐标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距离和欲确定的坐标X2,即在从观看者的对象的脸部距离D的对象的Y2的yrot角度。

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 *罪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.

查尔斯Bretana的答案似乎是正确的,我不知道,如果它涵盖overrotating(旋转> 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,通过),这是从一个距离d的方向重新presented由尖吨(其中 T: - PI&LT; T&1 + 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 重presents清楚。但是,如果你确定 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.

要覆盖overrotating,只取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天全站免登陆