在2D另一个点旋转一个点 [英] Rotate a point by another point in 2D
问题描述
我想知道怎么当的角度相对于另一点上的旋转制定出新的坐标一个点。
I want to know how to work out the new co-ordinates for a point when rotated by an angle relative to another point.
我有一个块的箭头,并希望通过相对于一个点在箭头的底部中间的角度theta转动它
I have a block arrow and want to rotate it by an angle theta relative to a point in the middle of the base of the arrow.
这是必需的,让我抽2屏幕控制之间的多边形。我不能使用和旋转图像。
This is required to allow me to draw a polygon between 2 onscreen controls. I can't use and rotate an image.
这是我到目前为止什么事情更加复杂的是,屏幕的原点在左上角考虑。
From what I have considered so far what complicates the matter further is that the origin of a screen is in the top left hand corner.
推荐答案
如果您旋转点(PX,PY)
各地点(牛, OY)
通过角 THETA
你会得到:
If you rotate point (px, py)
around point (ox, oy)
by angle theta
you'll get:
p'x = cos(theta) * (px-ox) - sin(theta) * (py-oy) + ox
p'y = sin(theta) * (px-ox) + cos(theta) * (py-oy) + oy
这篇关于在2D另一个点旋转一个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!