1 from __future__ import division
10 sys.path.append("../")
14 _NAME = "Trigonometry"
20 "CENTER": {"action": "[sinh]", "type": "text", "text": "sinh", },
21 "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
22 "showAllSlices": False,
25 "CENTER": {"action": "[cosh]", "type": "text", "text": "cosh", },
26 "SOUTH": {"action": "[acosh]", "type": "text", "text": "acosh", },
27 "showAllSlices": False,
30 "CENTER": {"action": "[tanh]", "type": "text", "text": "tanh", },
31 "SOUTH": {"action": "[atanh]", "type": "text", "text": "atanh", },
32 "showAllSlices": False,
35 "CENTER": {"action": "[exp]", "type": "text", "text": "e ** x", },
36 "NORTH": {"action": "[log]", "type": "text", "text": "ln", },
37 "showAllSlices": True,
40 "CENTER": {"action": "pi", "type": "text", "text": "pi", },
41 "NORTH": {"action": "e", "type": "text", "text": "e", },
42 "showAllSlices": True,
45 "CENTER": {"action": "[rad]", "type": "text", "text": "-> rad", },
46 "NORTH": {"action": "[deg]", "type": "text", "text": "-> deg", },
47 "showAllSlices": True,
50 "CENTER": {"action": "[sin]", "type": "text", "text": "sin", },
51 "NORTH": {"action": "[asin]", "type": "text", "text": "asin", },
52 "showAllSlices": False,
55 "CENTER": {"action": "[cos]", "type": "text", "text": "cos", },
56 "NORTH": {"action": "[acos]", "type": "text", "text": "acos", },
57 "showAllSlices": False,
60 "CENTER": {"action": "[tan]", "type": "text", "text": "tan", },
61 "NORTH": {"action": "[atan]", "type": "text", "text": "atan", },
62 "showAllSlices": False,
66 _ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
67 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
69 pi = operation.Constant("pi", operation.Value(math.pi, operation.render_float_eng))
70 e = operation.Constant("e", operation.Value(math.e, operation.render_float_eng))
72 def float_or_complex(float_func, complex_func):
74 def switching_func(self, *args, **kwd):
76 isinstance(arg, complex)
79 return complex_func(*args, **kwd)
81 return float_func(*args, **kwd)
83 switching_func.__name__ = complex_func.__name__
84 switching_func.__doc__ = complex_func.__doc__
87 exp = operation.generate_function(float_or_complex(math.exp, cmath.exp), "exp", operation.Function.REP_FUNCTION, 1)
88 log = operation.generate_function(float_or_complex(math.log, cmath.log), "log", operation.Function.REP_FUNCTION, 1)
90 PLUGIN.register_operation("exp", exp)
91 PLUGIN.register_operation("log", log)
93 cos = operation.generate_function(float_or_complex(math.cos, cmath.cos), "cos", operation.Function.REP_FUNCTION, 1)
94 acos = operation.generate_function(float_or_complex(math.acos, cmath.acos), "acos", operation.Function.REP_FUNCTION, 1)
95 sin = operation.generate_function(float_or_complex(math.sin, cmath.sin), "sin", operation.Function.REP_FUNCTION, 1)
96 asin = operation.generate_function(float_or_complex(math.asin, cmath.asin), "asin", operation.Function.REP_FUNCTION, 1)
97 tan = operation.generate_function(float_or_complex(math.tan, cmath.tan), "tan", operation.Function.REP_FUNCTION, 1)
98 atan = operation.generate_function(float_or_complex(math.atan, cmath.atan), "atan", operation.Function.REP_FUNCTION, 1)
100 PLUGIN.register_operation("cos", cos)
101 PLUGIN.register_operation("acos", acos)
102 PLUGIN.register_operation("sin", sin)
103 PLUGIN.register_operation("asin", asin)
104 PLUGIN.register_operation("tan", tan)
105 PLUGIN.register_operation("atan", atan)
107 cosh = operation.generate_function(float_or_complex(math.cosh, cmath.cosh), "cosh", operation.Function.REP_FUNCTION, 1)
108 acosh = operation.generate_function(cmath.acosh, "acosh", operation.Function.REP_FUNCTION, 1)
109 sinh = operation.generate_function(float_or_complex(math.sinh, cmath.sinh), "sinh", operation.Function.REP_FUNCTION, 1)
110 asinh = operation.generate_function(cmath.asinh, "asinh", operation.Function.REP_FUNCTION, 1)
111 tanh = operation.generate_function(float_or_complex(math.tanh, cmath.tanh), "tanh", operation.Function.REP_FUNCTION, 1)
112 atanh = operation.generate_function(cmath.atanh, "atanh", operation.Function.REP_FUNCTION, 1)
114 PLUGIN.register_operation("cosh", cosh)
115 PLUGIN.register_operation("acosh", acosh)
116 PLUGIN.register_operation("sinh", sinh)
117 PLUGIN.register_operation("asinh", asinh)
118 PLUGIN.register_operation("tanh", tanh)
119 PLUGIN.register_operation("atanh", atanh)
121 deg = operation.generate_function(math.degrees, "deg", operation.Function.REP_FUNCTION, 1)
122 rad = operation.generate_function(math.radians, "rad", operation.Function.REP_FUNCTION, 1)
124 PLUGIN.register_operation("deg", deg)
125 PLUGIN.register_operation("rad", rad)
128 #phase = operation.generate_function(cmath.phase, "phase", operation.Function.REP_FUNCTION, 1)
129 #polar = operation.generate_function(cmath.polar, "polar", operation.Function.REP_FUNCTION, 1)
130 #rect = operation.generate_function(cmath.rect, "rect", operation.Function.REP_FUNCTION, 1)