[yt-svn] commit/yt: MatthewTurk: Removing RX, RY, RZ and replacing with rotation matrix calls.

Bitbucket commits-noreply at bitbucket.org
Sat Jun 23 05:36:23 PDT 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/c5d54e6e4232/
changeset:   c5d54e6e4232
branch:      yt
user:        MatthewTurk
date:        2012-06-23 14:28:26
summary:     Removing RX, RY, RZ and replacing with rotation matrix calls.
affected #:  3 files

diff -r 5052c5ca60c3aa8f309af54b2a4cf490a4391698 -r c5d54e6e4232b812e4754e926318aa0c5f60d587 yt/analysis_modules/halo_finding/halo_objects.py
--- a/yt/analysis_modules/halo_finding/halo_objects.py
+++ b/yt/analysis_modules/halo_finding/halo_objects.py
@@ -42,7 +42,7 @@
 from yt.config import ytcfg
 from yt.utilities.performance_counters import \
     yt_counters, time_function
-from yt.utilities.math_utils import periodic_dist
+from yt.utilities.math_utils import periodic_dist, get_rotation_matrix
 from yt.utilities.physical_constants import rho_crit_now, mass_sun_cgs
 
 from .hop.EnzoHop import RunHOP
@@ -58,10 +58,6 @@
     ParallelAnalysisInterface, \
     parallel_blocking_call
 
-from yt.utilities.math_utils import RX
-from yt.utilities.math_utils import RY
-from yt.utilities.math_utils import RZ
-
 TINY = 1.e-40
 
 # Ellipsoid funtions.
@@ -528,10 +524,12 @@
         # after e0 is aligned with x axis
         # find the t1 angle needed to rotate about z axis to align e0 to x
         t1 = na.arctan(e0_vector[1] / e0_vector[0])
-        r1 = (e0_vector * RZ(t1).transpose()).sum(axis = 1)
+        RZ = get_rotation_matrix(-t1, (0, 0, 1)).transpose()
+        r1 = (e0_vector * rz).sum(axis = 1)
         # find the t2 angle needed to rotate about y axis to align e0 to x
         t2 = na.arctan(-r1[2] / r1[0])
-        r2 = na.dot(RY(t2), na.dot(RZ(t1), e1_vector))
+        RY = get_rotation_matrix(-t2, (0, 1, 0)).transpose()
+        r2 = na.dot(RY, na.dot(RZ, e1_vector))
         tilt = na.arctan(r2[2]/r2[1])
         return (mag_A, mag_B, mag_C, e0_vector[0], e0_vector[1],
             e0_vector[2], tilt)


diff -r 5052c5ca60c3aa8f309af54b2a4cf490a4391698 -r c5d54e6e4232b812e4754e926318aa0c5f60d587 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -58,9 +58,7 @@
 from yt.utilities.minimal_representation import \
     MinimalProjectionData, MinimalSliceData
 from yt.utilities.orientation import Orientation
-from yt.utilities.math_utils import RX
-from yt.utilities.math_utils import RY
-from yt.utilities.math_utils import RZ
+from yt.utilities.math_utils import get_rotation_matrix
 
 from .derived_quantities import DerivedQuantityCollection
 from .field_info_container import \
@@ -3425,11 +3423,11 @@
         self._e0 = e0
         self._tilt = tilt
         
-        # Should have rotation matrix RX,RY,RZ imported at top
         # find the t1 angle needed to rotate about z axis to align e0 to x
         t1 = na.arctan(e0[1] / e0[0])
         # rotate e0 by -t1
-        r1 = (e0 * RZ(-t1).transpose()).sum(axis = 1)
+        RZ = get_rotation_matrix(t1, (0,0,1)).transpose()
+        r1 = (e0 * RZ).sum(axis = 1)
         # find the t2 angle needed to rotate about y axis to align e0 to x
         t2 = na.arctan(-r1[2] / r1[0])
         """
@@ -3437,13 +3435,16 @@
         given the tilt about the x axis when e0 was aligned 
         to x after t1, t2 rotations about z, y
         """
-        e1 = ((0, 1, 0) * RX(tilt).transpose()).sum(axis = 1)
-        e1 = (e1 * RY(t2).transpose()).sum(axis = 1)
-        e1 = (e1 * RZ(t1).transpose()).sum(axis = 1)
+        RX = get_rotation_matrix(-tilt, (1,0,0)).transpose()
+        RY = get_rotation_matrix(-t2,   (0,1,0)).transpose()
+        RZ = get_rotation_matrix(-t1,   (0,0,1)).transpose()
+        e1 = ((0, 1, 0) * RX).sum(axis = 1)
+        e1 = (e1 * RY).sum(axis = 1)
+        e1 = (e1 * RZ).sum(axis = 1)
         e2 = na.cross(e0, e1)
 
-	self._e1 = e1
-	self._e2 = e2
+        self._e1 = e1
+        self._e2 = e2
 
         self.set_field_parameter('A', A)
         self.set_field_parameter('B', B)


diff -r 5052c5ca60c3aa8f309af54b2a4cf490a4391698 -r c5d54e6e4232b812e4754e926318aa0c5f60d587 yt/utilities/math_utils.py
--- a/yt/utilities/math_utils.py
+++ b/yt/utilities/math_utils.py
@@ -634,55 +634,3 @@
                   [uz*ux*(1-cost)-uy*sint, uz*uy*(1-cost)+ux*sint, cost+uz**2*(1-cost)]])
     
     return R
-
-def RX(ax):
-    """
-    Returns
-    -------
-    Gives the rotation matrix about the x-axis as an array
-
-    Example
-    -------
-    >>>>from yt.mods import *
-    >>>>from yt.utilities.math_utils import RX
-    >>>>RX(na.pi)
-    >>>>array([[  1.00000000e+00,   0.00000000e+00,   0.00000000e+00],
-               [  0.00000000e+00,  -1.00000000e+00,   1.22464680e-16],
-               [  0.00000000e+00,  -1.22464680e-16,  -1.00000000e+00]])
-    """
-    rot_matrix = get_rotation_matrix(-ax,(1,0,0))
-    return rot_matrix
-def RY(ay):
-    """
-    Returns
-    -------
-    Gives the rotation matrix about the y-axis as an array
-
-    Example
-    -------
-    >>>>from yt.mods import *
-    >>>>from yt.utilities.math_utils import RY
-    >>>>RY(na.pi)
-    >>>>array([[ -1.00000000e+00,   0.00000000e+00,  -1.22464680e-16],
-               [  0.00000000e+00,   1.00000000e+00,   0.00000000e+00],
-               [  1.22464680e-16,   0.00000000e+00,  -1.00000000e+00]])
-    """
-    rot_matrix = get_rotation_matrix(-ay,(0,1,0))
-    return rot_matrix
-def RZ(az):
-    """
-    Returns
-    -------
-    Gives the rotation matrix about the z-axis as an array
-
-    Example
-    -------
-    >>>>from yt.mods import *
-    >>>>from yt.utilities.math_utils import RZ
-    >>>>RZ(na.pi)
-    >>>>array([[ -1.00000000e+00,   1.22464680e-16,   0.00000000e+00],
-               [ -1.22464680e-16,  -1.00000000e+00,   0.00000000e+00],
-               [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00]])
-    """
-    rot_matrix = get_rotation_matrix(-az,(0,0,1))
-    return rot_matrix

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