This is a read-only mirror of pymolwiki.org

Difference between revisions of "Stereo ray"

From PyMOL Wiki
Jump to navigation Jump to search
m
Line 5: Line 5:
 
== Manually ==
 
== Manually ==
  
To get a stereo diagram you need to images. The left image is rotated +3 degrees and the right image is rotated -3 degrees.
+
To get a stereo diagram you need two images. The left image is rotated +3 degrees and the right image is rotated -3 degrees.
  
 
To obtain the left image, type:
 
To obtain the left image, type:

Revision as of 20:51, 5 July 2007

Left Image
Right Image
Combined Images


Manually

To get a stereo diagram you need two images. The left image is rotated +3 degrees and the right image is rotated -3 degrees.

To obtain the left image, type:

ray angle=+3
png left-image.png

Likewise, to obtain the right image, type:

ray angle=-3
png right-image.png

You still use any other ray based modifications, such as:

ray 1600,1200,angle=+3
png big-left-image.png

Script

A user on the PyMol list wrote a very nice little stereo ray tracing script. Just copy this to a text file. Then, in PyMol run

run dirName/scriptName.pym

where dirName is where you put it, and scriptName is what you named the file then run one something like the example lines given:

EXAMPLE
   stereo_ray output, 1000, 600
   stereo_ray secondImage.png

This will create to images, one with an L and one with an R suffix. Just paste the two images next to each other (in some image editing program) and you're done.

from pymol import cmd

def stereo_ray(output='', width='', height=''):
   '''
DESCRIPTION
   "stereo_ray" ray-traces the current scene twice (separated by 
   a six-degree rotation around the y axis)
   and saves a pair of images that can be combined in any image
   manipulation software to form a stereoimage.
   The first argument, the output file name, is mandatory.
   The second and third arguments, the size of the image, are not.
   If the width is given, the height will be calculated.

USAGE
   stereo_ray filename [, width [, height]]

EXAMPLE
   stereo_ray output, 1000, 600
   stereo_ray secondImage.png
   '''

   if output == '':
      print 'no output filename defined\n'
      print 'try: \'stereo_ray filename\''
      return -1
      # abort if no output file name given

   if width == '':
      width,height = cmd.get_session()['main'][0:2]
      # get dimensions from viewer if not given

   elif height == '':
      oldWidth,oldHeight = cmd.get_session()['main'][0:2]
      height = int(width)*oldHeight/oldWidth
      # calculate height from proportions of viewer if
      # only width is given

   cmd.ray(width, height, angle=-3)
   cmd.png(output+"_r")
   cmd.ray(width, height, angle=3)
   cmd.png(output+"_l")

cmd.extend('stereo_ray',stereo_ray)