[yt-svn] commit/yt: 6 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Oct 15 15:53:24 PDT 2015
6 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/b62da2350f0c/
Changeset: b62da2350f0c
Branch: yt
User: jisuoqing
Date: 2015-10-14 21:27:27+00:00
Summary: Improve rotation function by adding rotation center
Affected #: 1 file
diff -r 52b57ac913dd7e334914c7e8985f35ebb1618346 -r b62da2350f0cca8197e2050e8d841a4e28c6ec4a yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -299,7 +299,7 @@
north_vector=north_vector)
self._moved = True
- def rotate(self, theta, rot_vector=None):
+ def rotate(self, theta, rot_vector=None, rot_center=None):
r"""Rotate by a given angle
Rotate the view. If `rot_vector` is None, rotation will occur
@@ -313,6 +313,10 @@
Specify the rotation vector around which rotation will
occur. Defaults to None, which sets rotation around
`north_vector`
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur. Defaults
+ to None, which sets rotation around the original camera position
+ (i.e. the camera position does not change)
Examples
--------
@@ -323,12 +327,19 @@
rotate_all = rot_vector is not None
if rot_vector is None:
rot_vector = self.north_vector
+ if rot_center is None:
+ rot_center = self._position
rot_vector = ensure_numpy_array(rot_vector)
rot_vector = rot_vector/np.linalg.norm(rot_vector)
+ new_position = self._position - rot_center
R = get_rotation_matrix(theta, rot_vector)
+ new_position = np.dot(R, new_position) + rot_center
- normal_vector = self.unit_vectors[2]
+ if (new_position == self._position).all():
+ normal_vector = self.unit_vectors[2]
+ else:
+ normal_vector = rot_center - new_position
normal_vector = normal_vector/np.sqrt((normal_vector**2).sum())
if rotate_all:
@@ -337,8 +348,9 @@
north_vector=np.dot(R, self.unit_vectors[1]))
else:
self.switch_view(normal_vector=np.dot(R, normal_vector))
+ if (new_position != self._position).any(): self.set_position(new_position)
- def pitch(self, theta):
+ def pitch(self, theta, rot_center=None):
r"""Rotate by a given angle about the horizontal axis
Pitch the view.
@@ -354,9 +366,9 @@
>>> cam = Camera()
>>> cam.pitch(np.pi/4)
"""
- self.rotate(theta, rot_vector=self.unit_vectors[0])
+ self.rotate(theta, rot_vector=self.unit_vectors[0], rot_center=rot_center)
- def yaw(self, theta):
+ def yaw(self, theta, rot_center=None):
r"""Rotate by a given angle about the vertical axis
Yaw the view.
@@ -372,9 +384,9 @@
>>> cam = Camera()
>>> cam.yaw(np.pi/4)
"""
- self.rotate(theta, rot_vector=self.unit_vectors[1])
+ self.rotate(theta, rot_vector=self.unit_vectors[1], rot_center=rot_center)
- def roll(self, theta):
+ def roll(self, theta, rot_center=None):
r"""Rotate by a given angle about the view normal axis
Roll the view.
@@ -390,9 +402,9 @@
>>> cam = Camera()
>>> cam.roll(np.pi/4)
"""
- self.rotate(theta, rot_vector=self.unit_vectors[2])
+ self.rotate(theta, rot_vector=self.unit_vectors[2], rot_center=rot_center)
- def iter_rotate(self, theta, n_steps, rot_vector=None):
+ def iter_rotate(self, theta, n_steps, rot_vector=None, rot_center=None):
r"""Loop over rotate, creating a rotation
This will rotate `n_steps` until the current view has been
@@ -408,6 +420,10 @@
Specify the rotation vector around which rotation will
occur. Defaults to None, which sets rotation around the
original `north_vector`
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur. Defaults
+ to None, which sets rotation around the original camera position
+ (i.e. the camera position does not change)
Examples
--------
@@ -418,7 +434,7 @@
dtheta = (1.0*theta)/n_steps
for i in xrange(n_steps):
- self.rotate(dtheta, rot_vector=rot_vector)
+ self.rotate(dtheta, rot_vector=rot_vector, rot_center=rot_center)
yield i
def iter_move(self, final, n_steps, exponential=False):
@@ -502,7 +518,7 @@
yield i
def __repr__(self):
- disp = ("<Camera Object>:\n\tposition:%s\n\tfocus:%s\n\t" +
+ disp = ("<Camera Object>:\n\tposition:%s\n\tf.ocus:%s\n\t" +
"north_vector:%s\n\twidth:%s\n\tlight:%s\n\tresolution:%s\n") \
% (self.position, self.focus, self.north_vector, self.width,
self.light, self.resolution)
https://bitbucket.org/yt_analysis/yt/commits/4a1e60aec266/
Changeset: 4a1e60aec266
Branch: yt
User: jisuoqing
Date: 2015-10-14 21:28:36+00:00
Summary: Small tab fix
Affected #: 1 file
diff -r b62da2350f0cca8197e2050e8d841a4e28c6ec4a -r 4a1e60aec26624990cca96d99af8cb463e6a5a1a yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -336,7 +336,7 @@
R = get_rotation_matrix(theta, rot_vector)
new_position = np.dot(R, new_position) + rot_center
- if (new_position == self._position).all():
+ if (new_position == self._position).all():
normal_vector = self.unit_vectors[2]
else:
normal_vector = rot_center - new_position
https://bitbucket.org/yt_analysis/yt/commits/63891162a5a6/
Changeset: 63891162a5a6
Branch: yt
User: jisuoqing
Date: 2015-10-14 21:29:38+00:00
Summary: Typo fix
Affected #: 1 file
diff -r 4a1e60aec26624990cca96d99af8cb463e6a5a1a -r 63891162a5a697726d7c19674cb6282564eff0c0 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -518,7 +518,7 @@
yield i
def __repr__(self):
- disp = ("<Camera Object>:\n\tposition:%s\n\tf.ocus:%s\n\t" +
+ disp = ("<Camera Object>:\n\tposition:%s\n\tfocus:%s\n\t" +
"north_vector:%s\n\twidth:%s\n\tlight:%s\n\tresolution:%s\n") \
% (self.position, self.focus, self.north_vector, self.width,
self.light, self.resolution)
https://bitbucket.org/yt_analysis/yt/commits/b9564a1055b1/
Changeset: b9564a1055b1
Branch: yt
User: jisuoqing
Date: 2015-10-15 18:39:05+00:00
Summary: Add docs and missing docstring
Affected #: 2 files
diff -r 63891162a5a697726d7c19674cb6282564eff0c0 -r b9564a1055b1cc8acb8ed9cd379e0f8b92fc4c5d doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -283,7 +283,10 @@
:meth:`~yt.visualization.volume_rendering.camera.Camera.pitch`,
:meth:`~yt.visualization.volume_rendering.camera.Camera.yaw`, and
:meth:`~yt.visualization.volume_rendering.camera.Camera.roll` can rotate the
-camera in space.
+camera in space. The center around which the camera rotates can be specified by
+the optional parameter `rot_center` (very useful for perspective and spherical
+lenses), or by default `rot_center` is set to be at camera location (i.e. the
+camera will do self rotation without changing its position).
When examining a particular point in space,
:meth:`~yt.visualization.volume_rendering.camera.Camera.zoom` can be of
diff -r 63891162a5a697726d7c19674cb6282564eff0c0 -r b9564a1055b1cc8acb8ed9cd379e0f8b92fc4c5d yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -359,6 +359,8 @@
----------
theta : float, in radians
Angle (in radians) by which to pitch the view.
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur.
Examples
--------
@@ -377,6 +379,8 @@
----------
theta : float, in radians
Angle (in radians) by which to yaw the view.
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur.
Examples
--------
@@ -395,6 +399,8 @@
----------
theta : float, in radians
Angle (in radians) by which to roll the view.
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur.
Examples
--------
https://bitbucket.org/yt_analysis/yt/commits/0280f6e31cba/
Changeset: 0280f6e31cba
Branch: yt
User: jisuoqing
Date: 2015-10-15 22:34:24+00:00
Summary: Minor change in description
Affected #: 1 file
diff -r b9564a1055b1cc8acb8ed9cd379e0f8b92fc4c5d -r 0280f6e31cba0620eee920998cae67ee1ba0d9fb doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -286,7 +286,7 @@
camera in space. The center around which the camera rotates can be specified by
the optional parameter `rot_center` (very useful for perspective and spherical
lenses), or by default `rot_center` is set to be at camera location (i.e. the
-camera will do self rotation without changing its position).
+camera will rotate about its current position).
When examining a particular point in space,
:meth:`~yt.visualization.volume_rendering.camera.Camera.zoom` can be of
https://bitbucket.org/yt_analysis/yt/commits/009bb61a3f0e/
Changeset: 009bb61a3f0e
Branch: yt
User: ngoldbaum
Date: 2015-10-15 22:53:15+00:00
Summary: Merged in jisuoqing/yt (pull request #1797)
[Experimental] [Doc] Improve camera rotation function by adding rotation center, fix #1107
Affected #: 2 files
diff -r 562b253b734a3abc182b712fb9009034ea3b36c6 -r 009bb61a3f0e8fb34991c79cbdd6a78fdcff2546 doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -304,7 +304,10 @@
:meth:`~yt.visualization.volume_rendering.camera.Camera.pitch`,
:meth:`~yt.visualization.volume_rendering.camera.Camera.yaw`, and
:meth:`~yt.visualization.volume_rendering.camera.Camera.roll` can rotate the
-camera in space.
+camera in space. The center around which the camera rotates can be specified by
+the optional parameter `rot_center` (very useful for perspective and spherical
+lenses), or by default `rot_center` is set to be at camera location (i.e. the
+camera will rotate about its current position).
When examining a particular point in space,
:meth:`~yt.visualization.volume_rendering.camera.Camera.zoom` can be of
diff -r 562b253b734a3abc182b712fb9009034ea3b36c6 -r 009bb61a3f0e8fb34991c79cbdd6a78fdcff2546 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -299,7 +299,7 @@
north_vector=north_vector)
self._moved = True
- def rotate(self, theta, rot_vector=None):
+ def rotate(self, theta, rot_vector=None, rot_center=None):
r"""Rotate by a given angle
Rotate the view. If `rot_vector` is None, rotation will occur
@@ -313,6 +313,10 @@
Specify the rotation vector around which rotation will
occur. Defaults to None, which sets rotation around
`north_vector`
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur. Defaults
+ to None, which sets rotation around the original camera position
+ (i.e. the camera position does not change)
Examples
--------
@@ -323,12 +327,19 @@
rotate_all = rot_vector is not None
if rot_vector is None:
rot_vector = self.north_vector
+ if rot_center is None:
+ rot_center = self._position
rot_vector = ensure_numpy_array(rot_vector)
rot_vector = rot_vector/np.linalg.norm(rot_vector)
+ new_position = self._position - rot_center
R = get_rotation_matrix(theta, rot_vector)
+ new_position = np.dot(R, new_position) + rot_center
- normal_vector = self.unit_vectors[2]
+ if (new_position == self._position).all():
+ normal_vector = self.unit_vectors[2]
+ else:
+ normal_vector = rot_center - new_position
normal_vector = normal_vector/np.sqrt((normal_vector**2).sum())
if rotate_all:
@@ -337,8 +348,9 @@
north_vector=np.dot(R, self.unit_vectors[1]))
else:
self.switch_view(normal_vector=np.dot(R, normal_vector))
+ if (new_position != self._position).any(): self.set_position(new_position)
- def pitch(self, theta):
+ def pitch(self, theta, rot_center=None):
r"""Rotate by a given angle about the horizontal axis
Pitch the view.
@@ -347,6 +359,8 @@
----------
theta : float, in radians
Angle (in radians) by which to pitch the view.
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur.
Examples
--------
@@ -354,9 +368,9 @@
>>> cam = Camera()
>>> cam.pitch(np.pi/4)
"""
- self.rotate(theta, rot_vector=self.unit_vectors[0])
+ self.rotate(theta, rot_vector=self.unit_vectors[0], rot_center=rot_center)
- def yaw(self, theta):
+ def yaw(self, theta, rot_center=None):
r"""Rotate by a given angle about the vertical axis
Yaw the view.
@@ -365,6 +379,8 @@
----------
theta : float, in radians
Angle (in radians) by which to yaw the view.
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur.
Examples
--------
@@ -372,9 +388,9 @@
>>> cam = Camera()
>>> cam.yaw(np.pi/4)
"""
- self.rotate(theta, rot_vector=self.unit_vectors[1])
+ self.rotate(theta, rot_vector=self.unit_vectors[1], rot_center=rot_center)
- def roll(self, theta):
+ def roll(self, theta, rot_center=None):
r"""Rotate by a given angle about the view normal axis
Roll the view.
@@ -383,6 +399,8 @@
----------
theta : float, in radians
Angle (in radians) by which to roll the view.
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur.
Examples
--------
@@ -390,9 +408,9 @@
>>> cam = Camera()
>>> cam.roll(np.pi/4)
"""
- self.rotate(theta, rot_vector=self.unit_vectors[2])
+ self.rotate(theta, rot_vector=self.unit_vectors[2], rot_center=rot_center)
- def iter_rotate(self, theta, n_steps, rot_vector=None):
+ def iter_rotate(self, theta, n_steps, rot_vector=None, rot_center=None):
r"""Loop over rotate, creating a rotation
This will rotate `n_steps` until the current view has been
@@ -408,6 +426,10 @@
Specify the rotation vector around which rotation will
occur. Defaults to None, which sets rotation around the
original `north_vector`
+ rot_center : array_like, optional
+ Specifiy the center around which rotation will occur. Defaults
+ to None, which sets rotation around the original camera position
+ (i.e. the camera position does not change)
Examples
--------
@@ -418,7 +440,7 @@
dtheta = (1.0*theta)/n_steps
for i in xrange(n_steps):
- self.rotate(dtheta, rot_vector=rot_vector)
+ self.rotate(dtheta, rot_vector=rot_vector, rot_center=rot_center)
yield i
def iter_move(self, final, n_steps, exponential=False):
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