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()
    

[((15, 8, 15, 26), 'turtle.bgcolor', 't.bgcolor', ({(15, 18, 15, 25): '"""black"""'}, {}), "('black')", True, 'import turtle as t\n'), ((16, 8, 16, 27), 'turtle.pencolor', 't.pencolor', ({(16, 19, 16, 26): '"""white"""'}, {}), "('white')", True, 'import turtle as t\n'), ((20, 8, 20, 18), 'turtle.left', 't.left', ({(20, 15, 20, 17): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((21, 8, 21, 20), 'turtle.forward', 't.forward', ({(21, 18, 21, 19): '(5)'}, {}), '(5)', True, 'import turtle as t\n'), ((22, 8, 22, 20), 'turtle.right', 't.right', ({(22, 16, 22, 19): '(120)'}, {}), '(120)', True, 'import turtle as t\n'), ((23, 8, 23, 21), 'turtle.forward', 't.forward', ({(23, 18, 23, 20): '(10)'}, {}), '(10)', True, 'import turtle as t\n'), ((24, 8, 24, 20), 'turtle.right', 't.right', ({(24, 16, 24, 19): '(120)'}, {}), '(120)', True, 'import turtle as t\n'), ((25, 8, 25, 21), 'turtle.forward', 't.forward', ({(25, 18, 25, 20): '(10)'}, {}), '(10)', True, 'import turtle as t\n'), ((26, 8, 26, 20), 'turtle.right', 't.right', ({(26, 16, 26, 19): '(120)'}, {}), '(120)', True, 'import turtle as t\n'), ((27, 8, 27, 20), 'turtle.forward', 't.forward', ({(27, 18, 27, 19): '(5)'}, {}), '(5)', True, 'import turtle as t\n'), ((28, 8, 28, 19), 'turtle.right', 't.right', ({(28, 16, 28, 18): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((41, 8, 41, 28), 'turtle.forward', 't.forward', ({(41, 18, 41, 27): '(pixels % 10)'}, {}), '(pixels % 10)', True, 'import turtle as t\n'), ((45, 8, 45, 17), 'turtle.penup', 't.penup', ({}, {}), '()', True, 'import turtle as t\n'), ((46, 8, 46, 16), 'turtle.home', 't.home', ({}, {}), '()', True, 'import turtle as t\n'), ((47, 8, 47, 19), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((48, 8, 48, 18), 'turtle.speed', 't.speed', ({(48, 16, 48, 17): '(0)'}, {}), '(0)', True, 'import turtle as t\n'), ((49, 8, 49, 20), 'turtle.pensize', 't.pensize', ({(49, 18, 49, 19): '(2)'}, {}), '(2)', True, 'import turtle as t\n'), ((50, 8, 50, 27), 'turtle.pencolor', 't.pencolor', ({(50, 19, 50, 26): '"""white"""'}, {}), "('white')", True, 'import turtle as t\n'), ((55, 8, 55, 19), 'turtle.right', 't.right', ({(55, 16, 55, 18): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((56, 8, 56, 17), 'turtle.penup', 't.penup', ({}, {}), '()', True, 'import turtle as t\n'), ((57, 8, 57, 28), 'turtle.forward', 't.forward', ({(57, 18, 57, 27): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((58, 8, 58, 18), 'turtle.left', 't.left', ({(58, 15, 58, 17): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((59, 8, 59, 19), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((60, 8, 60, 27), 'turtle.circle', 't.circle', ({(60, 17, 60, 26): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((65, 8, 65, 17), 'turtle.penup', 't.penup', ({}, {}), '()', True, 'import turtle as t\n'), ((66, 8, 66, 34), 'turtle.backward', 't.backward', ({(66, 19, 66, 33): '(self.raio + 50)'}, {}), '(self.raio + 50)', True, 'import turtle as t\n'), ((67, 8, 67, 19), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((72, 8, 72, 18), 'turtle.left', 't.left', ({(72, 15, 72, 17): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((73, 8, 73, 17), 'turtle.penup', 't.penup', ({}, {}), '()', True, 'import turtle as t\n'), ((74, 8, 74, 34), 'turtle.backward', 't.backward', ({(74, 19, 74, 33): '(self.raio + 50)'}, {}), '(self.raio + 50)', True, 'import turtle as t\n'), ((75, 8, 75, 19), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((83, 8, 83, 25), 'turtle.left', 't.left', ({(83, 15, 83, 24): 'self.grau'}, {}), '(self.grau)', True, 'import turtle as t\n'), ((84, 8, 84, 28), 'turtle.forward', 't.forward', ({(84, 18, 84, 27): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((105, 8, 105, 25), 'turtle.left', 't.left', ({(105, 15, 105, 24): 'self.grau'}, {}), '(self.grau)', True, 'import turtle as t\n'), ((106, 8, 106, 28), 'turtle.forward', 't.forward', ({(106, 18, 106, 27): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((107, 8, 107, 25), 'turtle.pencolor', 't.pencolor', ({(107, 19, 107, 24): '"""red"""'}, {}), "('red')", True, 'import turtle as t\n'), ((138, 8, 138, 25), 'turtle.left', 't.left', ({(138, 15, 138, 24): 'self.grau'}, {}), '(self.grau)', True, 'import turtle as t\n'), ((139, 8, 139, 28), 'turtle.forward', 't.forward', ({(139, 18, 139, 27): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((140, 8, 140, 27), 'turtle.pencolor', 't.pencolor', ({(140, 19, 140, 26): '"""green"""'}, {}), "('green')", True, 'import turtle as t\n'), ((171, 8, 171, 25), 'turtle.left', 't.left', ({(171, 15, 171, 24): 'self.grau'}, {}), '(self.grau)', True, 'import turtle as t\n'), ((172, 8, 172, 17), 'turtle.penup', 't.penup', ({}, {}), '()', True, 'import turtle as t\n'), ((173, 8, 173, 26), 'turtle.pencolor', 't.pencolor', ({(173, 19, 173, 25): '"""blue"""'}, {}), "('blue')", True, 'import turtle as t\n'), ((36, 12, 36, 23), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((37, 12, 37, 24), 'turtle.forward', 't.forward', ({(37, 22, 37, 23): '(5)'}, {}), '(5)', True, 'import turtle as t\n'), ((38, 12, 38, 21), 'turtle.penup', 't.penup', ({}, {}), '()', True, 'import turtle as t\n'), ((39, 12, 39, 24), 'turtle.forward', 't.forward', ({(39, 22, 39, 23): '(5)'}, {}), '(5)', True, 'import turtle as t\n'), ((40, 12, 40, 23), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((87, 29, 87, 52), 'math.radians', 'math.radians', ({(87, 42, 87, 51): 'self.grau'}, {}), '(self.grau)', False, 'import math\n'), ((88, 32, 88, 55), 'math.radians', 'math.radians', ({(88, 45, 88, 54): 'self.grau'}, {}), '(self.grau)', False, 'import math\n'), ((89, 33, 89, 56), 'math.radians', 'math.radians', ({(89, 46, 89, 55): 'self.grau'}, {}), '(self.grau)', False, 'import math\n'), ((109, 12, 109, 35), 'turtle.left', 't.left', ({(109, 19, 109, 34): '(180 - self.grau)'}, {}), '(180 - self.grau)', True, 'import turtle as t\n'), ((111, 12, 111, 22), 'turtle.left', 't.left', ({(111, 19, 111, 21): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((112, 12, 112, 44), 'turtle.forward', 't.forward', ({(112, 22, 112, 43): '(self.seno * self.raio)'}, {}), '(self.seno * self.raio)', True, 'import turtle as t\n'), ((142, 12, 142, 35), 'turtle.right', 't.right', ({(142, 20, 142, 34): '(self.grau + 90)'}, {}), '(self.grau + 90)', True, 'import turtle as t\n'), ((144, 12, 144, 23), 'turtle.right', 't.right', ({(144, 20, 144, 22): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((145, 12, 145, 47), 'turtle.forward', 't.forward', ({(145, 22, 145, 46): '(self.cosseno * self.raio)'}, {}), '(self.cosseno * self.raio)', True, 'import turtle as t\n'), ((175, 12, 175, 32), 'turtle.forward', 't.forward', ({(175, 22, 175, 31): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((176, 12, 176, 23), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((178, 12, 178, 35), 'turtle.right', 't.right', ({(178, 20, 178, 34): '(self.grau + 90)'}, {}), '(self.grau + 90)', True, 'import turtle as t\n'), ((179, 12, 179, 48), 'turtle.forward', 't.forward', ({(179, 22, 179, 47): '(self.tangente * self.raio)'}, {}), '(self.tangente * self.raio)', True, 'import turtle as t\n'), ((115, 12, 115, 30), 'turtle.right', 't.right', ({(115, 20, 115, 29): 'self.grau'}, {}), '(self.grau)', True, 'import turtle as t\n'), ((117, 12, 117, 23), 'turtle.right', 't.right', ({(117, 20, 117, 22): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((118, 12, 118, 44), 'turtle.forward', 't.forward', ({(118, 22, 118, 43): '(self.seno * self.raio)'}, {}), '(self.seno * self.raio)', True, 'import turtle as t\n'), ((148, 12, 148, 35), 'turtle.right', 't.right', ({(148, 20, 148, 34): '(self.grau + 90)'}, {}), '(self.grau + 90)', True, 'import turtle as t\n'), ((150, 12, 150, 23), 'turtle.right', 't.right', ({(150, 20, 150, 22): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((151, 12, 151, 47), 'turtle.forward', 't.forward', ({(151, 22, 151, 46): '(self.cosseno * self.raio)'}, {}), '(self.cosseno * self.raio)', True, 'import turtle as t\n'), ((182, 12, 182, 23), 'turtle.left', 't.left', ({(182, 19, 182, 22): '(180)'}, {}), '(180)', True, 'import turtle as t\n'), ((183, 12, 183, 32), 'turtle.forward', 't.forward', ({(183, 22, 183, 31): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((184, 12, 184, 23), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((186, 12, 186, 34), 'turtle.left', 't.left', ({(186, 19, 186, 33): '(90 - self.grau)'}, {}), '(90 - self.grau)', True, 'import turtle as t\n'), ((187, 12, 187, 48), 'turtle.forward', 't.forward', ({(187, 22, 187, 47): '(self.tangente * self.raio)'}, {}), '(self.tangente * self.raio)', True, 'import turtle as t\n'), ((121, 12, 121, 30), 'turtle.right', 't.right', ({(121, 20, 121, 29): 'self.grau'}, {}), '(self.grau)', True, 'import turtle as t\n'), ((123, 12, 123, 22), 'turtle.left', 't.left', ({(123, 19, 123, 21): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((124, 12, 124, 49), 'turtle.forward', 't.forward', ({(124, 22, 124, 48): '(self.seno * self.raio * -1)'}, {}), '(self.seno * self.raio * -1)', True, 'import turtle as t\n'), ((154, 12, 154, 35), 'turtle.right', 't.right', ({(154, 20, 154, 34): '(self.grau - 90)'}, {}), '(self.grau - 90)', True, 'import turtle as t\n'), ((156, 12, 156, 23), 'turtle.right', 't.right', ({(156, 20, 156, 22): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((157, 12, 157, 52), 'turtle.forward', 't.forward', ({(157, 22, 157, 51): '(self.cosseno * self.raio * -1)'}, {}), '(self.cosseno * self.raio * -1)', True, 'import turtle as t\n'), ((177, 23, 177, 81), 'math.sqrt', 'math.sqrt', ({(177, 33, 177, 80): '((self.tangente * self.raio) ** 2 + self.raio ** 2)'}, {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)', False, 'import math\n'), ((190, 12, 190, 23), 'turtle.left', 't.left', ({(190, 19, 190, 22): '(180)'}, {}), '(180)', True, 'import turtle as t\n'), ((191, 12, 191, 32), 'turtle.forward', 't.forward', ({(191, 22, 191, 31): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((192, 12, 192, 23), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((194, 12, 194, 35), 'turtle.right', 't.right', ({(194, 20, 194, 34): '(self.grau - 90)'}, {}), '(self.grau - 90)', True, 'import turtle as t\n'), ((195, 12, 195, 48), 'turtle.forward', 't.forward', ({(195, 22, 195, 47): '(self.tangente * self.raio)'}, {}), '(self.tangente * self.raio)', True, 'import turtle as t\n'), ((127, 12, 127, 35), 'turtle.left', 't.left', ({(127, 19, 127, 34): '(180 - self.grau)'}, {}), '(180 - self.grau)', True, 'import turtle as t\n'), ((129, 12, 129, 22), 'turtle.left', 't.left', ({(129, 19, 129, 21): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((130, 12, 130, 44), 'turtle.forward', 't.forward', ({(130, 22, 130, 43): '(self.seno * self.raio)'}, {}), '(self.seno * self.raio)', True, 'import turtle as t\n'), ((160, 12, 160, 35), 'turtle.right', 't.right', ({(160, 20, 160, 34): '(self.grau - 90)'}, {}), '(self.grau - 90)', True, 'import turtle as t\n'), ((162, 12, 162, 22), 'turtle.left', 't.left', ({(162, 19, 162, 21): '(90)'}, {}), '(90)', True, 'import turtle as t\n'), ((163, 12, 163, 47), 'turtle.forward', 't.forward', ({(163, 22, 163, 46): '(self.cosseno * self.raio)'}, {}), '(self.cosseno * self.raio)', True, 'import turtle as t\n'), ((185, 23, 185, 81), 'math.sqrt', 'math.sqrt', ({(185, 33, 185, 80): '((self.tangente * self.raio) ** 2 + self.raio ** 2)'}, {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)', False, 'import math\n'), ((198, 12, 198, 32), 'turtle.forward', 't.forward', ({(198, 22, 198, 31): 'self.raio'}, {}), '(self.raio)', True, 'import turtle as t\n'), ((199, 12, 199, 23), 'turtle.pendown', 't.pendown', ({}, {}), '()', True, 'import turtle as t\n'), ((201, 12, 201, 35), 'turtle.right', 't.right', ({(201, 20, 201, 34): '(90 + self.grau)'}, {}), '(90 + self.grau)', True, 'import turtle as t\n'), ((202, 12, 202, 48), 'turtle.forward', 't.forward', ({(202, 22, 202, 47): '(self.tangente * self.raio)'}, {}), '(self.tangente * self.raio)', True, 'import turtle as t\n'), ((193, 23, 193, 81), 'math.sqrt', 'math.sqrt', ({(193, 33, 193, 80): '((self.tangente * self.raio) ** 2 + self.raio ** 2)'}, {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)', False, 'import math\n'), ((200, 23, 200, 81), 'math.sqrt', 'math.sqrt', ({(200, 33, 200, 80): '((self.tangente * self.raio) ** 2 + self.raio ** 2)'}, {}), '((self.tangente * self.raio) ** 2 + self.raio ** 2)', False, 'import math\n')]