在 2D 中将一个点旋转另一个点 [英] Rotate a point by another point in 2D
问题描述
我想知道如何计算一个点相对于另一个点旋转一个角度时的新坐标.
我有一个方块箭头,想将它旋转一个相对于箭头底部中间点的角度 theta.
这是允许我在 2 个屏幕控件之间绘制多边形所必需的.我无法使用和旋转图像.
从我目前所考虑的情况来看,使问题进一步复杂化的是屏幕的原点位于左上角.
如果将点 (px, py)
围绕点 (ox, oy)
旋转角度 theta
你会得到:
I want to know how to work out the new co-ordinates for a point when rotated by an angle relative to another point.
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.
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.
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屋!