Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2003-2014 Edward d'Auvergne # 4 # # 5 # This file is part of the program relax (http://www.nmr-relax.com). # 6 # # 7 # This program is free software: you can redistribute it and/or modify # 8 # it under the terms of the GNU General Public License as published by # 9 # the Free Software Foundation, either version 3 of the License, or # 10 # (at your option) any later version. # 11 # # 12 # This program is distributed in the hope that it will be useful, # 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 # GNU General Public License for more details. # 16 # # 17 # You should have received a copy of the GNU General Public License # 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. # 19 # # 20 ############################################################################### 21 22 # Python module imports. 23 from math import pi 24 from numpy import arccos, float64, zeros 25 2628 """Determine the spherical angles for a regular sphere point distribution. 29 30 @keyword inc: The number of increments in the distribution. 31 @type inc: int 32 @return: The phi angle array and the theta angle array. 33 @rtype: array of float, array of float 34 """ 35 36 # Generate the increment values of u. 37 u = zeros(inc, float64) 38 val = 1.0 / float(inc) 39 for i in range(inc): 40 u[i] = float(i) * val 41 42 # Generate the increment values of v. 43 v = zeros(inc/2+1, float64) 44 val = 1.0 / float(inc/2) 45 for i in range(int(inc/2+1)): 46 v[i] = float(i) * val 47 48 # Generate the distribution of spherical angles theta. 49 theta = 2.0 * pi * u 50 51 # Generate the distribution of spherical angles phi (from bottom to top). 52 phi = zeros(len(v), float64) 53 for i in range(len(v)): 54 phi[len(v)-1-i] = pi * v[i] 55 56 # Return the angle arrays. 57 return phi, theta58 5961 """Determine the spherical angles for a uniform sphere point distribution. 62 63 @keyword inc: The number of increments in the distribution. 64 @type inc: int 65 @return: The phi angle array and the theta angle array. 66 @rtype: array of float, array of float 67 """ 68 69 # Generate the increment values of u. 70 u = zeros(inc, float64) 71 val = 1.0 / float(inc) 72 for i in range(inc): 73 u[i] = float(i) * val 74 75 # Generate the increment values of v. 76 v = zeros(inc/2+2, float64) 77 val = 1.0 / float(inc/2) 78 for i in range(1, int(inc/2)+1): 79 v[i] = float(i-1) * val + val/2.0 80 v[-1] = 1.0 81 82 # Generate the distribution of spherical angles theta. 83 theta = 2.0 * pi * u 84 85 # Generate the distribution of spherical angles phi. 86 phi = arccos(2.0 * v - 1.0) 87 88 # Return the angle arrays. 89 return phi, theta90
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Jul 3 13:38:41 2014 | http://epydoc.sourceforge.net |