-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCollisionDynamics.py
49 lines (36 loc) · 2.11 KB
/
CollisionDynamics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#-----------------------------------------------------------------------------------------#
#-------------------------------- Collision Dynamics ----------------------------------#
#-----------------------------------------------------------------------------------------#
# Date: 11/2021 #
# File: CollisionDynamics.py #
#-----------------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------------------#
# Packages #
#-----------------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------------------#
# Global Variables #
#-----------------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------------------#
# Code #
#-----------------------------------------------------------------------------------------#
# PP stands for Particle-Particles
def PP_Collision(v1_x,v1_y,v2_x,v2_y):
'''
Returns an array with the velocities after a colision between a two particles.
'''
# Since we have same masses and no enery loss:
return [v2_x,v2_y,v1_x,v1_y]
# PW stands for Particle-Wall
def PW_Collision(v_x,v_y,wall):
'''
Returns an array with the velocity after a collision between a particle and a wall.
'''
# When the wall is horizontal, the y component of the velocity inverts
if wall == "x":
return [v_x,-v_y]
# When the wall is vertical, the x component of the velocity inverts
elif wall == "y":
return [-v_x,v_y]
# Leave this here just for aesthetics
else:
return [v_x,v_y]