如果你有一个点(在2d),你怎么能在python的另一个点(原点)周围旋转那个点?
例如,您可以将原点周围的第一个点倾斜10度.
基本上你有一个点PointA和它旋转的原点.代码看起来像这样:
PointA=(200,300)
origin=(100,100)
NewPointA=rotate(origin,PointA,10) #The rotate function rotates it by 10 degrees
Run Code Online (Sandbox Code Playgroud) 我想围绕一个支点,这是不是在中心旋转图像表面的pygame的。
枢轴是图像中的绿色十字:
我知道游戏窗口中枢轴的位置。我如何在此时跟踪图像并同时围绕该点旋转它。
image = pygame.image.load("boomerang64.png")
pos = (200, 200)
angle = 0
while True:
# [...]
rotate_rect, rotate_image = ???? # rotate around green cross by angle
surf.blit(rotated_image, rotate_rect)
angle += 1
# [...]
Run Code Online (Sandbox Code Playgroud)