aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/cone-vector.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/cone-vector.py b/contrib/cone-vector.py
index 1f28d07..9501464 100644
--- a/contrib/cone-vector.py
+++ b/contrib/cone-vector.py
@@ -21,25 +21,25 @@ from numpy.random import randn, random
from numpy.linalg import norm
from scipy.special import betainc, betaincinv, gamma
-def random_vector_on_sphere (dim):
+def random_vector_on_sphere(dim):
x = randn(dim)
return x / norm(x)
-def planar_angle2solid_angle_fraction (planar_angle, dim):
+def planar_angle2solid_angle_fraction(planar_angle, dim):
alpha = (dim - 1) / 2
beta = 1/2
return where(planar_angle < pi/2,
0.5*betainc(alpha, beta, sin(planar_angle)**2),
1 - 0.5*betainc(alpha, beta, sin(planar_angle)**2))
-def solid_angle_fraction2planar_angle (solid_angle_fraction, dim):
+def solid_angle_fraction2planar_angle(solid_angle_fraction, dim):
alpha = (dim - 1) / 2
beta = 1/2
return where(solid_angle_fraction < 1/2,
arcsin(sqrt(betaincinv(alpha, beta, 2*solid_angle_fraction))),
pi - arcsin(sqrt(betaincinv(alpha, beta, 2*(1-solid_angle_fraction)))))
-def rotate_from_nth_canonical (x, axis):
+def rotate_from_nth_canonical(x, axis):
xn = x[-1]
axisn = axis[-1]
if axisn != 1:
@@ -51,7 +51,7 @@ def rotate_from_nth_canonical (x, axis):
- axisn*(xn*s + a*(axisn - 1))/b
return x
-def random_vector_on_spherical_cap (axis, maximum_planar_angle):
+def random_vector_on_spherical_cap(axis, maximum_planar_angle):
dim = axis.size
maximum_solid_angle_fraction = planar_angle2solid_angle_fraction(maximum_planar_angle, dim)
solid_angle_fraction = maximum_solid_angle_fraction*random()