import turtle as t
import math


class circTrigo:

    def __init__(self):
        self.raio = 0
        self.grau = 0
        self.seno = 0
        self.cosseno = 0
        self.tangente = 0
        self.quadrante = 0
        self.tema = ''
        t.bgcolor("black")
        t.pencolor("white")
        
    def seta(self):
        # DESENHA UMA SETA
        t.left(90)
        t.forward(5)
        t.right(120)
        t.forward(10)
        t.right(120)
        t.forward(10)
        t.right(120)
        t.forward(5)
        t.right(90)

    def linha(self, pxls):
        # DESENHA UMA LINHA PONTILHADA
        pixels = int(pxls//1)
        if pixels % 2 == 0:
            pixels = pixels + 1
        for x in range(0, pixels//10):
            t.pendown()
            t.forward(5)
            t.penup()
            t.forward(5)
            t.pendown()
        t.forward(pixels%10)            
    
    def reset(self):
        # RETORNA PRA POSICAO INICIAL
        t.penup()
        t.home()
        t.pendown()
        t.speed(0)
        t.pensize(2)
        t.pencolor("white")

    def circulo(self, raio):
        # DESENHA O CIRCULO
        self.raio = raio
        t.right(90)
        t.penup()
        t.forward(self.raio)
        t.left(90)
        t.pendown()
        t.circle(self.raio)
        self.reset()

    def eixos(self):
        # EIXO X
        t.penup()
        t.backward(self.raio + 50)
        t.pendown()
        self.linha((self.raio*2)+100)
        self.seta()
        self.reset()
        # EIXO Y
        t.left(90)
        t.penup()
        t.backward(self.raio + 50)
        t.pendown()
        self.linha((self.raio*2)+100)
        self.seta()
        self.reset()

    def angulo(self, grau):
        # DESENHA O ANGULO
        self.grau = grau % 360
        t.left(self.grau)
        t.forward(self.raio)
        self.reset()
        # DEFINE O VALOR DO SENO, COSSENO E TANGENTE.
        self.seno = math.sin(math.radians(self.grau))
        self.cosseno = math.cos(math.radians(self.grau))
        self.tangente = math.tan(math.radians(self.grau))
        # DEFINE O QUADRANTE DO ANGULO
        vquad = self.grau
        if 0 < vquad < 90:
            self.quadrante = 1
        elif 90 < vquad < 180:
            self.quadrante = 2
        elif 180 < vquad < 270:
            self.quadrante = 3
        elif 270 < vquad < 360:
            self.quadrante = 4
        if vquad == 0 or vquad == 90 or vquad == 180 or vquad == 270 or vquad == 360:   # Quadrante 0 representa os angulos de resultados indefinidos
            self.quadrante = 0

    def sen(self):
        # DESENHA O SENO
        t.left(self.grau)
        t.forward(self.raio)
        t.pencolor("red")
        if self.quadrante == 1:
            t.left(180 - self.grau)
            self.linha(self.cosseno * self.raio)
            t.left(90)
            t.forward(self.seno * self.raio)
            print (self.seno)
        elif self.quadrante == 2:
            t.right(self.grau)
            self.linha((self.cosseno * self.raio) * -1)
            t.right(90)
            t.forward(self.seno * self.raio)
            print (self.seno)
        elif self.quadrante == 3:
            t.right(self.grau)
            self.linha(self.cosseno * self.raio * -1)
            t.left(90)
            t.forward(self.seno * self.raio * -1)
            print (self.seno)
        elif self.quadrante == 4:
            t.left(180 - self.grau)
            self.linha(self.cosseno * self.raio)
            t.left(90)
            t.forward(self.seno * self.raio)
            print (self.seno)
        else: 
            print("Erro: angulo invalido")
        self.reset()
    
    def csen(self):
        # DESENHA O COSSENO
        t.left(self.grau)
        t.forward(self.raio)
        t.pencolor("green")
        if self.quadrante == 1:
            t.right(self.grau + 90)
            self.linha(self.seno * self.raio)
            t.right(90)
            t.forward(self.cosseno * self.raio)
            print (self.cosseno)
        elif self.quadrante == 2:
            t.right(self.grau + 90)
            self.linha(self.seno * self.raio)
            t.right(90)
            t.forward(self.cosseno * self.raio)
            print (self.cosseno)
        elif self.quadrante == 3:
            t.right(self.grau - 90)
            self.linha(self.seno * self.raio * -1)
            t.right(90)
            t.forward(self.cosseno * self.raio * -1)
            print (self.cosseno)
        elif self.quadrante == 4:
            t.right(self.grau - 90)
            self.linha(self.seno * self.raio * -1)
            t.left(90)
            t.forward(self.cosseno * self.raio)
            print (self.cosseno)
        else: 
            print("Erro: angulo invalido")
        self.reset()
    
    def tan(self):
        # DESENHA A TANGENTE
        t.left(self.grau)
        t.penup()
        t.pencolor("blue")
        if self.quadrante == 1:
            t.forward(self.raio)
            t.pendown()
            self.linha(math.sqrt(((self.tangente*self.raio)**2) + (self.raio**2)) - self.raio)
            t.right(self.grau + 90)
            t.forward(self.tangente * self.raio)
            print (self.tangente)
        elif self.quadrante == 2:
            t.left(180)
            t.forward(self.raio)
            t.pendown()
            self.linha(math.sqrt(((self.tangente*self.raio)**2) + (self.raio**2)) - self.raio)
            t.left(90 - self.grau)
            t.forward(self.tangente * self.raio)
            print (self.tangente)
        elif self.quadrante == 3:
            t.left(180)
            t.forward(self.raio)
            t.pendown()
            self.linha(math.sqrt(((self.tangente*self.raio)**2) + (self.raio**2)) - self.raio)
            t.right(self.grau - 90)
            t.forward(self.tangente * self.raio)
            print (self.tangente)
        elif self.quadrante == 4:
            t.forward(self.raio)
            t.pendown()
            self.linha(math.sqrt(((self.tangente*self.raio)**2) + (self.raio**2)) - self.raio)
            t.right(90 + self.grau)
            t.forward(self.tangente * self.raio)
            print (self.tangente)
        else: 
            print("Erro: angulo invalido")
        self.reset()
    

[((250, 268), 'turtle.bgcolor', 't.bgcolor', (['"""black"""'], {}), "('black')\n", (259, 268), True, 'import turtle as t\n'), ((277, 296), 'turtle.pencolor', 't.pencolor', (['"""white"""'], {}), "('white')\n", (287, 296), True, 'import turtle as t\n'), ((361, 371), 'turtle.left', 't.left', (['(90)'], {}), '(90)\n', (367, 371), True, 'import turtle as t\n'), ((380, 392), 'turtle.forward', 't.forward', (['(5)'], {}), '(5)\n', (389, 392), True, 'import turtle as t\n'), ((401, 413), 'turtle.right', 't.right', (['(120)'], {}), '(120)\n', (408, 413), True, 'import turtle as t\n'), ((422, 435), 'turtle.forward', 't.forward', (['(10)'], {}), '(10)\n', (431, 435), True, 'import turtle as t\n'), ((444, 456), 'turtle.right', 't.right', (['(120)'], {}), '(120)\n', (451, 456), True, 'import turtle as t\n'), ((465, 478), 'turtle.forward', 't.forward', (['(10)'], {}), '(10)\n', (474, 478), True, 'import turtle as t\n'), ((487, 499), 'turtle.right', 't.right', (['(120)'], {}), '(120)\n', (494, 499), True, 'import turtle as t\n'), ((508, 520), 'turtle.forward', 't.forward', (['(5)'], {}), '(5)\n', (517, 520), True, 'import turtle as t\n'), ((529, 540), 'turtle.right', 't.right', (['(90)'], {}), '(90)\n', (536, 540), True, 'import turtle as t\n'), ((865, 887), 'turtle.forward', 't.forward', (['(pixels % 10)'], {}), '(pixels % 10)\n', (874, 887), True, 'import turtle as t\n'), ((970, 979), 'turtle.penup', 't.penup', ([], {}), '()\n', (977, 979), True, 'import turtle as t\n'), ((988, 996), 'turtle.home', 't.home', ([], {}), '()\n', (994, 996), True, 'import turtle as t\n'), ((1005, 1016), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (1014, 1016), True, 'import turtle as t\n'), ((1025, 1035), 'turtle.speed', 't.speed', (['(0)'], {}), '(0)\n', (1032, 1035), True, 'import turtle as t\n'), ((1044, 1056), 'turtle.pensize', 't.pensize', (['(2)'], {}), '(2)\n', (1053, 1056), True, 'import turtle as t\n'), ((1065, 1084), 'turtle.pencolor', 't.pencolor', (['"""white"""'], {}), "('white')\n", (1075, 1084), True, 'import turtle as t\n'), ((1176, 1187), 'turtle.right', 't.right', (['(90)'], {}), '(90)\n', (1183, 1187), True, 'import turtle as t\n'), ((1196, 1205), 'turtle.penup', 't.penup', ([], {}), '()\n', (1203, 1205), True, 'import turtle as t\n'), ((1214, 1234), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (1223, 1234), True, 'import turtle as t\n'), ((1243, 1253), 'turtle.left', 't.left', (['(90)'], {}), '(90)\n', (1249, 1253), True, 'import turtle as t\n'), ((1262, 1273), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (1271, 1273), True, 'import turtle as t\n'), ((1282, 1301), 'turtle.circle', 't.circle', (['self.raio'], {}), '(self.raio)\n', (1290, 1301), True, 'import turtle as t\n'), ((1370, 1379), 'turtle.penup', 't.penup', ([], {}), '()\n', (1377, 1379), True, 'import turtle as t\n'), ((1388, 1414), 'turtle.backward', 't.backward', (['(self.raio + 50)'], {}), '(self.raio + 50)\n', (1398, 1414), True, 'import turtle as t\n'), ((1423, 1434), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (1432, 1434), True, 'import turtle as t\n'), ((1539, 1549), 'turtle.left', 't.left', (['(90)'], {}), '(90)\n', (1545, 1549), True, 'import turtle as t\n'), ((1558, 1567), 'turtle.penup', 't.penup', ([], {}), '()\n', (1565, 1567), True, 'import turtle as t\n'), ((1576, 1602), 'turtle.backward', 't.backward', (['(self.raio + 50)'], {}), '(self.raio + 50)\n', (1586, 1602), True, 'import turtle as t\n'), ((1611, 1622), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (1620, 1622), True, 'import turtle as t\n'), ((1797, 1814), 'turtle.left', 't.left', (['self.grau'], {}), '(self.grau)\n', (1803, 1814), True, 'import turtle as t\n'), ((1823, 1843), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (1832, 1843), True, 'import turtle as t\n'), ((2633, 2650), 'turtle.left', 't.left', (['self.grau'], {}), '(self.grau)\n', (2639, 2650), True, 'import turtle as t\n'), ((2659, 2679), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (2668, 2679), True, 'import turtle as t\n'), ((2688, 2705), 'turtle.pencolor', 't.pencolor', (['"""red"""'], {}), "('red')\n", (2698, 2705), True, 'import turtle as t\n'), ((3720, 3737), 'turtle.left', 't.left', (['self.grau'], {}), '(self.grau)\n', (3726, 3737), True, 'import turtle as t\n'), ((3746, 3766), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (3755, 3766), True, 'import turtle as t\n'), ((3775, 3794), 'turtle.pencolor', 't.pencolor', (['"""green"""'], {}), "('green')\n", (3785, 3794), True, 'import turtle as t\n'), ((4831, 4848), 'turtle.left', 't.left', (['self.grau'], {}), '(self.grau)\n', (4837, 4848), True, 'import turtle as t\n'), ((4857, 4866), 'turtle.penup', 't.penup', ([], {}), '()\n', (4864, 4866), True, 'import turtle as t\n'), ((4875, 4893), 'turtle.pencolor', 't.pencolor', (['"""blue"""'], {}), "('blue')\n", (4885, 4893), True, 'import turtle as t\n'), ((749, 760), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (758, 760), True, 'import turtle as t\n'), ((773, 785), 'turtle.forward', 't.forward', (['(5)'], {}), '(5)\n', (782, 785), True, 'import turtle as t\n'), ((798, 807), 'turtle.penup', 't.penup', ([], {}), '()\n', (805, 807), True, 'import turtle as t\n'), ((820, 832), 'turtle.forward', 't.forward', (['(5)'], {}), '(5)\n', (829, 832), True, 'import turtle as t\n'), ((845, 856), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (854, 856), True, 'import turtle as t\n'), ((1948, 1971), 'math.radians', 'math.radians', (['self.grau'], {}), '(self.grau)\n', (1960, 1971), False, 'import math\n'), ((2005, 2028), 'math.radians', 'math.radians', (['self.grau'], {}), '(self.grau)\n', (2017, 2028), False, 'import math\n'), ((2063, 2086), 'math.radians', 'math.radians', (['self.grau'], {}), '(self.grau)\n', (2075, 2086), False, 'import math\n'), ((2750, 2773), 'turtle.left', 't.left', (['(180 - self.grau)'], {}), '(180 - self.grau)\n', (2756, 2773), True, 'import turtle as t\n'), ((2835, 2845), 'turtle.left', 't.left', (['(90)'], {}), '(90)\n', (2841, 2845), True, 'import turtle as t\n'), ((2858, 2890), 'turtle.forward', 't.forward', (['(self.seno * self.raio)'], {}), '(self.seno * self.raio)\n', (2867, 2890), True, 'import turtle as t\n'), ((3839, 3862), 'turtle.right', 't.right', (['(self.grau + 90)'], {}), '(self.grau + 90)\n', (3846, 3862), True, 'import turtle as t\n'), ((3921, 3932), 'turtle.right', 't.right', (['(90)'], {}), '(90)\n', (3928, 3932), True, 'import turtle as t\n'), ((3945, 3980), 'turtle.forward', 't.forward', (['(self.cosseno * self.raio)'], {}), '(self.cosseno * self.raio)\n', (3954, 3980), True, 'import turtle as t\n'), ((4938, 4958), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (4947, 4958), True, 'import turtle as t\n'), ((4971, 4982), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (4980, 4982), True, 'import turtle as t\n'), ((5090, 5113), 'turtle.right', 't.right', (['(self.grau + 90)'], {}), '(self.grau + 90)\n', (5097, 5113), True, 'import turtle as t\n'), ((5126, 5162), 'turtle.forward', 't.forward', (['(self.tangente * self.raio)'], {}), '(self.tangente * self.raio)\n', (5135, 5162), True, 'import turtle as t\n'), ((2967, 2985), 'turtle.right', 't.right', (['self.grau'], {}), '(self.grau)\n', (2974, 2985), True, 'import turtle as t\n'), ((3054, 3065), 'turtle.right', 't.right', (['(90)'], {}), '(90)\n', (3061, 3065), True, 'import turtle as t\n'), ((3078, 3110), 'turtle.forward', 't.forward', (['(self.seno * self.raio)'], {}), '(self.seno * self.raio)\n', (3087, 3110), True, 'import turtle as t\n'), ((4060, 4083), 'turtle.right', 't.right', (['(self.grau + 90)'], {}), '(self.grau + 90)\n', (4067, 4083), True, 'import turtle as t\n'), ((4142, 4153), 'turtle.right', 't.right', (['(90)'], {}), '(90)\n', (4149, 4153), True, 'import turtle as t\n'), ((4166, 4201), 'turtle.forward', 't.forward', (['(self.cosseno * self.raio)'], {}), '(self.cosseno * self.raio)\n', (4175, 4201), True, 'import turtle as t\n'), ((5243, 5254), 'turtle.left', 't.left', (['(180)'], {}), '(180)\n', (5249, 5254), True, 'import turtle as t\n'), ((5267, 5287), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (5276, 5287), True, 'import turtle as t\n'), ((5300, 5311), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (5309, 5311), True, 'import turtle as t\n'), ((5419, 5441), 'turtle.left', 't.left', (['(90 - self.grau)'], {}), '(90 - self.grau)\n', (5425, 5441), True, 'import turtle as t\n'), ((5454, 5490), 'turtle.forward', 't.forward', (['(self.tangente * self.raio)'], {}), '(self.tangente * self.raio)\n', (5463, 5490), True, 'import turtle as t\n'), ((3187, 3205), 'turtle.right', 't.right', (['self.grau'], {}), '(self.grau)\n', (3194, 3205), True, 'import turtle as t\n'), ((3272, 3282), 'turtle.left', 't.left', (['(90)'], {}), '(90)\n', (3278, 3282), True, 'import turtle as t\n'), ((3295, 3332), 'turtle.forward', 't.forward', (['(self.seno * self.raio * -1)'], {}), '(self.seno * self.raio * -1)\n', (3304, 3332), True, 'import turtle as t\n'), ((4281, 4304), 'turtle.right', 't.right', (['(self.grau - 90)'], {}), '(self.grau - 90)\n', (4288, 4304), True, 'import turtle as t\n'), ((4368, 4379), 'turtle.right', 't.right', (['(90)'], {}), '(90)\n', (4375, 4379), True, 'import turtle as t\n'), ((4392, 4432), 'turtle.forward', 't.forward', (['(self.cosseno * self.raio * -1)'], {}), '(self.cosseno * self.raio * -1)\n', (4401, 4432), True, 'import turtle as t\n'), ((5006, 5066), 'math.sqrt', 'math.sqrt', (['((self.tangente * self.raio) ** 2 + self.raio ** 2)'], {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)\n', (5015, 5066), False, 'import math\n'), ((5571, 5582), 'turtle.left', 't.left', (['(180)'], {}), '(180)\n', (5577, 5582), True, 'import turtle as t\n'), ((5595, 5615), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (5604, 5615), True, 'import turtle as t\n'), ((5628, 5639), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (5637, 5639), True, 'import turtle as t\n'), ((5747, 5770), 'turtle.right', 't.right', (['(self.grau - 90)'], {}), '(self.grau - 90)\n', (5754, 5770), True, 'import turtle as t\n'), ((5783, 5819), 'turtle.forward', 't.forward', (['(self.tangente * self.raio)'], {}), '(self.tangente * self.raio)\n', (5792, 5819), True, 'import turtle as t\n'), ((3409, 3432), 'turtle.left', 't.left', (['(180 - self.grau)'], {}), '(180 - self.grau)\n', (3415, 3432), True, 'import turtle as t\n'), ((3494, 3504), 'turtle.left', 't.left', (['(90)'], {}), '(90)\n', (3500, 3504), True, 'import turtle as t\n'), ((3517, 3549), 'turtle.forward', 't.forward', (['(self.seno * self.raio)'], {}), '(self.seno * self.raio)\n', (3526, 3549), True, 'import turtle as t\n'), ((4512, 4535), 'turtle.right', 't.right', (['(self.grau - 90)'], {}), '(self.grau - 90)\n', (4519, 4535), True, 'import turtle as t\n'), ((4599, 4609), 'turtle.left', 't.left', (['(90)'], {}), '(90)\n', (4605, 4609), True, 'import turtle as t\n'), ((4622, 4657), 'turtle.forward', 't.forward', (['(self.cosseno * self.raio)'], {}), '(self.cosseno * self.raio)\n', (4631, 4657), True, 'import turtle as t\n'), ((5335, 5395), 'math.sqrt', 'math.sqrt', (['((self.tangente * self.raio) ** 2 + self.raio ** 2)'], {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)\n', (5344, 5395), False, 'import math\n'), ((5900, 5920), 'turtle.forward', 't.forward', (['self.raio'], {}), '(self.raio)\n', (5909, 5920), True, 'import turtle as t\n'), ((5933, 5944), 'turtle.pendown', 't.pendown', ([], {}), '()\n', (5942, 5944), True, 'import turtle as t\n'), ((6052, 6075), 'turtle.right', 't.right', (['(90 + self.grau)'], {}), '(90 + self.grau)\n', (6059, 6075), True, 'import turtle as t\n'), ((6088, 6124), 'turtle.forward', 't.forward', (['(self.tangente * self.raio)'], {}), '(self.tangente * self.raio)\n', (6097, 6124), True, 'import turtle as t\n'), ((5663, 5723), 'math.sqrt', 'math.sqrt', (['((self.tangente * self.raio) ** 2 + self.raio ** 2)'], {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)\n', (5672, 5723), False, 'import math\n'), ((5968, 6028), 'math.sqrt', 'math.sqrt', (['((self.tangente * self.raio) ** 2 + self.raio ** 2)'], {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)\n', (5977, 6028), False, 'import math\n')]