Add a vector to a position

戏子无情 提交于 2019-12-13 20:11:32

问题


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.


回答1:


The result would be:

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

Edit: The vector equation is equivalent to:

X = A + D*cos(O)

Y = B + D*sin(O)



来源:https://stackoverflow.com/questions/22683302/add-a-vector-to-a-position

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!