2 Boolean geometry utilities.
6 from __future__ import absolute_import
7 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
10 from fabmetheus_utilities import euclidean
14 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
15 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
16 __date__ = '$Date: 2008/02/05 $'
17 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
20 globalNativeFunctions = 'acos asin atan atan2 ceil cos cosh degrees e exp fabs floor fmod frexp hypot'.split()
21 globalNativeFunctions += 'ldexp log log10 modf pi pow radians sin sinh sqrt tan tanh trunc'.split()
22 globalNativeFunctionSet = set(globalNativeFunctions)
23 #Constants from: http://www.physlink.com/reference/MathConstants.cfm
24 #Tau is from: http://tauday.com/
25 #If anyone wants to add stuff, more constants are at: http://en.wikipedia.org/wiki/Mathematical_constant
26 globalMathConstantDictionary = {
27 'euler' : 0.5772156649015328606065120,
28 'golden' : euclidean.globalGoldenRatio,
29 'goldenAngle' : euclidean.globalGoldenAngle,
30 'goldenRatio' : euclidean.globalGoldenRatio,
31 'tau' : euclidean.globalTau}
34 def _getAccessibleAttribute(attributeName):
35 'Get the accessible attribute.'
36 if attributeName in globalMathConstantDictionary:
37 return globalMathConstantDictionary[attributeName]
38 if attributeName in globalNativeFunctionSet:
39 return math.__dict__[attributeName]
40 if attributeName in globalAccessibleAttributeDictionary:
41 return globalAccessibleAttributeDictionary[attributeName]
49 def getBoolean(value):
73 def getMax(first, second):
75 return max(first, second)
77 def getMin(first, second):
79 return min(first, second)
90 globalAccessibleAttributeDictionary = {
92 'boolean' : getBoolean,
101 'string' : getString}