1

I have a distribution of points, and the same distribution rotated by an unknown amount. I want to estimate the rotation between the distributions and correct for it.

Origional and rotated plot

I have tried the following function which is able to align vectors.

# adding a third dimension as the function below (Rotation.align_vectors()) uses 3D vectors to calculate the rotation. By adding a 3D dimension of all 0, we basically are still in 2D space.
df['dimension'] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
df_rot['dimension'] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
# this function here is important, this is where the rotation is calculated. The output of a is what we need to adjust for the rotation. By taking PI and deviding it by the output value of the function we can rotate the image back to its origional position and thus adjust for any rotation of agar.
from scipy.spatial.transform import Rotation
a,b = Rotation.align_vectors(df_rot,df)

But the rotation parameters are insufficient to correct for the rotation (I use the following function to rotate my images (Rotate point about another point in degrees python).

How would I figure out the rotation of my image?

Edit:

The centre of rotation is always in the middle (50,50 in this plot).

Olaf
  • 146
  • 1
  • 8
  • Do you know the center of rotation? Is it guaranteed to be the midpoint of the plot, i.e., at (50,50), as it appears in your image? – pjs Aug 22 '22 at 18:27
  • @pjs Yes, the centre of rotation will always be 50,50. – Olaf Aug 22 '22 at 19:15
  • 1
    Transform to polar coordinates and find the right shift? – gre_gor Aug 22 '22 at 19:26
  • @gre_gor That's where I was going. Identify any point which is a unique distance away from (50, 50), find the point the same distance in the second set, and the delta between their polar coordinate angles is the rotation. – pjs Aug 22 '22 at 19:37

0 Answers0