billiards

How to create 'billiard ball' reflection boundary condition in python?

岁酱吖の 提交于 2021-01-29 06:51:13
问题 According to Erwin Schrodinger (in What is Life?), diffusion can be explained entirely by the random motion of particles. I want to test this myself by create a program the creates a time-step visualization of the diffusion of "gas molecules" in a closed container. The initial conditions would have two partitions, one with low and one with high concentration. After t0 the partition is removed and the gas is allowed to diffuse. The only mechanism I want to use is adding displacement random

I cannot figure out a way to move the balls

流过昼夜 提交于 2019-12-26 03:08:57
问题 I am currently working on a 3 cushion billiards game project. I have added two balls on the table so far. I am trying to move one of the balls but I am having a hard time doing that. Should I use a timer? If so then could you tell me an effective way to use the timer on my code so I can move my balls? Your help would be much appreciated. Thanks in advance. Farhan Hasan I have tried to create a move function for the class balls. But I am not sure what I should put inside the function, I have

Bouncing ball in a circle (Python Turtle)

落爺英雄遲暮 提交于 2019-12-11 11:55:14
问题 I am currently working on a circular billiards program using Turtle. My problem is that I can't figure out what angle or position I need to give Python once the ball has reached the sides of the circle in order to make it bounce. Here is the part of my program that needs to be fixed: while nbrebonds>=0: forward(1) if (distance(0,y)>rayon): #rayon means radius print(distance(0,y)) left(2*angleinitial) #I put this angle as a test but it doesn't work forward(1) nbrebonds+=(-1) 回答1: From what I