[yt-svn] commit/yt: bwkeller: Merged in jisuoqing/yt (pull request #1820)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Nov 2 11:34:30 PST 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/91d6eab3fe36/
Changeset: 91d6eab3fe36
Branch: yt
User: bwkeller
Date: 2015-11-02 19:34:21+00:00
Summary: Merged in jisuoqing/yt (pull request #1820)
[experimental] [bugfix] Fix the bug that some region does not get rendered in perspective lens, and some improvement
Affected #: 3 files
diff -r 60428e2d8aad1b87ca57ef6eb3c2fa53fed70dad -r 91d6eab3fe367ad1b11c5180554bd537249f7111 doc/source/cookbook/various_lens.py
--- a/doc/source/cookbook/various_lens.py
+++ b/doc/source/cookbook/various_lens.py
@@ -95,9 +95,8 @@
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)
+# In (stereo)spherical camera, camera width is not used since the entire volume
+# will be rendered
sc.camera = cam
sc.add_source(vol)
sc.render()
@@ -111,7 +110,8 @@
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)
+# In (stereo)spherical camera, camera width is not used since the entire volume
+# will be rendered
# Set the distance between left-eye and right-eye.
cam.lens.disparity = ds.domain_width[0] * 1.e-3
sc.camera = cam
diff -r 60428e2d8aad1b87ca57ef6eb3c2fa53fed70dad -r 91d6eab3fe367ad1b11c5180554bd537249f7111 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -99,6 +99,8 @@
self._focus = data_source.ds.domain_center
self._position = data_source.ds.domain_right_edge
self._width = 1.5*data_source.ds.domain_width
+ self._domain_center = data_source.ds.domain_center
+ self._domain_width = data_source.ds.domain_width
if auto:
self.set_defaults_from_data_source(data_source)
@@ -221,9 +223,9 @@
def set_defaults_from_data_source(self, data_source):
"""Resets the camera attributes to their default values"""
- self.position = data_source.pf.domain_right_edge
+ self.position = data_source.ds.domain_right_edge
- width = 1.5 * data_source.pf.domain_width.max()
+ width = 1.5 * data_source.ds.domain_width.max()
(xmi, xma), (ymi, yma), (zmi, zma) = \
data_source.quantities['Extrema'](['x', 'y', 'z'])
width = np.sqrt((xma - xmi) ** 2 + (yma - ymi) ** 2 +
@@ -231,20 +233,22 @@
focus = data_source.get_field_parameter('center')
if iterable(width) and len(width) > 1 and isinstance(width[1], str):
- width = data_source.pf.quan(width[0], input_units=width[1])
+ width = data_source.ds.quan(width[0], input_units=width[1])
# Now convert back to code length for subsequent manipulation
width = width.in_units("code_length") # .value
if not iterable(width):
- width = data_source.pf.arr([width, width, width],
+ width = data_source.ds.arr([width, width, width],
input_units='code_length')
# left/right, top/bottom, front/back
if not isinstance(width, YTArray):
- width = data_source.pf.arr(width, input_units="code_length")
+ width = data_source.ds.arr(width, input_units="code_length")
if not isinstance(focus, YTArray):
- focus = self.pf.arr(focus, input_units="code_length")
+ focus = self.ds.arr(focus, input_units="code_length")
self.set_width(width)
self.focus = focus
+ self._domain_center = data_source.ds.domain_center
+ self._domain_width = data_source.ds.domain_width
super(Camera, self).__init__(self.focus - self.position,
self.north_vector, steady_north=False)
diff -r 60428e2d8aad1b87ca57ef6eb3c2fa53fed70dad -r 91d6eab3fe367ad1b11c5180554bd537249f7111 yt/visualization/volume_rendering/lens.py
--- a/yt/visualization/volume_rendering/lens.py
+++ b/yt/visualization/volume_rendering/lens.py
@@ -180,7 +180,12 @@
normal_vecs = normal_vecs.reshape(
camera.resolution[0], camera.resolution[1], 3)
- vectors = sample_x + sample_y + normal_vecs * camera.width[2]
+ # The maximum possible length of ray
+ max_length = np.linalg.norm(camera.position - camera._domain_center) \
+ + 0.5 * np.linalg.norm(camera._domain_width)
+ # Rescale the ray to be long enough to cover the entire domain
+ vectors = (sample_x + sample_y + normal_vecs * camera.width[2]) * \
+ (max_length / camera.width[2])
positions = np.tile(
camera.position, camera.resolution[0] * camera.resolution[1])
@@ -345,7 +350,12 @@
east_vecs = east_vecs.reshape(
single_resolution_x, camera.resolution[1], 3)
- vectors = sample_x + sample_y + normal_vecs * camera.width[2]
+ # The maximum possible length of ray
+ max_length = np.linalg.norm(camera.position - camera._domain_center) \
+ + 0.5 * np.linalg.norm(camera._domain_width) + np.abs(self.disparity.d)
+ # Rescale the ray to be long enough to cover the entire domain
+ vectors = (sample_x + sample_y + normal_vecs * camera.width[2]) * \
+ (max_length / camera.width[2])
positions = np.tile(
camera.position, single_resolution_x * camera.resolution[1])
@@ -416,7 +426,7 @@
dx = np.dot(pos1 - sight_center.d, east_vec_rot)
dy = np.dot(pos1 - sight_center.d, north_vec)
- dz = np.dot(pos - camera_position_shift, normal_vec_rot)
+ dz = np.dot(pos - camera_position_shift.d, normal_vec_rot)
# Transpose into image coords.
px = (res0_h * 0.5 + res0_h / camera.width[0].d * dx).astype('int')
@@ -567,7 +577,12 @@
vectors[:, :, 0] = np.cos(px) * np.cos(py)
vectors[:, :, 1] = np.sin(px) * np.cos(py)
vectors[:, :, 2] = np.sin(py)
- vectors = vectors * camera.width[0]
+
+ # The maximum possible length of ray
+ max_length = np.linalg.norm(camera.position - camera._domain_center) \
+ + 0.5 * np.linalg.norm(camera._domain_width)
+ # Rescale the ray to be long enough to cover the entire domain
+ vectors = vectors * max_length
positions = np.tile(
camera.position,
@@ -673,7 +688,12 @@
vectors[:, :, 0] = np.cos(px) * np.cos(py)
vectors[:, :, 1] = np.sin(px) * np.cos(py)
vectors[:, :, 2] = np.sin(py)
- vectors = vectors * camera.width[0]
+
+ # The maximum possible length of ray
+ max_length = np.linalg.norm(camera.position - camera._domain_center) \
+ + 0.5 * np.linalg.norm(camera._domain_width) + np.abs(self.disparity.d)
+ # Rescale the ray to be long enough to cover the entire domain
+ vectors = vectors * max_length
vectors2 = np.zeros((single_resolution_x, camera.resolution[1], 3),
dtype='float64', order='C')
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