I am drawing rotated rectangle using matplotlib but I don't know how to adjust the angle?
rect = patches.Rectangle((int(arr[2])-0.5*int(arr[4]),int(arr[3])-0.5*int(arr[5])), int(arr[4]),int(arr[5]),
fill=False,
edgecolor='g', linewidth=1)
t = matplotlib.transforms.Affine2D().rotate_around(float(arr[2]), float(arr[3]),\
float(arr[6])*180/np.pi)
rect.set_transform(t + plt.gca().transData)
plt.gca().add_patch(rect)
1 10 3308 261 21 10 -88.363423
this is the data of one car
but the rectangel don't fit it.
It seems the angle of rotation should be -88 degrees.
Negative angles will rotate clockwise. .rotate_around
expects it's anglular argument to be in radiants.
You're using float(arr[6])*180/np.pi
, which would convert radiants to degrees, but makes little sense as you already have the angle in degrees.
Instead use
float(arr[6])*np.pi/180.
or
np.deg2rad(float(arr[6]))
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.