그래프 그리기

1부터 1000까지의 숫자로 만들었고, 짝수면 특정 각도, 홀수면 특정 각도로 틀었다.

인사이트를 얻고 싶기도 한데 그냥 재미가 있다. ㅋㅋㅋㅋ

from math import sin,cos,pi
def nums_to_point(num):
    x_points=[0]
    y_points=[0] 
    dir=0
    index=1
    for n in num[1:]:
        if n%2==0: 
            dir+=pi/6
            x_points.append(x_points[index-1]+sin(dir))
            y_points.append(y_points[index-1]+cos(dir))
        else:
            dir-=pi/3
            x_points.append(x_points[index-1]+6*sin(dir))
            y_points.append(y_points[index-1]+6*cos(dir))
        index+=1
    return x_points,y_points

Last updated

Was this helpful?