1
간단한 코사인 계산을 호출하려고합니다. 내 코드는파이 게임 : 단순 코사인 함수
import pygame
from pygame.locals import *
import math
pygame.init()
screen = pygame.display.set_mode((480, 480))
myfont = pygame.font.SysFont("monospace", 15)
angle = 90*(math.pi/180)
while True:
adj = math.cos(angle)
display = myfont.render("opposite side: " + str(adj), 1, (255, 255, 0))
screen.blit(display, (100,40))
pygame.display.flip()
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
exit(0)
이므로 cos (90) * 5 = 0이므로 코드에 해당 값이 표시 될 것으로 예상됩니다. 대신에 나는 다음과 같은 나타납니다
이6.12323399574e이-17
아주 기본적인 오류 : http://docs.python.org/2/library/math.html는 'cos'에 대해'x 코디네의 x 라디안을 반환합니다. '라고 말합니다. – usr2564301
그는 'angle = 90 * (math.pi/180)'을 사용하여 90을 라디안으로 변환 중입니다. – Jack