John Bott
John Bott

Reputation: 385

How to find rotation Angle, so two point's Y-axis is same

I have two points like this

enter image description here

I want to rotate the image, so it looks like this:

enter image description here

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.

Upvotes: 1

Views: 918

Answers (1)

MBo
MBo

Reputation: 80287

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.

Upvotes: 1

Related Questions