Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plotter/view/puzzletree/nodes/sine.py
blob: 493354eae5c87f4cf9e84fc09b922e235deb09b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

from .simplenode import SimpleNode
from gettext import gettext as _

import math


class Sine(SimpleNode):
    """Node representing the sine function: f(x) = sin(x)."""

    CLASS = "sine"
    background = SimpleNode.loadbackground("sine.svg")
    title = _("Sine")
    description = _(u"Returns the ratio of the length of a side opposite an "
        u"acute angle in a right trianale to the length of the hypotenuse.\n"
        u"For example, sin(pi / 4) = 1 / sqrt(2)")

    def __call__(self, x):
        """Calls the sine function."""
        return math.sin(x)


    def get_equation_string(self, variable):
        """Returns sin(x) given x."""
        return "sin(%s)" % variable