[yt-svn] commit/yt: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Sep 21 11:50:12 PDT 2015


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/e129373a1962/
Changeset:   e129373a1962
Branch:      yt
User:        jisuoqing
Date:        2015-09-14 06:24:18+00:00
Summary:     Add cookbook recipe of using different lenses for VR
Affected #:  3 files

diff -r fceb5ab0e3c639902f1d00e9ad6413367fd8fe27 -r e129373a1962ade16fedd19caf2d88899b0be6c4 doc/source/cookbook/complex_plots.rst
--- a/doc/source/cookbook/complex_plots.rst
+++ b/doc/source/cookbook/complex_plots.rst
@@ -212,6 +212,15 @@
 
 .. yt_cookbook:: zoomin_frames.py
 
+.. _cookbook-various_lens:
+
+Various Lens Types for Volume Rendering
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This example illustrates the usage and feature of different lenses for volume rendering.
+
+.. yt_cookbook:: various_lens.py
+
 .. _cookbook-opaque_rendering:
 
 Opaque Volume Rendering

diff -r fceb5ab0e3c639902f1d00e9ad6413367fd8fe27 -r e129373a1962ade16fedd19caf2d88899b0be6c4 doc/source/cookbook/various_lens.py
--- /dev/null
+++ b/doc/source/cookbook/various_lens.py
@@ -0,0 +1,114 @@
+import yt
+from yt.visualization.volume_rendering.api import Scene, Camera, VolumeSource
+import numpy as np
+
+field = ("gas", "density")
+
+# normal_vector points from camera to the center of tbe final projection.
+# Now we look at the positive x direction.
+normal_vector = [1., 0., 0.]
+# north_vector defines the "top" direction of the projection, which is
+# positive z direction here.
+north_vector = [0., 0., 1.]
+
+# Follow the simple_volume_rendering cookbook for the first part of this.
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
+sc = Scene()
+vol = VolumeSource(ds, field=field)
+tf = vol.transfer_function
+tf.grey_opacity = True
+
+# Plane-parallel lens
+cam = Camera(ds, lens_type='plane-parallel')
+# Set the resolution of tbe final projection.
+cam.resolution = [500, 500]
+# Set the location of the camera to be (x=0.2, y=0.5, z=0.5)
+# For plane-parallel lens, the location info along the normal_vector (here
+# is x=0.2) is ignored. 
+cam.position = ds.arr(np.array([0.2, 0.5, 0.5]), 'code_length')
+# Set the orientation of the camera.
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+# Set the width of the camera, where width[0] and width[1] specify the length and
+# height of final projection, while width[2] in plane-parallel lens is not used.
+cam.set_width(ds.domain_width * 0.5)
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_plane-parallel.png', clip_ratio=6.0)
+
+# Perspective lens
+cam = Camera(ds, lens_type='perspective')
+cam.resolution = [500, 500]
+# Standing at (x=0.2, y=0.5, z=0.5), we look at the area of x>0.2 (with some open angle
+# specified by camera width) along the positive x direction.
+cam.position = ds.arr([0.2, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+# Set the width of the camera, where width[0] and width[1] specify the length and
+# height of the final projection, while width[2] specifies the distance between the
+# camera and the final image.
+cam.set_width(ds.domain_width * 0.5)
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_perspective.png', clip_ratio=6.0)
+
+# Stereo-perspective lens
+cam = Camera(ds, lens_type='stereo-perspective')
+# Set the size ratio of the final projection to be 2:1, since stereo-perspective lens
+# will generate the final image with both left-eye and right-eye ones jointed together.
+cam.resolution = [1000, 500]
+cam.position = ds.arr([0.2, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+cam.set_width(ds.domain_width*0.5)
+# Set the distance between left-eye and right-eye.
+cam.lens.disparity = ds.domain_width[0] * 1.e-3
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_stereo-perspective.png', clip_ratio=6.0)
+
+# Fisheye lens
+dd = ds.sphere(ds.domain_center, ds.domain_width[0] / 10)
+cam = Camera(dd, lens_type='fisheye')
+cam.resolution = [500, 500]
+v, c = ds.find_max(field)
+cam.set_position(c - 0.0005 * ds.domain_width)
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+cam.set_width(ds.domain_width)
+cam.lens.fov = 360.0
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_fisheye.png', clip_ratio=6.0)
+
+# Spherical lens
+cam = Camera(ds, lens_type='spherical')
+# Set the size ratio of the final projection to be 2:1, since spherical lens
+# will generate the final image with length of 2*pi and height of pi.
+cam.resolution = [1000, 500]
+# Standing at (x=0.4, y=0.5, z=0.5), we look in all the radial directions
+# from this point in spherical coordinate.
+cam.position = ds.arr([0.4, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+# In (stereo)spherical camera, width[0] specifies the radius of the sphere (the
+# depth of your line of sight), while width[1] or width[2] are not used.
+cam.set_width(ds.domain_width * 0.5)
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_spherical.png', clip_ratio=6.0)
+
+# Stereo-spherical lens
+cam = Camera(ds, lens_type='stereo-spherical')
+# Set the size ratio of the final projection to be 4:1, since spherical-perspective lens
+# will generate the final image with both left-eye and right-eye ones jointed together.
+cam.resolution = [2000, 500]
+cam.position = ds.arr([0.4, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+cam.set_width(ds.domain_width * 0.5)
+# Set the distance between left-eye and right-eye.
+cam.lens.disparity = ds.domain_width[0] * 1.e-3
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_stereo-spherical.png', clip_ratio=6.0)
\ No newline at end of file

diff -r fceb5ab0e3c639902f1d00e9ad6413367fd8fe27 -r e129373a1962ade16fedd19caf2d88899b0be6c4 doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -314,7 +314,7 @@
 the `lens_type` argument with a string.
 
 At the present time, there are a few cameras that can be used:
-`plane-parallel`, `perspective`, `fisheye`, and `spherical`.
+`plane-parallel`, `(stereo)perspective`, `fisheye`, and `(stereo)spherical`.
 
  * Plane parallel: This lens type is the standard type used for orthographic
    projections.  All rays emerge parallel to each other, arranged along a
@@ -332,6 +332,9 @@
    <https://support.google.com/youtube/answer/6178631?hl=en>`, but it's a
    simple matter of running a script on an encoded movie file.)
 
+For more information on the usage of different lenses and their features, see the
+cookbook example :ref:`cookbook-various_lens`.
+
 Volume Rendering Method
 -----------------------
 


https://bitbucket.org/yt_analysis/yt/commits/48ae4275ed75/
Changeset:   48ae4275ed75
Branch:      yt
User:        ngoldbaum
Date:        2015-09-21 18:50:02+00:00
Summary:     Merged in jisuoqing/yt (pull request #1747)

[DOCS] Add cookbook recipe of using different lenses for VR
Affected #:  3 files

diff -r 61a5f08c0ef1e364c11f8b4ee36c3751e5796a34 -r 48ae4275ed75e7a4dc3ca2112fdd3431907bbc67 doc/source/cookbook/complex_plots.rst
--- a/doc/source/cookbook/complex_plots.rst
+++ b/doc/source/cookbook/complex_plots.rst
@@ -212,6 +212,15 @@
 
 .. yt_cookbook:: zoomin_frames.py
 
+.. _cookbook-various_lens:
+
+Various Lens Types for Volume Rendering
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This example illustrates the usage and feature of different lenses for volume rendering.
+
+.. yt_cookbook:: various_lens.py
+
 .. _cookbook-opaque_rendering:
 
 Opaque Volume Rendering

diff -r 61a5f08c0ef1e364c11f8b4ee36c3751e5796a34 -r 48ae4275ed75e7a4dc3ca2112fdd3431907bbc67 doc/source/cookbook/various_lens.py
--- /dev/null
+++ b/doc/source/cookbook/various_lens.py
@@ -0,0 +1,114 @@
+import yt
+from yt.visualization.volume_rendering.api import Scene, Camera, VolumeSource
+import numpy as np
+
+field = ("gas", "density")
+
+# normal_vector points from camera to the center of tbe final projection.
+# Now we look at the positive x direction.
+normal_vector = [1., 0., 0.]
+# north_vector defines the "top" direction of the projection, which is
+# positive z direction here.
+north_vector = [0., 0., 1.]
+
+# Follow the simple_volume_rendering cookbook for the first part of this.
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
+sc = Scene()
+vol = VolumeSource(ds, field=field)
+tf = vol.transfer_function
+tf.grey_opacity = True
+
+# Plane-parallel lens
+cam = Camera(ds, lens_type='plane-parallel')
+# Set the resolution of tbe final projection.
+cam.resolution = [500, 500]
+# Set the location of the camera to be (x=0.2, y=0.5, z=0.5)
+# For plane-parallel lens, the location info along the normal_vector (here
+# is x=0.2) is ignored. 
+cam.position = ds.arr(np.array([0.2, 0.5, 0.5]), 'code_length')
+# Set the orientation of the camera.
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+# Set the width of the camera, where width[0] and width[1] specify the length and
+# height of final projection, while width[2] in plane-parallel lens is not used.
+cam.set_width(ds.domain_width * 0.5)
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_plane-parallel.png', clip_ratio=6.0)
+
+# Perspective lens
+cam = Camera(ds, lens_type='perspective')
+cam.resolution = [500, 500]
+# Standing at (x=0.2, y=0.5, z=0.5), we look at the area of x>0.2 (with some open angle
+# specified by camera width) along the positive x direction.
+cam.position = ds.arr([0.2, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+# Set the width of the camera, where width[0] and width[1] specify the length and
+# height of the final projection, while width[2] specifies the distance between the
+# camera and the final image.
+cam.set_width(ds.domain_width * 0.5)
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_perspective.png', clip_ratio=6.0)
+
+# Stereo-perspective lens
+cam = Camera(ds, lens_type='stereo-perspective')
+# Set the size ratio of the final projection to be 2:1, since stereo-perspective lens
+# will generate the final image with both left-eye and right-eye ones jointed together.
+cam.resolution = [1000, 500]
+cam.position = ds.arr([0.2, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+cam.set_width(ds.domain_width*0.5)
+# Set the distance between left-eye and right-eye.
+cam.lens.disparity = ds.domain_width[0] * 1.e-3
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_stereo-perspective.png', clip_ratio=6.0)
+
+# Fisheye lens
+dd = ds.sphere(ds.domain_center, ds.domain_width[0] / 10)
+cam = Camera(dd, lens_type='fisheye')
+cam.resolution = [500, 500]
+v, c = ds.find_max(field)
+cam.set_position(c - 0.0005 * ds.domain_width)
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+cam.set_width(ds.domain_width)
+cam.lens.fov = 360.0
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_fisheye.png', clip_ratio=6.0)
+
+# Spherical lens
+cam = Camera(ds, lens_type='spherical')
+# Set the size ratio of the final projection to be 2:1, since spherical lens
+# will generate the final image with length of 2*pi and height of pi.
+cam.resolution = [1000, 500]
+# Standing at (x=0.4, y=0.5, z=0.5), we look in all the radial directions
+# from this point in spherical coordinate.
+cam.position = ds.arr([0.4, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+# In (stereo)spherical camera, width[0] specifies the radius of the sphere (the
+# depth of your line of sight), while width[1] or width[2] are not used.
+cam.set_width(ds.domain_width * 0.5)
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_spherical.png', clip_ratio=6.0)
+
+# Stereo-spherical lens
+cam = Camera(ds, lens_type='stereo-spherical')
+# Set the size ratio of the final projection to be 4:1, since spherical-perspective lens
+# will generate the final image with both left-eye and right-eye ones jointed together.
+cam.resolution = [2000, 500]
+cam.position = ds.arr([0.4, 0.5, 0.5], 'code_length')
+cam.switch_orientation(normal_vector=normal_vector,
+                       north_vector=north_vector)
+cam.set_width(ds.domain_width * 0.5)
+# Set the distance between left-eye and right-eye.
+cam.lens.disparity = ds.domain_width[0] * 1.e-3
+sc.camera = cam
+sc.add_source(vol)
+sc.render('lens_stereo-spherical.png', clip_ratio=6.0)
\ No newline at end of file

diff -r 61a5f08c0ef1e364c11f8b4ee36c3751e5796a34 -r 48ae4275ed75e7a4dc3ca2112fdd3431907bbc67 doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -314,7 +314,7 @@
 the `lens_type` argument with a string.
 
 At the present time, there are a few cameras that can be used:
-`plane-parallel`, `perspective`, `fisheye`, and `spherical`.
+`plane-parallel`, `(stereo)perspective`, `fisheye`, and `(stereo)spherical`.
 
  * Plane parallel: This lens type is the standard type used for orthographic
    projections.  All rays emerge parallel to each other, arranged along a
@@ -332,6 +332,9 @@
    <https://support.google.com/youtube/answer/6178631?hl=en>`, but it's a
    simple matter of running a script on an encoded movie file.)
 
+For more information on the usage of different lenses and their features, see the
+cookbook example :ref:`cookbook-various_lens`.
+
 Volume Rendering Method
 -----------------------

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list