pro eve_sam_rotate
erase
xc=160d
yc=120d
rx=105d
ry=100d
xfc=580
yfc=271
A1=[[1d,0,-xc],[0,1,-yc],[0,0,1]]
A2=[[ry/rx,0,0],[0,1,0],[0,0,1]]
A4=[[rx/ry,0,0],[0,1,0],[0,0,1]]
A5=[[1d,0,xc],[0,1,yc],[0,0,1]]
xfp=[286d,979,!values.d_nan,275,969,!values.d_nan,188,1021,!values.d_nan,209,934,!values.d_nan,305,881,!values.d_nan,580,580]-xfc
yfp=[241d,312,!values.d_nan,256,290,!values.d_nan,271, 271,!values.d_nan,292,251,!values.d_nan,302,238,!values.d_nan,496, 47]-yfc
img_rgb=read_png('latest_sam.png')
img_r=double(reform(img_rgb[0,*,*]))
print,"Left click to record an active region, middle click when done"
tv,img_r
cursor,this_x,this_y,/dev,/up
while !mouse.button ne 2 do begin
if n_elements(x_active) eq 0 then begin
x_active=this_x
y_active=this_y
end else begin
x_active=[x_active,this_x]
y_active=[y_active,this_y]
end
if n_elements(x_active) gt 0 then begin
erase
tv,img_r
plots,x_active,y_active,psym=2,color='0000ff'x,/dev
end
cursor,this_x,this_y,/dev,/up
end
theta=0
z=[[x_active],[y_active],[x_active*0+1]]
print,"Left click to rotate left, right click to rotate right, middle to quit"
cursor,this_x,this_y,/dev,/up
co=['0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x,'c0c0c0'x,'c0c0c0'x,'c0c0c0'x,'0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x,'0000ff'x]
while !mouse.button ne 2 do begin
s=sin(double(theta)*!dtor)
k=cos(double(theta)*!dtor)
A3=[[k,-s,0],[s,k,0],[0,0,1]]
A=A5##A4##A3##A2##A1
zp=invert(A) ## z
erase
img_rot=eve_affine_matrix(img_r,a,missing=0)
tv,img_rot
for i=0,n_elements(x_active)-1 do plots,xfp+zp[i,0],yfp+zp[i,1],/dev,color=co
xyouts,320,10,string(theta),/dev
cursor,this_x,this_y,/dev,/up
if !mouse.button eq 1 then theta-=5
if !mouse.button eq 4 then theta+=5
end
end