1 from __future__ import division
11 sys.path.append("../")
15 _MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "trig.map")
16 PLUGIN = plugin_utils.PieKeyboardPluginFactory("Trigonometry", _MAP_FILE_PATH)
18 pi = operation.Constant("pi", operation.Value(math.pi, operation.render_float_eng))
19 e = operation.Constant("e", operation.Value(math.e, operation.render_float_eng))
21 def float_or_complex(float_func, complex_func):
23 def switching_func(self, *args, **kwd):
25 isinstance(arg, complex)
28 return complex_func(*args, **kwd)
30 return float_func(*args, **kwd)
32 switching_func.__name__ = complex_func.__name__
33 switching_func.__doc__ = complex_func.__doc__
36 exp = operation.generate_function(float_or_complex(math.exp, cmath.exp), "exp", operation.Function.REP_FUNCTION, 1)
37 log = operation.generate_function(float_or_complex(math.exp, cmath.exp), "log", operation.Function.REP_FUNCTION, 1)
39 PLUGIN.register_operation("exp", exp)
40 PLUGIN.register_operation("log", log)
42 cos = operation.generate_function(float_or_complex(math.cos, cmath.cos), "cos", operation.Function.REP_FUNCTION, 1)
43 acos = operation.generate_function(float_or_complex(math.acos, cmath.acos), "acos", operation.Function.REP_FUNCTION, 1)
44 sin = operation.generate_function(float_or_complex(math.sin, cmath.sin), "sin", operation.Function.REP_FUNCTION, 1)
45 asin = operation.generate_function(float_or_complex(math.asin, cmath.asin), "asin", operation.Function.REP_FUNCTION, 1)
46 tan = operation.generate_function(float_or_complex(math.tan, cmath.tan), "tan", operation.Function.REP_FUNCTION, 1)
47 atan = operation.generate_function(float_or_complex(math.atan, cmath.atan), "atan", operation.Function.REP_FUNCTION, 1)
49 PLUGIN.register_operation("cos", cos)
50 PLUGIN.register_operation("acos", acos)
51 PLUGIN.register_operation("sin", sin)
52 PLUGIN.register_operation("asin", asin)
53 PLUGIN.register_operation("tan", tan)
54 PLUGIN.register_operation("atan", atan)
56 cosh = operation.generate_function(float_or_complex(math.cosh, cmath.cosh), "cosh", operation.Function.REP_FUNCTION, 1)
57 acosh = operation.generate_function(cmath.acosh, "acosh", operation.Function.REP_FUNCTION, 1)
58 sinh = operation.generate_function(float_or_complex(math.sinh, cmath.sinh), "sinh", operation.Function.REP_FUNCTION, 1)
59 asinh = operation.generate_function(cmath.asinh, "asinh", operation.Function.REP_FUNCTION, 1)
60 tanh = operation.generate_function(float_or_complex(math.tanh, cmath.tanh), "tanh", operation.Function.REP_FUNCTION, 1)
61 atanh = operation.generate_function(cmath.atanh, "atanh", operation.Function.REP_FUNCTION, 1)
63 PLUGIN.register_operation("cosh", cosh)
64 PLUGIN.register_operation("acosh", acosh)
65 PLUGIN.register_operation("sinh", sinh)
66 PLUGIN.register_operation("asinh", asinh)
67 PLUGIN.register_operation("tanh", tanh)
68 PLUGIN.register_operation("atanh", atanh)
70 deg = operation.generate_function(math.degrees, "deg", operation.Function.REP_FUNCTION, 1)
71 rad = operation.generate_function(math.radians, "rad", operation.Function.REP_FUNCTION, 1)
73 PLUGIN.register_operation("deg", deg)
74 PLUGIN.register_operation("rad", rad)
77 #phase = operation.generate_function(cmath.phase, "phase", operation.Function.REP_FUNCTION, 1)
78 #polar = operation.generate_function(cmath.polar, "polar", operation.Function.REP_FUNCTION, 1)
79 #rect = operation.generate_function(cmath.rect, "rect", operation.Function.REP_FUNCTION, 1)