简体   繁体   English

如何找到旋转角度,所以两点的Y轴相同

[英]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,100150, 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.

相关问题 如何在python中给定点(x,y)和线与y轴的夹角的情况下找到线的斜率(m)? - How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python? 找到具有正y轴的向量角度的最佳方法,顺时针 - Best way to find the angle of a vector with positive y-axis, clockwise 如何获得两个折线图(使用单独的y轴)以共享相同的日期x轴? - How to get two line charts (using seperate y-axis), to share the same date x-axis? Dash/Plotly:如何使用相同的 x 轴在 y 轴上绘制两列? - Dash/Plotly: How can I plot two columns on the y-axis with the same x axis? Plotly:在 Python 中将 y 轴两个图放在同一范围内 - Plotly: Putting y-axis two plots in the same range in Python 如何移动 plot 使 y 轴上的 label 不被切割? - How to shift a plot so that the label in the y-axis is not cut? 两个对应的y轴 - Two corresponding y-axis 如何在 y 轴上绘制一列(名称)并在同一 y 轴上绘制另一列的值 - How to subplot one column (name) on y-axis and in the same y-axis another column with values 如何使 pyplot 图表中的 y 轴显示相同值的两个测量值(计数和百分比)? - How to make y-axis in pyplot chart display two measurements of same value (counts AND percents)? 如何在与图例和次要y轴相同的情节上绘制两个大熊猫时间序列? - How to plot two pandas time series on same plot with legends and secondary y-axis?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM