I am trying to make a physics simulation using pygame but the collision is having problems. It gets shaky whenever there is a collision with another block because gravity is applied, but Rect collision only works when it is a pixel or more. I tried to make it so gravity = 0 for every block when it collides at a slow enough velocity, but that causes the blocks to hover due to certain collisions. Sorry for the whole file I do not even know where to start to fix my problem. import pygame import math # pygame setup pygame.init() screen = pygame.display.set_mode((1280, 720)) clock = pygame.time.Clock() running = True dt = 0 swap = 1 enemy_rect = pygame.Rect(500,500,20,20) objects= [[600,300,20,20,0,1.57,10,'blue',.2]] object=pygame.draw.rect(screen, 'blue', (600,300,20,20)) walls= [[0,700,1300,99999,0,0,99999]]#,[200,300,100,200]] while running: # poll for events # pygame.QUIT event means the user clicked X to close your window for event in pygame.event.get():...
I would like to plot 2 circles with differents radius using matplotlib given their faces and vertices. This is my code to define the circles and to plot them. r2,r3=2,3 n_t3=5 n_t2=n_t2 theta_t3=torch.linspace(0,2*torch.pi,n_t3,device=torchdeviceId) VT3 = torch.stack((r3*torch.cos(theta_t3),r3*torch.sin(theta_t3)),dim=1) theta_t2=torch.linspace(0,2*torch.pi,n_t2,device=torchdeviceId) VT2 = torch.stack((r2*torch.cos(theta_t2),r2*torch.sin(theta_t2)),dim=1) VT=torch.vstack((VT2,VT3)) FT3 = torch.cat((torch.arange(0,n_t3-1).reshape(n_t3-1,1),torch.arange(1,n_t3).reshape(n_t3-1,1)),dim=1) FT2 = torch.cat((torch.arange(n_t3,n_t3+n_t2-1).reshape(n_t2-1,1),torch.arange(n_t3+1,n_t3+n_t2).reshape(n_t2-1,1)),dim=1) FT=torch.vstack((FT2,FT3)).to(torchdeviceId) xt, yt = ( VT[FT,0].detach().cpu().numpy(), VT[FT,1].detach().cpu().numpy(), ) plt.figure() plt.plot(xt,yt,label='target',marker='x',markersize=10,alpha=0.2,lw=10); plt.show() But i have this weird result whe...