코드예시👨🏻💻▶️ 파이썬
파이썬 터틀 그래픽 (turtle graphics) 포물선 운동 그리기
코뮤니티
2020. 10. 21. 16:37
문제 내용
파이썬으로 각도와 속도를 입력값을 받고, 터틀로 포물선 운동을 표현해야합니다.
풀이 내용
import turtle as t
import math
t.setup(500,600)
t.shape("circle")
t.shapesize(0.1,0.1,0)
angle = float(input('각도 : '))
v = float(input('속도 : '))
def draw_pos(x,y): #그림을 그리는 draw_pos 함수
t.hideturtle()
t.penup()
t.setx(x)
t.sety(y)
t.stamp()
hl= -(t.window_height() / 2)
tm=0 #시간변수 초기화
while True:
X = (v * math.cos(angle*math.pi/180)) * tm
Y = (v * math.sin(angle*math.pi/180)) * tm - (9.8*tm*tm*(1/2))
nx = x + int(X)
ny = y + int(Y)
if ny >= y:
t.goto(nx, ny)
t.stamp()
tm = tm + 0.3
else:
break
draw_pos(0,0)
t.done()
코드 결과
나와 어울리는 개발자 유형 찾기
MBTI로 알아보는 개발자 유형 내 안의 개발자를 찾아서...⭐
comu.codeuniv.kr
참고
포물선 운동 도와주세요ㅠㅠ
대한민국 모임의 시작, 네이버 카페
cafe.naver.com