From f7b5705c76351f9a38af68cb4a9eea0dd4ca743b Mon Sep 17 00:00:00 2001 From: Pratyush Singh <78396437+Pratyush-IITBHU@users.noreply.github.com> Date: Mon, 25 Oct 2021 22:47:22 +0530 Subject: [PATCH] Fibonacci numbers visulalzation Hello Sir, This is my basic python pybullet simulation to run and learn Fibonacci numbers using rainfall visualization. --- .../fibonacci_rainfall.py | 41 +++++++++++++++++ fibonacci_rainfall_simulation/sphere.urdf | 44 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 fibonacci_rainfall_simulation/fibonacci_rainfall.py create mode 100644 fibonacci_rainfall_simulation/sphere.urdf diff --git a/fibonacci_rainfall_simulation/fibonacci_rainfall.py b/fibonacci_rainfall_simulation/fibonacci_rainfall.py new file mode 100644 index 0000000..4f5fcb5 --- /dev/null +++ b/fibonacci_rainfall_simulation/fibonacci_rainfall.py @@ -0,0 +1,41 @@ +'''hello everyone!!! I am Pratyush and this is a basic pybullet project to visualize Fibonacci numbers using simulation.''' + +import pybullet as p +import pybullet_data +import time + +physicsClient = p.connect(p.GUI) +p.setAdditionalSearchPath(pybullet_data.getDataPath()) + + +x=[] +ball=[] + +for i in range(1000): + + planeId = p.loadURDF("plane.urdf") #loading the plane + p.setGravity(0,0,-10) #setting the gravity + + + if(i==0 or i==1): #storing Fibonacci numbers + x.append(1) + else: + x.append(x[i-1]+x[i-2]) + + + print(i+1,"th wave , no of spheres=",x[i]) + + ball.clear() + for z in range(x[i]): + ball.append(p.loadURDF("sphere.urdf",[z,0,5])) #appending the number of balls and their coordinates + + for y in range(1000): #running the simulation + p.stepSimulation() + time.sleep(1./240.) + pos,_ = p.getBasePositionAndOrientation(ball[0]) + if pos[2]<=0.05: + time.sleep(1) + break + + +p.resetSimulation() diff --git a/fibonacci_rainfall_simulation/sphere.urdf b/fibonacci_rainfall_simulation/sphere.urdf new file mode 100644 index 0000000..ec020d6 --- /dev/null +++ b/fibonacci_rainfall_simulation/sphere.urdf @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +