From 8c08eff9dc4a46c9c0fb41330e45f4d0356ecdcb Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Mon, 15 Mar 2021 14:43:22 +0530
Subject: Fix solid_angle_fraction2planar_angle for solid_angle_fraction > 1/2.

* contrib/cone-vector.py (solid_angle_fraction2planar_angle): Fix for
solid_angle_fraction > 1/2.
---
 contrib/cone-vector.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'contrib')

diff --git a/contrib/cone-vector.py b/contrib/cone-vector.py
index 6526817..85c2c49 100644
--- a/contrib/cone-vector.py
+++ b/contrib/cone-vector.py
@@ -38,10 +38,9 @@ def solid_angle_fraction2planar_angle (solid_angle_fraction, dim):
     alpha = (dim - 1) / 2
     beta = 1/2
     if solid_angle_fraction < 1/2:
-        planar_angle = betaincinv(alpha, beta, 2*solid_angle_fraction)
+        return arcsin(sqrt(betaincinv(alpha, beta, 2*solid_angle_fraction)))
     else:
-        planar_angle = betaincinv(alpha, beta, 2*(1-solid_angle_fraction))
-    return arcsin(sqrt(planar_angle))
+        return pi - arcsin(sqrt(betaincinv(alpha, beta, 2*(1-solid_angle_fraction))))
 
 def rotate_from_nth_canonical (x, axis):
     xn = x[-1]
-- 
cgit v1.2.3