我的老师不太擅长把数学和代码联系起来,所以我无法从课堂上弄明白这一点。在
在pygame中(老师希望我们在这个作业中使用pygame+numpy),我应该使用矩阵来围绕一个点(太阳)旋转一个物体(行星的图像)。我已经找到了很多没有矩阵的方法,但是因为我们被特别要求用矩阵来做,这些都是没有用的。在
我不知道如何根据矩阵来改变我星球的中心。
任何提示/提示。我想自己做编程来学习,所以我只需要一些关于如何完成的建议。下面是我目前的尝试。在
编辑:
我知道,要绕着一个点旋转,你必须像移动原点一样移动,旋转,然后向后移动相同的距离。我只需要知道怎么做。在import sys,pygame, numpy, time
from math import *
pygame.init()
size = width, height = 1280, 720
black = 0,0,0
screen = pygame.display.set_mode(size)
sun = pygame.image.load("sun.png")
sun.convert_alpha()
sunRect = sun.get_rect()
#Placing the sun to the left in the window
sunRect = sunRect.move(20,200)
#creating another object and placing it more to the right of the sun
osuni = sun
osuni = pygame.transform.