# Draw a line from the previously picked point to the eye # You must be in orthographic perspective for this to work #VMD --- start of VMD description block #Name: # Eye line #Synopsis: # Draws a cylinder from the picked atom through the eye #Version: # 1.0 #Uses VMD version: # 1.1 #Ease of use: # 1 #Procedures: # eye_line #Description: # After an atom has been picked, call "eye_line". It generates a # cylinder (using "draw") from the picked atom along the line through # the eye, assuming VMD is using an orthographic projection. It also # prints the endpoints of the cylinder. #Comments: # This is a pretty good example of how to manipulate the viewing matrix. #Files: # eye_line.vmd #See also: # the VMD user's guide #Author: # Andrew Dalke <dalke@ks.uiuc.edu> #\VMD --- end of block proc eye_line {} { global vmd_pick_atom vmd_pick_mol set sel [atomselect $vmd_pick_mol "index $vmd_pick_atom"] # coordinates of the atom set coords [lindex [$sel get {x y z}] 0] # position in world space set mat [lindex [molinfo $vmd_pick_mol get view_matrix] 0] set world [vectrans $mat $coords] # since this is orthographic, I just get the projection lassign $world x y # get a coordinate behind the eye set world2 "$x $y 5" # convert back to molecule space # (need an inverse, which is only available with the measure command) set inv [measure inverse $mat] set coords2 [vectrans $inv $world2] # and draw the line draw cylinder $coords $coords2 radius 0.3 puts "Start: $coords" puts "End: $coords2" }