从两个矢量计算方位角θ [英] Calculate direction angle from two vectors?

查看:674
本文介绍了从两个矢量计算方位角θ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有两个2D向量,一个用于对象的当前位置和一个用于对象previous位置。我怎样才能制定出旅行的角方向?

Say I have two 2D vectors, one for an objects current position and one for that objects previous position. How can I work out the angular direction of travel?

此图像可能有助于了解我后:

This image might help understand what I'm after:

推荐答案

行进的方向向量将是二号位向量的差异,

The direction vector of travel will be the difference of the two position vectors,

d = (x1, y1) - (x, y) = (x1 - x, y1 - y)

现在当你要求为方向的角度,这取决于你要衡量的角度什么方向。它是对x轴?去拉杜的答案。针对任意矢量?见justjeff的回答。

Now when you ask for the direction angle, that depends what direction you want to measure the angle against. Is it against the x axis? Go with Radu's answer. Against an arbitrary vector? See justjeff's answer.

编辑:要获得对y轴的角度:

To get the angle against the y-axis:

tan (theta) = (x1 -x)/(y1 - y)          

的角的正切是差矢量的的比率x坐标的y坐标的差矢量的

the tangent of the angle is the ratio of the x-coordinate of the difference vector to the y-coordinate of the difference vector.

于是

theta = arctan[(x1 - x)/(y1 - y)]

在哪里反正切表示反正切。不要与切线,其中很多人做的倒数相混淆,因为他们俩都常常表示谭^ -1。并确保你知道你工作在度或弧度。

Where arctan means inverse tangent. Not to be confused with the reciprocal of the tangent, which many people do, since they're both frequently denoted tan^-1. And make sure you know whether you're working in degrees or radians.

这篇关于从两个矢量计算方位角θ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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