将向量添加到位置 [英] Add a vector to a position

查看:22
本文介绍了将向量添加到位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 2D 空间中有一个对象,其位置为 (A, B) 并且具有方向(在 0 到 360 之间).我有一段距离,D 说.我想将 D 添加到对象的位置,即对象所面向的方向.

I have an object in 2D space whose position is (A, B) and which has an orientation (between 0 and 360). I have a distance, say D. I would like to add D to the object's position, in the direction that the object is looking toward.

从数学上讲,我该怎么做呢?谢谢.

Mathematically, how would I go about doing that? Thank you.

推荐答案

结果是:

(X,Y) = (A,B) + D*(cos(O),sin(O))

(X,Y) = (A,B) + D*(cos(O),sin(O))

向量方程等价于:

X = A + D*cos(O)

X = A + D*cos(O)

Y = B + D*sin(O)

Y = B + D*sin(O)

这篇关于将向量添加到位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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