1
我试图调用一个简单的余弦计算。这是我的代码:Pygame:简单余弦函数
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弧度的余弦。“ – usr2564301
他将90°转换为弧度= 90 *(math.pi/180)' – Jack