[Yt-svn] commit/yt: sskory: Fixing the distribution of angles. Hat tip to Geoffrey So.

Bitbucket commits-noreply at bitbucket.org
Wed Mar 9 07:39:17 PST 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/cacf2082fa2c/
changeset:   r3806:cacf2082fa2c
branch:      yt
user:        sskory
date:        2011-03-09 16:38:54
summary:     Fixing the distribution of angles. Hat tip to Geoffrey So.
affected #:  1 file (185 bytes)

--- a/yt/analysis_modules/two_point_functions/two_point_functions.py	Tue Mar 08 06:53:57 2011 -0800
+++ b/yt/analysis_modules/two_point_functions/two_point_functions.py	Wed Mar 09 07:38:54 2011 -0800
@@ -473,12 +473,15 @@
             r1[:,dim] = self.mt.uniform(low=self.ds.left_edge[dim],
                 high=self.ds.right_edge[dim], size=size)
         # Next we find the second point, determined by a random
-        # theta, phi angle.
+        # theta, phi angle. See Eqns. 1 & 2 from 
+        # http://mathworld.wolfram.com/SpherePointPicking.html,
+        # but phi and theta are switched to the Physics convention.
         if self.constant_phi is None:
             phi = self.mt.uniform(low=0, high=2.*math.pi, size=size)
         else: phi = self.constant_phi * na.ones(size, dtype='float64')
         if self.constant_theta is None:
-            theta = self.mt.uniform(low=0., high=math.pi, size=size)
+            v = self.mt.uniform(low=0., high=1, size=size)
+            theta = na.arccos(2 * v - 1)
         else: theta = self.constant_theta * na.ones(size, dtype='float64')
         r2 = na.empty((size,3), dtype='float64')
         r2[:,0] = r1[:,0] + length * na.cos(phi) * na.sin(theta)

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