where the green polygon is the rotated polygon and the purple is the extent of the polygon.
Is there a way to calculate the angle of rotation of the green polygon from the extent?
I am using python to do this as well, so if you have it in python code, that would be helpful too, but not needed.
I created the following code:
def distance(ptA, ptB): """ calculates theta """ diffX = math.pow((ptB - ptA), 2) diffY = math.pow((ptB - ptA), 2) return math.sqrt((diffX + diffY)) def theta(p1, p2, p3): """ """ radians = math.atan((distance(ptA=p2, ptB=p3)/distance(ptA=p1, ptB=p3))) degree = radians * 360 / math.pi return degree
p1,p2, and p3 are [X,Y] pairs.
The result doesn't seem to be the correct rotation value. Any suggestions?