#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목터틀 모듈로 이등변 삼각형 그리기.2019-04-21 17:34
작성자

이등변 삼각형을 그리는 함수를 만들어 보려고 하는데 이해가 안가는 부분이 있어서 질문드립니다.



import turtle as t

import math


def make_triangle(main_degree):


    x = (180-main_degree)/2

    y = 180 - x 

    lengthFortwo = 50

    lengthForone = lengthFortwo*math.cos(x)*2 

    

    t.right(x)

    t.forward(lengthFortwo)

    t.right(y)

    t.forward(lengthForone)

    t.right(y)

    t.forward(lengthFortwo)

   

    return


make_triangle(60)



여기서 이등변의 길이는 각각 50이고 밑변의 길이는 

이등변의 길이 * cos(밑변과 이등변의 각) * 2 로 설정했는데

거북이가 이상하게 기어가네요..


    lengthForone = lengthFortwo*math.cos(x)*2 

이 부분을 그냥 50으로 지정하면 잘 그립니다.

math 모듈의 함수 cos(x)를 쓰면 거북이의 방향이 바뀌는거 같은데..

이유를 알 수 있을까요?


댓글