[英]How to find rotation Angle, so two point's Y-axis is same
I have two points like this我有这样的两点
I want to rotate the image, so it looks like this:我想旋转图像,所以它看起来像这样:
I have the code to rotate the image.我有旋转图像的代码。 I just want to find the rotation angle like 5 degrees, 2 degrees.
我只想找到像 5 度、2 度这样的旋转角度。
I have the coordinates of both the points like 50,100
and 150, 94
(X,Y).我有两个点的坐标,例如
50,100
和150, 94
(X,Y)。 I want to rotate the image such that, both Y-axis points become 100.我想旋转图像,使两个 Y 轴点都变为 100。
You can find rotation angle using math.atan2
function with point coordinates.您可以使用带有点坐标的
math.atan2
function 找到旋转角度。
angle = math.atan2(p2.y-p1.y, p2.x-p1,x)
Note that rotation about coordinate origin would shift the first point also, so you perhaps need to make rotation about the first point.请注意,围绕坐标原点的旋转也会移动第一个点,因此您可能需要围绕第一个点进行旋转。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.