简体   繁体   中英

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.

I have the coordinates of both the points like 50,100 and 150, 94 (X,Y). I want to rotate the image such that, both Y-axis points become 100.

You can find rotation angle using math.atan2 function with point coordinates.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM