1 from __future__ import division
10 sys.path.append("../")
14 _NAME = "Trigonometry"
20 "CENTER": {"action": "7", "type": "text", "text": "7", },
21 "SOUTH": {"action": "[sinh]", "type": "text", "text": "sinh", },
22 "SOUTH_EAST": {"action": "[cosh]", "type": "text", "text": "cosh", },
23 "EAST": {"action": "[tanh]", "type": "text", "text": "tanh", },
24 "showAllSlices": False,
27 "CENTER": {"action": "8", "type": "text", "text": "8", },
28 "showAllSlices": False,
31 "CENTER": {"action": "9", "type": "text", "text": "9", },
32 "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
33 "SOUTH_WEST": {"action": "[acosh]", "type": "text", "text": "acosh", },
34 "WEST": {"action": "[atanh]", "type": "text", "text": "atanh", },
35 "showAllSlices": True,
38 "CENTER": {"action": "4", "type": "text", "text": "4", },
39 "showAllSlices": True,
42 "CENTER": {"action": "5", "type": "text", "text": "5", },
43 "NORTH": {"action": "[exp]", "type": "text", "text": "e ** x", },
44 "SOUTH": {"action": "[log]", "type": "text", "text": "ln", },
45 "WEST": {"action": "e", "type": "text", "text": "e", },
46 "EAST": {"action": "j", "type": "text", "text": "j", },
47 "showAllSlices": True,
50 "CENTER": {"action": "6", "type": "text", "text": "6", },
51 "WEST": {"action": "pi", "type": "text", "text": "pi", },
52 "NORTH": {"action": "[rad]", "type": "text", "text": "-> rad", },
53 "SOUTH": {"action": "[deg]", "type": "text", "text": "-> deg", },
54 "showAllSlices": True,
57 "CENTER": {"action": "1", "type": "text", "text": "1", },
58 "NORTH": {"action": ".", "type": "text", "text": ".", },
59 "EAST": {"action": "0", "type": "text", "text": "0", },
60 "showAllSlices": True,
63 "CENTER": {"action": "2", "type": "text", "text": "2", },
64 "WEST": {"action": "[sin]", "type": "text", "text": "sin", },
65 "NORTH": {"action": "[cos]", "type": "text", "text": "cos", },
66 "EAST": {"action": "[tan]", "type": "text", "text": "tan", },
67 "showAllSlices": True,
70 "CENTER": {"action": "3", "type": "text", "text": "3", },
71 "NORTH": {"action": "[asin]", "type": "text", "text": "asin", },
72 "NORTH_WEST": {"action": "[acos]", "type": "text", "text": "acos", },
73 "WEST": {"action": "[atan]", "type": "text", "text": "atan", },
74 "showAllSlices": False,
78 _ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
79 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
81 pi = operation.Constant("pi", operation.Value(math.pi, operation.render_float_eng))
82 e = operation.Constant("e", operation.Value(math.e, operation.render_float_eng))
84 def float_or_complex(float_func, complex_func):
86 def switching_func(self, *args, **kwd):
88 isinstance(arg, complex)
91 return complex_func(*args, **kwd)
93 return float_func(*args, **kwd)
95 switching_func.__name__ = complex_func.__name__
96 switching_func.__doc__ = complex_func.__doc__
99 exp = operation.generate_function(float_or_complex(math.exp, cmath.exp), "exp", operation.Function.REP_FUNCTION, 1)
100 log = operation.generate_function(float_or_complex(math.log, cmath.log), "log", operation.Function.REP_FUNCTION, 1)
102 PLUGIN.register_operation("exp", exp)
103 PLUGIN.register_operation("log", log)
105 cos = operation.generate_function(float_or_complex(math.cos, cmath.cos), "cos", operation.Function.REP_FUNCTION, 1)
106 acos = operation.generate_function(float_or_complex(math.acos, cmath.acos), "acos", operation.Function.REP_FUNCTION, 1)
107 sin = operation.generate_function(float_or_complex(math.sin, cmath.sin), "sin", operation.Function.REP_FUNCTION, 1)
108 asin = operation.generate_function(float_or_complex(math.asin, cmath.asin), "asin", operation.Function.REP_FUNCTION, 1)
109 tan = operation.generate_function(float_or_complex(math.tan, cmath.tan), "tan", operation.Function.REP_FUNCTION, 1)
110 atan = operation.generate_function(float_or_complex(math.atan, cmath.atan), "atan", operation.Function.REP_FUNCTION, 1)
112 PLUGIN.register_operation("cos", cos)
113 PLUGIN.register_operation("acos", acos)
114 PLUGIN.register_operation("sin", sin)
115 PLUGIN.register_operation("asin", asin)
116 PLUGIN.register_operation("tan", tan)
117 PLUGIN.register_operation("atan", atan)
119 cosh = operation.generate_function(float_or_complex(math.cosh, cmath.cosh), "cosh", operation.Function.REP_FUNCTION, 1)
120 acosh = operation.generate_function(cmath.acosh, "acosh", operation.Function.REP_FUNCTION, 1)
121 sinh = operation.generate_function(float_or_complex(math.sinh, cmath.sinh), "sinh", operation.Function.REP_FUNCTION, 1)
122 asinh = operation.generate_function(cmath.asinh, "asinh", operation.Function.REP_FUNCTION, 1)
123 tanh = operation.generate_function(float_or_complex(math.tanh, cmath.tanh), "tanh", operation.Function.REP_FUNCTION, 1)
124 atanh = operation.generate_function(cmath.atanh, "atanh", operation.Function.REP_FUNCTION, 1)
126 PLUGIN.register_operation("cosh", cosh)
127 PLUGIN.register_operation("acosh", acosh)
128 PLUGIN.register_operation("sinh", sinh)
129 PLUGIN.register_operation("asinh", asinh)
130 PLUGIN.register_operation("tanh", tanh)
131 PLUGIN.register_operation("atanh", atanh)
133 deg = operation.generate_function(math.degrees, "deg", operation.Function.REP_FUNCTION, 1)
134 rad = operation.generate_function(math.radians, "rad", operation.Function.REP_FUNCTION, 1)
136 PLUGIN.register_operation("deg", deg)
137 PLUGIN.register_operation("rad", rad)
140 #phase = operation.generate_function(cmath.phase, "phase", operation.Function.REP_FUNCTION, 1)
141 #polar = operation.generate_function(cmath.polar, "polar", operation.Function.REP_FUNCTION, 1)
142 #rect = operation.generate_function(cmath.rect, "rect", operation.Function.REP_FUNCTION, 1)