Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show_rectangles rotated with respect to corner, not with respect to center. #473

Open
leungcalvin opened this issue May 15, 2022 · 1 comment

Comments

@leungcalvin
Copy link

leungcalvin commented May 15, 2022

Hi! I noticed a small bug in show_rectangles as follows:

Since in show_rectangles the coordinates are those of the rectangle's center, I thought that rotations (with the angle keyword) would also be about the rectangle's center. I tried to do this with

show_rectangles(self=zoom_out_fig,
                         xw = gal_ra, 
                         yw = gal_dec, 
                         width = 1.5/60/60, 
                         height = 10/60/60, angle=0, 
                         layer=False, 
                         zorder=None, 
                         coords_frame='world',
                         edgecolor='white')
show_rectangles(self=zoom_out_fig,
                         xw = gal_ra, 
                         yw = gal_dec, 
                         width = 1.5/60/60, 
                         height = 10/60/60, angle=10, 
                         layer=False, 
                         zorder=None, 
                         coords_frame='world',
                         edgecolor='white')
show_rectangles(self=zoom_out_fig,
                         xw = gal_ra, 
                         yw = gal_dec, 
                         width = 1.5/60/60, 
                         height = 10/60/60, angle=-10, 
                         layer=False, 
                         zorder=None, 
                         coords_frame='world',
                         edgecolor='white')

but I get image

A quick fix is to modify show_rectangle:

x = x - w / 2.

and to change that line to the following:

    x = x - (w / 2 * np.cos(a*np.pi/180) - h / 2 * np.sin(a*np.pi/180))
    y = y - (w / 2 * np.sin(a*np.pi/180) + h / 2 * np.cos(a*np.pi/180))

which gave me what I (and maybe other naive users like myself) expected.

image

@Sullofect
Copy link

Encounter same thing! Thanks for your edition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants