1 from __future__ import division
7 from ejpi import operation
8 from ejpi import plugin_utils
11 _NAME = "Trigonometry"
17 "CENTER": {"action": "7", "type": "text", "text": "7", },
18 "SOUTH": {"action": "[sinh]", "type": "text", "text": "sinh", },
19 "SOUTH_EAST": {"action": "[cosh]", "type": "text", "text": "cosh", },
20 "EAST": {"action": "[tanh]", "type": "text", "text": "tanh", },
21 "showAllSlices": False,
24 "CENTER": {"action": "8", "type": "text", "text": "8", },
25 "showAllSlices": False,
28 "CENTER": {"action": "9", "type": "text", "text": "9", },
29 "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
30 "SOUTH_WEST": {"action": "[acosh]", "type": "text", "text": "acosh", },
31 "WEST": {"action": "[atanh]", "type": "text", "text": "atanh", },
32 "showAllSlices": True,
35 "CENTER": {"action": "4", "type": "text", "text": "4", },
36 "showAllSlices": True,
39 "CENTER": {"action": "5", "type": "text", "text": "5", },
40 "NORTH": {"action": "[exp]", "type": "text", "text": "e ** x", },
41 "SOUTH": {"action": "[log]", "type": "text", "text": "ln", },
42 "WEST": {"action": "e", "type": "text", "text": "e", },
43 "EAST": {"action": "j", "type": "text", "text": "j", },
44 "showAllSlices": True,
47 "CENTER": {"action": "6", "type": "text", "text": "6", },
48 "WEST": {"action": "pi", "type": "text", "text": "pi", },
49 "NORTH": {"action": "[rad]", "type": "text", "text": "-> rad", },
50 "SOUTH": {"action": "[deg]", "type": "text", "text": "-> deg", },
51 "showAllSlices": True,
54 "CENTER": {"action": "1", "type": "text", "text": "1", },
55 "NORTH": {"action": ".", "type": "text", "text": ".", },
56 "EAST": {"action": "0", "type": "text", "text": "0", },
57 "showAllSlices": True,
60 "CENTER": {"action": "2", "type": "text", "text": "2", },
61 "WEST": {"action": "[sin]", "type": "text", "text": "sin", },
62 "NORTH": {"action": "[cos]", "type": "text", "text": "cos", },
63 "EAST": {"action": "[tan]", "type": "text", "text": "tan", },
64 "showAllSlices": True,
67 "CENTER": {"action": "3", "type": "text", "text": "3", },
68 "NORTH": {"action": "[asin]", "type": "text", "text": "asin", },
69 "NORTH_WEST": {"action": "[acos]", "type": "text", "text": "acos", },
70 "WEST": {"action": "[atan]", "type": "text", "text": "atan", },
71 "showAllSlices": False,
75 _ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
76 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
78 pi = operation.Constant("pi", operation.Value(math.pi, operation.render_float_eng))
79 e = operation.Constant("e", operation.Value(math.e, operation.render_float_eng))
81 def float_or_complex(float_func, complex_func):
83 def switching_func(self, *args, **kwd):
85 isinstance(arg, complex)
88 return complex_func(*args, **kwd)
90 return float_func(*args, **kwd)
92 switching_func.__name__ = complex_func.__name__
93 switching_func.__doc__ = complex_func.__doc__
96 exp = operation.generate_function(float_or_complex(math.exp, cmath.exp), "exp", operation.Function.REP_FUNCTION, 1)
97 log = operation.generate_function(float_or_complex(math.log, cmath.log), "log", operation.Function.REP_FUNCTION, 1)
99 PLUGIN.register_operation("exp", exp)
100 PLUGIN.register_operation("log", log)
102 cos = operation.generate_function(float_or_complex(math.cos, cmath.cos), "cos", operation.Function.REP_FUNCTION, 1)
103 acos = operation.generate_function(float_or_complex(math.acos, cmath.acos), "acos", operation.Function.REP_FUNCTION, 1)
104 sin = operation.generate_function(float_or_complex(math.sin, cmath.sin), "sin", operation.Function.REP_FUNCTION, 1)
105 asin = operation.generate_function(float_or_complex(math.asin, cmath.asin), "asin", operation.Function.REP_FUNCTION, 1)
106 tan = operation.generate_function(float_or_complex(math.tan, cmath.tan), "tan", operation.Function.REP_FUNCTION, 1)
107 atan = operation.generate_function(float_or_complex(math.atan, cmath.atan), "atan", operation.Function.REP_FUNCTION, 1)
109 PLUGIN.register_operation("cos", cos)
110 PLUGIN.register_operation("acos", acos)
111 PLUGIN.register_operation("sin", sin)
112 PLUGIN.register_operation("asin", asin)
113 PLUGIN.register_operation("tan", tan)
114 PLUGIN.register_operation("atan", atan)
116 cosh = operation.generate_function(float_or_complex(math.cosh, cmath.cosh), "cosh", operation.Function.REP_FUNCTION, 1)
117 acosh = operation.generate_function(cmath.acosh, "acosh", operation.Function.REP_FUNCTION, 1)
118 sinh = operation.generate_function(float_or_complex(math.sinh, cmath.sinh), "sinh", operation.Function.REP_FUNCTION, 1)
119 asinh = operation.generate_function(cmath.asinh, "asinh", operation.Function.REP_FUNCTION, 1)
120 tanh = operation.generate_function(float_or_complex(math.tanh, cmath.tanh), "tanh", operation.Function.REP_FUNCTION, 1)
121 atanh = operation.generate_function(cmath.atanh, "atanh", operation.Function.REP_FUNCTION, 1)
123 PLUGIN.register_operation("cosh", cosh)
124 PLUGIN.register_operation("acosh", acosh)
125 PLUGIN.register_operation("sinh", sinh)
126 PLUGIN.register_operation("asinh", asinh)
127 PLUGIN.register_operation("tanh", tanh)
128 PLUGIN.register_operation("atanh", atanh)
130 deg = operation.generate_function(math.degrees, "deg", operation.Function.REP_FUNCTION, 1)
131 rad = operation.generate_function(math.radians, "rad", operation.Function.REP_FUNCTION, 1)
133 PLUGIN.register_operation("deg", deg)
134 PLUGIN.register_operation("rad", rad)
137 #phase = operation.generate_function(cmath.phase, "phase", operation.Function.REP_FUNCTION, 1)
138 #polar = operation.generate_function(cmath.polar, "polar", operation.Function.REP_FUNCTION, 1)
139 #rect = operation.generate_function(cmath.rect, "rect", operation.Function.REP_FUNCTION, 1)