update_v (413)
# 6030048821 1 (2021-02-01 21:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1=(r1)**2 m2=(r2)**2 theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) phi=math.atan((y2-y1)/(x2-x1)) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6030182121 2 (2021-02-01 16:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) lowerphi = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = v1x/math.cos(theta1) v2 = v2x/math.cos(theta2) v1_x = (((v1*math.cos(theta1-lowerphi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-lowerphi)))/(m1+m2))*math.cos(lowerphi) \ + (v1*math.sin(theta1-lowerphi)*math.cos(lowerphi+(math.pi/2))) v1_y = (((v1*math.cos(theta1-lowerphi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-lowerphi)))/(m1+m2))*math.sin(lowerphi) \ + (v1*math.sin(theta1-lowerphi)*math.sin(lowerphi+(math.pi/2))) v2_x = (((v2*math.cos(theta1-lowerphi)*(m1-m2)) + (2*m2*v1*math.cos(theta2-lowerphi)))/(m1+m2))*math.cos(lowerphi) \ + (v2*math.sin(theta1-lowerphi)*math.cos(lowerphi+(math.pi/2))) v2_y = (((v2*math.cos(theta1-lowerphi)*(m1-m2)) + (2*m2*v1*math.cos(theta2-lowerphi)))/(m1+m2))*math.sin(lowerphi) \ + (v2*math.sin(theta1-lowerphi)*math.sin(lowerphi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6030239321 3 (2021-01-28 22:26) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # insert your code here v1_x = vx(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y) v1_y = vy(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y) v2_x = vx(x2, y2, r2, v2x, v2y, x1, y1, r1, v1x, v1y) v2_y = vy(x2, y2, r2, v2x, v2y, x1, y1, r1, v1x, v1y) return (v1_x, v1_y), (v2_x, v2_y) def vx(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): if (v1x==0):theta1=math.pi/2*(v1y/abs(v1y)) else:theta1 = math.atan(v1y/v1x) if (v2x==0):theta2=math.pi/2*(v2y/abs(v2y)) else:theta2 = math.atan(v2y/v2x) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) phi = math.atan((x2-x1)/(y2-y1)) m1 = r1**2 m2 = r2**2 v_new = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) return v_new def vy(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): if (v1x==0):theta1=math.pi/2*(v1y/abs(v1y)) else:theta1 = math.atan(v1y/v1x) if (v2x==0):theta2=math.pi/2*(v2y/abs(v2y)) else:theta2 = math.atan(v2y/v2x) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) phi = math.atan((x2-x1)/(y2-y1)) m1 = r1**2 m2 = r2**2 v_new = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) return v_new |
# 6030380021 4 (2021-02-01 23:44) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = math.pow(r1,2) m2 = math.pow(r2,2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) v1 = math.sqrt(math.pow(v1x,2)+math.pow(v1y,2)) v2 = math.sqrt(math.pow(v2x,2)+math.pow(v2y,2)) zeta = math.asin((y2-y1)/(r1+r2)) v1_x = (((v1*math.cos(theta1-zeta)*(m1-m2))+(2*m2*v2*math.cos(theta2-zeta)))/(m1+m2))*math.cos(zeta)+v1*math.sin(theta1-zeta)*math.cos(zeta+math.pi/2) v1_y = (((v1*math.cos(theta1-zeta)*(m1-m2))+(2*m2*v2*math.cos(theta2-zeta)))/(m1+m2))*math.sin(zeta)+v1*math.sin(theta1-zeta)*math.sin(zeta+math.pi/2) v2_x = (((v2*math.cos(theta2-zeta)*(m2-m1))+(2*m1*v1*math.cos(theta1-zeta)))/(m1+m2))*math.cos(zeta)+v2*math.sin(theta2-zeta)*math.cos(zeta+math.pi/2) v2_y = (((v2*math.cos(theta2-zeta)*(m2-m1))+(2*m1*v1*math.cos(theta1-zeta)))/(m1+m2))*math.sin(zeta)+v2*math.sin(theta2-zeta)*math.sin(zeta+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6030924521 5 (2021-01-31 19:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) seta1 = math.acos(v1x/v1) seta2 = math.acos(v2x/v2) m1 = r1**2 m2 = r2**2 phi = math.atan2((y2-y1),(x2 - x1)) v1_x = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2) )*math.cos(phi) + v1*math.sin(seta1-phi)*math.cos(phi+ (math.pi/2)) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2) )*math.sin(phi) + v1*math.sin(seta1-phi)*math.sin(phi+ (math.pi/2)) v2_x = ((v2*math.cos(seta2-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2) )*math.cos(phi) + v2*math.sin(seta1-phi)*math.cos(phi+ (math.pi/2)) v2_y = ((v2*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2) )*math.sin(phi) + v2*math.sin(seta1-phi)*math.sin(phi+ (math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6130097621 6 (2021-02-01 17:18) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) k = math.atan2(y2-y1, x2-x1) m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(theta1-k)*(m1-m2)) + (2*m2*v2*math.cos(theta2-k))) / (m1+m2)) * math.cos(k) + (v1*math.sin(theta1-k)*math.cos(k+(math.pi/2))) v1_y = (((v1*math.cos(theta1-k)*(m1-m2)) + (2*m2*v2*math.cos(theta2-k))) / (m1+m2)) * math.sin(k) + (v1*math.sin(theta1-k)*math.sin(k+(math.pi/2))) v2_x = (((v2*math.cos(theta2-k)*(m2-m1)) + (2*m1*v1*math.cos(theta1-k))) / (m1+m2)) * math.cos(k) + (v2*math.sin(theta2-k)*math.cos(k+(math.pi/2))) v2_y = (((v2*math.cos(theta2-k)*(m2-m1)) + (2*m1*v1*math.cos(theta1-k))) / (m1+m2)) * math.sin(k) + (v2*math.sin(theta2-k)*math.sin(k+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6130917221 7 (2021-01-31 17:18) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 alpha = math.atan2((y2-y1),(x2-x1)) seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = (((v1*math.cos(seta1-alpha)*(m1-m2)) + (2*m2*v2*math.cos(seta2-alpha)))*(math.cos(alpha))/(m1+m2)) + (v1*math.sin(seta1-alpha)*math.cos(alpha+(math.pi/2))) v1_y = (((v1*math.cos(seta1-alpha)*(m1-m2)) + (2*m2*v2*math.cos(seta2-alpha)))*(math.sin(alpha))/(m1+m2)) + (v1*math.sin(seta1-alpha)*math.sin(alpha+(math.pi/2))) v2_x = (((v2*math.cos(seta2-alpha)*(m2-m1)) + (2*m1*v1*math.cos(seta1-alpha)))*(math.cos(alpha))/(m1+m2)) + (v2*math.sin(seta2-alpha)*math.cos(alpha+(math.pi/2))) v2_y = (((v2*math.cos(seta2-alpha)*(m2-m1)) + (2*m1*v1*math.cos(seta1-alpha)))*(math.sin(alpha))/(m1+m2)) + (v2*math.sin(seta2-alpha)*math.sin(alpha+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6130924621 8 (2021-02-01 22:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=((v1x**2)+(v1y**2))**0.5 v2=((v2x**2)+(v2y**2))**0.5 s1=math.atan2(v1y,v1x) s2=math.atan2(v2y,v2x) a=math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*math.cos(s1-a)*(m1-m2))+(2*m2*v2*math.cos(s2-a)))*(math.cos(a))/(m1+m2))+(v1*math.sin(s1-a)*math.cos(a+(math.pi/2))) v1_y = (((v1*math.cos(s1-a)*(m1-m2))+(2*m2*v2*math.cos(s2-a)))*(math.sin(a))/(m1+m2))+(v1*math.sin(s1-a)*math.sin(a+(math.pi/2))) v2_x = (((v2*math.cos(s2-a)*(m2-m1))+(2*m1*v1*math.cos(s1-a)))*(math.cos(a))/(m1+m2))+(v2*math.sin(s2-a)*math.cos(a+(math.pi/2))) v2_y = (((v2*math.cos(s2-a)*(m2-m1))+(2*m1*v1*math.cos(s1-a)))*(math.sin(a))/(m1+m2))+(v2*math.sin(s2-a)*math.sin(a+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6230041021 9 (2021-02-01 22:03) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a1 = float(math.atan2(v1y,v1x)) a2 = float(math.atan2(v2y,v2x)) b0 = float(math.atan2(abs(y2- y1),abs(x2- x1))) v1 = ((v1x**2) + (v1y**2))**0.5 v2 = ((v2x**2) + (v2y**2))**0.5 v1_x = ((v1*math.cos(a1 - b0)*float(r1**2- r2**2)+ 2*float(r2**2)*v2*math.cos(a2- b0))/ float(r1**2+ r2**2))*math.cos(b0)+v1*math.sin(a1- b0)*math.cos(b0+ 90) v1_y = ((v1*math.cos(a1 - b0)*float(r1**2- r2**2)+ 2*float(r2**2)*v2*math.cos(a2- b0))/ float(r1**2+ r2**2))*math.sin(b0)+v1*math.sin(a1- b0)*math.sin(b0+ 90) v2_x = ((v2*math.cos(a2 - b0)*float(-r1**2+ r2**2)+ 2*float(r1**2)*v1*math.cos(a1- b0))/ float(r1**2+ r2**2))*math.cos(b0)+v2*math.sin(a2- b0)*math.cos(b0+ 90) v2_y = ((v2*math.cos(a2 - b0)*float(-r1**2+ r2**2)+ 2*float(r1**2)*v1*math.cos(a1- b0))/ float(r1**2+ r2**2))*math.sin(b0)+v2*math.sin(a2- b0)*math.sin(b0+ 90) return (v1_x, v1_y), (v2_x, v2_y) |
# 6230092021 10 (2021-01-30 00:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) # insert your code here return (v1_x, v1_y), (v2_x, v2_y) |
# 6230131921 11 (2021-01-31 04:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision a = math.atan2(v1y,v1x) # Theta 1 b = math.atan2(v2y,v2x) # Theta 2 c = r1**2 # m1 d = r2**2 # m2 e = (((v1x)**2) + ((v1y)**2))**0.5 # v1 f = (((v2x)**2) + ((v2y)**2))**0.5 # v2 p = math.atan2(y2-y1,x2-x1) # Phi1 v1_x = (((e*math.cos(a-p)*(c-d) + 2*d*f*math.cos(b-p))*math.cos(p))/(c+d)) + (e*math.sin(a-p)*math.cos(p+(math.pi/2))) v1_y = (((e*math.cos(a-p)*(c-d) + 2*d*f*math.cos(b-p))*math.sin(p))/(c+d)) + (e*math.sin(a-p)*math.sin(p+(math.pi/2))) v2_x = (((f*math.cos(b-p)*(d-c) + 2*c*e*math.cos(a-p))*math.cos(p))/(d+c)) + (f*math.sin(b-p)*math.cos(p+(math.pi/2))) v2_y = (((f*math.cos(b-p)*(d-c) + 2*c*e*math.cos(a-p))*math.sin(p))/(d+c)) + (f*math.sin(b-p)*math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6230133121 12 (2021-02-01 16:17) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = (v1x/math.cos(theta1)*math.cos(theta1-phi)*(m1-m2)+2*m2*v2x/math.cos(theta2)*math.cos(theta2-phi))/(m1+m2)*math.cos(phi)+v1x/math.cos(theta1)*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1y/math.sin(theta1)*math.cos(theta1-phi)*(m1-m2)+2*m2*v2y/math.sin(theta2)*math.cos(theta2-phi))/(m1+m2)*math.sin(phi)+v1y/math.sin(theta1)*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2x/math.cos(theta2)*math.cos(theta2-phi)*(m2-m1)+2*m1*v1x/math.cos(theta1)*math.cos(theta1-phi))/(m1+m2)*math.cos(phi)+v2x/math.cos(theta2)*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v1y/math.sin(theta2)*math.cos(theta2-phi)*(m2-m1)+2*m1*v1y/math.sin(theta1)*math.cos(theta1-phi))/(m1+m2)*math.sin(phi)+v2y/math.sin(theta2)*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6230153721 13 (2021-01-31 01:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y o2=math.atan2(v2y,v2x) o1=math.atan2(v1y,v1x) k=math.atan2((y2-y1),(x2-x1)) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) m1=r1**2 m2=r2**2 v1_x=((v1*math.cos(o1-k)*(m1-m2)+2*m2*v2*math.cos(o2-k))/(m1+m2)*math.cos(k))+(v1*math.sin(o1-k)*math.cos(k+(math.pi/2))) v1_y=((v1*math.cos(o1-k)*(m1-m2)+2*m2*v2*math.cos(o2-k))/(m1+m2)*math.sin(k))+(v1*math.sin(o1-k)*math.sin(k+(math.pi/2))) v2_x=((v2*math.cos(o2-k)*(m2-m1)+2*m1*v1*math.cos(o1-k))/(m1+m2)*math.cos(k))+(v2*math.sin(o2-k)*math.cos(k+(math.pi/2))) v2_y=((v2*math.cos(o2-k)*(m2-m1)+2*m1*v1*math.cos(o1-k))/(m1+m2)*math.sin(k))+(v2*math.sin(o2-k)*math.sin(k+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6230154321 14 (2021-02-01 16:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) b = math.atan2(y1-y2,x1-x2) v1_x = ((((v1*math.cos(a1-b)*(r1**2-r2**2))+(2*(r2**2)*v2*math.cos(a2-b)))/(r1**2+r2**2))*math.cos(b))+(v1*math.sin(a1-b)*math.cos(b+(math.pi/2))) v1_y = ((((v1*math.cos(a1-b)*(r1**2-r2**2))+(2*(r2**2)*v2*math.cos(a2-b)))/(r1**2+r2**2))*math.sin(b))+(v1*math.sin(a1-b)*math.sin(b+(math.pi/2))) v2_x = ((((v2*math.cos(a2-b)*(r2**2-r1**2))+(2*(r1**2)*v1*math.cos(a1-b)))/(r2**2+r1**2))*math.cos(b))+(v2*math.sin(a2-b)*math.cos(b+(math.pi/2))) v2_y = ((((v2*math.cos(a2-b)*(r2**2-r1**2))+(2*(r1**2)*v1*math.cos(a1-b)))/(r2**2+r1**2))*math.sin(b))+(v2*math.sin(a2-b)*math.sin(b+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6230444321 15 (2021-02-01 20:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) θ1 = math.atan2(v1y,v1x) θ2 = math.atan2(v2y,v2x) θ3 = math.atan2((y2-y1),x2-x1) v1_x = (((v1*(math.cos(θ1-θ3))*(m1-m2))+(2*m2*v2*(math.cos(θ2-θ3))))/(m1+m2))*math.cos(θ3) + (v1*math.sin(θ1-θ3)*math.cos(θ3+math.pi/2)) v1_y = (((v1*(math.cos(θ1-θ3))*(m1-m2))+(2*m2*v2*(math.cos(θ2-θ3))))/(m1+m2))*math.sin(θ3) + (v1*math.sin(θ1-θ3)*math.sin(θ3+math.pi/2)) v2_x = (((v2*(math.cos(θ2-θ3))*(m2-m1))+(2*m1*v1*(math.cos(θ1-θ3))))/(m1+m2))*math.cos(θ3) + (v2*math.sin(θ2-θ3)*math.cos(θ3+math.pi/2)) v2_y = (((v2*(math.cos(θ2-θ3))*(m2-m1))+(2*m1*v1*(math.cos(θ1-θ3))))/(m1+m2))*math.sin(θ3) + (v2*math.sin(θ2-θ3)*math.sin(θ3+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6230585121 16 (2021-02-01 17:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here dx = x2-x1 dy = y2-y1 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan(dy/dx) m1 = r1**2 m2 = r2**2 v1 = v1x/math.cos(theta1) v2 = v2x/math.cos(theta2) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231004021 17 (2021-01-30 23:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) t1=(math.atan2(v1y,v1x)) t2=(math.atan2(v2y,v2x)) p=math.atan2((y2-y1),(x2-x1)) v1_x = ((((v1*math.cos(t1-p)*(m1-m2))+(2*m2*v2*math.cos(t2-p)))/(m1+m2))*math.cos(p))+(v1*math.sin(t1-p)*math.cos(p+(math.pi/2))) v1_y = ((((v1*math.cos(t1-p)*(m1-m2))+(2*m2*v2*math.cos(t2-p)))/(m1+m2))*math.sin(p))+(v1*math.sin(t1-p)*math.sin(p+(math.pi/2))) v2_x = ((((v2*math.cos(t2-p)*(m2-m1))+(2*m1*v1*math.cos(t1-p)))/(m2+m1))*math.cos(p))+(v2*math.sin(t2-p)*math.cos(p+(math.pi/2))) v2_y = ((((v2*math.cos(t2-p)*(m2-m1))+(2*m1*v1*math.cos(t1-p)))/(m2+m1))*math.sin(p))+(v2*math.sin(t2-p)*math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231008621 18 (2021-01-30 23:29) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) ceta1=(math.atan2(v1y,v1x)) ceta2=(math.atan2(v2y,v2x)) theta=math.atan2((y2-y1),(x2-x1)) v1_x = ((((v1*math.cos(ceta1-theta)*(m1-m2))+(2*m2*v2*math.cos(ceta2-theta)))/(m1+m2))*math.cos(theta))+(v1*math.sin(ceta1-theta)*math.cos(theta+(math.pi/2))) v1_y = ((((v1*math.cos(ceta1-theta)*(m1-m2))+(2*m2*v2*math.cos(ceta2-theta)))/(m1+m2))*math.sin(theta))+(v1*math.sin(ceta1-theta)*math.sin(theta+(math.pi/2))) v2_x = ((((v2*math.cos(ceta2-theta)*(m2-m1))+(2*m1*v1*math.cos(ceta1-theta)))/(m2+m1))*math.cos(theta))+(v2*math.sin(ceta2-theta)*math.cos(theta+(math.pi/2))) v2_y = ((((v2*math.cos(ceta2-theta)*(m2-m1))+(2*m1*v1*math.cos(ceta1-theta)))/(m2+m1))*math.sin(theta))+(v2*math.sin(ceta2-theta)*math.sin(theta+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231012021 19 (2021-01-29 23:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) m1=r1**2 m2=r2**2 t1=math.atan2(v1y,v1x) t2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) v1_x = ((v1*math.cos(t1-phi)*(m1-m2))+(2*m2*v2*math.cos(t2-phi)))*math.cos(phi)/(m1+m2)+v1*math.sin(t1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(t1-phi)*(m1-m2))+(2*m2*v2*math.cos(t2-phi)))*math.sin(phi)/(m1+m2)+v1*math.sin(t1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(t2-phi)*(m2-m1))+(2*m1*v1*math.cos(t1-phi)))*math.cos(phi)/(m1+m2)+v2*math.sin(t2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(t2-phi)*(m2-m1))+(2*m1*v1*math.cos(t1-phi)))*math.sin(phi)/(m1+m2)+v2*math.sin(t2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231019521 20 (2021-01-31 15:15) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) phi=math.atan2((y2-y1),(x2-x1)) z1=math.atan2(v1y,v1x) z2=math.atan2(v2y,v2x) v1_x = ((((v1*math.cos(z1-phi)*(m1-m2))+(2*m2*v2*math.cos(z2-phi)))/(m1+m2))*math.cos(phi))+(v1*math.sin(z1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(z1-phi)*(m1-m2))+(2*m2*v2*math.cos(z2-phi)))/(m1+m2))*math.sin(phi))+(v1*math.sin(z1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(z2-phi)*(m1-m2))+(2*m1*v1*math.cos(z1-phi)))/(m1+m2))*math.cos(phi))+(v2*math.sin(z2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(z2-phi)*(m1-m2))+(2*m1*v1*math.cos(z1-phi)))/(m1+m2))*math.sin(phi))+(v2*math.sin(z2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231205921 21 (2021-01-31 14:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) dy = y1-y2 dx = x1-x2 phi = math.atan2(dy,dx) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi))) / (m1+m2)*math.cos(phi)) + (v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi))) / (m1+m2)*math.sin(phi)) + (v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi))) / (m1+m2))*math.cos(phi) + (v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi))) / (m1+m2)*math.sin(phi)) + (v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231207121 22 (2021-01-30 17:45) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here #mass m1 = r1**2 m2 = r2**2 #speed v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) #theta angle theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) #phi angle dy = y2-y1 dx = x2-x1 phi_ = math.atan2(dy,dx) v1_x = (v1*math.cos(theta1-phi_)*(m1-m2)+2*m2*v2*math.cos(theta2-phi_))*(math.cos(phi_)/(m1+m2))+v1*math.sin(theta1-phi_)*math.cos(phi_+0.5*math.pi) v1_y = (v1*math.cos(theta1-phi_)*(m1-m2)+2*m2*v2*math.cos(theta2-phi_))*(math.sin(phi_)/(m1+m2))+v1*math.sin(theta1-phi_)*math.sin(phi_+0.5*math.pi) v2_x = (v2*math.cos(theta2-phi_)*(m2-m1)+2*m1*v1*math.cos(theta1-phi_))*(math.cos(phi_)/(m1+m2))+v2*math.sin(theta2-phi_)*math.cos(phi_+0.5*math.pi) v2_y = (v2*math.cos(theta2-phi_)*(m2-m1)+2*m1*v1*math.cos(theta1-phi_))*(math.sin(phi_)/(m1+m2))+v2*math.sin(theta2-phi_)*math.sin(phi_+0.5*math.pi) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231213921 23 (2021-02-01 17:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) alpha = math.atan((y1-y2)/(x1-x2)) v1_x = ((v1*math.cos(theta1-alpha)*(m1-m2)+2*m2*v2*math.cos(theta2-alpha))/(m1+m2))*math.cos(alpha)+v1*math.sin(theta1-alpha)*math.cos(alpha+math.pi/2) v1_y = ((v1*math.cos(theta1-alpha)*(m1-m2)+2*m2*v2*math.cos(theta2-alpha))/(m1+m2))*math.sin(alpha)+v1*math.sin(theta1-alpha)*math.sin(alpha+math.pi/2) v2_x = ((v2*math.cos(theta2-alpha)*(m2-m1)+2*m1*v1*math.cos(theta1-alpha))/(m1+m2))*math.cos(alpha)+v2*math.sin(theta2-alpha)*math.cos(alpha+math.pi/2) v2_y = ((v2*math.cos(theta2-alpha)*(m2-m1)+2*m1*v1*math.cos(theta1-alpha))/(m1+m2))*math.sin(alpha)+v2*math.sin(theta2-alpha)*math.sin(alpha+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231214521 24 (2021-01-31 15:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) p = math.atan((y1-y2)/(x1-x2)) v1x = ((v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))/(m1+m2))*math.cos(p) + v1*math.sin(a1-p)*math.cos(p+(math.pi/2)) v1y = ((v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))/(m1+m2))*math.sin(p) + v1*math.sin(a1-p)*math.sin(p+(math.pi/2)) v2x = ((v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))/(m1+m2))*math.cos(p) + v2*math.sin(a2-p)*math.cos(p+(math.pi/2)) v2y = ((v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))/(m1+m2))*math.sin(p) + v2*math.sin(a2-p)*math.sin(p+(math.pi/2)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6231220221 25 (2021-02-01 17:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here seta1 = math.atan2(v1y,v1x) #seta1 seta2 = math.atan2(v2y,v2x) #seta2 phi = math.atan((y2-y1)/(x2-x1)) #phi m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = ((v1*(math.cos(seta1-phi))*(m1-m2)+(2*m2*v2*math.cos(seta2-phi)))*(math.cos(phi)/(m1+m2)))+v1*math.sin(seta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*(math.cos(seta1-phi))*(m1-m2)+(2*m2*v2*math.cos(seta2-phi)))*(math.sin(phi)/(m1+m2)))+v1*math.sin(seta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*(math.cos(seta2-phi))*(m2-m1)+(2*m1*v1*math.cos(seta1-phi)))*(math.cos(phi)/(m1+m2)))+v2*math.sin(seta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*(math.cos(seta2-phi))*(m2-m1)+(2*m1*v1*math.cos(seta1-phi)))*(math.sin(phi)/(m1+m2)))+v2*math.sin(seta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231222521 26 (2021-01-31 05:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 , m2 = r1*r1 , r2*r2 v1 , v2 = math.sqrt(v1x*v1x+v1y*v1y) , math.sqrt(v2x*v2x+v2y*v2y) theta1 , theta2 = math.atan2(v1y,v1x) , math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1fxr = (v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2) v2fxr = (v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m1+m2) v1yr = v1*math.sin(theta1-phi) v2yr = v2*math.sin(theta2-phi) v1_x = v1fxr*math.cos(phi) + v1yr*math.cos(phi+math.pi/2) v1_y = v1fxr*math.sin(phi) + v1yr*math.sin(phi+math.pi/2) v2_x = v2fxr*math.cos(phi) + v2yr*math.cos(phi+math.pi/2) v2_y = v2fxr*math.sin(phi) + v2yr*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231223121 27 (2021-01-29 23:14) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi=math.atan2((y2-y1),(x2-x1)) m1=r1**2 m2=r2**2 theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) v1_x=(((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y=(((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x=(((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y=(((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231224821 28 (2021-02-01 20:48) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) dx = x2-x1 dy = y2-y1 phi = math.atan2(dy,dx) m1 = r1**2 m2 = r2**2 v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi/(m1+m2)))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi/(m1+m2)))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi/(m1+m2)))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi/(m1+m2)))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231510221 29 (2021-01-31 02:04) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 v1 = ((v1x)**2+(v1y)**2)**0.5 v2 = ((v2x)**2+(v2y)**2)**0.5 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) mn1 = m1-m2 mn2 = m2-m1 mt = m1+m2 b1 = ((v1*math.cos(theta1-phi)*mn1)+(2*math.cos(theta2-phi))*v2*m2)/mt b2 = ((v2*math.cos(theta2-phi)*mn2)+(2*math.cos(theta1-phi))*v1*m1)/mt v1_x = b1*math.cos(phi)+v1*(math.sin(theta1-phi))*(math.cos(phi+(math.pi/2))) v1_y = b1*math.sin(phi)+v1*(math.sin(theta1-phi))*(math.sin(phi+(math.pi/2))) v2_x = b2*math.cos(phi)+v2*(math.sin(theta2-phi))*(math.cos(phi+(math.pi/2))) v2_y = b2*math.sin(phi)+v2*(math.sin(theta2-phi))*(math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231511921 30 (2021-01-31 17:26) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math a = math.atan2(v1y,v1x) #theta1 b = math.atan2(v2y,v2x) #theta2 c = math.atan2(y1-y2,x1-x2) #phi m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = (((v1*(math.cos(a-c))*(m1-m2))+(2*m2*v2*math.cos(b-c)))/(m1+m2))*math.cos(c)+((v1*math.sin(a-c))*(math.cos(c+(math.pi/2)))) v1_y = (((v1*(math.cos(a-c))*(m1-m2))+(2*m2*v2*math.cos(b-c)))/(m1+m2))*math.sin(c)+((v1*math.sin(a-c))*(math.sin(c+(math.pi/2)))) v2_x = (((v2*(math.cos(b-c))*(m2-m1))+(2*m1*v1*math.cos(a-c)))/(m2+m1))*math.cos(c)+((v2*math.sin(b-c))*(math.cos(c+(math.pi/2)))) v2_y = (((v2*(math.cos(b-c))*(m2-m1))+(2*m1*v1*math.cos(a-c)))/(m2+m1))*math.sin(c)+((v2*math.sin(b-c))*(math.sin(c+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231707621 31 (2021-01-29 18:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 ay=math.atan2((y1-y2),(x1-x2)) v1=(v1x**2+v1y**2)**(0.5) v2=(v2x**2+v2y**2)**(0.5) a1=math.atan2(v1y,v1x) a2=math.atan2(v2y,v2x) v1_x = (v1*math.cos(a1-ay)*(m1-m2)+2*m2*v2*math.cos(a2-ay))/(m1+m2)*math.cos(ay)+v1*math.sin(a1-ay)*math.cos(ay+math.pi/2) v1_y = (v1*math.cos(a1-ay)*(m1-m2)+2*m2*v2*math.cos(a2-ay))/(m1+m2)*math.sin(ay)+v1*math.sin(a1-ay)*math.sin(ay+math.pi/2) v2_x = (v2*math.cos(a2-ay)*(m2-m1)+2*m1*v1*math.cos(a1-ay))/(m1+m2)*math.cos(ay)+v2*math.sin(a2-ay)*math.cos(ay+math.pi/2) v2_y = (v2*math.cos(a2-ay)*(m2-m1)+2*m1*v1*math.cos(a1-ay))/(m1+m2)*math.sin(ay)+v2*math.sin(a2-ay)*math.sin(ay+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231709921 32 (2021-01-29 09:04) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # insert your code here m1 = r1**2 m2 = r2**2 mt1 = m1-m2 mt2 = m2-m1 mp = m1+m2 rs = r1+r2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 ceta1 = math.atan2(v1y,v1x) ceta2 = math.atan2(v2y,v2x) phi = math.atan((y1-y2)/(x1-x2)) v1_x = ((((v1*math.cos(ceta1-phi)*mt1)+(2*m2*v2*math.cos(ceta2-phi)))/mp)*math.cos(phi))+(v1*math.sin(ceta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(ceta1-phi)*mt1)+(2*m2*v2*math.cos(ceta2-phi)))/mp)*math.sin(phi))+(v1*math.sin(ceta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(ceta2-phi)*mt2)+(2*m1*v1*math.cos(ceta1-phi)))/mp)*math.cos(phi))+(v2*math.sin(ceta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(ceta2-phi)*mt2)+(2*m1*v1*math.cos(ceta1-phi)))/mp)*math.sin(phi))+(v2*math.sin(ceta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6231718521 33 (2021-01-31 21:33) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1=r1**2 m2=r2**2 v1=((v1x**2)+(v1y**2))**0.5 v2=((v2x**2)+(v2y**2))**0.5 zeta1=math.atan2(v1y,v1x) zeta2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) v1_x=(((v1*(math.cos(zeta1-phi))*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))/(m1+m2))*math.cos(phi)+(v1*(math.sin(zeta1-phi)*(math.cos(phi+(math.pi/2))))) v1_y=(((v1*(math.cos(zeta1-phi))*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))/(m1+m2))*math.sin(phi)+(v1*(math.sin(zeta1-phi)*(math.sin(phi+(math.pi/2))))) v2_x=(((v2*(math.cos(zeta2-phi))*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))/(m1+m2))*math.cos(phi)+(v2*(math.sin(zeta2-phi)*(math.cos(phi+(math.pi/2))))) v2_y=(((v2*(math.cos(zeta2-phi))*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))/(m1+m2))*math.sin(phi)+(v2*(math.sin(zeta2-phi)*(math.sin(phi+(math.pi/2))))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330170421 34 (2021-01-29 16:59) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) P = math.atan((y1-y2)/(x1-x2)) T1 = math.atan2(v1y,v1x) T2 = math.atan2(v2y,v2x) v1_x = (((((v1*math.cos(T1-P))*(m1-m2))+(2*m2*v2*math.cos(T2-P)))/(m1+m2))*math.cos(P))+(v1*math.sin(T1-P)*math.cos(P+(math.pi/2))) v1_y = (((((v1*math.cos(T1-P))*(m1-m2))+(2*m2*v2*math.cos(T2-P)))/(m1+m2))*math.sin(P))+(v1*math.sin(T2-P)*math.sin(P+(math.pi/2))) v2_x = (((((v2*math.cos(T2-P))*(m2-m1))+(2*m1*v1*math.cos(T1-P)))/(m1+m2))*math.cos(P))+(v2*math.sin(T2-P)*math.cos(P+(math.pi/2))) v2_y = (((((v2*math.cos(T2-P))*(m2-m1))+(2*m1*v1*math.cos(T1-P)))/(m1+m2))*math.sin(P))+(v2*math.sin(T2-P)*math.sin(P+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330171021 35 (2021-01-29 00:57) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here varphi = math.atan((y2-y1)/(x2-x1)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(t1-varphi))*(m1-m2))+2*m2*v2*math.cos(t2-varphi))/(m1+m2)*math.cos(varphi))+v1*math.sin(t1-varphi)*math.cos(varphi+math.pi/2) v1_y = (((v1*math.cos(t1-varphi))*(m1-m2)+2*m2*v2*math.cos(t2-varphi))/(m1+m2)*math.sin(varphi))+v1*math.sin(t1-varphi)*math.sin(varphi+math.pi/2) v2_x = (((v2*math.cos(t2-varphi))*(m2-m1)+2*m1*v1*math.cos(t1-varphi))/(m1+m2)*math.cos(varphi))+v2*math.sin(t2-varphi)*math.cos(varphi+math.pi/2) v2_y = ((((v2*math.cos(t2-varphi))*(m2-m1)+2*m1*v1*math.cos(t1-varphi))/(m1+m2))*math.sin(varphi))+v2*math.sin(t2-varphi)*math.sin(varphi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330172721 36 (2021-01-31 02:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here pi=math.pi m1,m2 = r1**2,r2**2 v1,v2 = math.sqrt(v1x**2+v1y**2),math.sqrt(v2x**2+v2y**2) theta1,theta2 = math.atan2(v1y,v1x),math.atan2(v2y,v2x) s_phi = math.atan2(y1-y2,x1-x2) v1_x = x_axis(v1,m1,theta1,v2,m2,theta2,s_phi) v1_y = y_axis(v1,m1,theta1,v2,m2,theta2,s_phi) v2_x = x_axis(v2,m2,theta2,v1,m1,theta1,s_phi) v2_y = y_axis(v2,m2,theta2,v1,m1,theta1,s_phi) return (v1_x, v1_y), (v2_x, v2_y) def x_axis(v1,m1,tt1,v2,m2,tt2,phi): return (v1*cos(tt1-phi)*(m1-m2) + \ 2*m2*v2*cos(tt2-phi))/(m1+m2)*cos(phi) + \ v1*sin(tt1-phi)*cos(phi+pi/2) def cos(x): return math.cos(x) def sin(x): return math.sin(x) def y_axis(v1,m1,tt1,v2,m2,tt2,phi): return (v1*cos(tt1-phi)*(m1-m2) + \ 2*m2*v2*cos(tt2-phi))/(m1+m2)*sin(phi) + \ v1*sin(tt1-phi)*sin(phi+pi/2) |
# 6330173321 37 (2021-01-30 20:24) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 p1 = math.atan2((y2-y1),(x2-x1)) v1_x = (((v1x*math.cos(p1)+v1y*math.sin(p1))*(m1-m2))+2*m2*(v2x*math.cos(p1)+v2y*math.sin(p1)))*(math.cos(p1)/(m1+m2))+((v1y*math.cos(p1))-(v1x*math.sin(p1)))*math.cos(p1+math.pi/2) v1_y = (((v1x*math.cos(p1)+v1y*math.sin(p1))*(m1-m2))+2*m2*(v2x*math.cos(p1)+v2y*math.sin(p1)))*(math.sin(p1)/(m1+m2))+((v1y*math.cos(p1))-(v1x*math.sin(p1)))*math.sin(p1+math.pi/2) v2_x = (((v2x*math.cos(p1)+v2y*math.sin(p1))*(m2-m1))+2*m1*(v1x*math.cos(p1)+v1y*math.sin(p1)))*(math.cos(p1)/(m1+m2))+((v2y*math.cos(p1))-(v2x*math.sin(p1)))*math.cos(p1+math.pi/2) v2_y = (((v2x*math.cos(p1)+v2y*math.sin(p1))*(m2-m1))+2*m1*(v1x*math.cos(p1)+v1y*math.sin(p1)))*(math.sin(p1)/(m1+m2))+((v2y*math.cos(p1))-(v2x*math.sin(p1)))*math.sin(p1+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330174021 38 (2021-01-31 15:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) rad_1 = math.acos(v1x / v1) rad_2 = math.acos(v2x / v2) cnt_ang = math.atan2((y1 - y2), (x1 - x2)) m1 = r1**2 m2 = r2**2 v1_x = ( v1*math.cos(rad_1 - cnt_ang)*(m1 - m2) + 2*m2*v2*math.cos(rad_2 - cnt_ang) )*math.cos(cnt_ang)/(m1 + m2) + v1*math.sin(rad_1 - cnt_ang)*math.cos(cnt_ang + math.pi/2) v1_y = ( v1*math.cos(rad_1 - cnt_ang)*(m1 - m2) + 2*m2*v2*math.cos(rad_2 - cnt_ang) )*math.sin(cnt_ang)/(m1 + m2) + v1*math.sin(rad_1 - cnt_ang)*math.sin(cnt_ang + math.pi/2) v2_x = ( v2*math.cos(rad_2 - cnt_ang)*(m2 - m1) + 2*m1*v1*math.cos(rad_1 - cnt_ang) )*math.cos(cnt_ang)/(m1 + m2) + v2*math.sin(rad_2 - cnt_ang)*math.cos(cnt_ang + math.pi/2) v2_y = ( v2*math.cos(rad_2 - cnt_ang)*(m2 - m1) + 2*m1*v1*math.cos(rad_1 - cnt_ang) )*math.sin(cnt_ang)/(m1 + m2) + v2*math.sin(rad_2 - cnt_ang)*math.sin(cnt_ang + math.pi/2) ''' v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*(r1**2-r2**2))+(2*(r2**2)*v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))))*math.cos(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v1*math.sin(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*math.cos(math.atan2(y1-y2,x2-x1)+(math.pi/2))) v1_y = ((v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*(r1**2-r2**2))+(2*(r2**2)*v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))))*math.sin(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v1*math.sin(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*math.sin(math.atan2(y1-y2,x2-x1)+(math.pi/2))) v2_x = ((v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*(r2**2-r1**2))+(2*(r1**2)*v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))))*math.cos(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v2*math.sin(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*math.cos(math.atan2(y1-y2,x2-x1)+(math.pi/2))) v2_y = ((v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*(r2**2-r1**2))+(2*(r1**2)*v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))))*math.sin(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v2*math.sin(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*math.sin(math.atan2(y1-y2,x2-x1)+(math.pi/2))) ''' return (v1_x, v1_y), (v2_x, v2_y) |
# 6330176221 39 (2021-01-29 22:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) v1_x = (v1*(math.cos(theta1-phi))*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*(math.cos(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = (v1*(math.cos(theta1-phi))*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*(math.sin(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = (v2*(math.cos(theta2-phi))*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*(math.cos(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = (v2*(math.cos(theta2-phi))*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*(math.sin(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330177921 40 (2021-01-29 19:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y v1 = math.sqrt(v1_x**2+v1_y**2) v2 = math.sqrt(v2_x**2+v2_y**2) deg1 = math.atan2(v1_y,v1_x) deg2 = math.atan2(v2_y,v2_x) deg0 = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1_x = ((v1*math.cos(deg1-deg0)*(m1-m2))+(2*m2*v2*math.cos(deg2-deg0)))*(math.cos(deg0))/(m1+m2)\ +v1*math.sin(deg1-deg0)*math.cos(deg0+math.pi/2) v1_y = ((v1*math.cos(deg1-deg0)*(m1-m2))+(2*m2*v2*math.cos(deg2-deg0)))*(math.sin(deg0))/(m1+m2)\ +v1*math.sin(deg1-deg0)*math.sin(deg0+math.pi/2) v2_x = ((v2*math.cos(deg2-deg0)*(m2-m1))+(2*m1*v1*math.cos(deg1-deg0)))*(math.cos(deg0))/(m1+m2)\ +v2*math.sin(deg2-deg0)*math.cos(deg0+math.pi/2) v2_y = ((v2*math.cos(deg2-deg0)*(m2-m1))+(2*m1*v1*math.cos(deg1-deg0)))*(math.sin(deg0))/(m1+m2)\ +v2*math.sin(deg2-deg0)*math.sin(deg0+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330178521 41 (2021-01-30 19:16) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math a = math.atan2(y1-y2, x1-x2) a1 = math.atan2(v1y, v1x) a2 = math.atan2(v2y, v2x) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m = v1*math.cos(a1-a)*(m1-m2)+2*m2*v2*math.cos(a2-a) n = v1*math.sin(a1-a) o = m1+m2 j = v2*math.cos(a2-a)*(m2-m1)+2*m1*v1*math.cos(a1-a) k = v2*math.sin(a2-a) v1_x = (m*math.cos(a)/o) + n*math.cos(a+math.pi/2) v1_y = (m*math.sin(a)/o) + n*math.sin(a+math.pi/2) v2_x = (j*math.cos(a)/o) + k*math.cos(a+math.pi/2) v2_y = (j*math.sin(a)/o) + k*math.sin(a+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330179121 42 (2021-01-28 19:07) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) p = math.atan2((y1-y2),(x1-x2)) v1 = v1y/math.sin(s1) v2 = v2y/math.sin(s2) v1_x = (((v1*math.cos(s1-p)*(m1-m2)+2*m2*v2*math.cos(s2-p)))/ \ (m1+m2)*math.cos(p)) + (v1*math.sin(s1-p)*math.cos(p+math.pi/2)) v1_y = (((v1*math.cos(s1-p)*(m1-m2)+2*m2*v2*math.cos(s2-p)))/ \ (m1+m2)*math.sin(p)) + (v1*math.sin(s1-p)*math.sin(p+math.pi/2)) v2_x = (((v2*math.cos(s2-p)*(m2-m1)+2*m1*v1*math.cos(s1-p)))/ \ (m1+m2)*math.cos(p)) + (v2*math.sin(s2-p)*math.cos(p+math.pi/2)) v2_y = (((v2*math.cos(s2-p)*(m2-m1)+2*m1*v1*math.cos(s1-p)))/ \ (m1+m2)*math.sin(p)) + (v2*math.sin(s2-p)*math.sin(p+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330180721 43 (2021-01-28 15:15) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2; m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2); v2= math.sqrt(v2x**2 + v2y**2) deg1 = math.atan2(v1y,v1x); deg2 = math.atan2(v2y,v2x); deg3= math.atan2(y2-y1,x2-x1) v1_x = (v1*math.cos(deg1-deg3)*(m1-m2) + 2*m2*v2*math.cos(deg2-deg3))/(m1+m2)*math.cos(deg3) + v1*math.sin(deg1-deg3)*math.cos(deg3+math.pi/2) v1_y = (v1*math.cos(deg1-deg3)*(m1-m2) + 2*m2*v2*math.cos(deg2-deg3))/(m1+m2)*math.sin(deg3) + v1*math.sin(deg1-deg3)*math.sin(deg3+math.pi/2) v2_x = (v2*math.cos(deg2-deg3)*(m2-m1) + 2*m1*v1*math.cos(deg1-deg3))/(m1+m2)*math.cos(deg3) + v2*math.sin(deg2-deg3)*math.cos(deg3+math.pi/2) v2_y = (v2*math.cos(deg2-deg3)*(m2-m1) + 2*m1*v1*math.cos(deg1-deg3))/(m1+m2)*math.sin(deg3) + v2*math.sin(deg2-deg3)*math.sin(deg3+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330181321 44 (2021-01-31 23:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here st1=math.atan2(v1y,v1x) st2=math.atan2(v2y,v2x) mum=math.atan2(abs(y2-y1),abs(x2-x1)) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) korn1=v1*(math.cos(st1-mum))*(m1-m2)+2*m2*v2*math.cos(st2-mum) v1_x =(korn1*math.cos(mum)/(m1+m2))+v1*math.sin(st1-mum)*math.cos(mum+math.pi/2) v1_y =(korn1*math.sin(mum)/(m1+m2))+v1*math.sin(st1-mum)*math.sin(mum+math.pi/2) korn2=v2*(math.cos(st2-mum))*(m2-m1)+2*m1*v1*math.cos(st1-mum) v2_x = (korn2*math.cos(mum)/(m1+m2))+v2*math.sin(st2-mum)*math.cos(mum+math.pi/2) v2_y = (korn2*math.sin(mum)/(m1+m2))+v2*math.sin(st2-mum)*math.sin(mum+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330182021 45 (2021-01-30 16:37) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 s = math.atan2((y1-y2),(x1-x2)) c1 = math.atan2(v1y,v1x) c2 = math.atan2(v2y,v2x) v1 = v1x/math.cos(c1) v2 = v2x/math.cos(c2) v1_x = (((v1*math.cos(c1-s)*(m1-m2))+(2*m2*v2*math.cos(c2-s)))*math.cos(s)/(m1+m2))+(v1*math.sin(c1-s)*math.cos(s+math.pi/2)) v1_y = (((v1*math.cos(c1-s)*(m1-m2))+(2*m2*v2*math.cos(c2-s)))*math.sin(s)/(m1+m2))+(v1*math.sin(c1-s)*math.sin(s+math.pi/2)) v2_x = (((v2*math.cos(c2-s)*(m2-m1))+(2*m1*v1*math.cos(c1-s)))*math.cos(s)/(m2+m1))+(v2*math.sin(c2-s)*math.cos(s+math.pi/2)) v2_y = (((v2*math.cos(c2-s)*(m2-m1))+(2*m1*v1*math.cos(c1-s)))*math.sin(s)/(m2+m1))+(v2*math.sin(c2-s)*math.sin(s+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330183621 46 (2021-01-29 22:02) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here angle1=math.atan2(v1y,v1x) angle2=math.atan2(v2y,v2x) dy=y1-y2 dx=x1-x2 angle=math.atan2(dy,dx) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) a1_a = angle1-angle a2_a = angle2-angle v1_x = ((v1*math.cos(a1_a)*(m1-m2)+2*m2*v2*math.cos(a2_a))*math.cos(angle)/(m1+m2))+(v1*math.sin(a1_a)*math.cos(angle+(math.pi/2))) v1_y = ((v1*math.cos(a1_a)*(m1-m2)+2*m2*v2*math.cos(a2_a))*math.sin(angle)/(m1+m2))+(v1*math.sin(a1_a)*math.sin(angle+(math.pi/2))) v2_x = ((v2*math.cos(a2_a)*(m2-m1)+2*m1*v1*math.cos(a1_a))*math.cos(angle)/(m1+m2))+(v2*math.sin(a2_a)*math.cos(angle+(math.pi/2))) v2_y = ((v2*math.cos(a2_a)*(m2-m1)+2*m1*v1*math.cos(a1_a))*math.sin(angle)/(m1+m2))+(v2*math.sin(a2_a)*math.sin(angle+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330184221 47 (2021-01-31 01:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) p = math.atan2(y1-y2,x1-x2) v1 = math.sqrt((v1x**2) + (v1y**2)) v2 = math.sqrt((v2x**2) + (v2y**2)) v1_x = (((v1*math.cos(o1-p)*(m1-m2)) + (2*m2*v2*math.cos(o2-p)))*(math.cos(p)/(m1+m2))) + (v1*math.sin(o1-p)*math.cos(p+(math.pi/2))) v1_y = (((v1*math.cos(o1-p)*(m1-m2)) + (2*m2*v2*math.cos(o2-p)))*(math.sin(p)/(m1+m2))) + (v1*math.sin(o1-p)*math.sin(p+(math.pi/2))) v2_x = (((v2*math.cos(o2-p)*(m2-m1)) + (2*m1*v1*math.cos(o1-p)))*(math.cos(p)/(m2+m1))) + (v2*math.sin(o2-p)*math.cos(p+(math.pi/2))) v2_y = (((v2*math.cos(o2-p)*(m2-m1)) + (2*m1*v1*math.cos(o1-p)))*(math.sin(p)/(m2+m1))) + (v2*math.sin(o2-p)*math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330185921 48 (2021-02-01 17:18) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt((v1y)**2+(v1x)**2) v2=math.sqrt((v2x)**2+(v2y)**2) d1=math.atan2(v1y,v1x) d2=math.atan2(v2y,v1x) g=math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1_x =(v1*math.cos(d1-g)*(m1-m2)+2*m2*v2*math.cos(d2-g))*math.cos(g)/(m1+m2)+v1*math.sin(d1-g)*math.cos(g+math.pi/2) v1_y =(v1*math.cos(d1-g)*(m1-m2)+2*m2*v2*math.cos(d2-g))*math.sin(g)/(m1+m2)+v1*math.sin(d1-g)*math.sin(g+math.pi/2) v2_x =(v2*math.cos(d2-g)*(m2-m1)+2*m1*v1*math.cos(d1-g))*math.cos(g)/(m2+m1)+v2*math.sin(d2-g)*math.cos(g+math.pi/2) v2_y =(v2*math.cos(d2-g)*(m2-m1)+2*m1*v1*math.cos(d1-g))*math.sin(g)/(m2+m1)+v2*math.sin(d2-g)*math.sin(g+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330186521 49 (2021-01-30 23:17) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 gamma = math.atan2((y1-y2),(x1-x2)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (v1*math.cos(theta1-gamma)*(m1-m2)+2*m2*v2*math.cos(theta2-gamma))/(m1+m2)*math.cos(gamma)+v1*math.sin(theta1-gamma)*math.cos(gamma+math.pi/2) v1_y = (v1*math.cos(theta1-gamma)*(m1-m2)+2*m2*v2*math.cos(theta2-gamma))/(m1+m2)*math.sin(gamma) +v1*math.sin(theta1-gamma)*math.sin(gamma+math.pi/2) v2_x = (v2*math.cos(theta2-gamma)*(m2-m1)+2*m1*v1*math.cos(theta1-gamma))/(m1+m2)*math.cos(gamma)+v2*math.sin(theta2-gamma)*math.cos(gamma+math.pi/2) v2_y = (v2*math.cos(theta2-gamma)*(m2-m1)+2*m1*v1*math.cos(theta1-gamma))/(m1+m2)*math.sin(gamma)+v2*math.sin(theta2-gamma)*math.sin(gamma+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330187121 50 (2021-01-28 16:46) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1 = math.sqrt(v1x ** 2 + v1y ** 2) v2 = math.sqrt(v2x ** 2 + v2y ** 2) theta1 = math.atan2(v1y , v1x) theta2 = math.atan2(v2y , v2x) phase = math.atan((y2 - y1)/(x2 - x1)) m1 = r1 ** 2 m2 = r2 ** 2 # insert your code here v1_x = ((((v1 * math.cos(theta1 - phase) * (m1 - m2)) + (2 * m2 * v2 * math.cos(theta2 - phase)))/(m1 + m2)) * math.cos(phase)) + (v1 * math.sin(theta1 - phase) * math.cos(phase + (math.pi / 2))) v1_y = ((((v1 * math.cos(theta1 - phase) * (m1 - m2)) + (2 * m2 * v2 * math.cos(theta2 - phase)))/(m1 + m2)) * math.sin(phase)) + (v1 * math.sin(theta1 - phase) * math.sin(phase + (math.pi / 2))) v2_x = ((((v2 * math.cos(theta2 - phase) * (m2 - m1)) + (2 * m1 * v1 * math.cos(theta1 - phase)))/(m1 + m2)) * math.cos(phase)) + (v2 * math.sin(theta2 - phase) * math.cos(phase + (math.pi / 2))) v2_y = ((((v2 * math.cos(theta2 - phase) * (m2 - m1)) + (2 * m1 * v1 * math.cos(theta1 - phase)))/(m1 + m2)) * math.sin(phase)) + (v2 * math.sin(theta2 - phase) * math.sin(phase + (math.pi / 2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330188821 51 (2021-02-01 23:14) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # m1=r1**2 m2=r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) an_1 = math.atan2(v1y , v1x) an_2 = math.atan2(v2y , v2x) an_x = math.atan((y2-y1)/(x2-x1)) v1_x = v1 * math.cos(an_1-an_x) v1_x = v1_x * (m1 - m2) v1_x = v1_x + (2*m2*v2*math.cos(an_2-an_x)) v1_x = v1_x / (m1 + m2) v1_x = v1_x * math.cos(an_x) v1_x = v1_x + (v1*math.sin(an_1-an_x)*math.cos(an_x+(math.pi/2))) v1_y = v1 * math.cos(an_1-an_x) v1_y = v1_y * (m1 - m2) v1_y = v1_y + (2*m2*v2*math.cos(an_2-an_x)) v1_y = v1_y / (m1 + m2) v1_y = v1_y * math.sin(an_x) v1_y = v1_y + (v1*math.sin(an_1-an_x)*math.sin(an_x+(math.pi/2))) v2_x = v2 * math.cos(an_2-an_x) v2_x = v2_x * (m2 - m1) v2_x = v2_x + (2*m1*v1*math.cos(an_1-an_x)) v2_x = v2_x / (m1 + m2) v2_x = v2_x * math.cos(an_x) v2_x = v2_x + (v2*math.sin(an_2-an_x)*math.cos(an_x+(math.pi/2))) v2_y = v2 * math.cos(an_2-an_x) v2_y = v2_y * (m2 - m1) v2_y = v2_y + (2*m1*v1*math.cos(an_1-an_x)) v2_y = v2_y / (m1 + m2) v2_y = v2_y * math.sin(an_x) v2_y = v2_y + (v2*math.sin(an_2-an_x)*math.sin(an_x+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330189421 52 (2021-01-30 22:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**(1/2) v2 = (v2x**2+v2y**2)**(1/2) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330190021 53 (2021-01-31 13:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here #v1 = math.sqrt(v1x**2+v1y**2) #ceta_1 = math.atan2(abs(v1y), abs(v1x)) #v2 = math.sqrt(v2x**2+v2y**2) #ceta_2 = math.atan2(abs(v2y), abs(v2x)) m1 = r1**2 m2 = r2**2 phi = math.atan2((y2-y1), (x2-x1)) v1_x = ( (v1x*math.cos(phi)+v1y*math.sin(phi))*(m1-m2)+(2*m2*(v2x*math.cos(phi)+v2y*math.sin(phi))) )/(m1+m2) * math.cos(phi) + (v1y*math.cos(phi)-v1x*math.sin(phi))*math.cos(phi+math.pi/2) v1_y = ( (v1x*math.cos(phi)+v1y*math.sin(phi))*(m1-m2)+(2*m2*(v2x*math.cos(phi)+v2y*math.sin(phi))) )/(m1+m2) * math.sin(phi) + (v1y*math.cos(phi)-v1x*math.sin(phi))*math.sin(phi+math.pi/2) v2_x = ( (v2x*math.cos(phi)+v2y*math.sin(phi))*(m2-m1)+(2*m1*(v1x*math.cos(phi)+v1y*math.sin(phi))) )/(m1+m2) * math.cos(phi) + (v2y*math.cos(phi)-v2x*math.sin(phi))*math.cos(phi+math.pi/2) v2_y = ( (v2x*math.cos(phi)+v2y*math.sin(phi))*(m2-m1)+(2*m1*(v1x*math.cos(phi)+v1y*math.sin(phi))) )/(m1+m2) * math.sin(phi) + (v2y*math.cos(phi)-v2x*math.sin(phi))*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330191621 54 (2021-02-01 16:44) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) z1 = math.atan2(v1y, (v1x+0.01)) z2 = math.atan2(v2y, (v2x+0.01)) phi = math.atan2((y2 - y1), (x2 - x1)) m1 = r1**2 m2 = r2**2 v1_x = (v1 * math.cos(z1 - phi) * (m1 - m2) + 2 * m2 * v2 * math.cos(z2 - phi)) * math.cos(phi) / (m1 + m2) + v1 * math.sin(z1 - phi) * math.cos(phi + math.pi / 2) v1_y = (v1 * math.cos(z1 - phi) * (m1 - m2) + 2 * m2 * v2 * math.cos(z2 - phi)) * math.sin(phi) / (m1 + m2) + v1 * math.sin(z1 - phi) * math.sin(phi + math.pi / 2) v2_x = (v2 * math.cos(z2 - phi) * (m2 - m1) + 2 * m1 * v1 * math.cos(z1 - phi)) * math.cos(phi) / (m1 + m2) + v2 * math.sin(z2 - phi) * math.cos(phi + math.pi / 2) v2_y = (v2 * math.cos(z2 - phi) * (m2 - m1) + 2 * m1 * v1 * math.cos(z1 - phi)) * math.sin(phi) / (m1 + m2) + v2 * math.sin(z2 - phi) * math.sin(phi + math.pi / 2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330192221 55 (2021-02-01 15:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1=r1**2 m2=r2**2 phi=math.atan2(y1-y2,x1-x2) v1=math.pow(v1x**2+v1y**2,1/2) v2=math.pow(v2x**2+v2y**2,1/2) v1_x=(v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y=(v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x=(v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y=(v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330193921 56 (2021-01-30 00:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here e1 = math.atan2(v1y , v1x) e2 = math.atan2(v2y , v2x) f = math.atan2((y1-y2),(x1-x2)) m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**(0.5) v2 = (v2x**2 + v2y**2)**(0.5) v1_x = ((v1*math.cos(e1-f)*(m1-m2)+2*m2*v2*math.cos(e2-f))/(m1+m2))*math.cos(f)+v1*math.sin(e1-f)*math.cos(f+(math.pi/2)) v1_y = ((v1*math.cos(e1-f)*(m1-m2)+2*m2*v2*math.cos(e2-f))/(m1+m2))*math.sin(f)+v1*math.sin(e1-f)*math.sin(f+(math.pi/2)) v2_x = ((v2*math.cos(e2-f)*(m2-m1)+2*m1*v1*math.cos(e1-f))/(m1+m2))*math.cos(f)+v2*math.sin(e2-f)*math.cos(f+(math.pi/2)) v2_y = ((v2*math.cos(e2-f)*(m2-m1)+2*m1*v1*math.cos(e1-f))/(m1+m2))*math.sin(f)+v2*math.sin(e2-f)*math.sin(f+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330194521 57 (2021-01-31 15:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 fee = math.atan2((y2-y1),(x2-x1)) w1 = math.cos(fee) w2 = math.sin(fee) v1_x = (((v1x*w1+v1y*w2)*(m1-m2)+(2*m2)*(v2x*w1+v2y*w2))/(m1+m2))*w1+(v1y*w1-v1x*w2)*(math.cos(fee+math.pi/2)) v1_y = (((v1x*w1+v1y*w2)*(m1-m2)+(2*m2)*(v2x*w1+v2y*w2))/(m1+m2))*w2+(v1y*w1-v1x*w2)*(math.sin(fee+math.pi/2)) v2_x = (((v2x*w1+v2y*w2)*(m2-m1)+(2*m1)*(v1x*w1+v1y*w2))/(m1+m2))*w1+(v2y*w1-v2x*w2)*(math.cos(fee+math.pi/2)) v2_y = (((v2x*w1+v2y*w2)*(m2-m1)+(2*m1)*(v1x*w1+v1y*w2))/(m1+m2))*w2+(v2y*w1-v2x*w2)*(math.sin(fee+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330197421 58 (2021-01-31 22:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.cos(phi)\ +v1*math.sin(seta1-phi)*math.cos(phi+(math.pi)/2) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.sin(phi)\ +v1*math.sin(seta1-phi)*math.sin(phi+(math.pi)/2) v2_x = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.cos(phi)\ +v2*math.sin(seta2-phi)*math.cos(phi+(math.pi)/2) v2_y = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.sin(phi)\ +v2*math.sin(seta2-phi)*math.sin(phi+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330198021 59 (2021-02-01 23:05) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) p = math.atan2((y1-y2),(x1-x2)) v1_x = ((v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))/(m1+m2))*(math.cos(p))+v1*math.sin(a1-p)*math.cos(p+(math.pi/2)) v1_y = ((v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))/(m1+m2))*(math.sin(p))+v1*math.sin(a1-p)*math.sin(p+(math.pi/2)) v2_x = ((v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))/(m1+m2))*(math.cos(p))+v2*math.sin(a2-p)*math.cos(p+(math.pi/2)) v2_y = ((v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))/(m1+m2))*(math.sin(p))+v2*math.sin(a2-p)*math.sin(p+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330199721 60 (2021-02-01 15:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) ons = math.atan2(y1-y2,x1-x2) v1_x = ((v1*math.cos(zeta1-ons)*((r1**2)-(r2**2))+2*(r2**2)*v2*math.cos(zeta2-ons))/((r1**2)+(r2**2)))*math.cos(ons)+v1*math.sin(zeta1-ons)*math.cos(ons+(math.pi/2)) v1_y = ((v1*math.cos(zeta1-ons)*((r1**2)-(r2**2))+2*(r2**2)*v2*math.cos(zeta2-ons))/((r1**2)+(r2**2)))*math.sin(ons)+v1*math.sin(zeta1-ons)*math.sin(ons+(math.pi/2)) v2_x = ((v2*math.cos(zeta2-ons)*((r2**2)-(r1**2))+2*(r1**2)*v1*math.cos(zeta1-ons))/((r1**2)+(r2**2)))*math.cos(ons)+v2*math.sin(zeta2-ons)*math.cos(ons+(math.pi/2)) v2_y = ((v2*math.cos(zeta2-ons)*((r2**2)-(r1**2))+2*(r1**2)*v1*math.cos(zeta1-ons))/((r1**2)+(r2**2)))*math.sin(ons)+v2*math.sin(zeta2-ons)*math.sin(ons+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330200621 61 (2021-01-29 01:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) ons = math.atan2(y1-y2,x1-x2) v1x = ((v1*math.cos(zeta1-ons)*(m1-m2)+2*m2*v2*math.cos(zeta2-ons))/(m1+m2))*math.cos(ons)+v1*math.sin(zeta1-ons)*math.cos(ons+(math.pi/2)) v1y = ((v1*math.cos(zeta1-ons)*(m1-m2)+2*m2*v2*math.cos(zeta2-ons))/(m1+m2))*math.sin(ons)+v1*math.sin(zeta1-ons)*math.sin(ons+(math.pi/2)) v2x = ((v2*math.cos(zeta2-ons)*(m2-m1)+2*m1*v1*math.cos(zeta1-ons))/(m1+m2))*math.cos(ons)+v2*math.sin(zeta2-ons)*math.cos(ons+(math.pi/2)) v2y = ((v2*math.cos(zeta2-ons)*(m2-m1)+2*m1*v1*math.cos(zeta1-ons))/(m1+m2))*math.sin(ons)+v2*math.sin(zeta2-ons)*math.sin(ons+(math.pi/2)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330201221 62 (2021-01-29 23:11) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 m1 = r1**2 m2 = r2**2 c1 = math.atan2(v1y , v1x) c2 = math.atan2(v2y , v2x) phi = math.atan2((y1-y2),(x1-x2)) v1_x = (((((v1*math.cos(c1-phi))*(m1-m2))+(2*m2*v2*(math.cos(c2-phi))))/(m1+m2))*math.cos(phi))+((v1*math.sin(c1-phi))*math.cos(phi+(math.pi/2))) v1_y = (((((v1*math.cos(c1-phi))*(m1-m2))+(2*m2*v2*(math.cos(c2-phi))))/(m1+m2))*math.sin(phi))+((v1*math.sin(c1-phi))*math.sin(phi+(math.pi/2))) v2_x = (((((v2*math.cos(c2-phi))*(m2-m1))+(2*m1*v1*(math.cos(c1-phi))))/(m1+m2))*math.cos(phi))+((v2*math.sin(c2-phi))*math.cos(phi+(math.pi/2))) v2_y = (((((v2*math.cos(c2-phi))*(m2-m1))+(2*m1*v1*(math.cos(c1-phi))))/(m1+m2))*math.sin(phi))+((v2*math.sin(c2-phi))*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330202921 63 (2021-02-01 20:30) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 W=math.atan2((y1-y2),(x1-x2)) Q1=math.atan2(v1y,v1x) Q2=math.atan2(v2y,v2x) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(Q1-W)*(m1-m2)+2*m2*v2*math.cos(Q2-W))/(m1+m2))*math.cos(W)+v1*math.sin(Q1-W)*math.cos(W+math.pi/2) v1_y = ((v1*math.cos(Q1-W)*(m1-m2)+2*m2*v2*math.cos(Q2-W))/(m1+m2))*math.sin(W)+v1*math.sin(Q1-W)*math.sin(W+math.pi/2) v2_x = ((v2*math.cos(Q2-W)*(m2-m1)+2*m1*v1*math.cos(Q1-W))/(m1+m2))*math.cos(W)+v2*math.sin(Q2-W)*math.cos(W+math.pi/2) v2_y = ((v2*math.cos(Q2-W)*(m2-m1)+2*m1*v1*math.cos(Q1-W))/(m1+m2))*math.sin(W)+v2*math.sin(Q2-W)*math.sin(W+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330203521 64 (2021-01-30 15:02) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math m1 = (r1)**2 m2 = (r2)**2 s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) y = math.atan2((y1-y2),(x1-x2)) v1 = math.sqrt((v1x)**2 + (v1y)**2) v2 = math.sqrt((v2x)**2 + (v2y)**2) v1_x = (((v1*(math.cos(s1-y))*(m1 - m2)) + 2*m2*v2*math.cos(s2-y))/(m1+m2))*(math.cos(y)) + (v1*(math.sin(s1 - y))*(math.cos(y+ (math.pi)/2))) v1_y = (((v1*(math.cos(s1-y))*(m1 - m2)) + 2*m2*v2*math.cos(s2-y))/(m1+m2))*(math.sin(y)) + (v1*(math.sin(s1 - y))*(math.sin(y+ (math.pi)/2))) v2_x = (((v2*(math.cos(s2-y))*(m2 - m1)) + 2*m1*v1*math.cos(s1-y))/(m1+m2))*(math.cos(y)) + (v2*(math.sin(s2 - y))*(math.cos(y+ (math.pi)/2))) v2_y = (((v2*(math.cos(s2-y))*(m2 - m1)) + 2*m1*v1*math.cos(s1-y))/(m1+m2))*(math.sin(y)) + (v2*(math.sin(s2 - y))*(math.sin(y+ (math.pi)/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330205821 65 (2021-01-30 00:18) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y,v2x) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) phi = math.atan2((y1-y2),(x1-x2)) m1 = r1**2 m2 = r2**2 v1_x = (((((v1*math.cos(theta1-phi))*(m1-m2))+2*m2*v2*math.cos(theta2-phi))/(m1+m2)))* math.cos(phi) +v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = (((((v1*math.cos(theta1-phi))*(m1-m2))+2*m2*v2*math.cos(theta2-phi))/(m1+m2)))* math.sin(phi) +v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = (((((v2*math.cos(theta2-phi))*(m2-m1))+2*m1*v1*math.cos(theta1-phi))/(m2+m1)))* math.cos(phi) +v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = (((((v2*math.cos(theta2-phi))*(m2-m1))+2*m1*v1*math.cos(theta1-phi))/(m2+m1)))* math.sin(phi) +v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330206421 66 (2021-01-30 15:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) v1 = v1y/math.sin(seta1) v2 = v2y/math.sin(seta2) m1 = r1**2 m2 = r2**2 file = math.atan(((y2-y1)/(x2-x1))) v1_x = ((((v1*math.cos(seta1-file)*(m1-m2))+(2*m2*v2*math.cos(seta2-file)))/(m1+m2))*math.cos(file))+(v1*math.sin(seta1-file)*math.cos(file+(math.pi/2))) v1_y = ((((v1*math.cos(seta1-file)*(m1-m2))+(2*m2*v2*math.cos(seta2-file)))/(m1+m2))*math.sin(file))+(v1*math.sin(seta1-file)*math.sin(file+(math.pi/2))) v2_x = ((((v2*math.cos(seta2-file)*(m2-m1))+(2*m1*v1*math.cos(seta1-file)))/(m2+m1))*math.cos(file))+(v2*math.sin(seta2-file)*math.cos(file+(math.pi/2))) v2_y = ((((v2*math.cos(seta2-file)*(m2-m1))+(2*m1*v1*math.cos(seta1-file)))/(m2+m1))*math.sin(file))+(v2*math.sin(seta2-file)*math.sin(file+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330208721 67 (2021-01-29 18:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): phi = math.atan((y1-y2)/(x1-x2)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) v1x = (v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1y = (v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2x = (v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2y = (v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330209321 68 (2021-01-31 00:25) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi=math.atan2((y1-y2),(x1-x2)) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) ceta1=math.atan2(v1y,v1x) ceta2=math.atan2(v2y,v2x) v1_x=((((v1*math.cos(ceta1-phi)*(m1-m2))+(2*m2*v2*math.cos(ceta2-phi)))*math.cos(phi))/(m1+m2))+(v1*math.sin(ceta1-phi)*math.cos(phi+math.pi*0.5)) v1_y=((((v1*math.cos(ceta1-phi)*(m1-m2))+(2*m2*v2*math.cos(ceta2-phi)))*math.sin(phi))/(m1+m2))+(v1*math.sin(ceta1-phi)*math.sin(phi+math.pi*0.5)) v2_x=((((v2*math.cos(ceta2-phi)*(m2-m1))+(2*m1*v1*math.cos(ceta1-phi)))*math.cos(phi))/(m1+m2))+(v2*math.sin(ceta2-phi)*math.cos(phi+math.pi*0.5)) v2_y=((((v2*math.cos(ceta2-phi)*(m2-m1))+(2*m1*v1*math.cos(ceta1-phi)))*math.sin(phi))/(m1+m2))+(v2*math.sin(ceta2-phi)*math.sin(phi+math.pi*0.5)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330210921 69 (2021-01-28 12:25) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) def cos(data): return(math.cos(data)) def sin(data): return(math.sin(data)) def v1x(): part1 = (v1*cos(zeta1-phi)*(m1-m2) + 2*m2*v2*cos(zeta2-phi)) / (m1+m2) part2 = v1*sin(zeta1-phi)*cos(phi+math.pi/2) return(part1*cos(phi)+part2) def v1y(): part1 = (v1*cos(zeta1-phi)*(m1-m2) + 2*m2*v2*cos(zeta2-phi)) / (m1+m2) part2 = v1*sin(zeta1-phi)*sin(phi+math.pi/2) return(part1*sin(phi)+part2) def v2x(): part1 = (v2*cos(zeta2-phi)*(m2-m1) + 2*m1*v1*cos(zeta1-phi)) / (m2+m1) part2 = v2*sin(zeta2-phi)*cos(phi+math.pi/2) return(part1*cos(phi)+part2) def v2y(): part1 = (v2*cos(zeta2-phi)*(m2-m1) + 2*m1*v1*cos(zeta1-phi)) / (m2+m1) part2 = v2*sin(zeta2-phi)*sin(phi+math.pi/2) return(part1*sin(phi)+part2) v1_x = v1x() v1_y = v1y() v2_x = v2x() v2_y = v2y() return (v1_x, v1_y), (v2_x, v2_y) |
# 6330211521 70 (2021-02-01 12:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*(r1**2-r2**2))+(2*(r2**2)*v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))))*math.cos(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v1*math.sin(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*math.cos(math.atan2(y1-y2,x2-x1)+(math.pi/2))) v1_y = ((v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*(r1**2-r2**2))+(2*(r2**2)*v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))))*math.sin(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v1*math.sin(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))*math.sin(math.atan2(y1-y2,x2-x1)+(math.pi/2))) v2_x = ((v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*(r2**2-r1**2))+(2*(r1**2)*v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))))*math.cos(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v2*math.sin(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*math.cos(math.atan2(y1-y2,x2-x1)+(math.pi/2))) v2_y = ((v2*math.cos(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*(r2**2-r1**2))+(2*(r1**2)*v1*math.cos(math.acos(v1x/v1)-math.atan2(y1-y2,x2-x1))))*math.sin(math.atan2(y1-y2,x2-x1))/(r1**2+r2**2)+(v2*math.sin(math.acos(v2x/v2)-math.atan2(y1-y2,x2-x1))*math.sin(math.atan2(y1-y2,x2-x1)+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330212121 71 (2021-01-28 11:53) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=(r1)**2 m2=(r2)**2 v1=math.sqrt(((v1x)**2) + ((v1y)**2)) v2=math.sqrt(((v2x)**2) + ((v2y)**2)) theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) phi=math.atan2(y1-y2,x1-x2) v1_x = ((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*(math.cos(phi)))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*(math.sin(phi)))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*(math.cos(phi)))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*(math.sin(phi)))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) ##---------- return (v1_x, v1_y), (v2_x, v2_y) |
# 6330213821 72 (2021-01-31 20:29) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): O1 = math.atan2(v1y,v1x) O2 = math.atan2(v2y,v2x) fee = math.atan2((y2-y1),(x2-x1)) v1 = v1x/math.cos(O1) v2 = v2x/math.cos(O2) m1 = r1**2 m2 = r2**2 v1_x = ((v1*math.cos(O1-fee)*(m1-m2))+(2*m2*v2*math.cos(O2-fee)))*math.cos(fee)/(m1+m2)+(v1*math.sin(O1-fee)*math.cos(fee+math.pi/2)) v1_y = ((v1*math.cos(O1-fee)*(m1-m2))+(2*m2*v2*math.cos(O2-fee)))*math.sin(fee)/(m1+m2)+(v1*math.sin(O1-fee)*math.sin(fee+math.pi/2)) v2_x = ((v2*math.cos(O2-fee)*(m2-m1))+(2*m1*v1*math.cos(O1-fee)))*math.cos(fee)/(m2+m1)+(v2*math.sin(O2-fee)*math.cos(fee+math.pi/2)) v2_y = ((v2*math.cos(O2-fee)*(m2-m1))+(2*m1*v1*math.cos(O1-fee)))*math.sin(fee)/(m2+m1)+(v2*math.sin(O2-fee)*math.sin(fee+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330214421 73 (2021-01-30 12:50) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v_1 = math.sqrt(v1x**2+v1y**2) v_2 = math.sqrt(v2x**2+v2y**2) a_1 = math.atan2(v1y,v1x) a_2 = math.atan2(v2y,v2x) m_1 = r1**2 m_2 = r2**2 k = math.atan((y1-y2)/(x1-x2)) v1_x= ((v_1*math.cos(a_1-k)*(m_1-m_2)+2*m_2*v_2*math.cos(a_2-k))/(m_1+m_2)*math.cos(k))+v_1*math.sin(a_1-k)*math.cos(k+(math.pi/2)) v1_y= ((v_1*math.cos(a_1-k)*(m_1-m_2)+2*m_2*v_2*math.cos(a_2-k))/(m_1+m_2)*math.sin(k))+v_1*math.sin(a_1-k)*math.sin(k+(math.pi/2)) v2_x= ((v_2*math.cos(a_2-k)*(m_2-m_1)+2*m_1*v_1*math.cos(a_1-k))/(m_1+m_2)*math.cos(k))+v_2*math.sin(a_2-k)*math.cos(k+(math.pi/2)) v2_y= ((v_2*math.cos(a_2-k)*(m_2-m_1)+2*m_1*v_1*math.cos(a_1-k))/(m_1+m_2)*math.sin(k))+v_2*math.sin(a_2-k)*math.sin(k+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330215021 74 (2021-01-29 22:06) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan((y1-y2)/(x1-x2)) m1 = r1**2 m2 = r2**2 v1_x = ((((v1x*math.cos(phi)+v1y*math.sin(phi))*(m1-m2)+((2)*(m2)*(v2x*math.cos(phi)+v2y*math.sin(phi))))*math.cos(phi)/(m1+m2)))+((v1y*math.cos(phi)-v1x*math.sin(phi))*math.cos(phi+math.pi/2)) v1_y = ((((v1x*math.cos(phi)+v1y*math.sin(phi))*(m1-m2)+((2)*(m2)*(v2x*math.cos(phi)+v2y*math.sin(phi))))*math.sin(phi)/(m1+m2)))+((v1y*math.cos(phi)-v1x*math.sin(phi))*math.sin(phi+math.pi/2)) v2_x = ((((v2x*math.cos(phi)+v2y*math.sin(phi))*(m2-m1)+((2)*(m1)*(v1x*math.cos(phi)+v1y*math.sin(phi))))*math.cos(phi)/(m2+m1)))+((v2y*math.cos(phi)-v2x*math.sin(phi))*math.cos(phi+math.pi/2)) v2_y = ((((v2x*math.cos(phi)+v2y*math.sin(phi))*(m2-m1)+((2)*(m1)*(v1x*math.cos(phi)+v1y*math.sin(phi))))*math.sin(phi)/(m2+m1)))+((v2y*math.cos(phi)-v2x*math.sin(phi))*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330216721 75 (2021-01-28 11:37) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here # define helper function dot = lambda z1, z2: (z1 * z2.conjugate()).real to_tuple = lambda z: (z.real, z.imag) # calculate mass m1 = r1*r1 m2 = r2*r2 # convert position and velocity to "vector" V1 = complex(v1x, v1y) V2 = complex(v2x, v2y) X1 = complex(x1, y1) X2 = complex(x2, y2) # define the formula (angle-free representation) def after(m1, m2, x1, x2, v1, v2): dx = x1-x2 dv = v1-v2 mass_term = 2*m2/(m1+m2) vel_term = dot(dv, dx) pos_term = dx/(abs(dx)**2) return v1 - mass_term*vel_term*pos_term # calculate and return v1_after = after(m1, m2, X1, X2, V1, V2) v2_after = after(m2, m1, X2, X1, V2, V1) return to_tuple(v1_after), to_tuple(v2_after) |
# 6330217321 76 (2021-01-30 02:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1=(v1x**2+v1y**2)**0.5 v2=(v2x**2+v2y**2)**0.5 m1=r1**2 m2=r2**2 t1=math.atan2(v1y,v1x) t2=math.atan2(v2y,v2x) f=math.atan2((y1-y2),(x1-x2)) v1x=((v1*math.cos(t1-f)*(m1-m2)+(2*m2*v2*math.cos(t2-f)))/(m1+m2))*math.cos(f)+v1*math.sin(t1-f)*math.cos(f+math.pi/2) v1y=((v1*math.cos(t1-f)*(m1-m2)+(2*m2*v2*math.cos(t2-f)))/(m1+m2))*math.sin(f)+v1*math.sin(t1-f)*math.sin(f+math.pi/2) v2x=((v2*math.cos(t2-f)*(m2-m1)+(2*m1*v1*math.cos(t1-f)))/(m1+m2))*math.cos(f)+v2*math.sin(t2-f)*math.cos(f+math.pi/2) v2y=((v2*math.cos(t2-f)*(m2-m1)+(2*m1*v1*math.cos(t1-f)))/(m1+m2))*math.sin(f)+v2*math.sin(t2-f)*math.sin(f+math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330219621 77 (2021-01-30 11:29) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) a3 = math.atan2(y2-y1,x2-x1) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) m1 = (r1)**2 m2 = (r2)**2 v1_x = (((v1*math.cos(a1-a3)*(m1-m2)+2*m2*v2*math.cos(a2-a3)))*math.cos(a3)/(m1+m2))+(v1*math.sin(a1-a3)*math.cos(a3+(math.pi/2))) v1_y = (((v1*math.cos(a1-a3)*(m1-m2)+2*m2*v2*math.cos(a2-a3)))*math.sin(a3)/(m1+m2))+(v1*math.sin(a1-a3)*math.sin(a3+(math.pi/2))) v2_x = (((v2*math.cos(a2-a3)*(m2-m1)+2*m1*v1*math.cos(a1-a3)))*math.cos(a3)/(m1+m2))+(v2*math.sin(a2-a3)*math.cos(a3+(math.pi/2))) v2_y = (((v2*math.cos(a2-a3)*(m2-m1)+2*m1*v1*math.cos(a1-a3)))*math.sin(a3)/(m1+m2))+(v2*math.sin(a2-a3)*math.sin(a3+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330221821 78 (2021-01-31 20:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2(y1-y2, x1-x2) m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 a = (v1*math.cos(theta1 - phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2) b = (v2*math.cos(theta2 - phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m1+m2) v1_x = a*math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = a*math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = b*math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = b*math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330222421 79 (2021-01-30 21:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here # seta1=a,seta2=b p = math.atan2(y2-y1,x2-x1) v1 = math.sqrt((v1x ** 2)+(v1y ** 2)) v2 = math.sqrt((v2x ** 2)+(v2y ** 2)) a = (math.atan2(v1y,v1x)) b = (math.atan2(v2y,v2x)) m1 = r1**2 m2 = r2**2 v1_x = (math.cos(p)*(((v1*math.cos(a-p)*(m1-m2))+(2*m2*v2*math.cos(b-p)))/(m1+m2)))+(v1*math.sin(a-p)*math.cos(p+(math.pi)/2)) v1_y = (math.sin(p)*(((v1*math.cos(a-p)*(m1-m2))+(2*m2*v2*math.cos(b-p)))/(m1+m2)))+(v1*math.sin(a-p)*math.sin(p+(math.pi)/2)) v2_x = (math.cos(p)*(((v2*math.cos(b-p)*(m2-m1))+(2*m1*v1*math.cos(a-p)))/(m2+m1)))+(v2*math.sin(b-p)*math.cos(p+(math.pi)/2)) v2_y = (math.sin(p)*(((v2*math.cos(b-p)*(m2-m1))+(2*m1*v1*math.cos(a-p)))/(m2+m1)))+(v2*math.sin(b-p)*math.sin(p+(math.pi)/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330223021 80 (2021-01-29 22:45) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 phi = math.atan2((y2-y1),(x2-x1)) seta_1 = math.atan2(v1y , v1x) seta_2 = math.atan2(v2y , v2x) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((((v1*math.cos(seta_1-phi)*(m1-m2))+(2*m2*v2*math.cos(seta_2-phi)))/(m1+m2))*math.cos(phi))+(v1*math.sin(seta_1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(seta_1-phi)*(m1-m2))+(2*m2*v2*math.cos(seta_2-phi)))/(m1+m2))*math.sin(phi))+(v1*math.sin(seta_1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(seta_2-phi)*(m2-m1))+(2*m1*v1*math.cos(seta_1-phi)))/(m1+m2))*math.cos(phi))+(v2*math.sin(seta_2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(seta_2-phi)*(m2-m1))+(2*m1*v1*math.cos(seta_1-phi)))/(m1+m2))*math.sin(phi))+(v2*math.sin(seta_2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330224721 81 (2021-01-31 17:59) def update_v(x1, y1, r1, v1x, v1y,x2, y2, r2, v2x, v2y): m1=r1**2 m2=r2**2 v1=(v1x**2+v1y**2)**(1/2) #ขนาด v2=(v2x**2+v2y**2)**(1/2) #ขนาด s1=math.atan2(v1y,v1x) #แก้ปัญหาarctan s2=math.atan2(v2y,v2x) #แก้ปัญหาarctan phi=math.atan2(y2-y1,x2-x1) #แก้ปัญหาarctan v1_x = (v1*math.cos(s1-phi)*(m1-m2)+2*m2*v2*math.cos(s2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(s1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(s1-phi)*(m1-m2)+2*m2*v2*math.cos(s2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(s1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(s2-phi)*(m2-m1)+2*m1*v1*math.cos(s1-phi))*math.cos(phi)/(m1+m2)+v2*math.sin(s2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(s2-phi)*(m2-m1)+2*m1*v1*math.cos(s1-phi))*math.sin(phi)/(m1+m2)+v2*math.sin(s2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330225321 82 (2021-02-01 01:50) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x2-x1)) v1 = (v1x**2+v1y**2)**(1/2) v2 = (v2x**2+v2y**2)**(1/2) m1 = r1**2 m2 = r2**2 v1_x = math.cos(phi)*(v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = math.sin(phi)*(v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = math.cos(phi)*(v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = math.sin(phi)*(v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330226021 83 (2021-01-28 22:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan((y2-y1)/(x2-x1)) sp = math.sin(phi) spp2 = math.sin(phi+(math.pi/2)) cp = math.cos(phi) cpp2 = math.cos(phi+(math.pi/2)) m1 = r1**2 m2 = r2**2 v1_x = ((((m1-m2)*((v1x*cp)+(v1y*sp)))+(2*m2*((v2x*cp)+(v2y*sp))))*cp/(m1+m2))+(((v1y*cp)-(v1x*sp))*cpp2) v1_y = ((((m1-m2)*((v1x*cp)+(v1y*sp)))+(2*m2*((v2x*cp)+(v2y*sp))))*sp/(m1+m2))+(((v1y*cp)-(v1x*sp))*spp2) v2_x = ((((m2-m1)*((v2x*cp)+(v2y*sp)))+(2*m1*((v1x*cp)+(v1y*sp))))*cp/(m2+m1))+(((v2y*cp)-(v2x*sp))*cpp2) v2_y = ((((m2-m1)*((v2x*cp)+(v2y*sp)))+(2*m1*((v1x*cp)+(v1y*sp))))*sp/(m2+m1))+(((v2y*cp)-(v2x*sp))*spp2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330227621 84 (2021-02-01 14:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) Y = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = ((v1*math.cos(zeta1-Y)*(m1-m2)+(2*m2*v2*math.cos(zeta2-Y)))*math.cos(Y)/(m1+m2))+(v1*math.sin(zeta1-Y)*(math.cos(Y+math.pi/2))) v1_y = ((v1*math.cos(zeta1-Y)*(m1-m2)+(2*m2*v2*math.cos(zeta2-Y)))*math.sin(Y)/(m1+m2))+(v1*math.sin(zeta1-Y)*(math.sin(Y+math.pi/2))) v2_x = ((v2*math.cos(zeta2-Y)*(m2-m1)+(2*m1*v1*math.cos(zeta1-Y)))*math.cos(Y)/(m2+m1))+(v2*math.sin(zeta2-Y)*(math.cos(Y+math.pi/2))) v2_y = ((v2*math.cos(zeta2-Y)*(m2-m1)+(2*m1*v1*math.cos(zeta1-Y)))*math.sin(Y)/(m2+m1))+(v2*math.sin(zeta2-Y)*(math.sin(Y+math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330228221 85 (2021-01-31 21:14) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1 = ((v1x**2) + (v1y**2))**0.5 seta1 = math.atan2(v1y,v1x) v2 = ((v2x**2) + (v2y**2))**0.5 seta2 = math.atan2(v2y,v2x) dy = y2-y1 dx = x2-x1 phi = math.atan(dy/dx) m1 = r1**2 m2 = r2**2 v1_x = ((v1*math.cos(seta1-phi)*(m1-m2)+(2*m2*v2*math.cos(seta2-phi)))/(m1+m2)*math.cos(phi))+(v1*math.sin(seta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2)+(2*m2*v2*math.cos(seta2-phi)))/(m1+m2)*math.sin(phi))+(v1*math.sin(seta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((v2*math.cos(seta2-phi)*(m2-m1)+(2*m1*v1*math.cos(seta1-phi)))/(m1+m2)*math.cos(phi))+(v2*math.sin(seta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((v2*math.cos(seta2-phi)*(m2-m1)+(2*m1*v1*math.cos(seta1-phi)))/(m1+m2)*math.sin(phi))+(v2*math.sin(seta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330229921 86 (2021-02-01 10:50) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here thet1 = math.atan2(v1y, v1x) thet2 = math.atan2(v2y, v2x) m1 = r1**2 m2 = r2**2 phi = math.atan2((y1-y2), (x1-x2)) v1 = v1y/math.sin(thet1) v2 = v2y/math.sin(thet2) v1_x = ((v1*math.cos(thet1-phi)*(m1-m2))+(2*m2*v2*math.cos(thet2-phi)))*math.cos(phi)/(m1+m2)+v1*math.sin(thet1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(thet1-phi)*(m1-m2))+(2*m2*v2*math.cos(thet2-phi)))*math.sin(phi)/(m1+m2)+v1*math.sin(thet1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(thet2-phi)*(m2-m1))+(2*m1*v1*math.cos(thet1-phi)))*math.cos(phi)/(m1+m2)+v2*math.sin(thet2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(thet2-phi)*(m2-m1))+(2*m1*v1*math.cos(thet1-phi)))*math.sin(phi)/(m1+m2)+v2*math.sin(thet2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330230421 87 (2021-01-29 09:17) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) O1 = math.atan2(v1y , v1x) O2 = math.atan2(v2y , v2x) m1 = r1**2 m2 = r2**2 P = math.atan2((y1-y2),(x1-x2)) v1_x = ((((v1*math.cos(O1-P))*(m1-m2) + 2*m2*v2*math.cos(O2-P)) / (m1+m2))*math.cos(P)) + (v1*math.sin(O1-P)*math.cos(P+(math.pi/2))) v1_y = ((((v1*math.cos(O1-P))*(m1-m2) + 2*m2*v2*math.cos(O2-P)) / (m1+m2))*math.sin(P)) + (v1*math.sin(O1-P)*math.sin(P+(math.pi/2))) v2_x = ((((v2*math.cos(O2-P))*(m2-m1) + 2*m1*v1*math.cos(O1-P)) / (m1+m2))*math.cos(P)) + (v2*math.sin(O2-P)*math.cos(P+(math.pi/2))) v2_y = ((((v2*math.cos(O2-P))*(m2-m1) + 2*m1*v1*math.cos(O1-P)) / (m1+m2))*math.sin(P)) + (v2*math.sin(O2-P)*math.sin(P+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330232721 88 (2021-02-01 13:46) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here sym = math.atan((y2-y1)/(x2-x1)) Ssym = math.sin(sym) Csym = math.cos(sym) v1_x = ((((v1y*Ssym+v1x*Csym)*(r1**2-r2**2))+(2*r2**2*v2x*Csym+(2*r2**2*v2y*Ssym)))/(r1**2+r2**2))*Csym+((v1y*Csym-(v1x*Ssym))*math.cos(sym+(math.pi/2))) v1_y = ((((v1y*Ssym+v1x*Csym)*(r1**2-r2**2))+(2*r2**2*v2x*Csym+(2*r2**2*v2y*Ssym)))/(r1**2+r2**2))*Ssym+((v1y*Csym-(v1x*Ssym))*math.sin(sym+(math.pi/2))) v2_x = ((((v2y*Ssym+v2x*Csym)*(r2**2-r1**2))+(2*r1**2*v1x*Csym+(2*r1**2*v1y*Ssym)))/(r2**2+r1**2))*Csym+((v2y*Csym-(v2x*Ssym))*math.cos(sym+(math.pi/2))) v2_y = ((((v2y*Ssym+v2x*Csym)*(r2**2-r1**2))+(2*r1**2*v1x*Csym+(2*r1**2*v1y*Ssym)))/(r2**2+r1**2))*Ssym+((v2y*Csym-(v2x*Ssym))*math.sin(sym+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330233321 89 (2021-01-30 14:08) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # mass m1 = r1 ** 2 m2 = r2 ** 2 # theta theta1 = math.atan2(v1y , v1x) theta2 = math.atan2(v2y , v2x) # phi phi = math.atan2(y1 - y2, x1 - x2) # v1 & v2 v1 = math.sqrt(v1x ** 2 + v1y ** 2) v2 = math.sqrt(v2x ** 2 + v2y ** 2) # v final v1_x = (v1 * math.cos(theta1 - phi) * (m1 - m2) + 2 * m2 * v2 * math.cos(theta2 - phi)) / (m1 + m2) * math.cos(phi) + v1 * math.sin(theta1 - phi) * math.cos(phi + math.pi/2) v1_y = (v1 * math.cos(theta1 - phi) * (m1 - m2) + 2 * m2 * v2 * math.cos(theta2 - phi)) / (m1 + m2) * math.sin(phi) + v1 * math.sin(theta1 - phi) * math.sin(phi + math.pi/2) v2_x = (v2 * math.cos(theta2 - phi) * (m2 - m1) + 2 * m1 * v1 * math.cos(theta1 - phi)) / (m2 + m1) * math.cos(phi) + v2 * math.sin(theta2 - phi) * math.cos(phi + math.pi/2) v2_y = (v2 * math.cos(theta2 - phi) * (m2 - m1) + 2 * m1 * v1 * math.cos(theta1 - phi)) / (m2 + m1) * math.sin(phi) + v2 * math.sin(theta2 - phi) * math.sin(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330234021 90 (2021-02-01 19:18) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here c1 = math.atan2(v1y , v1x) c2 = math.atan2(v2y , v2x) f = math.atan((y1-y2),(x1-x2)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 v1_x = [[[[v1*math.cos(c1-f)]*(m1-m2) + 2*m2*v2*math.cos(c2-f)] / (m1+m2)]*math.cos(f)] + [v1*math.sin(c1-f)*math.cos(f+(math.pi/2))] v1_y = [[[[v1*math.cos(c1-f)]*(m1-m2) + 2*m2*v2*math.cos(c2-f)] / (m1+m2)]*math.sin(f)] + [v1*math.sin(c1-f)*math.sin(f + math.pi/2)] v2_x = [[[[v2*math.cos(c2-f)]*(m2-m1) + 2*m1*v1*math.cos(c1-f)] / (m1+m2)]*math.cos(f)] + [v2*math.sin(c2-f)*math.cos(f + math.pi/2)] v2_y = [[[[v2*math.cos(c2-f)]*(m2-m1) + 2*m1*v1*math.cos(c1-f)] / (m1+m2)]*math.sin(f)] + [v2*math.sin(c2-f)*math.sin(f + math.pi/2)] return (v1_x, v1_y), (v2_x, v2_y) |
# 6330235621 91 (2021-02-01 18:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330236221 92 (2021-01-30 12:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 l = math.asin(r1/(r1 + r2)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) p = math.atan2(v2y,v2x) s = math.atan2(v1y,v1x) v1_x = ((v1*math.cos(s-l)*(m1-m2) + 2*m2*v2*math.cos(p-l))/(m1 + m2)*math.cos(l)) + v1*math.sin(s-l)*math.cos(l+(math.pi)/2) v1_y = ((v1*math.cos(s-l)*(m1-m2) + 2*m2*v2*math.cos(p-l))/(m1 + m2)*math.sin(l)) + v1*math.sin(s-l)*math.cos(l+(math.pi)/2) v2_x = ((v2*math.cos(p-l)*(m2-m1) + 2*m1*v1*math.cos(s-l))/(m1 + m2)*math.cos(l)) + v2*math.sin(p-l)*math.cos(l+(math.pi)/2) v2_y = ((v2*math.cos(p-l)*(m2-m1) + 2*m1*v1*math.cos(s-l))/(m1 + m2)*math.sin(l)) + v2*math.sin(p-l)*math.sin(l+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330238521 93 (2021-01-29 21:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m2+m1))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m2+m1))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330239121 94 (2021-01-30 19:44) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2(y1-y2, x1-x2) m1 = r1**2 m2 = r2**2 v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330240721 95 (2021-01-29 11:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1= math.sqrt(v1x*v1x+v1y*v1y) v2= math.sqrt(v2x*v2x+v2y*v2y) A= math.atan2(v1y,v1x) B= math.atan2(v2y,v2x) Z= math.atan2(y1-y2,x1-x2) m1=r1**2 m2=r2**2 v1_x=(v1*math.cos(A-Z)*(m1-m2)+2*m2*v2*math.cos(B-Z))/(m1+m2)*math.cos(Z)+v1*math.sin(A-Z)*math.cos(Z+math.pi/2) v1_y=(v1 * math.cos(A - Z)*(m1 - m2) + 2 * m2 * v2 * math.cos(B - Z)) / (m1 + m2) * math.sin(Z) + v1 * math.sin(A - Z) * math.sin(Z + math.pi / 2) v2_x=(v2 * math.cos(B - Z)*(m2 - m1) + 2 * m1 * v1 * math.cos(A - Z)) / ( m2 + m1) * math.cos(Z) + v2 * math.sin(B - Z) *math.cos(Z+math.pi/2) v2_y = (v2 * math.cos(B - Z)*(m2 - m1) + 2 * m1 * v1 * math.cos(A - Z)) / ( m2 + m1) * math.sin(Z) + v2 * math.sin(B - Z) * math.sin(Z + math.pi / 2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330241321 96 (2021-02-01 18:23) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) y = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (((v1*math.cos(o1-y)*(m1-m2))+(2*m2*v2*math.cos(o2-y)))/(m1+m2)*math.cos(y))+(v1*math.sin(o1-y)*math.cos(y+(math.pi/2))) v1_y = (((v1*math.cos(o1-y)*(m1-m2))+(2*m2*v2*math.cos(o2-y)))/(m1+m2)*math.sin(y))+(v1*math.sin(o1-y)*math.sin(y+(math.pi/2))) v2_x = (((v2*math.cos(o2-y)*(m2-m1))+(2*m1*v1*math.cos(o1-y)))/(m1+m2)*math.cos(y))+(v2*math.sin(o2-y)*math.cos(y+(math.pi/2))) v2_y = (((v2*math.cos(o2-y)*(m2-m1))+(2*m1*v1*math.cos(o1-y)))/(m1+m2)*math.sin(y))+(v2*math.sin(o2-y)*math.sin(y+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330243621 97 (2021-01-30 20:21) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1, m2 = r1**2, r2**2 dm1, dm2 = m1-m2, m2-m1 sm = m1+m2 t = (math.pi)/2 st1 = math.atan2(v1y,v1x) st2 = math.atan2(v2y,v2x) ph = math.atan((y1-y2)/(x1-x2)) cosp = math.cos(ph) sinp = math.sin(ph) cos1 = math.cos(st1-ph) cos2 = math.cos(st2-ph) sin1 = math.sin(st1-ph) sin2 = math.sin(st2-ph) cost = math.cos(ph+t) sint = math.sin(ph+t) v1_x = (((v1*cos1*dm1+2*m2*v2*cos2)/sm)*cosp)+(v1*sin1*cost) v1_y = (((v1*cos1*dm1+2*m2*v2*cos2)/sm)*sinp)+(v1*sin1*sint) v2_x = ((((v2*cos2*dm2+2*m1*v1*cos1)/sm)*cosp)+(v2*sin2*cost)) v2_y = ((((v2*cos2*dm2+2*m1*v1*cos1)/sm)*sinp)+(v2*sin2*sint)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330245921 98 (2021-01-29 23:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) p1 = math.atan2(y1-y2,x1-x2) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = ((((v1*math.cos(t1-p1)*(m1-m2))+(2*m2*v2*math.cos(t2-p1)))/(m1+m2))*math.cos(p1))+((v1*math.sin(t1-p1))*math.cos(p1+(math.pi/2))) v1_y = ((((v1*math.cos(t1-p1)*(m1-m2))+(2*m2*v2*math.cos(t2-p1)))/(m1+m2))*math.sin(p1))+((v1*math.sin(t1-p1))*math.sin(p1+(math.pi/2))) v2_x = ((((v2*math.cos(t2-p1)*(m2-m1))+(2*m1*v1*math.cos(t1-p1)))/(m2+m1))*math.cos(p1))+((v2*math.sin(t2-p1))*math.cos(p1+(math.pi/2))) v2_y = ((((v2*math.cos(t2-p1)*(m2-m1))+(2*m1*v1*math.cos(t1-p1)))/(m2+m1))*math.sin(p1))+((v2*math.sin(t2-p1))*math.sin(p1+(math.pi/2))) #v1_x = v1x #v1_y = v1y #v2_x = v2x #v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330246521 99 (2021-01-28 20:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) theta1 = math.atan2(v1y, v1x) v2 = math.sqrt(v2x**2 + v2y**2) theta2 = math.atan2(v2y, v2x) m1 = r1**2 m2 = r2**2 phi = math.atan2((y1-y2), (x1-x2)) v1_x = (v1*math.cos(theta1 - phi)*(m1-m2) + 2*m2*v2*math.cos(theta2 - phi))*math.cos(phi)/(m1 + m2) + v1*math.sin(theta1 - phi)*math.cos(phi + math.pi/2) v1_y = (v1*math.cos(theta1 - phi)*(m1-m2) + 2*m2*v2*math.cos(theta2 - phi))*math.sin(phi)/(m1 + m2) + v1*math.sin(theta1 - phi)*math.sin(phi + math.pi/2) v2_x = (v2*math.cos(theta2 - phi)*(m2-m1) + 2*m1*v1*math.cos(theta1 - phi))*math.cos(phi)/(m1 + m2) + v2*math.sin(theta2 - phi)*math.cos(phi + math.pi/2) v2_y = (v2*math.cos(theta2 - phi)*(m2-m1) + 2*m1*v1*math.cos(theta1 - phi))*math.sin(phi)/(m1 + m2) + v2*math.sin(theta2 - phi)*math.sin(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330247121 100 (2021-02-01 14:03) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) w = math.atan2(y2-y1,x2-x1) v1 = (((v1x**2)+(v1y**2))**(1/2)) v2 = (((v2x**2)+(v2y**2))**(1/2)) v1_x = (((((v1*math.cos(s1-w))*(m1-m2))+((2*m2*v2)*(math.cos(s2-w))))/(m1+m2))*(math.cos(w)))+((v1*math.sin(s1-w))*math.cos(w+math.pi/2)) v1_y = (((((v1*math.cos(s1-w))*(m1-m2))+((2*m2*v2)*(math.cos(s2-w))))/(m1+m2))*(math.sin(w)))+((v1*math.sin(s1-w))*math.sin(w+math.pi/2)) v2_x = (((((v2*math.cos(s2-w))*(m2-m1))+((2*m1*v1)*(math.cos(s1-w))))/(m1+m2))*(math.cos(w)))+((v2*math.sin(s2-w))*math.cos(w+math.pi/2)) v2_y = (((((v2*math.cos(s2-w))*(m2-m1))+((2*m1*v1)*(math.cos(s1-w))))/(m1+m2))*(math.sin(w)))+((v2*math.sin(s2-w))*math.sin(w+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330248821 101 (2021-02-01 17:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) v1 = v1x/math.cos(o1) v1 = v1y/math.sin(o1) v2 = v2x/math.cos(o2) v2 = v2y/math.sin(o2) y = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(o1-y)*(m1-m2))+(2*m2*v2*math.cos(o2-y)))/(m1+m2))*math.cos(y))+(v1*math.sin(o1-y)*math.cos(y+(math.pi/2))) v1_y = ((((v1*math.cos(o1-y)*(m1-m2))+(2*m2*v2*math.cos(o2-y)))/(m1+m2))*math.sin(y))+(v1*math.sin(o1-y)*math.sin(y+(math.pi/2))) v2_x = ((((v2*math.cos(o2-y)*(m2-m1))+(2*m1*v1*math.cos(o1-y)))/(m1+m2))*math.cos(y))+(v2*math.sin(o2-y)*math.cos(y+(math.pi/2))) v2_y = ((((v2*math.cos(o2-y)*(m2-m1))+(2*m1*v1*math.cos(o1-y)))/(m1+m2))*math.sin(y))+(v2*math.sin(o2-y)*math.sin(y+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330249421 102 (2021-01-30 22:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=(r1)**2 m2=(r2)**2 v1=((v1y)**2+(v1x)**2)**(1/2) v2=((v2x)**2+(v2y)**2)**(1/2) t1=math.atan2(v1y,v1x) t2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*math.cos(t2-phi))/(m1+m2))*math.cos(phi))+v1*math.sin(t1-phi)*math.cos(phi+math.pi/2) v1_y = (((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*math.cos(t2-phi))/(m1+m2))*math.sin(phi))+v1*math.sin(t1-phi)*math.sin(phi+math.pi/2) v2_x = (((v2*math.cos(t2-phi)*(m2-m1)+2*m1*v1*math.cos(t1-phi))/(m1+m2))*math.cos(phi))+v2*math.sin(t2-phi)*math.cos(phi+math.pi/2) v2_y = (((v2*math.cos(t2-phi)*(m2-m1)+2*m1*v1*math.cos(t1-phi))/(m1+m2))*math.sin(phi))+v2*math.sin(t2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330250021 103 (2021-01-31 15:06) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) th1 = math.atan2(v1y,v1x) th2 = math.atan2(v2y,v2x) ph = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1_x = (v1*math.cos(th1-ph)*(m1-m2)+2*m2*v2*math.cos(th2-ph))/(m1+m2)*math.cos(ph)+v1*math.sin(th1-ph)*math.cos(ph+math.pi/2) v1_y = (v1*math.cos(th1-ph)*(m1-m2)+2*m2*v2*math.cos(th2-ph))/(m1+m2)*math.sin(ph)+v1*math.sin(th1-ph)*math.sin(ph+math.pi/2) v2_x = (v2*math.cos(th2-ph)*(m2-m1)+2*m1*v1*math.cos(th1-ph))/(m1+m2)*math.cos(ph)+v2*math.sin(th2-ph)*math.cos(ph+math.pi/2) v2_y = (v2*math.cos(th2-ph)*(m2-m1)+2*m1*v1*math.cos(th1-ph))/(m1+m2)*math.sin(ph)+v2*math.sin(th2-ph)*math.sin(ph+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330251621 104 (2021-01-31 11:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 g1 = math.atan2(v1y,v1x) g2 = math.atan2(v2y,v2x) v1 = v1x / math.cos(g1) v2 = v2x / math.cos(g2) c = math.atan2(y2-y1,x2-x1) v1_x = (v1*math.cos(g1-c)*(m1-m2)+2*m2*v2*math.cos(g2-c))*math.cos(c)/(m1+m2) +v1*math.sin(g1-c)*math.cos(c+math.pi/2) v1_y = (v1*math.cos(g1-c)*(m1-m2)+2*m2*v2*math.cos(g2-c))*math.sin(c)/(m1+m2) +v1*math.sin(g1-c)*math.sin(c+math.pi/2) v2_x = (v2*math.cos(g2-c)*(m2-m1)+2*m1*v1*math.cos(g1-c))*math.cos(c)/(m1+m2) +v2*math.sin(g2-c)*math.cos(c+math.pi/2) v2_y = (v2*math.cos(g2-c)*(m2-m1)+2*m1*v1*math.cos(g1-c))*math.sin(c)/(m1+m2) +v2*math.sin(g2-c)*math.sin(c+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330252221 105 (2021-02-01 08:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) a = math.atan((y1-y2)/(x1-x2)) v1_x = ((v1*math.cos(theta1-a)*(m1-m2)+2*m2*v2*math.cos(theta2-a))/(m1+m2))*math.cos(a) + v1*math.sin(theta1-a)*math.cos(a+math.pi/2) v1_y = ((v1*math.cos(theta1-a)*(m1-m2)+2*m2*v2*math.cos(theta2-a))/(m1+m2))*math.sin(a) + v1*math.sin(theta1-a)*math.sin(a+math.pi/2) v2_x = ((v2*math.cos(theta2-a)*(m2-m1)+2*m1*v1*math.cos(theta1-a))/(m1+m2))*math.cos(a) + v2*math.sin(theta2-a)*math.cos(a+math.pi/2) v2_y = ((v2*math.cos(theta2-a)*(m2-m1)+2*m1*v1*math.cos(theta1-a))/(m1+m2))*math.sin(a) + v2*math.sin(theta2-a)*math.sin(a+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330253921 106 (2021-02-01 23:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision m1 = r1**2 m2 = r2**2 s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) f = math.atan2(y2-y1,x2-x1) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = (((v1*math.cos(s1-f)*(m1-m2))+(2*m2*v2*math.cos(s2-f)))/(m1+m2))*math.cos(f)+((v1*math.sin(s1-f))*math.cos(f+(math.pi/2))) v2_x = (((v2*math.cos(s2-f)*(m2-m1))+(2*m1*v1*math.cos(s1-f)))/(m1+m2))*math.cos(f)+((v2*math.sin(s2-f))*math.cos(f+(math.pi/2))) v1_y = (((v1*math.cos(s1-f)*(m1-m2))+(2*m2*v2*math.cos(s2-f)))/(m1+m2))*math.sin(f)+(v1*math.sin(s1-f)*math.sin(f+(math.pi/2))) v2_y = (((v2*math.cos(s2-f)*(m2-m1))+(2*m1*v1*math.cos(s1-f)))/(m1+m2))*math.sin(f)+(v2*math.sin(s2-f)*math.sin(f+(math.pi/2))) #v1_x = v1x #v1_y = v1y #v2_x = v2x #v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330254521 107 (2021-02-01 12:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 q=m1-m2 z=m2-m1 p=m1+m2 P=math.atan2((y2-y1),(x2-x1)) t1=math.atan2(v1y,v1x) t2=math.atan2(v2y,v2x) v1=(v1y**2+v1x**2)**(1/2) v2=(v2y**2+v2x**2)**(1/2) v1_x = ((v1*math.cos(t1-P)*q)+(2*m2*v2*math.cos(t2-P)))*math.cos(P)/p+(v1*math.sin(t1-P)*math.cos(math.pi/2+P)) v1_y = ((v1*math.cos(t1-P)*q)+(2*m2*v2*math.cos(t2-P)))*math.sin(P)/p+(v1*math.sin(t1-P)*math.sin(math.pi/2+P)) v2_x = ((v2*math.cos(t2-P)*z)+(2*m1*v1*math.cos(t1-P)))*math.cos(P)/p+(v2*math.sin(t2-P)*math.cos(math.pi/2+P)) v2_y = ((v2*math.cos(t2-P)*z)+(2*m1*v1*math.cos(t1-P)))*math.sin(P)/p+(v2*math.sin(t2-P)*math.sin(math.pi/2+P)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330255121 108 (2021-02-01 18:32) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = ((v1*math.cos(a1-phi)*(m1-m2)) + 2*m2*v2*math.cos(a2-phi))*math.cos(phi)/(m1+m2) + (v1*math.sin(a1-phi)*math.cos(phi+math.pi/2)) v1_y = ((v1*math.cos(a1-phi)*(m1-m2)) + 2*m2*v2*math.cos(a2-phi))*math.sin(phi)/(m1+m2) + (v1*math.sin(a1-phi)*math.sin(phi+math.pi/2)) v2_x = ((v2*math.cos(a2-phi)*(m2-m1)) + 2*m1*v1*math.cos(a1-phi))*math.cos(phi)/(m2+m1) + (v2*math.sin(a2-phi)*math.cos(phi+math.pi/2)) v2_y = ((v2*math.cos(a2-phi)*(m2-m1)) + 2*m1*v1*math.cos(a1-phi))*math.sin(phi)/(m2+m1) + (v2*math.sin(a2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330256821 109 (2021-02-01 23:59) def update_v(x1, y1, r1, v1x, v1y, x2,y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan(y1-y2/x1-x2) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) v1_x = ((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*(t2-phi))/m1+m2)*math.cos(phi)+v1*math.sin(t1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*(t2-phi))/m1+m2)*math.sin(phi)+v1*math.sin(t1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(t2-phi)*(m2-m1)+2*m1*v1*(t1-phi))/m1+m2)*math.cos(phi)+v1*math.sin(t2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(t2-phi)*(m2-m1)+2*m2*v2*(t1-phi))/m1+m2)*math.sin(phi)+v1*math.sin(t2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330257421 110 (2021-01-30 21:37) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a1 = math.atan2((v1y),(v1x)) a2 = math.atan2((v2y),(v2x)) c = math.atan((y2-y1)/(x2-x1)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(a1-c)*(m1-m2)+2*m2*v2*math.cos(a2-c))*math.cos(c))/(m1+m2)+v1*math.sin(a1-c)*math.cos(c+math.pi/2) v1_y = ((v1*math.cos(a1-c)*(m1-m2)+2*m2*v2*math.cos(a2-c))*math.sin(c))/(m1+m2)+v1*math.sin(a1-c)*math.sin(c+math.pi/2) v2_x = ((v2*math.cos(a2-c)*(m2-m1)+2*m1*v1*math.cos(a1-c))*math.cos(c))/(m1+m2)+v2*math.sin(a2-c)*math.cos(c+math.pi/2) v2_y = ((v2*math.cos(a2-c)*(m2-m1)+2*m1*v1*math.cos(a1-c))*math.sin(c))/(m1+m2)+v2*math.sin(a2-c)*math.sin(c+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330258021 111 (2021-01-29 22:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1,m2 = r1**2,r2**2 theta1,theta2 = math.atan2(v1y,v1x),math.atan2(v2y,v2x) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) phi = math.atan2((y2-y1),(x2-x1)) v1_x = ((((v1*math.cos(theta1-phi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-phi)))/(m1+m2)) * math.cos(phi)) + (v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = ((((v1*math.cos(theta1-phi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-phi)))/(m1+m2)) * math.sin(phi)) + (v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = ((((v2*math.cos(theta2-phi)*(m2-m1)) + (2*m1*v1*math.cos(theta1-phi)))/(m1+m2)) * math.cos(phi)) + (v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = ((((v2*math.cos(theta2-phi)*(m2-m1)) + (2*m1*v1*math.cos(theta1-phi)))/(m1+m2)) * math.sin(phi)) + (v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330259721 112 (2021-01-30 22:32) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 Theta1 = math.atan2(v1y,v1x) Theta2 = math.atan2(v2y,v2x) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 psi = math.atan2(y2-y1,x2-x1) v1_x = ((v1*math.cos(Theta1-psi)*(m1-m2)+2*m2*v2*math.cos(Theta2-psi))*math.cos(psi))/(m1+m2)+v1*math.sin(Theta1-psi)*math.cos(psi+(math.pi)/2) v1_y = ((v1*math.cos(Theta1-psi)*(m1-m2)+2*m2*v2*math.cos(Theta2-psi))*math.sin(psi))/(m1+m2)+v1*math.sin(Theta1-psi)*math.sin(psi+(math.pi)/2) v2_x = ((v2*math.cos(Theta2-psi)*(m2-m1)+2*m1*v1*math.cos(Theta1-psi))*math.cos(psi))/(m2+m1)+v2*math.sin(Theta2-psi)*math.cos(psi+(math.pi)/2) v2_y = ((v2*math.cos(Theta2-psi)*(m2-m1)+2*m1*v1*math.cos(Theta1-psi))*math.sin(psi))/(m2+m1)+v2*math.sin(Theta2-psi)*math.sin(psi+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330260221 113 (2021-01-30 14:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x ** 2 + v1y ** 2) v2 = math.sqrt(v2x ** 2 + v2y ** 2) A1 = math.atan2(v1y,v1x) A2 = math.atan2(v2y,v2x) phi = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1_x = (v1*math.cos(A1-phi)*(m1-m2)+2*m2*v2*math.cos(A2-phi))*math.cos(phi)/(m2+m1)+v1*math.sin(A1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(A1-phi)*(m1-m2)+2*m2*v2*math.cos(A2-phi))*math.sin(phi)/(m2+m1)+v1*math.sin(A1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(A2-phi)*(m2-m1)+2*m1*v1*math.cos(A1-phi))*math.cos(phi)/(m2+m1)+v2*math.sin(A2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(A2-phi)*(m2-m1)+2*m1*v1*math.cos(A1-phi))*math.sin(phi)/(m2+m1)+v2*math.sin(A2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330261921 114 (2021-01-28 21:06) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here p = math.pi v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 sm = m1+m2 #ใส่ ab phi = math.atan2((y2-y1),(x2-x1)) # พจน 1 a1 = v1* math.cos(s1-phi) * (m1-m2) # v1*cos*m1-m2 a2 = v2* math.cos(s2-phi) * (m2-m1) # v2*cos*m2-m1 # พจ 2 b1 = 2*m2*v2*math.cos(s2-phi) # 2*m2*v2*cos b2 = 2*m1*v1*math.cos(s1-phi) # 2*m2*v2*cos # พจ หลัง c1x = v1*math.sin (s1 - phi) * math.cos(phi + p/2) # v1 * sin * cos c1y = v1*math.sin (s1 - phi) * math.sin(phi + p/2) # v1 * sin * sin c2x = v2*math.sin (s2 - phi) * math.cos(phi + p/2) # v2 * sin * cos c2y = v2*math.sin (s2 - phi) * math.sin(phi + p/2) # v2 * sin * sin #ความเร็วใหม่ v1_x = (a1+b1)/sm * math.cos(phi)+c1x v1_y = (a1+b1)/sm * math.sin(phi)+c1y v2_x = (a2+b2)/sm * math.cos(phi)+c2x v2_y = (a2+b2)/sm * math.sin(phi)+c2y ###v1_x = v1x ###v1_y = v1y ###v2_x = v2x ###v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330262521 115 (2021-01-28 23:01) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 ang_1 = math.atan2(v1y,v1x) ang_2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) v1 = (v1y**2+v1x**2)**0.5 v2 = (v2y**2+v2x**2)**0.5 v1_x = ((v1*math.cos(ang_1-phi)*(m1-m2)+(2*m2*v2*math.cos(ang_2-phi)))/(m1+m2))*(math.cos(phi)) + v1*math.sin(ang_1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(ang_1-phi)*(m1-m2)+(2*m2*v2*math.cos(ang_2-phi)))/(m1+m2))*(math.sin(phi)) + v1*math.sin(ang_1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(ang_2-phi)*(m2-m1)+(2*m1*v1*math.cos(ang_1-phi)))/(m1+m2))*(math.cos(phi)) + v2*math.sin(ang_2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(ang_2-phi)*(m2-m1)+(2*m1*v1*math.cos(ang_1-phi)))/(m1+m2))*(math.sin(phi)) + v2*math.sin(ang_2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330263121 116 (2021-01-31 17:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here s1 = math.atan2(v1y,v1x) #เซต้า1 s2 = math.atan2(v2y,v2x) #เซต้า2 m1 = r1**2 #มวลm1 m2 = r2**2 #มวล m2 c = math.atan2(y1-y2,x1-x2) #มุมอีกตัว v1 = math.sqrt((v1x**2) + (v1y**2))#ความเร็ว v1 v2 = math.sqrt((v2x**2) + (v2y**2)) #ความเร็ว v2 v1_x = ((((v1*math.cos(s1-c)*(m1-m2)) + (2*m2*v2*math.cos(s2-c)))/(m1+m2))*(math.cos(c)))+(v1*math.sin(s1-c)*math.cos(c+(math.pi/2))) v1_y = ((((v1*math.cos(s1-c)*(m1-m2)) + (2*m2*v2*math.cos(s2-c)))/(m1+m2))*(math.sin(c)))+(v1*math.sin(s1-c)*math.sin(c+(math.pi/2))) v2_x = ((((v2*math.cos(s2-c)*(m2-m1)) + (2*m1*v1*math.cos(s1-c)))/(m1+m2))*(math.cos(c)))+(v2*math.sin(s2-c)*math.cos(c+(math.pi/2))) v2_y = ((((v2*math.cos(s2-c)*(m2-m1)) + (2*m1*v1*math.cos(s1-c)))/(m1+m2))*(math.sin(c)))+(v2*math.sin(s2-c)*math.sin(c+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330264821 117 (2021-01-29 12:17) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 phi = math.atan((y1-y2)/(x1-x2)) front1 = (v1*(m1-m2)*math.cos(seta1-phi)+2*m2*v2*math.cos(seta2-phi))/(m1+m2) front2 = (v2*(m2-m1)*math.cos(seta2-phi)+2*m1*v1*math.cos(seta1-phi))/(m1+m2) back1 = v1*math.sin(seta1-phi) back2 = v2*math.sin(seta2-phi) v1_x = front1*math.cos(phi)+back1*math.cos(phi+math.pi/2) v1_y = front1*math.sin(phi)+back1*math.sin(phi+math.pi/2) v2_x = front2*math.cos(phi)+back2*math.cos(phi+math.pi/2) v2_y = front2*math.sin(phi)+back2*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330265421 118 (2021-01-31 22:07) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 angle1 = math.atan2(v1y,v1x) angle2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) v1_x = (((v1*math.cos(angle1-phi)*(m1-m2)) + (2*m2*v2*math.cos(angle2-phi)))/(m1+m2))*math.cos(phi)+v1*math.sin(angle1-phi)*math.cos(phi+(math.pi/2)) v1_y = (((v1*math.cos(angle1-phi)*(m1-m2)) + (2*m2*v2*math.cos(angle2-phi)))/(m1+m2))*math.sin(phi)+v1*math.sin(angle1-phi)*math.sin(phi+(math.pi/2)) v2_x = (((v2*math.cos(angle2-phi)*(m2-m1)) + (2*m1*v1*math.cos(angle1-phi)))/(m1+m2))*math.cos(phi)+v2*math.sin(angle2-phi)*math.cos(phi+(math.pi/2)) v2_y = (((v2*math.cos(angle2-phi)*(m2-m1)) + (2*m1*v1*math.cos(angle1-phi)))/(m1+m2))*math.sin(phi)+v2*math.sin(angle2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330266021 119 (2021-02-01 22:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 p1 = math.atan2(v1y , v1x) p2 = math.atan2(v2y , v2x) v1 = v1x/math.cos(p1) v2 = v2x/math.cos(p2) d = math.atan2(y2-y1 , x2-x1) v1_x = ((v1*math.cos(p1-d)*(m1-m2)+2*m2*v2*math.cos(p2-d))/(m1+m2))*math.cos(d)+v1*math.sin(p1-d)*math.cos(d+math.pi/2) v1_y = ((v1*math.cos(p1-d)*(m1-m2)+2*m2*v2*math.cos(p2-d))/(m1+m2))*math.sin(d)+v1*math.sin(p1-d)*math.sin(d+math.pi/2) v2_x = ((v2*math.cos(p2-d)*(m2-m1)+2*m1*v1*math.cos(p1-d))/(m1+m2))*math.cos(d)+v2*math.sin(p2-d)*math.cos(d+math.pi/2) v2_y = ((v2*math.cos(p2-d)*(m2-m1)+2*m1*v1*math.cos(p1-d))/(m1+m2))*math.sin(d)+v2*math.sin(p2-d)*math.sin(d+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330267721 120 (2021-01-29 22:04) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan((y2-y1)/(x2-x1)) v1_x = ((((v1x*math.cos(a)+v1y*math.sin(a))*(r1**2-r2**2)+(2*r2**2*v2x*math.cos(a)+2*r2**2*v2y*math.sin(a)))/(r1**2+r2**2))*math.cos(a))+(((v1y*math.cos(a))-(v1x*math.sin(a)))*(math.cos(a+math.pi/2))) v1_y = ((((v1x*math.cos(a)+v1y*math.sin(a))*(r1**2-r2**2)+(2*r2**2*v2x*math.cos(a)+2*r2**2*v2y*math.sin(a)))/(r1**2+r2**2))*math.sin(a))+(((v1y*math.cos(a))-(v1x*math.sin(a)))*(math.sin(a+math.pi/2))) v2_x = ((((v2x*math.cos(a)+v2y*math.sin(a))*(r2**2-r1**2)+(2*r1**2*v1x*math.cos(a)+2*r1**2*v1y*math.sin(a)))/(r1**2+r2**2))*math.cos(a))+(((v2y*math.cos(a))-(v2x*math.sin(a)))*(math.cos(a+math.pi/2))) v2_y = ((((v2x*math.cos(a)+v2y*math.sin(a))*(r2**2-r1**2)+(2*r1**2*v1x*math.cos(a)+2*r1**2*v1y*math.sin(a)))/(r1**2+r2**2))*math.sin(a))+(((v2y*math.cos(a))-(v2x*math.sin(a)))*(math.sin(a+math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330268321 121 (2021-01-31 09:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here p=math.atan2((y1-y2),(x1-x2)) a1=math.atan2(v1y,v1x) a2=math.atan2(v2y,v2x) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))/(m1+m2))*(math.cos(p))+v1*math.sin(a1-p)*math.cos(p+math.pi/2) v1_y = ((v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))/(m1+m2))*(math.sin(p))+v1*math.sin(a1-p)*math.sin(p+math.pi/2) v2_x = ((v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))/(m1+m2))*(math.cos(p))+v2*math.sin(a2-p)*math.cos(p+math.pi/2) v2_y = ((v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))/(m1+m2))*(math.sin(p))+v2*math.sin(a2-p)*math.sin(p+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330269021 122 (2021-01-30 22:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.pi - math.atan2((y1 - y2), (x1 - x2)) v1_x = ((v1*math.cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(theta2 - phi))/(m1 + m2))*math.cos(phi) + v1*math.sin(theta1 - phi)*math.cos(phi + math.pi/2) v1_y = ((v1*math.cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(theta2 - phi))/(m1 + m2))*math.sin(phi) + v1*math.sin(theta1 - phi)*math.sin(phi + math.pi/2) v2_x = ((v2*math.cos(theta2 - phi)*(m2 - m1) + 2*m1*v1*math.cos(theta1 - phi))/(m2 + m1))*math.cos(phi) + v2*math.sin(theta2 - phi)*math.cos(phi + math.pi/2) v2_y = ((v2*math.cos(theta2 - phi)*(m2 - m1) + 2*m1*v1*math.cos(theta1 - phi))/(m2 + m1))*math.sin(phi) + v2*math.sin(theta2 - phi)*math.sin(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330270521 123 (2021-01-30 23:48) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here angle1 = math.atan2(v1y,v1x) angle2 = math.atan2(v2y,v2x) phi = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**(1/2) v2 = (v2x**2+v2y**2)**(1/2) v1_x = (v1*math.cos(angle1-phi)*(m1-m2)+2*m2*v2*math.cos(angle2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(angle1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(angle1-phi)*(m1-m2)+2*m2*v2*math.cos(angle2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(angle1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(angle2-phi)*(m2-m1)+2*m1*v1*math.cos(angle1-phi))*math.cos(phi)/(m2+m1)+v2*math.sin(angle2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(angle2-phi)*(m2-m1)+2*m1*v1*math.cos(angle1-phi))*math.sin(phi)/(m2+m1)+v2*math.sin(angle2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330271121 124 (2021-01-29 22:27) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) p = math.atan2((y1-y2),(x1-x2)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1y**2+v1x**2) v2 = math.sqrt(v2y**2+v2x**2) v1_x = (v1*math.cos(s1-p)*(m1-m2)+2*m2*v2*math.cos(s2-p))/(m1+m2)*math.cos(p)+v1*math.sin(s1-p)*math.cos(p+math.pi/2) v1_y = (v1*math.cos(s1-p)*(m1-m2)+2*m2*v2*math.cos(s2-p))/(m1+m2)*math.sin(p)+v1*math.sin(s1-p)*math.sin(p+math.pi/2) v2_x = (v2*math.cos(s2-p)*(m2-m1)+2*m1*v1*math.cos(s1-p))/(m1+m2)*math.cos(p)+v2*math.sin(s2-p)*math.cos(p+math.pi/2) v2_y = (v2*math.cos(s2-p)*(m2-m1)+2*m1*v1*math.cos(s1-p))/(m1+m2)*math.sin(p)+v2*math.sin(s2-p)*math.sin(p+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330273421 125 (2021-01-30 07:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) g = math.atan2((y1-y2),(x1-x2)) #หน่วยradius s1 = math.atan2(v1y,v1x) #หน่วยradius s2 = math.atan2(v2y,v2x) #หน่วยradius v1_x = (v1*math.cos(s1-g)*(m1-m2)+2*m2*v2*math.cos(s2-g))*math.cos(g)/(m1+m2)+v1*math.sin(s1-g)*math.cos(g+math.pi/2) v1_y = (v1*math.cos(s1-g)*(m1-m2)+2*m2*v2*math.cos(s2-g))*math.sin(g)/(m1+m2)+v1*math.sin(s1-g)*math.sin(g+math.pi/2) v2_x = (v2*math.cos(s2-g)*(m2-m1)+2*m1*v1*math.cos(s1-g))*math.cos(g)/(m1+m2)+v2*math.sin(s2-g)*math.cos(g+math.pi/2) v2_y = (v2*math.cos(s2-g)*(m2-m1)+2*m1*v1*math.cos(s1-g))*math.sin(g)/(m1+m2)+v2*math.sin(s2-g)*math.sin(g+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330274021 126 (2021-01-31 13:48) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2(y1-y2,x1-x2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (((v1*math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi)/(m1+m2)+(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = (((v1*math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi)/(m1+m2)+(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = (((v2*math.cos(theta2-phi))*(m1-m2))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi)/(m1+m2)+(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = (((v2*math.cos(theta2-phi))*(m1-m2))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi)/(m1+m2)+(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330275721 127 (2021-01-31 02:37) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 phi = math.atan2(y2-y1,x2-x1) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330276321 128 (2021-01-29 15:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # insert your code here theta1 = angle_cal(v1x, v1y) theta2 = angle_cal(v2x, v2y) if y1 == y2 : if x1 >= x2 : phi = angle_cal((x1-x2), (y1-y2)) else : phi = math.pi - angle_cal((x1-x2), (y1-y2)) else : phi = angle_cal((x1-x2), (y1-y2)) # phi = angle_cal((x1-x2), (y1-y2)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 a1x = v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi) b1x = math.cos(phi) / (m1 + m2) c1x = v1*math.sin(theta1-phi)*math.cos(phi + (math.pi/2)) a1y = v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi) b1y = math.sin(phi) / (m1 + m2) c1y = v1*math.sin(theta1-phi)*math.sin(phi + (math.pi/2)) a2x = v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi) b2x = math.cos(phi) / (m1 + m2) c2x = v2*math.sin(theta2-phi)*math.cos(phi + (math.pi/2)) a2y = v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi) b2y = math.sin(phi) / (m1 + m2) c2y = v2*math.sin(theta2-phi)*math.sin(phi + (math.pi/2)) v1x = a1x * b1x + c1x v1y = a1y * b1y + c1y v2x = a2x * b2x + c2x v2y = a2y * b2y + c2y v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) def angle_cal(vx, vy) : return math.atan2(vy, vx) |
# 6330277021 129 (2021-01-30 17:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2(y1-y2, x1-x2) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) gon1 = v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi) v1_x = (gon1/(m1+m2))*math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = (gon1/(m1+m2))*math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) gon2 = v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi) v2_x = (gon2/(m1+m2))*math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = (gon2/(m1+m2))*math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330278621 130 (2021-01-31 13:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here #ball1 v1 = math.sqrt(v1x**2+v1y**2) theta1 = math.atan2(v1y,v1x) m1 = r1**2 #ball2 v2 = math.sqrt(v2x**2+v2y**2) theta2 = math.atan2(v2y,v2x) m2 = r2**2 phi = math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*(math.cos(phi)/(m1+m2)))+(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*(math.sin(phi)/(m1+m2)))+(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*(math.cos(phi)/(m1+m2)))+(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*(math.sin(phi)/(m1+m2)))+(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330279221 131 (2021-01-31 14:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 z1 = math.atan2(v1y, v1x) z2 = math.atan2(v2y, v2x) p = math.atan2(y2-y1, x2-x1) v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 v1_x = (((v1*math.cos(z1-p)*(m1-m2)+2*m2*v2*math.cos(z2-p))/(m1+m2))*math.cos(p))+(v1*math.sin(z1-p)*math.cos(p+math.pi/2)) v1_y = (((v1*math.cos(z1-p)*(m1-m2)+2*m2*v2*math.cos(z2-p))/(m1+m2))*math.sin(p))+(v1*math.sin(z1-p)*math.sin(p+math.pi/2)) v2_x = (((v2*math.cos(z2-p)*(m2-m1)+2*m1*v1*math.cos(z1-p))/(m2+m1))*math.cos(p))+(v2*math.sin(z2-p)*math.cos(p+math.pi/2)) v2_y = (((v2*math.cos(z2-p)*(m2-m1)+2*m1*v1*math.cos(z1-p))/(m2+m1))*math.sin(p))+(v2*math.sin(z2-p)*math.sin(p+math.pi/2)) #v1_x = v1x #v1_y = v1y #v2_x = v2x #v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330280821 132 (2021-01-30 21:05) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision theta1 = (math.atan2(v1y,v1x)) theta2 = (math.atan2(v2y,v2x)) gamma = (math.atan2((y2-y1),(x2-x1))) m1 = r1**2 m2 = r2**2 v1 = (math.sqrt(v1x**2+v1y**2)) v2 = (math.sqrt(v2x**2+v2y**2)) v1x = ((v1*((math.cos(theta1-gamma))*(m1-m2))+2*m2*v2*math.cos(theta2-gamma))/(m1+m2))*math.cos(gamma)+v1*(math.sin(theta1-gamma))*(math.cos((gamma)+(math.pi/2))) v1y = ((v1*((math.cos(theta1-gamma))*(m1-m2))+2*m2*v2*math.cos(theta2-gamma))/(m1+m2))*math.sin(gamma)+v1*(math.sin(theta1-gamma))*(math.sin((gamma)+(math.pi/2))) v2x = ((v2*((math.cos(theta2-gamma))*(m2-m1))+2*m1*v1*math.cos(theta1-gamma))/(m1+m2))*math.cos(gamma)+v2*(math.sin(theta2-gamma))*(math.cos((gamma)+(math.pi/2))) v2y = ((v2*((math.cos(theta2-gamma))*(m2-m1))+2*m1*v1*math.cos(theta1-gamma))/(m1+m2))*math.sin(gamma)+v2*(math.sin(theta2-gamma))*(math.sin((gamma)+(math.pi/2))) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330281421 133 (2021-01-29 11:40) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): import math # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) gr = math.atan2(y2-y1,x2-x1) v1_x = ( (v1*math.cos(zeta1-gr) * (m1-m2) + 2*m2*v2*math.cos(zeta2-gr) ) * math.cos(gr) )/(m1+m2) + v1*math.sin(zeta1-gr) * math.cos(gr+math.pi/2) v1_y = ( (v1*math.cos(zeta1-gr) * (m1-m2) + 2*m2*v2*math.cos(zeta2-gr) ) * math.sin(gr) )/(m1+m2) + v1*math.sin(zeta1-gr) * math.sin(gr+math.pi/2) v2_x = ( (v2*math.cos(zeta2-gr) * (m2-m1) + 2*m1*v1*math.cos(zeta1-gr) ) * math.cos(gr) )/(m1+m2) + v2*math.sin(zeta2-gr) * math.cos(gr+math.pi/2) v2_y = ( (v2*math.cos(zeta2-gr) * (m2-m1) + 2*m1*v1*math.cos(zeta1-gr) ) * math.sin(gr) )/(m1+m2) + v2*math.sin(zeta2-gr) * math.sin(gr+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330282021 134 (2021-01-29 22:15) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) a3 = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 v1_x = ((((v1*math.cos(a1-a3)*(m1-m2))+(2*m2*v2*math.cos(a2-a3)))/(m1+m2))*math.cos(a3))+(v1*math.sin(a1-a3)*math.cos(a3+(math.pi/2))) v1_y = ((((v1*math.cos(a1-a3)*(m1-m2))+(2*m2*v2*math.cos(a2-a3)))/(m1+m2))*math.sin(a3))+(v1*math.sin(a1-a3)*math.sin(a3+(math.pi/2))) v2_x = ((((v2*math.cos(a2-a3)*(m2-m1))+(2*m1*v1*math.cos(a1-a3)))/(m2+m1))*math.cos(a3))+(v2*math.sin(a2-a3)*math.cos(a3+(math.pi/2))) v2_y = ((((v2*math.cos(a2-a3)*(m2-m1))+(2*m1*v1*math.cos(a1-a3)))/(m2+m1))*math.sin(a3))+(v2*math.sin(a2-a3)*math.sin(a3+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330283721 135 (2021-01-28 11:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a= (x1-x2)/((x1-x2)**2+(y1-y2)**2)**(1/2) b= (y1-y2)/((x1-x2)**2+(y1-y2)**2)**(1/2) v1_x = (((v1x*a + v1y*b)*(r1**2-r2**2)+ (2*r2**2)*(v2x*a+v2y*b))*a/(r1**2+r2**2))+(v1y*a-v1x*b)*(-b) v1_y = (((v1x*a + v1y*b)*(r1**2-r2**2)+ (2*r2**2)*(v2x*a+v2y*b))*b/(r1**2+r2**2))+(v1y*a-v1x*b)*a v2_x = (((v2x*a + v2y*b)*(r2**2-r1**2)+ (2*r1**2)*(v1x*a+v1y*b))*a/(r2**2+r1**2))+(v2y*a-v2x*b)*(-b) v2_y = (((v2x*a + v2y*b)*(r2**2-r1**2)+ (2*r1**2)*(v1x*a+v1y*b))*b/(r2**2+r1**2))+(v2y*a-v2x*b)*a return (v1_x, v1_y), (v2_x, v2_y) |
# 6330284321 136 (2021-01-30 15:39) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x * v1x + v1y * v1y) v2 = math.sqrt(v2x * v2x + v2y * v2y) t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) p = math.atan2(y1 - y2,x1 - x2) m1 = r1 * r1 m2 = r2 * r2 ft1 = (v1 * math.cos(t1 - p) * (m1 - m2) + 2 * m2 * v2 * math.cos(t2 -p)) / (m1 + m2) ft2 = (v2 * math.cos(t2 - p) * (m2 - m1) + 2* m1 * v1 * math.cos(t1 - p)) / (m2 + m1) se1 = v1 * math.sin(t1 - p) se2 = v2 * math.sin(t2 - p) v1_x = ft1 * math.cos(p) + se1 * math.cos(p + math.pi / 2) v1_y = ft1 * math.sin(p) + se1 * math.sin(p + math.pi / 2) v2_x = ft2 * math.cos(p) + se2 * math.cos(p + math.pi / 2) v2_y = ft2 * math.sin(p) + se2 * math.sin(p + math.pi / 2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330285021 137 (2021-01-30 17:07) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) y = math.atan2((y1-y2),(x2-x1)) v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) v1_x = (((v1*math.cos(t1-y)*(m1-m2))+(2*m2*v2*math.cos(t2-y)))*(math.cos(y)/(m1+m2)))+(v1*math.sin(t1-y)*math.cos(y+(math.pi)/2)) v1_y = (((v1*math.cos(t1-y)*(m1-m2))+(2*m2*v2*math.cos(t2-y)))*(math.sin(y)/(m1+m2)))+(v1*math.sin(t1-y)*math.sin(y+(math.pi)/2)) v2_x = (((v2*math.cos(t2-y)*(m2-m1))+(2*m1*v1*math.cos(t1-y)))*(math.cos(y)/(m1+m2)))+(v2*math.sin(t2-y)*math.cos(y+(math.pi)/2)) v2_y = (((v2*math.cos(t2-y)*(m2-m1))+(2*m1*v1*math.cos(t1-y)))*(math.sin(y)/(m1+m2)))+(v2*math.sin(t2-y)*math.sin(y+(math.pi)/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330286621 138 (2021-01-29 14:58) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 phi=math.atan2((y2-y1),(x2-x1)) #atan = (pi/2 to -pi/2) theta1=math.atan2(v1y,v1x) #atan2 = (0 to pi) and vx can =0 theta2=math.atan2(v2y,v2x) cos1=math.cos(theta1-phi) cos2=math.cos(theta2-phi) cosphi=math.cos(phi) sinphi=math.sin(phi) sin1=math.sin(theta1-phi) sin2=math.sin(theta2-phi) cosphipi=math.cos(phi+math.pi/2) sinphipi=math.sin(phi+math.pi/2) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x =(v1*cos1*(m1-m2)+2*m2*v2*cos2)*cosphi/(m1+m2)+(v1*sin1*cosphipi) v1_y =(v1*cos1*(m1-m2)+2*m2*v2*cos2)*sinphi/(m1+m2)+(v1*sin1*sinphipi) v2_x =(v2*cos2*(m2-m1)+2*m1*v1*cos1)*cosphi/(m1+m2)+(v2*sin2*cosphipi) v2_y =(v2*cos2*(m2-m1)+2*m1*v1*cos1)*sinphi/(m1+m2)+(v2*sin2*sinphipi) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330288921 139 (2021-01-30 21:11) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 a = math.atan2(v1y,v1x) z = math.atan2(v2y,v2x) r = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = ((v1*math.cos(a-r)*(m1-m2)+2*m2*v2*math.cos(z-r))/(m1+m2))*math.cos(r)+v1*math.sin(a-r)*math.cos(r+math.pi/2) v1_y = ((v1*math.cos(a-r)*(m1-m2)+2*m2*v2*math.cos(z-r))/(m1+m2))*math.sin(r)+v1*math.sin(a-r)*math.sin(r+math.pi/2) v2_x = ((v2*math.cos(z-r)*(m2-m1)+2*m1*v1*math.cos(a-r))/(m1+m2))*math.cos(r)+v2*math.sin(z-r)*math.cos(r+math.pi/2) v2_y = ((v2*math.cos(z-r)*(m2-m1)+2*m1*v1*math.cos(a-r))/(m1+m2))*math.sin(r)+v2*math.sin(z-r)*math.sin(r+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330289521 140 (2021-01-29 11:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=((v1x**2)+(v1y**2))**0.5 v2=((v2x**2)+(v2y**2))**0.5 m1=r1*r1 m2=r2*r2 angle1=math.atan2(v1y,v1x) angle2=math.atan2(v2y,v2x) angle3=math.atan2((y2-y1),(x2-x1)) dcos13=math.cos(angle1-angle3) dsin13=math.sin(angle1-angle3) dcos23=math.cos(angle2-angle3) dsin23=math.sin(angle2-angle3) dcpi3=math.cos(angle3+math.pi/2) dspi3=math.sin(angle3+math.pi/2) v1_x=((v1*dcos13*(m1-m2)+2*m2*v2*dcos23)/(m1+m2)*math.cos(angle3))+v1*dsin13*dcpi3 v1_y=((v1*dcos13*(m1-m2)+2*m2*v2*dcos23)/(m1+m2)*math.sin(angle3))+v1*dsin13*dspi3 v2_x=((v2*dcos23*(m2-m1)+2*m1*v1*dcos13)/(m1+m2)*math.cos(angle3))+v2*dsin23*dcpi3 v2_y=((v2*dcos23*(m2-m1)+2*m1*v1*dcos13)/(m1+m2)*math.sin(angle3))+v2*dsin23*dspi3 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330290021 141 (2021-01-31 22:17) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 A = math.atan2(y2-y1,x2-x1) B = math.atan2(v1y,v1x) C = math.atan2(v2y,v2x) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1x = ((((v1*math.cos(B-A)*(m1-m2)+ 2*m2*v2*math.cos(C-A))/(m1+m2))*math.cos(A))+v1*math.sin(B-A)*math.cos(A+(math.pi/2))) v1y = ((((v1*math.cos(B-A)*(m1-m2)+ 2*m2*v2*math.cos(C-A))/(m1+m2))*math.sin(A))+v1*math.sin(B-A)*math.sin(A+(math.pi/2))) v2x = ((((v2*math.cos(C-A)*(m2-m1)+ 2*m1*v1*math.cos(B-A))/(m1+m2))*math.cos(A))+v2*math.sin(C-A)*math.cos(A+(math.pi/2))) v2y = ((((v2*math.cos(C-A)*(m2-m1)+ 2*m1*v1*math.cos(B-A))/(m1+m2))*math.sin(A))+v2*math.sin(C-A)*math.sin(A+(math.pi/2))) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330291721 142 (2021-01-30 21:30) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1 **2 m2 = r2 **2 v1 = ((v1x)**2 + (v1y)**2)**(1/2) v2 = ((v2x)**2 + (v2y)**2)**(1/2) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) a12 = math.atan2((y1-y2),(x1-x2)) v1_x = (((v1 * math.cos(a1-a12)*(m1-m2)) + (2*m2*v2*math.cos(a2-a12)))/(m1+m2)*math.cos(a12))+v1*math.sin(a1-a12)*math.cos(a12 + math.pi/2) v1_y = (((v1 * math.cos(a1-a12)*(m1-m2)) + (2*m2*v2*math.cos(a2-a12)))/(m1+m2)*math.sin(a12))+v1*math.sin(a1-a12)*math.sin(a12 + math.pi/2) v2_x = (((v2 * math.cos(a2-a12)*(m2-m1)) + (2*m1*v1*math.cos(a1-a12)))/(m1+m2)*math.cos(a12))+v2*math.sin(a2-a12)*math.cos(a12 + math.pi/2) v2_y = (((v2 * math.cos(a2-a12)*(m2-m1)) + (2*m1*v1*math.cos(a1-a12)))/(m1+m2)*math.sin(a12))+v2*math.sin(a2-a12)*math.sin(a12 + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330292321 143 (2021-01-30 19:07) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) l = math.atan2((y1-y2),(x1-x2)) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = ((((v1*math.cos(s1-l)*(m1-m2))+(2*m2*v2*math.cos(s2-l)))/(m1+m2))*(math.cos(l)))+(v1*math.sin(s1-l)*math.cos(l+math.pi/2)) v1_y = ((((v1*math.cos(s1-l)*(m1-m2))+(2*m2*v2*math.cos(s2-l)))/(m1+m2))*(math.sin(l)))+(v1*math.sin(s1-l)*math.sin(l+math.pi/2)) v2_x = ((((v2*math.cos(s2-l)*(m2-m1))+(2*m1*v1*math.cos(s1-l)))/(m2+m1))*(math.cos(l)))+(v2*math.sin(s2-l)*math.cos(l+math.pi/2)) v2_y = ((((v2*math.cos(s2-l)*(m2-m1))+(2*m1*v1*math.cos(s1-l)))/(m2+m1))*(math.sin(l)))+(v2*math.sin(s2-l)*math.sin(l+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330293021 144 (2021-01-31 00:11) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) a = math.atan((y1-y2)/(x1-x2)) v1_x = (((v1*(math.cos(zeta1-a)))*(m1-m2))+(2*m2*v2*(math.cos(zeta2-a))))*((math.cos(a))/(m1+m2))+v1*(math.sin(zeta1-a))*(math.cos(a+(math.pi)/2)) v1_y = (((v1*(math.cos(zeta1-a)))*(m1-m2))+(2*m2*v2*(math.cos(zeta2-a))))*((math.sin(a))/(m1+m2))+v1*(math.sin(zeta1-a))*(math.sin(a+(math.pi)/2)) v2_x = (((v2*(math.cos(zeta2-a)))*(m2-m1))+(2*m1*v1*(math.cos(zeta1-a))))*((math.cos(a))/(m1+m2))+v2*(math.sin(zeta2-a))*(math.cos(a+(math.pi)/2)) v2_y = (((v2*(math.cos(zeta2-a)))*(m2-m1))+(2*m1*v1*(math.cos(zeta1-a))))*((math.sin(a))/(m1+m2))+v2*(math.sin(zeta2-a))*(math.sin(a+(math.pi)/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330294621 145 (2021-01-31 23:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = (math.pow(r1, 2)+math.pow(r2, 2)) v1 = (math.pow(v1x**2+v1y**2,0.5)) v2 = (math.pow(v2x**2+v2y**2,0.5)) theta1 = (math.atan2(v1y,v1x)) theta2 = (math.atan2(v2y,v2x)) phi = (math.atan((y2-y1)/(x2-x1))) dm12 = (math.pow(r1, 2)-math.pow(r2, 2)) dm21 = (math.pow(r2, 2)-math.pow(r1, 2)) _2m2v2 = 2*(r2**2)*v2*math.cos(theta2-phi) _2m1v1 = 2*(r1**2)*v1*math.cos(theta1-phi) j11 = v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) j12 = v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) j21 = v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) j22 = v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) v1_x = (((v1*math.cos(theta1-phi)*dm12)+_2m2v2)/a)*math.cos(phi)+j11 v1_y = (((v1*math.cos(theta1-phi)*dm12)+_2m2v2)/a)*math.sin(phi)+j12 v2_x = (((v2*math.cos(theta2-phi)*dm21)+_2m1v1)/a)*math.cos(phi)+j21 v2_y = (((v2*math.cos(theta2-phi)*dm21)+_2m1v1)/a)*math.sin(phi)+j22 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330295221 146 (2021-01-29 00:06) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 phi = math.atan2((y2-y1),(x2-x1)) v1_x = (v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330296921 147 (2021-02-01 13:11) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here A1 = math.atan2(v1y,v1x) A2 = math.atan2(v2y,v2x) phi1 = math.atan2(y1-y2,x1-x2) phi2 = math.atan2(y2-y1,x2-x1) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(A1-phi1)*(m1-m2)+2*m2*v2*math.cos(A2-phi1))/(m1+m2))*math.cos(phi1))+(v1*math.sin(A1-phi1)*math.cos(phi1+(math.pi/2))) v1_y = (((v1*math.cos(A1-phi1)*(m1-m2)+2*m2*v2*math.cos(A2-phi1))/(m1+m2))*math.sin(phi1))+(v1*math.sin(A1-phi1)*math.sin(phi1+(math.pi/2))) v2_x = (((v2*math.cos(A2-phi2)*(m2-m1)+2*m1*v1*math.cos(A1-phi2))/(m1+m2))*math.cos(phi2))+(v2*math.sin(A2-phi2)*math.cos(phi2+(math.pi/2))) v2_y = (((v2*math.cos(A2-phi2)*(m2-m1)+2*m1*v1*math.cos(A1-phi2))/(m1+m2))*math.sin(phi2))+(v2*math.sin(A2-phi2)*math.sin(phi2+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330298121 148 (2021-01-31 21:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 theta2 = math.atan2(v2y, v2x) theta1 = math.atan2(v1y, v1x) phi = math.atan2((y2-y1),(x2-x1)) v1x = (v1*math.cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(theta2 - phi))/(m1+m2) * math.cos(phi) + v1*math.sin(theta1 - phi)*math.cos(phi + math.pi/2) v1y = (v1*math.cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(theta2 - phi))/(m1+m2) * math.sin(phi) + v1*math.sin(theta1 - phi)*math.sin(phi + math.pi/2) v2x = (v2*math.cos(theta2 - phi)*(m2 - m1) + 2*m1*v1*math.cos(theta1 - phi))/(m1+m2) * math.cos(phi) + v2*math.sin(theta2 - phi)*math.cos(phi + math.pi/2) v2y = (v2*math.cos(theta2 - phi)*(m2 - m1) + 2*m1*v1*math.cos(theta1 - phi))/(m1+m2) * math.sin(phi) + v2*math.sin(theta2 - phi)*math.sin(phi + math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330299821 149 (2021-01-28 15:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2((v2y-v1y), (v1x-v2x)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = (((((v1*math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi))/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((((v1*math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi))/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((((v2*math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi))/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((((v2*math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi))/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330300721 150 (2021-01-29 23:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 dg1 = math.atan2(v1y,v1x) dg2 = math.atan2(v2y,v2x) iu = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(dg1-iu)*(m1-m2)+2*m2*v2*math.cos(dg2-iu))*math.cos(iu)/(m1+m2))+v1*math.sin(dg1-iu)*math.cos(iu+math.pi/2) v1_y = ((v1*math.cos(dg1-iu)*(m1-m2)+2*m2*v2*math.cos(dg2-iu))*math.sin(iu)/(m1+m2))+v1*math.sin(dg1-iu)*math.sin(iu+math.pi/2) v2_x = ((v2*math.cos(dg2-iu)*(m2-m1)+2*m1*v1*math.cos(dg1-iu))*math.cos(iu)/(m1+m2))+v2*math.sin(dg2-iu)*math.cos(iu+math.pi/2) v2_y = ((v2*math.cos(dg2-iu)*(m2-m1)+2*m1*v1*math.cos(dg1-iu))*math.sin(iu)/(m1+m2))+v2*math.sin(dg2-iu)*math.sin(iu+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330301321 151 (2021-01-30 12:50) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): #-------------------------start of student's work--- pi = math.pi m1 = r1 * r1 m2 = r2 * r2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) phi = math.atan2(y2-y1,x2-x1) thet1 = math.atan2(v1y,v1x) thet2 = math.atan2(v2y,v2x) v1_x = ( ( ( (v1*math.cos(thet1-phi)*(m1-m2)) + (2*m2*v2*math.cos(thet2-phi)) ) / (m1+m2) ) * math.cos(phi) ) + (v1*math.sin(thet1-phi)*math.cos(phi+(pi/2))) v1_y = ( ( ( (v1*math.cos(thet1-phi)*(m1-m2)) + (2*m2*v2*math.cos(thet2-phi)) ) / (m1+m2) ) * math.sin(phi) ) + (v1*math.sin(thet1-phi)*math.sin(phi+(pi/2))) v2_x = ( ( ( (v2*math.cos(thet2-phi)*(m2-m1)) + (2*m1*v1*math.cos(thet1-phi)) ) / (m2+m1) ) * math.cos(phi) ) + (v2*math.sin(thet2-phi)*math.cos(phi+(pi/2))) v2_y = ( ( ( (v2*math.cos(thet2-phi)*(m2-m1)) + (2*m1*v1*math.cos(thet1-phi)) ) / (m2+m1) ) * math.sin(phi) ) + (v2*math.sin(thet2-phi)*math.sin(phi+(pi/2))) #--------------------------end of student's work--- return (v1_x, v1_y), (v2_x, v2_y) |
# 6330302021 152 (2021-02-01 23:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 distancey = y2 - y1 distancex = x2 - x1 seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) phi = math.atan2((distancey),(distancex)) v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 v1x = (((v1*(math.cos(seta1-phi))*(m1-m2))+(2*m2*v2*math.cos(seta2-phi)))/(m1+m2))*(math.cos(phi))+v1*math.sin(seta1-phi)*math.cos(phi+math.pi/2) v1y = (((v1*(math.cos(seta1-phi))*(m1-m2))+(2*m2*v2*math.cos(seta2-phi)))/(m1+m2))*(math.sin(phi))+v1*math.sin(seta1-phi)*math.sin(phi+math.pi/2) v2x = (((v2*(math.cos(seta2-phi))*(m2-m1))+(2*m1*v1*math.cos(seta1-phi)))/(m1+m2))*(math.cos(phi))+v2*math.sin(seta2-phi)*math.cos(phi+math.pi/2) v2y = (((v2*(math.cos(seta2-phi))*(m2-m1))+(2*m1*v1*math.cos(seta1-phi)))/(m1+m2))*(math.sin(phi))+v2*math.sin(seta2-phi)*math.sin(phi+math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330303621 153 (2021-01-31 15:05) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here c1 = math.atan2(v1y, v1x) phi = math.atan2(y1-y2, x1-x2) m1 = r1**2 v1 = ((v1x**2)+(v1y**2))**0.5 c2 = math.atan2(v2y, v2x) m2 = r2**2 v2 = ((v2x**2)+(v2y**2))**0.5 v1_x = (((v1*math.cos(c1-phi)*(m1-m2))+(2*m2*v2*math.cos(c2-phi)))*math.cos(phi)/(m1+m2)+((v1*math.sin(c1-phi)*math.cos(phi+(math.pi/2))))) v1_y = (((v1*math.cos(c1-phi)*(m1-m2))+(2*m2*v2*math.cos(c2-phi)))*math.sin(phi)/(m1+m2)+((v1*math.sin(c1-phi)*math.sin(phi+(math.pi/2))))) v2_x = (((v2*math.cos(c2-phi)*(m2-m1))+(2*m1*v1*math.cos(c1-phi)))*math.cos(phi)/(m1+m2)+((v2*math.sin(c2-phi)*math.cos(phi+(math.pi/2))))) v2_y = (((v2*math.cos(c2-phi)*(m2-m1))+(2*m1*v1*math.cos(c1-phi)))*math.sin(phi)/(m1+m2)+((v2*math.sin(c2-phi)*math.sin(phi+(math.pi/2))))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330304221 154 (2021-01-29 22:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def v_net(vx, vy): """ Calculate the net velocity """ return math.sqrt(math.pow(vx, 2) + math.pow(vy, 2)) def controlVar(v1, r1,theta_1, v2, r2, theta_2, phi): """ Calculate the same expression for the velocity formula """ m1 = r1 ** 2 m2 = r2 ** 2 control_var = (v1*math.cos(theta_1-phi)*(m1 - m2) + 2*m2*v2*math.cos(theta_2-phi))/(m1+m2) return control_var phi = math.atan2(y2-y1, x2-x1) theta_1 = math.atan2(v1y, v1x) theta_2 = math.atan2(v2y, v2x) v1 = v_net(v1x, v1y) v2 = v_net(v2x, v2y) cont1 = controlVar(v1, r1, theta_1, v2, r2, theta_2, phi) cont2 = controlVar(v2, r2, theta_2, v1, r1, theta_1, phi) v1_x = cont1 * math.cos(phi) + (v1 * math.sin(theta_1-phi) * math.cos(phi+(math.pi)/2)) v1_y = cont1 * math.sin(phi) + (v1 * math.sin(theta_1-phi) * math.sin(phi+(math.pi)/2)) v2_x = cont2 * math.cos(phi) + (v2 * math.sin(theta_2-phi) * math.cos(phi+(math.pi)/2)) v2_y = cont2 * math.sin(phi) + (v2 * math.sin(theta_2-phi) * math.sin(phi+(math.pi)/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330305921 155 (2021-01-29 23:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 ang1 = (math.atan2(v1y,v1x)) ang2 = (math.atan2(v2y,v2x)) ang3 = (math.atan2((y2-y1),(x2-x1))) m1 = r1**2 m2 = r2**2 # insert your code here v1_x = ((v1*math.cos(ang1-ang3)*(m1-m2)+2*m2*v2*math.cos(ang2-ang3))/(m1+m2))*math.cos(ang3)+v1*math.sin(ang1-ang3)*math.cos(ang3+math.pi/2) v1_y = ((v1*math.cos(ang1-ang3)*(m1-m2)+2*m2*v2*math.cos(ang2-ang3))/(m1+m2))*math.sin(ang3)+v1*math.sin(ang1-ang3)*math.sin(ang3+math.pi/2) v2_x = ((v2*math.cos(ang2-ang3)*(m2-m1)+2*m1*v1*math.cos(ang1-ang3))/(m1+m2))*math.cos(ang3)+v2*math.sin(ang2-ang3)*math.cos(ang3+math.pi/2) v2_y = ((v2*math.cos(ang2-ang3)*(m2-m1)+2*m1*v1*math.cos(ang1-ang3))/(m1+m2))*math.sin(ang3)+v2*math.sin(ang2-ang3)*math.sin(ang3+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330306521 156 (2021-01-31 00:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) beta = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 u1x = ((v1*math.cos(seta1-beta)*(m1-m2)+2*m2*v2*math.cos(seta2-beta))*math.cos(beta)/(m1+m2))\ +v1*math.sin(seta1-beta)*math.cos(beta+math.pi/2) u1y = ((v1*math.cos(seta1-beta)*(m1-m2)+2*m2*v2*math.cos(seta2-beta))*math.sin(beta)/(m1+m2))\ +v1*math.sin(seta1-beta)*math.sin(beta+math.pi/2) u2x = ((v2*math.cos(seta2-beta)*(m2-m1)+2*m1*v1*math.cos(seta1-beta))*math.cos(beta)/(m1+m2))\ +v2*math.sin(seta2-beta)*math.cos(beta+math.pi/2) u2y = ((v2*math.cos(seta2-beta)*(m2-m1)+2*m1*v1*math.cos(seta1-beta))*math.sin(beta)/(m1+m2))\ +v2*math.sin(seta2-beta)*math.sin(beta+math.pi/2) v1_x = u1x v1_y = u1y v2_x = u2x v2_y = u2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330308821 157 (2021-01-28 23:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) seta1 = math.atan2(v1y, v1x) seta2 = math.atan2(v2y, v2x) phi = math.atan2((y2-y1), (x2-x1)) v1_x = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))*math.cos(phi))/(m1+m2) + v1*math.sin(seta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))*math.sin(phi))/(m1+m2) + v1*math.sin(seta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))*math.cos(phi))/(m2+m1) + v2*math.sin(seta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))*math.sin(phi))/(m2+m1) + v2*math.sin(seta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330309421 158 (2021-02-01 15:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = ((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.cos(phi)) + (v1*(math.sin(theta1-phi))*(math.cos(phi+(math.pi)/2))) v1_y = ((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.sin(phi)) + (v1*(math.sin(theta1-phi))*(math.sin(phi+(math.pi)/2))) v2_x = ((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.cos(phi)) + (v2*(math.sin(theta2-phi))*(math.cos(phi+(math.pi)/2))) v2_y = ((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.sin(phi)) + (v2*(math.sin(theta2-phi))*(math.sin(phi+(math.pi)/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330310021 159 (2021-01-29 22:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here delta1 = math.atan2(v1y, v1x) delta2 = math.atan2(v2y, v2x) lowercase_phi = math.atan2((y2-y1), (x2-x1)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 v1_x = ((v1*math.cos(delta1 - lowercase_phi)*(m1-m2) + 2*m2*v2*math.cos(delta2 - lowercase_phi))*math.cos(lowercase_phi)/(m1+m2)) + v1*math.sin(delta1 - lowercase_phi)*math.cos(lowercase_phi + (math.pi/2)) v1_y = ((v1*math.cos(delta1 - lowercase_phi)*(m1-m2) + 2*m2*v2*math.cos(delta2 - lowercase_phi))*math.sin(lowercase_phi)/(m1+m2)) + v1*math.sin(delta1 - lowercase_phi)*math.sin(lowercase_phi + (math.pi/2)) v2_x = ((v2*math.cos(delta2 - lowercase_phi)*(m2-m1) + 2*m1*v1*math.cos(delta1 - lowercase_phi))*math.cos(lowercase_phi)/(m1+m2)) + v2*math.sin(delta2 - lowercase_phi)*math.cos(lowercase_phi + (math.pi/2)) v2_y = ((v2*math.cos(delta2 - lowercase_phi)*(m2-m1) + 2*m1*v1*math.cos(delta1 - lowercase_phi))*math.sin(lowercase_phi)/(m1+m2)) + v2*math.sin(delta2 - lowercase_phi)*math.sin(lowercase_phi + (math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330311621 160 (2021-01-29 21:20) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan2(v1y,v1x) b = math.atan2(v2y,v2x) c = math.atan2((y1-y2),(x1-x2)) v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 m1 = r1**2 m2 = r2**2 v1x = (((((v1*math.cos(a-c)*(m1-m2))+(2*m2*(v2*math.cos(b-c))))/(m1+m2)))*math.cos(c))+(v1*math.sin(a-c)*math.cos(c+(math.pi/2))) v1y = (((((v1*math.cos(a-c)*(m1-m2))+(2*m2*(v2*math.cos(b-c))))/(m1+m2)))*math.sin(c))+(v1*math.sin(a-c)*math.sin(c+(math.pi/2))) v2x = (((((v2*math.cos(b-c)*(m2-m1))+(2*m1*(v1*math.cos(a-c))))/(m1+m2)))*math.cos(c))+(v2*math.sin(b-c)*math.cos(c+(math.pi/2))) v2y = (((((v2*math.cos(b-c)*(m2-m1))+(2*m1*(v1*math.cos(a-c))))/(m1+m2)))*math.sin(c))+(v2*math.sin(b-c)*math.sin(c+(math.pi/2))) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330312221 161 (2021-01-28 23:46) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) f = math.atan2((y1-y2),(x1-x2)) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(o1-f)*(m1-m2))+(2*m2*v2*math.cos(o2-f)))/(m1+m2))*math.cos(f))+(v1*(math.sin(o1-f))*math.cos(f+(math.pi/2))) v1_y = ((((v1*math.cos(o1-f)*(m1-m2))+(2*m2*v2*math.cos(o2-f)))/(m1+m2))*math.sin(f))+(v1*(math.sin(o1-f))*math.sin(f+(math.pi/2))) v2_x = ((((v2*math.cos(o2-f)*(m2-m1))+(2*m1*v1*math.cos(o1-f)))/(m1+m2))*math.cos(f))+(v2*(math.sin(o2-f))*math.cos(f+(math.pi/2))) v2_y = ((((v2*math.cos(o2-f)*(m2-m1))+(2*m1*v1*math.cos(o1-f)))/(m1+m2))*math.sin(f))+(v2*(math.sin(o2-f))*math.sin(f+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330313921 162 (2021-01-31 01:23) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = (r1)**2 m2 = (r2)**2 theta1 = math.atan2(v1y , v1x) theta2 = math.atan2(v2y , v2x) phi = math.atan2((y1-y2) , (x1-x2)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = (((v1*(math.cos(theta1 - phi))*(m1 - m2) + 2*m2*v2*(math.cos(theta2 - phi)))*(math.cos(phi)))/(m1 + m2)) + v1*math.sin(theta1 - phi)*math.cos(phi + math.pi/2) v1_y = (((v1*(math.cos(theta1 - phi))*(m1 - m2) + 2*m2*v2*(math.cos(theta2 - phi)))*(math.sin(phi)))/(m1 + m2)) + v1*math.sin(theta1 - phi)*math.sin(phi + math.pi/2) v2_x = (((v2*(math.cos(theta2 - phi))*(m2 - m1) + 2*m1*v1*(math.cos(theta1 - phi)))*(math.cos(phi)))/(m1 + m2)) + v2*math.sin(theta2 - phi)*math.cos(phi + math.pi/2) v2_y = (((v2*(math.cos(theta2 - phi))*(m2 - m1) + 2*m1*v1*(math.cos(theta1 - phi)))*(math.sin(phi)))/(m1 + m2)) + v2*math.sin(theta2 - phi)*math.sin(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330314521 163 (2021-02-01 15:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1 ** 2 m2 = r2 ** 2 v1 = math.sqrt((v1x ** 2) + (v1y ** 2)) v2 = math.sqrt((v2x ** 2) + (v2y ** 2)) A1 = math.atan2(v1y,v1x) A2 = math.atan2(v2y,v2x) B = math.atan2(y2-y1,x2-x1) v1_x = ( ( ( (v1 * math.cos(A1 - B) * (m1 - m2))+(2 * m2 * v2 * math.cos(A2 - B)) )/(m1 + m2) ) * math.cos(B) ) + (v1 * math.sin(A1 - B) * math.cos(B + (math.pi/2))) v2_x = ( ( ( (v2 * math.cos(A2 - B) * (m2 - m1))+(2 * m1 * v1 * math.cos(A1 - B)) )/(m1 + m2) ) * math.cos(B) ) + (v2 * math.sin(A2 - B) * math.cos(B + (math.pi/2))) v1_y = ( ( ( (v1 * math.cos(A1 - B) * (m1 - m2))+(2 * m2 * v2 * math.cos(A2 - B)) )/(m1 + m2) ) * math.sin(B) ) + (v1 * math.sin(A1 - B) * math.sin(B + (math.pi/2))) v2_y = ( ( ( (v2 * math.cos(A2 - B) * (m2 - m1))+(2 * m1 * v1 * math.cos(A1 - B)) )/(m1 + m2) ) * math.sin(B) ) + (v2 * math.sin(A2 - B) * math.sin(B + (math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330315121 164 (2021-01-31 13:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) phi = math.atan2(y1-y2,x1-x2) v1_x = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.cos(phi) + v1*math.sin(seta1-phi)*math.cos(phi + math.pi/2) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.sin(phi) + v1*math.sin(seta1-phi)*math.sin(phi + math.pi/2) v2_x = ((v2*math.cos(seta2-phi)*(m2-m1) + 2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.cos(phi) + v2*math.sin(seta2-phi)*math.cos(phi + math.pi/2) v2_y = ((v2*math.cos(seta2-phi)*(m2-m1) + 2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.sin(phi) + v2*math.sin(seta2-phi)*math.sin(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330316821 165 (2021-01-31 23:03) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) grammar = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**(1/2) v2 = (v2x**2+v2y**2)**(1/2) diff_cosin1 = math.cos(seta1)*math.cos(grammar) + math.sin(seta1)*math.sin(grammar) diff_cosin2 = math.cos(seta2)*math.cos(grammar) + math.sin(seta2)*math.sin(grammar) diff_sin1 = math.sin(seta1)*math.cos(grammar) - math.cos(seta1)*math.sin(grammar) diff_sin2 = math.sin(seta2)*math.cos(grammar) - math.cos(seta2)*math.sin(grammar) cosin_y = math.cos(grammar) sin_y = math.sin(grammar) cosin_pi = math.cos(grammar)*math.cos(math.pi/2) - math.sin(grammar)*math.sin(math.pi/2) sin_pi = math.sin(grammar)*math.cos(math.pi/2)+ math.cos(grammar)*math.sin(math.pi/2) v1_x = (v1*diff_cosin1*(m1-m2) + 2*m2*v2*diff_cosin2)*cosin_y/(m1+m2) + v1*diff_sin1*cosin_pi v1_y = (v1*diff_cosin1*(m1-m2) + 2*m2*v2*diff_cosin2)*sin_y/(m1+m2) + v1*diff_sin1*sin_pi v2_x = (v2*diff_cosin2*(m2-m1) + 2*m1*v1*diff_cosin1)*cosin_y/(m1+m2) + v2*diff_sin2*cosin_pi v2_y = (v2*diff_cosin2*(m2-m1) + 2*m1*v1*diff_cosin1)*sin_y/(m1+m2) + v2*diff_sin2*sin_pi return (v1_x, v1_y), (v2_x, v2_y) |
# 6330317421 166 (2021-01-29 23:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2y) b = math.atan2((y1-y2),(x1-x2)) v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 v1x = (v1*math.cos(a1-b)*(m1-m2) + 2*m2*v2*math.cos(a2-b))/(m1 + m2)*math.cos(b) + v1*math.sin(a1 - b)*math.cos(b + math.pi/2) v1y = (v1*math.cos(a1-b)*(m1-m2) + 2*m2*v2*math.cos(a2-b))/(m1 + m2)*math.sin(b) + v1*math.sin(a1 - b)*math.sin(b + math.pi/2) v2x = (v2*math.cos(a2-b)*(m2-m1) + 2*m1*v1*math.cos(a1-b))/(m1 + m2)*math.cos(b) + v2*math.sin(a2 - b)*math.cos(b + math.pi/2) v2y = (v2*math.cos(a2-b)*(m2-m1) + 2*m1*v1*math.cos(a1-b))/(m1 + m2)*math.sin(b) + v2*math.sin(a2 - b)*math.sin(b + math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330318021 167 (2021-02-01 22:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) phi=math.atan2((y2-y1),(x2-x1)) th1=math.atan2(v1y,v1x) th2=math.atan2(v2y,v2x) m1=r1**2 m2=r2**2 v1_x = (math.cos(phi)*(v1*math.cos(th1-phi)*(m1-m2)+2*m2*v2*math.cos(th2-phi)))/(m1+m2)+v1*math.sin(th1-phi)*math.cos(phi+math.pi/2) v1_y = (math.sin(phi)*(v1*math.cos(th1-phi)*(m1-m2)+2*m2*v2*math.cos(th2-phi)))/(m1+m2)+v1*math.sin(th1-phi)*math.sin(phi+math.pi/2) v2_x = (math.cos(phi)*(v2*math.cos(th2-phi)*(m2-m1)+2*m1*v1*math.cos(th1-phi)))/(m1+m2)+v2*math.sin(th2-phi)*math.cos(phi+math.pi/2) v2_y = (math.sin(phi)*(v2*math.cos(th2-phi)*(m2-m1)+2*m1*v1*math.cos(th1-phi)))/(m1+m2)+v2*math.sin(th2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330319721 168 (2021-02-01 12:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2(y2-y1,x2-x1) zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 v1x = (((v1*math.cos(zeta1-phi)*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))/(m1+m2))*math.cos(phi)+(v1*math.sin(zeta1-phi)*math.cos(phi+(math.pi/2))) v1y = (((v1*math.cos(zeta1-phi)*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))/(m1+m2))*math.sin(phi)+(v1*math.sin(zeta1-phi)*math.sin(phi+(math.pi/2))) v2x = (((v2*math.cos(zeta2-phi)*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))/(m1+m2))*math.cos(phi)+(v2*math.sin(zeta2-phi)*math.cos(phi+(math.pi/2))) v2y = (((v2*math.cos(zeta2-phi)*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))/(m1+m2))*math.sin(phi)+(v2*math.sin(zeta2-phi)*math.sin(phi+(math.pi/2))) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330320221 169 (2021-01-30 18:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 dx=x2-x1 dy=y2-y1 phi=math.atan2(dy,dx) theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) v1=(v1x**2+v1y**2)**0.5 v2=(v2x**2+v2y**2)**0.5 v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330321921 170 (2021-01-31 21:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1 ** 2 m2 = r2 ** 2 v1 = math.sqrt(v1x ** 2 + v1y ** 2) v2 = math.sqrt(v2x ** 2 + v2y ** 2) theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2((y1 - y2), (x1 - x2)) v1_x = (v1*math.cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(theta2 - phi))*math.cos(phi) / (m1 + m2) + v1*math.sin(theta1 - phi)*math.cos(phi + math.pi/2) v1_y = (v1*math.cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(theta2 - phi))*math.sin(phi) / (m1 + m2) + v1*math.sin(theta1 - phi)*math.cos(phi + math.pi/2) v2_x = (v2*math.cos(theta2 - phi)*(m1 - m2) + 2*m1*v1*math.cos(theta1 - phi))*math.cos(phi) / (m1 + m2) + v2*math.sin(theta2 - phi)*math.cos(phi + math.pi/2) v2_y = (v2*math.cos(theta2 - phi)*(m1 - m2) + 2*m1*v1*math.cos(theta1 - phi))*math.sin(phi) / (m1 + m2) + v2*math.sin(theta2 - phi)*math.cos(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330322521 171 (2021-01-31 15:44) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 a=math.atan2(v1y,v1x) b=math.atan2(v2y,v2x) c=math.atan2(y2-y1,x2-x1) v1=(v1x**2+v1y**2)**0.5 v2=(v2x**2+v2y**2)**0.5 v1_x = (v1*math.cos(a-c)*(m1-m2)+2*m2*v2*math.cos(b-c))*math.cos(c)/(m1+m2)+v1*math.sin(a-c)*math.cos(c+math.pi/2) v1_y = (v1*math.cos(a-c)*(m1-m2)+2*m2*v2*math.cos(b-c))*math.sin(c)/(m1+m2)+v1*math.sin(a-c)*math.sin(c+math.pi/2) v2_x = (v2*math.cos(b-c)*(m2-m1)+2*m1*v1*math.cos(a-c))*math.cos(c)/(m1+m2)+v2*math.sin(b-c)*math.cos(c+math.pi/2) v2_y = (v2*math.cos(b-c)*(m2-m1)+2*m1*v1*math.cos(a-c))*math.sin(c)/(m1+m2)+v2*math.sin(b-c)*math.sin(c+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330323121 172 (2021-02-01 00:11) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) cos1 = math.cos(a1-phi) cos2 = math.cos(a2-phi) cos3 = math.cos(phi) cos4 = math.cos(phi+math.pi/2) sin1 = math.sin(a1-phi) sin2 = math.sin(a2-phi) sin3 = math.sin(phi) sin4 = math.sin(phi+math.pi/2) v1_x = ((v1*cos1*(m1-m2)+2*m2*v2*cos2)*cos3/(m1+m2))+v1*sin1*cos4 v1_y = ((v1*cos1*(m1-m2)+2*m2*v2*cos2)*sin3/(m1+m2))+v1*sin1*sin4 v2_x = ((v2*cos2*(m2-m1)+2*m1*v1*cos1)*cos3/(m1+m2))+v2*sin2*cos4 v2_y = ((v2*cos2*(m2-m1)+2*m1*v1*cos1)*sin3/(m1+m2))+v2*sin2*sin4 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330324821 173 (2021-01-30 17:46) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1=math.atan2(float(v1y),float(v1x)) theta2=math.atan2(float(v2y),float(v2x)) phi=math.atan2(y1-y2,x1-x2) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) a1=v1*(math.cos(theta1-phi)) a2=v2*(math.cos(theta2-phi)) b1=2*m2*v2*math.cos(theta2-phi) b2=2*m1*v1*math.cos(theta1-phi) c1=v1*math.sin(theta1-phi) c2=v2*math.sin(theta2-phi) v1_x = (((a1*(m1-m2)+b1)/(m1+m2))*math.cos(phi))+c1*math.cos(phi+math.pi/2) v1_y = (((a1*(m1-m2)+b1)/(m1+m2))*math.sin(phi))+c1*math.sin(phi+math.pi/2) v2_x = (((a2*(m2-m1)+b2)/(m2+m1))*math.cos(phi))+c2*math.cos(phi+math.pi/2) v2_y = (((a2*(m2-m1)+b2)/(m2+m1))*math.sin(phi))+c2*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330325421 174 (2021-01-30 17:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) teta1=math.atan2(v1y,v1x) teta2=math.atan2(v2y,v2x) phi=math.atan2(y1-y2,x1-x2) m1=r1**2 m2=r2**2 up=(v1*math.cos(teta1-phi)*(m1-m2)+2*m2*v2*math.cos(teta2-phi))/(m1+m2) up2=(v2*math.cos(teta2-phi)*(m2-m1)+2*m1*v1*math.cos(teta1-phi))/(m1+m2) v1x=up*math.cos(phi)+v1*math.sin(teta1-phi)*math.cos(phi+math.pi/2) v1y=up*math.sin(phi)+v1*math.sin(teta1-phi)*math.sin(phi+math.pi/2) v2x=up2*math.cos(phi)+v2*math.sin(teta2-phi)*math.cos(phi+math.pi/2) v2y=up2*math.sin(phi)+v2*math.sin(teta2-phi)*math.sin(phi+math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330326021 175 (2021-01-30 18:29) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi)/(m1+m2)) + (v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi)/(m1+m2)) + (v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi)/(m2+m1)) + (v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi)/(m2+m1)) + (v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330327721 176 (2021-02-01 04:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = ((v1x**2)+(v1y**2))**(1/2) v2 = ((v2x**2)+(v2y**2))**(1/2) q = math.atan2((y1-y2),(x1-x2)) q1 = math.atan2(v1y,v1x) q2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1_x = (((v1 * math.cos(q1-q) * (m1-m2) )+ (2 * m2*v2*math.cos(q2-q)))/(m1+m2))*math.cos(q)+(v1*math.sin(q1-q)*math.cos(q+(math.pi/2))) v1_y = (((v1 * math.cos(q1-q) * (m1-m2) )+ (2 * m2*v2*math.cos(q2-q)))/(m1+m2))*math.sin(q)+(v1*math.sin(q1-q)*math.sin(q+(math.pi/2))) v2_x = (((v2 * math.cos(q2-q) * (m2-m1) )+ (2 * m1*v1*math.cos(q1-q)))/(m1+m2))*math.cos(q)+(v2*math.sin(q2-q)*math.cos(q+(math.pi/2))) v2_y = (((v2 * math.cos(q2-q) * (m2-m1) )+ (2 * m1*v1*math.cos(q1-q)))/(m1+m2))*math.sin(q)+(v2*math.sin(q2-q)*math.sin(q+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330328321 177 (2021-01-30 00:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) v1_x = (((v1*math.cos(zeta1-phi)*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))*math.cos(phi) /(m1+m2))+(v1*math.sin(zeta1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((v1*math.cos(zeta1-phi)*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))*math.sin(phi) /(m1+m2))+(v1*math.sin(zeta1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((v2*math.cos(zeta2-phi)*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))*math.cos(phi) /(m1+m2))+(v2*math.sin(zeta2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((v2*math.cos(zeta2-phi)*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))*math.sin(phi) /(m1+m2))+(v2*math.sin(zeta2-phi)*math.sin(phi+(math.pi/2))) # v1_x = v1x # v1_y = v1y # v2_x = v2x # v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330330521 178 (2021-01-30 22:02) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) tee1 = math.atan2(v1y,v1x) tee2 = math.atan2(v2y,v2x) ep = math.atan2(y2-y1,x2-x1) v1_x = (((v1*math.cos(tee1-ep)*(m1-m2)+2*m2*v2*math.cos(tee2-ep)))/(m1+m2))*math.cos(ep)+(v1*math.sin(tee1-ep)*math.cos(ep+(math.pi/2))) v1_y = (((v1*math.cos(tee1-ep)*(m1-m2)+2*m2*v2*math.cos(tee2-ep)))/(m1+m2))*math.sin(ep)+(v1*math.sin(tee1-ep)*math.sin(ep+(math.pi/2))) v2_x = (((v2*math.cos(tee2-ep)*(m2-m1)+2*m1*v1*math.cos(tee1-ep)))/(m1+m2))*math.cos(ep)+(v2*math.sin(tee2-ep)*math.cos(ep+(math.pi/2))) v2_y = (((v2*math.cos(tee2-ep)*(m2-m1)+2*m1*v1*math.cos(tee1-ep)))/(m1+m2))*math.sin(ep)+(v2*math.sin(tee2-ep)*math.sin(ep+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330331121 179 (2021-01-30 18:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 s1=math.sqrt(v1x**2 + v1y**2) s2=math.sqrt(v2x**2 + v2y**2) a1=math.atan2(v1y,v1x) a2=math.atan2(v2y,v2x) p=math.atan2(y1-y2,x1-x2) v1_x = (((s1*math.cos(a1-p)*(m1-m2))+(2*m2*s2*math.cos(a2-p)))/(m1+m2)*math.cos(p))+(s1*math.sin(a1-p)*math.cos(p+(math.pi/2))) v1_y = (((s1*math.cos(a1-p)*(m1-m2))+(2*m2*s2*math.cos(a2-p)))/(m1+m2)*math.sin(p))+(s1*math.sin(a1-p)*math.sin(p+(math.pi/2))) v2_x = (((s2*math.cos(a2-p)*(m2-m1))+(2*m1*s1*math.cos(a1-p)))/(m1+m2)*math.cos(p))+(s2*math.sin(a2-p)*math.cos(p+(math.pi/2))) v2_y = (((s2*math.cos(a2-p)*(m2-m1))+(2*m1*s1*math.cos(a1-p)))/(m1+m2)*math.sin(p))+(s2*math.sin(a2-p)*math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330332821 180 (2021-01-31 12:59) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt(((v1x)**2)+((v1y)**2)) v2=math.sqrt(((v2x)**2)+((v2y)**2)) z1=math.atan2(v1y,v1x) z2=math.atan2(v2y,v2x) ph=math.atan2(y2-y1,x2-x1) m1=(r1)**2 m2=(r2)**2 v1_x=((((v1*math.cos(z1-ph)*(m1-m2)+2*m2*v2*math.cos(z2-ph))))*math.cos(ph)/(m1+m2))+(v1*math.sin(z1-ph)*math.cos(ph+(math.pi/2))) v1_y=((((v1*math.cos(z1-ph)*(m1-m2)+2*m2*v2*math.cos(z2-ph))))*math.sin(ph)/(m1+m2))+(v1*math.sin(z1-ph)*math.sin(ph+(math.pi/2))) v2_x=((((v2*math.cos(z2-ph)*(m2-m1)+2*m1*v1*math.cos(z1-ph))))*math.cos(ph)/(m1+m2))+(v2*math.sin(z2-ph)*math.cos(ph+(math.pi/2))) v2_y=((((v2*math.cos(z2-ph)*(m2-m1)+2*m1*v1*math.cos(z1-ph))))*math.sin(ph)/(m1+m2))+(v2*math.sin(z2-ph)*math.sin(ph+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330333421 181 (2021-01-30 11:00) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here zeta1=math.atan2(v1y,v1x) zeta2=math.atan2(v2y,v2x) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) phi=math.atan2(y2-y1,x2-x1) prefixv1=(v1*math.cos(zeta1-phi)*(m1-m2)+2*m2*v2*math.cos(zeta2-phi))/(m1+m2) v1_x =prefixv1*math.cos(phi)+v1*math.sin(zeta1-phi)*math.cos(phi+math.pi/2) v1_y =prefixv1*math.sin(phi)+v1*math.sin(zeta1-phi)*math.sin(phi+math.pi/2) prefixv2=(v2*math.cos(zeta2-phi)*(m2-m1)+2*m1*v1*math.cos(zeta1-phi))/(m1+m2) v2_x =prefixv2*math.cos(phi)+v2*math.sin(zeta2-phi)*math.cos(phi+math.pi/2) v2_y =prefixv2*math.sin(phi)+v2*math.sin(zeta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330334021 182 (2021-01-29 23:05) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2((y1-y2), (x1-x2)) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330335721 183 (2021-01-28 20:21) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here pi = math.pi ang = math.atan2((y2-y1),(x2-x1)) seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 m1 = r1**2 m2 = r2**2 pod11 = v1*math.cos(seta1-ang)*(m1-m2);pod12 = 2*m2*v2*math.cos(seta2-ang);mtotal = m1+m2;pod13 = v1*math.sin(seta1-ang)*math.cos((pi/2)+ang) pod21 = v1*math.cos(seta1-ang)*(m1-m2);pod22 = 2*m2*v2*math.cos(seta2-ang);mtotal = m1+m2;pod23 = v1*math.sin(seta1-ang)*math.sin((pi/2)+ang) pod31 = v2*math.cos(seta2-ang)*(m2-m1);pod32 = 2*m1*v1*math.cos(seta1-ang);mtotal = m1+m2;pod33 = v2*math.sin(seta2-ang)*math.cos((pi/2)+ang) pod41 = v2*math.cos(seta2-ang)*(m2-m1);pod42 = 2*m1*v1*math.cos(seta1-ang);mtotal = m1+m2;pod43 = v2*math.sin(seta2-ang)*math.sin((pi/2)+ang) v1_x = ((pod11+pod12)*math.cos(ang)/mtotal)+pod13 v1_y = ((pod21+pod22)*math.sin(ang)/mtotal)+pod23 v2_x = ((pod31+pod32)*math.cos(ang)/mtotal)+pod33 v2_y = ((pod41+pod42)*math.sin(ang)/mtotal)+pod43 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330336321 184 (2021-01-28 20:40) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # theta_1 = math.atan(v1y/v1x) # theta_2 = math.atan(v2y/v2x) phi = math.atan2((y1-y2),(x1-x2)) sphi = math.sin(phi) cphi = math.cos(phi) m1 = r1 ** 2 m2 = r2 ** 2 pi = math.pi #vv1 = math.sqrt(v1x**2 + v1y**2) #vv2 = math.sqrt(v2x**2 + v2y**2) v1_x = ( ((v1x*cphi + v1y*sphi)*(m1-m2) + (2*m2*(v2x*cphi + v2y*sphi)))/(m1+m2) )*cphi + (v1y*cphi - v1x*sphi)*(math.cos(phi+(pi/2))) v1_y = ( ((v1x*cphi + v1y*sphi)*(m1-m2) + (2*m2*(v2x*cphi + v2y*sphi)))/(m1+m2) )*sphi + (v1y*cphi - v1x*sphi)*(math.sin(phi+(pi/2))) v2_x = ( ((v2x*cphi + v2y*sphi)*(m2-m1) + (2*m1*(v1x*cphi + v1y*sphi)))/(m1+m2) )*cphi + (v2y*cphi - v2x*sphi)*(math.cos(phi+(pi/2))) v2_y = ( ((v2x*cphi + v2y*sphi)*(m2-m1) + (2*m1*(v1x*cphi + v1y*sphi)))/(m1+m2) )*sphi + (v2y*cphi - v2x*sphi)*(math.sin(phi+(pi/2))) #v1_x = v1x #v1_y = v1y #v2_x = v2x #v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330337021 185 (2021-01-31 00:03) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 alpha = math.atan2((y1-y2),(x1-x2)) v1_x = (((((v1x*math.cos(alpha)+v1y*math.sin(alpha))*(m1-m2))+(2*(m2)*(v2x*math.cos(alpha)+v2y*math.sin(alpha))))*math.cos(alpha))/(m1+m2))+((v1y*math.cos(alpha)-v1x*math.sin(alpha))*math.cos(alpha+(math.pi/2))) v1_y = (((((v1x*math.cos(alpha)+v1y*math.sin(alpha))*(m1-m2))+(2*(m2)*(v2x*math.cos(alpha)+v2y*math.sin(alpha))))*math.sin(alpha))/(m1+m2))+((v1y*math.cos(alpha)-v1x*math.sin(alpha))*math.sin(alpha+(math.pi/2))) v2_x = (((((v2x*math.cos(alpha)+v2y*math.sin(alpha))*(m2-m1))+(2*(m1)*(v1x*math.cos(alpha)+v1y*math.sin(alpha))))*math.cos(alpha))/(m1+m2))+((v2y*math.cos(alpha)-v2x*math.sin(alpha))*math.cos(alpha+(math.pi/2))) v2_y = (((((v2x*math.cos(alpha)+v2y*math.sin(alpha))*(m2-m1))+(2*(m1)*(v1x*math.cos(alpha)+v1y*math.sin(alpha))))*math.sin(alpha))/(m1+m2))+((v2y*math.cos(alpha)-v2x*math.sin(alpha))*math.sin(alpha+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330338621 186 (2021-01-30 09:42) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) p = math.atan((y1-y2)/(x1-x2)) v1_x = ((((v1*math.cos(o1-p)*(m1-m2)) + (2*m2*v2*math.cos(o2-p)))/(m1+m2))*math.cos(p))\ +(v1*math.sin(o1-p)*math.cos(p+(math.pi/2))) v1_y = ((((v1*math.cos(o1-p)*(m1-m2)) + (2*m2*v2*math.cos(o2-p)))/(m1+m2))*math.sin(p))\ +(v1*math.sin(o1-p)*math.sin(p+(math.pi/2))) v2_x = ((((v2*math.cos(o2-p)*(m2-m1)) + (2*m1*v1*math.cos(o1-p)))/(m1+m2))*math.cos(p))\ +(v2*math.sin(o2-p)*math.cos(p+(math.pi/2))) v2_y = ((((v2*math.cos(o2-p)*(m2-m1)) + (2*m1*v1*math.cos(o1-p)))/(m1+m2))*math.sin(p))\ +(v2*math.sin(o2-p)*math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330339221 187 (2021-01-29 16:24) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a1 = math.atan2(v1y, v1x) a2 = math.atan2(v2y, v2x) a3 = math.atan2(y2-y1 , x2-x1) m1 = r1**2 m2 = r2**2 v1 = v1y/math.sin(a1) v2 = v2y/math.sin(a2) v1_x = (((v1*math.cos(a1-a3)*(m1-m2))+(2*m2*v2*math.cos(a2-a3)))/(m1+m2))*math.cos(a3)+(v1*math.sin(a1-a3)*math.cos(a3+(math.pi/2))) v1_y = (((v1*math.cos(a1-a3)*(m1-m2))+(2*m2*v2*math.cos(a2-a3)))/(m1+m2))*math.sin(a3)+(v1*math.sin(a1-a3)*math.sin(a3+(math.pi/2))) v2_x = (((v2*math.cos(a2-a3)*(m2-m1))+(2*m1*v1*math.cos(a1-a3)))/(m1+m2))*math.cos(a3)+(v2*math.sin(a2-a3)*math.cos(a3+(math.pi/2))) v2_y = (((v2*math.cos(a2-a3)*(m2-m1))+(2*m1*v1*math.cos(a1-a3)))/(m1+m2))*math.sin(a3)+(v2*math.sin(a2-a3)*math.sin(a3+(math.pi/2))) return ((v1_x, v1_y), (v2_x, v2_y)) |
# 6330340821 188 (2021-01-29 23:40) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) seta1=math.atan2(v1y,v1x) seta2=math.atan2(v2y,v2x) fine=math.atan((y2-y1)/(x2-x1)) v1_x = ((((v1*math.cos(seta1-fine)*(m1-m2))+(2*m2*v2*math.cos(seta2-fine)))/(m1+m2))*math.cos(fine))+(v1*math.sin(seta1-fine)*math.cos(fine+(math.pi)/2)) v1_y = ((((v1*math.cos(seta1-fine)*(m1-m2))+(2*m2*v2*math.cos(seta2-fine)))/(m1+m2))*math.sin(fine))+(v1*math.sin(seta1-fine)*math.sin(fine+(math.pi)/2)) v2_x = ((((v2*math.cos(seta2-fine)*(m2-m1))+(2*m1*v1*math.cos(seta1-fine)))/(m2+m1))*math.cos(fine))+(v2*math.sin(seta2-fine)*math.cos(fine+(math.pi)/2)) v2_y = ((((v2*math.cos(seta2-fine)*(m2-m1))+(2*m1*v1*math.cos(seta1-fine)))/(m2+m1))*math.sin(fine))+(v2*math.sin(seta2-fine)*math.sin(fine+(math.pi)/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330341421 189 (2021-01-31 09:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = ((v1x*v1x)+(v1y*v1y))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 m1 = r1**2 m2 = r2**2 o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) q = math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*(math.cos(o1-q))*(m1-m2))+(2*m2*v2*(math.cos(o2-q))))*(math.cos(q)/(m1+m2)))+(v1*(math.sin(o1-q))*math.cos(q+(math.pi/2))) v1_y = (((v1*(math.cos(o1-q))*(m1-m2))+(2*m2*v2*(math.cos(o2-q))))*(math.sin(q)/(m1+m2)))+(v1*(math.sin(o1-q))*math.sin(q+(math.pi/2))) v2_x = (((v2*(math.cos(o2-q))*(m2-m1))+(2*m1*v1*(math.cos(o1-q))))*(math.cos(q)/(m1+m2)))+(v2*(math.sin(o2-q))*math.cos(q+(math.pi/2))) v2_y = (((v2*(math.cos(o2-q))*(m2-m1))+(2*m1*v1*(math.cos(o1-q))))*(math.sin(q)/(m1+m2)))+(v2*(math.sin(o2-q))*math.sin(q+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330342021 190 (2021-02-01 19:25) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) phi=math.atan((y2-y1)/(x2-x1)) m1=math.pow(r1,2) m2=math.pow(r2,2) v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) v1_x=(((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y=(((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x=(((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y=(((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330343721 191 (2021-02-01 20:26) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # insert your code here Thetaone = math.atan2(v1y,v1x) Thetatwo = math.atan2(v2y,v2x) m1 = r1*r1 m2 = r2*r2 phi = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x*v1x+v1y*v1y) v2 = math.sqrt(v2x*v2x+v2y*v2y) v1_x = ((v1*math.cos(Thetaone-phi)*(m1-m2)+2*m2*v2*math.cos(Thetatwo-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(Thetaone-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(Thetaone-phi)*(m1-m2)+2*m2*v2*math.cos(Thetatwo-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(Thetaone-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(Thetatwo-phi)*(m2-m1)+2*m1*v1*math.cos(Thetaone-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(Thetatwo-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(Thetatwo-phi)*(m2-m1)+2*m1*v1*math.cos(Thetaone-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(Thetatwo-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330344321 192 (2021-02-01 23:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) m1 = r1**2 m2 = r2**2 thet1 = math.atan2(v1y,v1x) thet2 = math.atan2(v2y,v2x) phi = math.atan((y1-y2)/(x2-x1)) pi = math.pi coeff1 = ((((v1)*(math.cos(thet1-phi))*(m1-m2))+(2*m2*v2*(math.cos(thet2-phi))))/(m1+m2)) coeff2 = ((((v2)*(math.cos(thet2-phi))*(m2-m1))+(2*m1*v1*(math.cos(thet1-phi))))/(m1+m2)) v1_x = (coeff1*(math.cos(phi))) + (v1*(math.sin(thet1-phi))*(math.cos(phi+(pi/2)))) v1_y = (coeff1*(math.sin(phi))) + (v1*(math.sin(thet1-phi))*(math.sin(phi+(pi/2)))) v2_x = (coeff2*(math.cos(phi))) + (v2*(math.sin(thet2-phi))*(math.cos(phi+(pi/2)))) v2_y = (coeff2*(math.sin(phi))) + (v2*(math.sin(thet2-phi))*(math.sin(phi+(pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330345021 193 (2021-01-29 23:26) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def mass(r): a = r**2 return a m1 = mass(r1) m2 = mass(r2) seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) v1_x = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))*math.cos(phi)/(m1+m2)) + v1*math.sin(seta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))*math.sin(phi)/(m1+m2)) + v1*math.sin(seta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(seta2-phi)*(m2-m1) + 2*m1*v1*math.cos(seta1-phi))*math.cos(phi)/(m1+m2)) + v2*math.sin(seta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(seta2-phi)*(m2-m1) + 2*m1*v1*math.cos(seta1-phi))*math.sin(phi)/(m1+m2)) + v2*math.sin(seta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330346621 194 (2021-01-29 23:11) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=(v1x**2+v1y**2)**0.5 v2=(v2x**2+v2y**2)**0.5 a1=math.atan2(v1y,v1x) a2=math.atan2(v2y,v2x) p=math.atan2(y2-y1,x2-x1) v1_x = (v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))*math.cos(p)/(m1+m2)+v1*math.sin(a1-p)*math.cos(p+math.pi/2) v1_y = (v1*math.cos(a1-p)*(m1-m2)+2*m2*v2*math.cos(a2-p))*math.sin(p)/(m1+m2)+v1*math.sin(a1-p)*math.sin(p+math.pi/2) v2_x = (v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))*math.cos(p)/(m1+m2)+v2*math.sin(a2-p)*math.cos(p+math.pi/2) v2_y = (v2*math.cos(a2-p)*(m2-m1)+2*m1*v1*math.cos(a1-p))*math.sin(p)/(m1+m2)+v2*math.sin(a2-p)*math.sin(p+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330347221 195 (2021-01-31 21:42) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) fi = math.atan2(y1-y2,x1-x2) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(seta1-fi)*(m1-m2)+2*m2*v2*math.cos(seta2-fi))/(m1+m2))*math.cos(fi))+v1*math.sin(seta1-fi)*math.cos(fi+math.pi/2) v1_y = (((v1*math.cos(seta1-fi)*(m1-m2)+2*m2*v2*math.cos(seta2-fi))/(m1+m2))*math.sin(fi))+v1*math.sin(seta1-fi)*math.sin(fi+math.pi/2) v2_x = (((v2*math.cos(seta2-fi)*(m2-m1)+2*m1*v1*math.cos(seta1-fi))/(m2+m1))*math.cos(fi))+v2*math.sin(seta2-fi)*math.cos(fi+math.pi/2) v2_y = (((v2*math.cos(seta2-fi)*(m2-m1)+2*m1*v1*math.cos(seta1-fi))/(m2+m1))*math.sin(fi))+v2*math.sin(seta2-fi)*math.sin(fi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330348921 196 (2021-01-31 01:02) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) psi = math.atan2(y2-y1,x2-x1) #print('theta1 =', t1) #print('theta2 =', t2) #print('psi=', psi) v1_x = (math.cos(psi)*(((v1*math.cos(t1-psi))*(m1-m2))+(2*(m2)*v2*math.cos(t2-psi)))/(m1+m2))+ (v1*(math.sin(t1-psi))*(math.cos(psi+(math.pi/2)))) v1_y = (math.sin(psi)*(((v1*math.cos(t1-psi))*(m1-m2))+(2*(m2)*v2*math.cos(t2-psi)))/(m1+m2))+ (v1*(math.sin(t1-psi))*(math.sin(psi+(math.pi/2)))) v2_x = (math.cos(psi)*(((v2*math.cos(t2-psi))*(m2-m1))+(2*(m1)*v1*math.cos(t1-psi)))/(m1+m2))+ (v2*(math.sin(t2-psi))*(math.cos(psi+(math.pi/2)))) v2_y = (math.sin(psi)*(((v2*math.cos(t2-psi))*(m2-m1))+(2*(m1)*v1*math.cos(t1-psi)))/(m1+m2))+ (v2*(math.sin(t2-psi))*(math.sin(psi+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330349521 197 (2021-01-31 09:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) phi = math.atan(abs(y1-y2)/abs(x1-x2)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1x = (v1*math.cos(a1-phi)*(m1-m2)+(2*m2*v2*math.cos(a2-phi)))/(m1+m2)*math.cos(phi)+(v1*math.sin(a1-phi)*math.cos(phi+math.pi/2)) v1y = (v1*math.cos(a1-phi)*(m1-m2)+(2*m2*v2*math.cos(a2-phi)))/(m1+m2)*math.sin(phi)+(v1*math.sin(a1-phi)*math.sin(phi+math.pi/2)) v2x = (v2*math.cos(a2-phi)*(m2-m1)+(2*m1*v1*math.cos(a1-phi)))/(m1+m2)*math.cos(phi)+(v2*math.sin(a2-phi)*math.cos(phi+math.pi/2)) v2y = (v2*math.cos(a2-phi)*(m2-m1)+(2*m1*v1*math.cos(a1-phi)))/(m1+m2)*math.sin(phi)+(v2*math.sin(a2-phi)*math.sin(phi+math.pi/2)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330350021 198 (2021-02-01 08:23) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 zeta1 = math.atan2(v1y, v1x) zeta2 = math.atan2(v2y, v2x) phi = math.atan2((y1-y2), (x1-x2)) v1_x = (v1*math.cos(zeta1-phi)*(m1-m2)+2*m2*v2*math.cos(zeta2-phi))/(m1+m2)*math.cos(phi)+v1*math.sin(zeta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(zeta1-phi)*(m1-m2)+2*m2*v2*math.cos(zeta2-phi))/(m1+m2)*math.sin(phi)+v1*math.sin(zeta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(zeta2-phi)*(m2-m1)+2*m1*v1*math.cos(zeta1-phi))/(m1+m2)*math.cos(phi)+v2*math.sin(zeta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(zeta2-phi)*(m2-m1)+2*m1*v1*math.cos(zeta1-phi))/(m1+m2)*math.sin(phi)+v2*math.sin(zeta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330351721 199 (2021-01-30 23:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 beta = -(math.atan((y1-y2)/(x2-x1))) v1_x = ((v1x*math.cos(beta)+v1y*math.sin(beta))*(m1-m2)+2*m2*(v2x*math.cos(beta)+v2y*math.sin(beta)))/(m1+m2)*math.cos(beta)+(v1y*math.cos(beta)-v1x*math.sin(beta))*math.cos(beta+math.pi/2) v1_y = ((v1x*math.cos(beta)+v1y*math.sin(beta))*(m1-m2)+2*m2*(v2x*math.cos(beta)+v2y*math.sin(beta)))/(m1+m2)*math.sin(beta)+(v1y*math.cos(beta)-v1x*math.sin(beta))*math.sin(beta+math.pi/2) v2_x = ((v2x*math.cos(beta)+v2y*math.sin(beta))*(m2-m1)+2*m1*(v1x*math.cos(beta)+v1y*math.sin(beta)))/(m2+m1)*math.cos(beta)+(v2y*math.cos(beta)-v2x*math.sin(beta))*math.cos(beta+math.pi/2) v2_y = ((v2x*math.cos(beta)+v2y*math.sin(beta))*(m2-m1)+2*m1*(v1x*math.cos(beta)+v1y*math.sin(beta)))/(m2+m1)*math.sin(beta)+(v2y*math.cos(beta)-v2x*math.sin(beta))*math.sin(beta+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330352321 200 (2021-01-30 23:32) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) p = math.atan2((y1-y2),(x1-x2)) c1 = math.cos(a1-p) c2 = math.cos(a2-p) c3 = math.cos(p) c4 = math.cos(p+math.pi/2) s1 = math.sin(a1-p) s2 = math.sin(a2-p) s3 = math.sin(p) s4 = math.sin(p+math.pi/2) v1_x = (v1*c1*(m1-m2)+2*m2*v2*c2)*c3/(m1+m2)+v1*s1*c4 v1_y = (v1*c1*(m1-m2)+2*m2*v2*c2)*s3/(m1+m2)+v1*s1*s4 v2_x = (v2*c2*(m2-m1)+2*m1*v1*c1)*c3/(m1+m2)+v2*s2*c4 v2_y = (v2*c2*(m2-m1)+2*m1*v1*c1)*s3/(m1+m2)+v2*s2*s4 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330353021 201 (2021-01-30 21:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan((y2-y1)/(x2-x1)) m1 = r1**2 m2 = r2**2 v1 = v1x/math.cos(theta1) v2 = v2x/math.cos(theta2) v1_x = ((v1*math.cos(theta1 - phi)*(m1-m2)+2*m2*v2*math.cos(theta2 - phi))*math.cos(phi)/(m1+m2))+v1 * math.sin(theta1 - phi) * math.cos(phi + math.pi/2) v1_y = ((v1*math.cos(theta1 - phi)*(m1-m2)+2*m2*v2*math.cos(theta2 - phi))*math.sin(phi)/(m1+m2))+v1 * math.sin(theta1 - phi) * math.sin(phi + math.pi/2) v2_x = ((v2*math.cos(theta2 - phi)*(m2-m1)+2*m1*v1*math.cos(theta1 - phi))*math.cos(phi)/(m1+m2))+v2 * math.sin(theta2 - phi) * math.cos(phi + math.pi/2) v2_y = ((v2*math.cos(theta2 - phi)*(m2-m1)+2*m1*v1*math.cos(theta1 - phi))*math.sin(phi)/(m1+m2))+v2 * math.sin(theta2 - phi) * math.sin(phi + math.pi/2) # v1_x = (((v1x * ( r1**2 - r2**2 ) + 2 * r2**2 * v2x) / r1**2 + r2**2) * math.cos(math.atan(0.6))) + v1y*math.cos(math.atan(0.6)+math.pi/2) #v1_y = (((v1x * ( r1**2 - r2**2 ) + 2 * r2**2 * v2x) / r1**2 + r2**2) * math.sin(math.atan(0.6))) + v1y*math.sin(math.atan(0.6)+math.pi/2) #v2_x = (((v2x * ( r1**2 - r2**2 ) + 2 * r2**2 * v1x) / r1**2 + r2**2) * math.cos(math.atan(0.6))) + v2y*math.cos(math.atan(0.6)+math.pi/2) #v2_y = (((v2x * ( r1**2 - r2**2 ) + 2 * r2**2 * v1x) / r1**2 + r2**2) * math.sin(math.atan(0.6))) + v2y*math.sin(math.atan(0.6)+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330354621 202 (2021-01-31 15:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision t=math.atan2(y2-y1,x2-x1) zeta1=math.atan2(v1y,v1x) zeta2=math.atan2(v2y,v2x) m1=r1**2 m2=r2**2 v1=((v1x**2)+(v1y**2))**0.5 v2=((v2x**2)+(v2y**2))**0.5 v1x=(((v1*math.cos(zeta1-t)*(m1-m2))+(2*m2*v2*math.cos(zeta2-t)))*math.cos(t)/(m1+m2))+(v1*math.sin(zeta1-t)*math.cos(t+(math.pi/2))) v1y=(((v1*math.cos(zeta1-t)*(m1-m2))+(2*m2*v2*math.cos(zeta2-t)))*math.sin(t)/(m1+m2))+(v1*math.sin(zeta1-t)*math.sin(t+(math.pi/2))) v2x=(((v2*math.cos(zeta2-t)*(m2-m1))+(2*m1*v1*math.cos(zeta1-t)))*math.cos(t)/(m1+m2))+(v2*math.sin(zeta2-t)*math.cos(t+(math.pi/2))) v2y=(((v2*math.cos(zeta2-t)*(m2-m1))+(2*m1*v1*math.cos(zeta1-t)))*math.sin(t)/(m1+m2))+(v2*math.sin(zeta2-t)*math.sin(t+(math.pi/2))) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330355221 203 (2021-01-30 19:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan2(v1y,v1x) b = math.atan2(v2y,v2x) c = math.atan2(y1-y2,x1-x2) v1 = v1y/math.sin(a) v2 = v2y/math.sin(b) v1_x = ((((v1*math.cos(a-c)*((r1)**2-(r2)**2))+(2*((r2)**2)*v2*math.cos(b-c)))/(((r1)**2)+((r2)**2)))*math.cos(c))+((v1*math.sin(a-c))*math.cos(c+(math.pi/2))) v1_y = ((((v1*math.cos(a-c)*((r1)**2-(r2)**2))+(2*((r2)**2)*v2*math.cos(b-c)))/(((r1)**2)+((r2)**2)))*math.sin(c))+((v1*math.sin(a-c))*math.sin(c+(math.pi/2))) v2_x = ((((v2*math.cos(b-c)*((r2)**2-(r1)**2))+(2*((r1)**2)*v1*math.cos(a-c)))/(((r2)**2)+((r1)**2)))*math.cos(c))+((v2*math.sin(b-c))*math.cos(c+(math.pi/2))) v2_y = ((((v2*math.cos(b-c)*((r2)**2-(r1)**2))+(2*((r1)**2)*v1*math.cos(a-c)))/(((r2)**2)+((r1)**2)))*math.sin(c))+((v2*math.sin(b-c))*math.sin(c+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330356921 204 (2021-01-29 22:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 g1 = math.atan2(v1y,v1x) g2 = math.atan2(v2y,v2x) f = math.atan2(y2-y1,x2-x1) v1 = v1y/math.sin(g1) v2 = v2y/math.sin(g2) v1_x = ((((v1*((math.cos(g1-f))*(m1-m2)))+(2*m2*v2*(math.cos(g2-f))))/(m1+m2)))*math.cos(f)+(v1*math.sin(g1-f)*math.cos(f+(math.pi/2))) v1_y = ((((v1*((math.cos(g1-f))*(m1-m2)))+(2*m2*v2*(math.cos(g2-f))))/(m1+m2)))*math.sin(f)+(v1*math.sin(g1-f)*math.sin(f+(math.pi/2))) v2_x = ((((v2*((math.cos(g2-f))*(m2-m1)))+(2*m1*v1*(math.cos(g1-f))))/(m1+m2)))*math.cos(f)+(v2*math.sin(g2-f)*math.cos(f+(math.pi/2))) v2_y = ((((v2*((math.cos(g2-f))*(m2-m1)))+(2*m1*v1*(math.cos(g1-f))))/(m1+m2)))*math.sin(f)+(v2*math.sin(g2-f)*math.sin(f+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330357521 205 (2021-02-01 10:23) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) phi = math.atan2((y2-y1),(x2-x1)) mum1 = math.atan2(v1y,v1x) mum2 = math.atan2(v2y,v2x) m1 = (r1)**2 m2 = (r2)**2 v1_x = ((v1)*(math.cos(mum1-phi))*(m1-m2)+2*m2*v2*math.cos(mum2-phi))/(m1+m2)*math.cos(phi)+v1*math.sin(mum1-phi)*math.cos(phi+math.pi/2) v2_x = ((v2)*(math.cos(mum2-phi))*(m2-m1)+2*m1*v1*math.cos(mum1-phi))/(m1+m2)*math.cos(phi)+v2*math.sin(mum2-phi)*math.cos(phi+math.pi/2) v1_y = ((v1)*(math.cos(mum1-phi))*(m1-m2)+2*m2*v2*math.cos(mum2-phi))/(m1+m2)*math.sin(phi)+v1*math.sin(mum1-phi)*math.sin(phi+math.pi/2) v2_y = ((v2)*(math.cos(mum2-phi))*(m2-m1)+2*m1*v1*math.cos(mum1-phi))/(m1+m2)*math.sin(phi)+v2*math.sin(mum2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330360321 206 (2021-02-01 02:20) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) a1 = math.atan2((v1y),(v1x)) a2 = math.atan2((v2y),(v2x)) a3 = math.atan2((y1-y2),(x1-x2)) pi = math.pi r1=r1**2 r2=r2**2 v1_x = (((v1*(math.cos(a1-a3))*(r1-r2)+(2*r2*v2*(math.cos(a2-a3))))/(r1+r2))*(math.cos(a3)))+v1*(math.sin(a1-a3))*(math.cos(a3+(pi/2))) v1_y = (((v1*(math.cos(a1-a3))*(r1-r2)+(2*r2*v2*(math.cos(a2-a3))))/(r1+r2))*(math.sin(a3)))+v1*(math.sin(a1-a3))*(math.sin(a3+(pi/2))) v2_x = (((v2*(math.cos(a2-a3))*(r2-r1)+(2*r1*v1*(math.cos(a1-a3))))/(r1+r2))*(math.cos(a3)))+v2*(math.sin(a2-a3))*(math.cos(a3+(pi/2))) v2_y = (((v2*(math.cos(a2-a3))*(r2-r1)+(2*r1*v1*(math.cos(a1-a3))))/(r1+r2))*(math.sin(a3)))+v2*(math.sin(a2-a3))*(math.sin(a3+(pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330361021 207 (2021-01-29 08:07) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision angle1 = math.atan2(v1y,v1x) angle2 = math.atan2(v2y,v2x) angle_between = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (((v1*(m1-m2)*math.cos(angle1-angle_between))+(2*m2*v2*math.cos(angle2-angle_between)))*math.cos(angle_between)/(m1+m2))+v1*math.sin(angle1-angle_between)*math.cos(angle_between+math.pi/2) v1_y = (((v1*(m1-m2)*math.cos(angle1-angle_between))+(2*m2*v2*math.cos(angle2-angle_between)))*math.sin(angle_between)/(m1+m2))+v1*math.sin(angle1-angle_between)*math.sin(angle_between+math.pi/2) v2_x = (((v2*(m2-m1)*math.cos(angle2-angle_between))+(2*m1*v1*math.cos(angle1-angle_between)))*math.cos(angle_between)/(m1+m2))+v2*math.sin(angle2-angle_between)*math.cos(angle_between+math.pi/2) v2_y = (((v2*(m2-m1)*math.cos(angle2-angle_between))+(2*m1*v1*math.cos(angle1-angle_between)))*math.sin(angle_between)/(m1+m2))+v2*math.sin(angle2-angle_between)*math.sin(angle_between+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330362621 208 (2021-01-30 22:42) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here #ต้องการ v1/v2 phi m1/m2 v1_x/v2_x v1_y/v2_y zeta v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) phi = math.atan2((y2-y1),(x2-x1)) zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) m1 = (r1)**2 m2 = (r2)**2 v1_x = ((v1)*(math.cos(zeta1-phi))*(m1-m2)+2*m2*v2*math.cos(zeta2-phi))/(m1+m2)*math.cos(phi)+v1*math.sin(zeta1-phi)*math.cos(phi+math.pi/2) v2_x = ((v2)*(math.cos(zeta2-phi))*(m2-m1)+2*m1*v1*math.cos(zeta1-phi))/(m1+m2)*math.cos(phi)+v2*math.sin(zeta2-phi)*math.cos(phi+math.pi/2) v1_y = ((v1)*(math.cos(zeta1-phi))*(m1-m2)+2*m2*v2*math.cos(zeta2-phi))/(m1+m2)*math.sin(phi)+v1*math.sin(zeta1-phi)*math.sin(phi+math.pi/2) v2_y = ((v2)*(math.cos(zeta2-phi))*(m2-m1)+2*m1*v1*math.cos(zeta1-phi))/(m1+m2)*math.sin(phi)+v2*math.sin(zeta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330365521 209 (2021-01-29 22:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1*r1 m2=r2*r2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) seta1=math.atan2(v1y,v1x) seta2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) v1_x = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(seta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(seta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(seta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(seta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330366121 210 (2021-01-29 00:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1= math.sqrt((v1x**2)+(v1y**2)) v2= math.sqrt((v2x**2)+(v2y**2)) zeta1= math.atan2(v1y,v1x) zeta2= math.atan2(v2y,v2x) lln= math.atan((y1-y2)/(x1-x2)) m1= r1**2 m2= r2**2 v1_x = (((v1*math.cos(zeta1-lln)*(m1-m2))+(2*m2*v2*math.cos(zeta2-lln)))/(m1+m2))*math.cos(lln)+(v1*math.sin(zeta1-lln)*math.cos(lln+(math.pi/2))) v1_y = (((v1*math.cos(zeta1-lln)*(m1-m2))+(2*m2*v2*math.cos(zeta2-lln)))/(m1+m2))*math.sin(lln)+(v1*math.sin(zeta1-lln)*math.sin(lln+(math.pi/2))) v2_x = (((v2*math.cos(zeta2-lln)*(m2-m1))+(2*m1*v1*math.cos(zeta1-lln)))/(m2+m1))*math.cos(lln)+(v2*math.sin(zeta2-lln)*math.cos(lln+(math.pi/2))) v2_y = (((v2*math.cos(zeta2-lln)*(m2-m1))+(2*m1*v1*math.cos(zeta1-lln)))/(m2+m1))*math.sin(lln)+(v2*math.sin(zeta2-lln)*math.sin(lln+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330367821 211 (2021-02-01 10:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) p = math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*math.cos(t1-p)*(m1-m2))+(2*m2*v2*math.cos(t2-p)))*math.cos(p)/(m1+m2))+(v1*math.sin(t1-p)*math.cos(p+(math.pi/2))) v1_y = (((v1*math.cos(t1-p)*(m1-m2))+(2*m2*v2*math.cos(t2-p)))*math.sin(p)/(m1+m2))+(v1*math.sin(t1-p)*math.sin(p+(math.pi/2))) v2_x = (((v2*math.cos(t2-p)*(m2-m1))+(2*m1*v1*math.cos(t1-p)))*math.cos(p)/(m1+m2))+(v2*math.sin(t2-p)*math.cos(p+(math.pi/2))) v2_y = (((v2*math.cos(t2-p)*(m2-m1))+(2*m1*v1*math.cos(t1-p)))*math.sin(p)/(m1+m2))+(v2*math.sin(t2-p)*math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330370621 212 (2021-01-30 23:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 qp = math.atan2((y1-y2),(x1-x2)) cos = math.cos(qp) sin = math.sin(qp) v1_x = ((v1x*cos+v1y*sin)*(m1-m2)+2*m2*(v2x*cos+v2y*sin))*(cos/(m1+m2))+(v1y*cos-v1x*sin)*math.cos(qp+(math.pi/2)) v1_y = ((v1x*cos+v1y*sin)*(m1-m2)+2*m2*(v2x*cos+v2y*sin))*(sin/(m1+m2))+(v1y*cos-v1x*sin)*math.sin(qp+(math.pi/2)) v2_x = ((v2x*cos+v2y*sin)*(m2-m1)+2*m1*(v1x*cos+v1y*sin))*(cos/(m1+m2))+(v2y*cos-v2x*sin)*math.cos(qp+(math.pi/2)) v2_y = ((v2x*cos+v2y*sin)*(m2-m1)+2*m1*(v1x*cos+v1y*sin))*(sin/(m1+m2))+(v2y*cos-v2x*sin)*math.sin(qp+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330371221 213 (2021-02-01 16:23) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) p = math.atan2(y2-y1,x2-x1) m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = (((v1*math.cos(theta1-p)*(m1-m2)+2*m2*v2*math.cos(theta2-p))/(m1+m2))*math.cos(p))+(v1*math.sin(theta1-p)*math.cos(p+math.pi/2)) v1_y = (((v1*math.cos(theta1-p)*(m1-m2)+2*m2*v2*math.cos(theta2-p))/(m1+m2))*math.sin(p))+(v1*math.sin(theta1-p)*math.sin(p+math.pi/2)) v2_x = (((v2*math.cos(theta2-p)*(m2-m1)+2*m1*v1*math.cos(theta1-p))/(m1+m2))*math.cos(p))+(v2*math.sin(theta2-p)*math.cos(p+math.pi/2)) v2_y = (((v2*math.cos(theta2-p)*(m2-m1)+2*m1*v1*math.cos(theta1-p))/(m1+m2))*math.sin(p))+(v2*math.sin(theta2-p)*math.sin(p+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330372921 214 (2021-01-31 23:17) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 seta1 = math.atan2(v1y, v1x) seta2 = math.atan2(v2y, v2x) alpha = math.atan2((y1-y2), (x1-x2)) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = (((v1*math.cos(seta1-alpha)*(m1-m2))+(2*m2*v2*math.cos(seta2-alpha)))/(m1+m2))*math.cos(alpha)+v1*math.sin(seta1-alpha)*math.cos(alpha+(math.pi/2)) v1_y = (((v1*math.cos(seta1-alpha)*(m1-m2))+(2*m2*v2*math.cos(seta2-alpha)))/(m1+m2))*math.sin(alpha)+v1*math.sin(seta1-alpha)*math.sin(alpha+(math.pi/2)) v2_x = (((v2*math.cos(seta2-alpha)*(m2-m1))+(2*m1*v1*math.cos(seta1-alpha)))/(m1+m2))*math.cos(alpha)+v2*math.sin(seta2-alpha)*math.cos(alpha+(math.pi/2)) v2_y = (((v2*math.cos(seta2-alpha)*(m2-m1))+(2*m1*v1*math.cos(seta1-alpha)))/(m1+m2))*math.sin(alpha)+v2*math.sin(seta2-alpha)*math.sin(alpha+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330374121 215 (2021-01-30 02:48) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 total_mass = m1+m2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/total_mass)*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/total_mass)*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/total_mass)*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/total_mass)*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330376421 216 (2021-01-31 17:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision V1=((v1x**2)+(v1y**2))**0.5 V2=((v2x**2)+(v2y**2))**0.5 T1=math.atan2(v1y,v1x) T2=math.atan2(v2y,v2x) O=math.atan2(y2-y1,x2-x1) ''' if v1x>=0 and v1y>=0: T1=math.asin(abs(v1y)/V1) elif v1x<0 and v1y>0: T1=math.pi-math.asin(abs(v1y)/V1) elif v1x<=0 and v1y<=0: T1=math.pi+math.asin(abs(v1y)/V1) elif v1x>=0 and v1y<=0: T1=(2*math.pi)-math.asin(abs(v1y)/V1) if v2x>=0 and v2y>=0: T2=math.asin(abs(v2y)/V2) elif v2x<=0 and v2y>=0: T2=math.pi-math.asin(abs(v2y)/V2) elif v2x<=0 and v2y<=0: T2=math.pi+math.asin(abs(v2y)/V2) elif v2x>=0 and v2y<=0: T2=(2*math.pi)-math.asin(abs(v2y)/V2) #print(math.degrees(T1),math.degrees(T2)) #T1=math.asin(v1y/V1) #T2=math.asin(v2y/V2) D=r1+r2 if y2-y1>0 and x2-x1>0: O=math.asin(abs(y1-y2)/D) elif x2-x1<0 and y2-y1>0: O=math.pi-math.asin(abs(y1-y2)/D) elif x2-x1<0 and y2-y1<0: O=math.pi+math.asin(abs(y1-y2)/D) elif x2-x1>0 and y2-y1<0: O=(2*math.pi)-math.asin(abs(y1-y2)/D) elif y2==y1 and abs(x2-x1)==D: O=0 elif x2==x1: O=math.pi/2 elif x2==-x1: O=-math.pi/2 O=math.asin(abs(y1-y2)/D) ''' # insert your code here m1=r1**2 m2=r2**2 v1_x = (((V1*math.cos(T1-O)*(m1-m2)+(2*m2*V2*math.cos(T2-O)))/(m1+m2))*math.cos(O))+(V1*math.sin(T1-O)*math.cos(O+(math.pi/2))) v1_y = (((V1*math.cos(T1-O)*(m1-m2)+(2*m2*V2*math.cos(T2-O)))/(m1+m2))*math.sin(O))+(V1*math.sin(T1-O)*math.sin(O+(math.pi/2))) v2_x = ((((V2*math.cos(T2-O)*(m2-m1)+(2*m1*V1*math.cos(T1-O)))/(m1+m2))*math.cos(O))+(V2*math.sin(T2-O)*math.cos(O+(math.pi/2)))) v2_y = ((((V2*math.cos(T2-O)*(m2-m1)+(2*m1*V1*math.cos(T1-O)))/(m1+m2))*math.sin(O))+(V2*math.sin(T2-O)*math.sin(O+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330377021 217 (2021-02-01 14:57) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1 = v1y/math.sin(theta1) v2 = v2y/math.sin(theta2) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330378721 218 (2021-01-30 23:22) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 phi = math.atan2(y2-y1,x2-x1) v1_x = (((((v1)*(math.cos(theta1-phi))*(m1-m2))+((2)*(m2)*(v2)*(math.cos(theta2-phi))))/(m1+m2))*(math.cos(phi)))+((v1)*(math.sin(theta1-phi))*(math.cos(phi+(math.pi/2)))) v1_y = (((((v1)*(math.cos(theta1-phi))*(m1-m2))+((2)*(m2)*(v2)*(math.cos(theta2-phi))))/(m1+m2))*(math.sin(phi)))+((v1)*(math.sin(theta1-phi))*(math.sin(phi+(math.pi/2)))) v2_x = (((((v2)*(math.cos(theta2-phi))*(m2-m1))+((2)*(m1)*(v1)*(math.cos(theta1-phi))))/(m1+m2))*(math.cos(phi)))+((v2)*(math.sin(theta2-phi))*(math.cos(phi+(math.pi/2)))) v2_y = (((((v2)*(math.cos(theta2-phi))*(m2-m1))+((2)*(m1)*(v1)*(math.cos(theta1-phi))))/(m1+m2))*(math.sin(phi)))+((v2)*(math.sin(theta2-phi))*(math.sin(phi+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330379321 219 (2021-01-31 20:08) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1= math.atan2(v1y,(v1x)) theta2= math.atan2(v2y,(v2x)) phi=math.atan2((y1-y2),(x1-x2)) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2) +(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2) +(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2) +(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2) +(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330380921 220 (2021-01-30 18:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2((y1-y2),(x1-x2)) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) v1_x = ((v1)*math.cos(theta1 - phi)*(m1-m2)*math.cos(phi)/(m1+m2)) + (2*(m2)*(v2)*math.cos(theta2 - phi)*math.cos(phi)/(m1+m2)) + ((v1)*math.sin(theta1 - phi)*math.cos(phi + (math.pi/2))) v1_y = ((v1)*math.cos(theta1 - phi)*(m1-m2)*math.sin(phi)/(m1+m2)) + (2*(m2)*(v2)*math.cos(theta2 - phi)*math.sin(phi)/(m1+m2)) + ((v1)*math.sin(theta1 - phi)*math.sin(phi + (math.pi/2))) v2_x = ((v2)*math.cos(theta2 - phi)*(m2-m1)*math.cos(phi)/(m1+m2)) + (2*(m1)*(v1)*math.cos(theta1 - phi)*math.cos(phi)/(m1+m2)) + ((v2)*math.sin(theta2 - phi)*math.cos(phi + (math.pi/2))) v2_y = ((v2)*math.cos(theta2 - phi)*(m2-m1)*math.sin(phi)/(m1+m2)) + (2*(m1)*(v1)*math.cos(theta1 - phi)*math.sin(phi)/(m1+m2)) + ((v2)*math.sin(theta2 - phi)*math.sin(phi + (math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330381521 221 (2021-02-01 23:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = math.pow(r1,2) m2 = math.pow(r2,2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) phi = math.atan2(y2-y1,x2-x1) v1_x = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*(m2*v2*(math.cos(theta2-phi)))))/(m1+m2))*(math.cos(phi)))+((v1*(math.sin(theta1-phi)))*(math.cos(phi+(math.pi/2)))) v1_y = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*(m2*v2*(math.cos(theta2-phi)))))/(m1+m2))*(math.sin(phi)))+((v1*(math.sin(theta1-phi)))*(math.sin(phi+(math.pi/2)))) v2_x = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*(m1*v1*(math.cos(theta1-phi)))))/(m1+m2))*(math.cos(phi)))+((v2*(math.sin(theta2-phi)))*(math.cos(phi+(math.pi/2)))) v2_y = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*(m1*v1*(math.cos(theta1-phi)))))/(m1+m2))*(math.sin(phi)))+((v2*(math.sin(theta2-phi)))*(math.sin(phi+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330382121 222 (2021-01-29 12:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1 ** 2 m2 = r2 ** 2 phi = math.atan((y2-y1)/(x2-x1)) v1_x = ((m1 - m2)*(v1x * math.cos(phi) + v1y * math.sin(phi)) + 2 * m2 *(v2x * math.cos(phi) + v2y * math.sin(phi)))*(math.cos(phi))/(m1+m2) + (v1y * math.cos(phi) - v1x * math.sin(phi)) * (math.cos(phi + math.pi/2)) v1_y = ((m1 - m2)*(v1x * math.cos(phi) + v1y * math.sin(phi)) + 2 * m2 *(v2x * math.cos(phi) + v2y * math.sin(phi)))*(math.sin(phi))/(m1+m2) + (v1y * math.cos(phi) - v1x * math.sin(phi)) * (math.sin(phi + math.pi/2)) v2_x = (m1 * v1x + m2 * v2x - m1 * v1_x)/m2 v2_y = (m1 * v1y + m2 * v2y - m1 * v1_y)/m2 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330384421 223 (2021-01-30 21:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt(v1x**2 + v1y**2) v2=math.sqrt(v2x**2 + v2y**2) M = r1**2+r2**2 m = r1**2-r2**2 m3= r2**2-r1**2 m1=r1**2 m2=r2**2 o1= math.atan2(v1y,v1x) o2= math.atan2(v2y,v2x) o3= math.atan2(y1-y2,x1-x2) v1_x = (((v1*math.cos(o1-o3)*m+2*m2*v2*math.cos(o2-o3))/M)*math.cos(o3))+(v1*math.sin(o1-o3)*math.cos(o3+math.pi/2)) v1_y = (((v1*math.cos(o1-o3)*m+2*m2*v2*math.cos(o2-o3))/M)*math.sin(o3))+(v1*math.sin(o1-o3)*math.sin(o3+math.pi/2)) v2_x = (((v2*math.cos(o2-o3)*m3+2*m1*v1*math.cos(o1-o3))/M)*math.cos(o3))+(v2*math.sin(o2-o3)*math.cos(o3+math.pi/2)) v2_y = (((v2*math.cos(o2-o3)*m3+2*m1*v1*math.cos(o1-o3))/M)*math.sin(o3))+(v2*math.sin(o2-o3)*math.sin(o3+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330386721 224 (2021-02-01 22:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 v1 = (((v1x)**2) + ((v1y)**2))**0.5 v2 = (((v2x)**2) + ((v2y)**2))**0.5 phi = math.atan2((y1-y2),(x1-x2)) the1 = math.atan2(v1y, v1x) the2 = math.atan2(v2y, v2x) v1xx = ((((((v1) *(math.cos(the1 - phi)) *(m1 - m2)) + (2 *(m2) *(v2) *(math.cos(the2 - phi)))) / (m1 + m2)) *(math.cos(phi))) + ((v1) *(math.sin(the1 - phi)) *(math.cos(phi + (math.pi/2))))) v1yy = ((((((v1) *(math.cos(the1 - phi)) *(m1 - m2)) + (2 *(m2) *(v2) *(math.cos(the2 - phi)))) / (m1 + m2)) *(math.sin(phi))) + ((v1) *(math.sin(the1 - phi)) *(math.sin(phi + (math.pi/2))))) v2xx = ((((((v2) *(math.cos(the2 - phi)) *(m2 - m1)) + (2 *(m1) *(v1) *(math.cos(the1 - phi)))) / (m1 + m2)) *(math.cos(phi))) + ((v2) *(math.sin(the2 - phi)) *(math.cos(phi + (math.pi/2))))) v2yy = ((((((v2) *(math.cos(the2 - phi)) *(m2 - m1)) + (2 *(m1) *(v1) *(math.cos(the1 - phi)))) / (m1 + m2)) *(math.sin(phi))) + ((v2) *(math.sin(the2 - phi)) *(math.sin(phi + (math.pi/2))))) v1_x = v1xx v1_y = v1yy v2_x = v2xx v2_y = v2yy return (v1_x, v1_y), (v2_x, v2_y) |
# 6330387321 225 (2021-01-31 20:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): import math m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2((y2-y1), (x2-x1)) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*(math.cos(phi)/(m1+m2))+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*(math.sin(phi)/(m1+m2))+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*(math.cos(phi)/(m1+m2))+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*(math.sin(phi)/(m1+m2))+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330388021 226 (2021-01-29 23:32) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here x1=float(x1) y1=float(y1) r1=float(r1) v1x=float(v1x) v1y=float(v1y) x2=float(x2) y2=float(y2) r2=float(r2) v2x=float(v2x) v2y=float(v2y) v1=math.sqrt(v1y**2+v1x**2) v2=math.sqrt(v2y**2+v2x**2) sin_a=v1y/v1 cos_a=v1x/v1 sin_b=v2y/v2 cos_b=v2x/v2 sin_c=(y2-y1)/math.sqrt((y2-y1)**2+(x2-x1)**2) cos_c=(x2-x1)/math.sqrt((y2-y1)**2+(x2-x1)**2) m1=r1**2 m2=r2**2 v1_x=(v1*(cos_a*cos_c+sin_a*sin_c)*(m1-m2)+2*m2*v2*(cos_b*cos_c+sin_b*sin_c))*cos_c/(m1+m2)+v1*(sin_a*cos_c-cos_a*sin_c)*(-sin_c) v1_y=(v1*(cos_a*cos_c+sin_a*sin_c)*(m1-m2)+2*m2*v2*(cos_b*cos_c+sin_b*sin_c))*sin_c/(m1+m2)+v1*(sin_a*cos_c-cos_a*sin_c)*(cos_c) v2_x=(v2*(cos_b*cos_c+sin_b*sin_c)*(m2-m1)+2*m1*v1*(cos_a*cos_c+sin_a*sin_c))*cos_c/(m1+m2)+v2*(sin_b*cos_c-cos_b*sin_c)*(-sin_c) v2_y=(v2*(cos_b*cos_c+sin_b*sin_c)*(m2-m1)+2*m1*v1*(cos_a*cos_c+sin_a*sin_c))*sin_c/(m1+m2)+v2*(sin_b*cos_c-cos_b*sin_c)*(cos_c) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330389621 227 (2021-01-31 23:30) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) T1 = math.atan2(v1y,v1x) T2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(T1-phi)*(m1-m2))+(2*(m2)*v2*math.cos(T2-phi)))*((math.cos(phi))/(m1+m2)))+v1*math.sin(T1-phi)*math.cos(phi+(math.pi/2)) v1_y = (((v1*math.cos(T1-phi)*(m1-m2))+(2*(m2)*v2*math.cos(T2-phi)))*((math.sin(phi))/(m1+m2)))+v1*math.sin(T1-phi)*math.sin(phi+(math.pi/2)) v2_x = (((v2*math.cos(T2-phi)*(m1-m2))+(2*(m1)*v1*math.cos(T1-phi)))*((math.cos(phi))/(m1+m2)))+v2*math.sin(T2-phi)*math.cos(phi+(math.pi/2)) v2_y = (((v2*math.cos(T2-phi)*(m1-m2))+(2*(m1)*v1*math.cos(T1-phi)))*((math.sin(phi))/(m1+m2)))+v2*math.sin(T2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330391821 228 (2021-01-30 20:07) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.hypot(v1x, v1y) v2 = math.hypot(v2x, v2y) z1 = math.atan2(v1y,v1x) z2 = math.atan2(v2y,v2x) dx = x2-x1 dy = y1-y2 g = -math.atan2(dy,dx) v1_x = ((((v1*math.cos(z1-g)*(m1-m2))+(2*m2*v2*(math.cos(z2-g))))*math.cos(g))/(m1+m2))+(v1*(math.sin(z1-g))*(math.cos(g+(math.pi/2)))) v1_y = ((((v1*math.cos(z1-g)*(m1-m2))+(2*m2*v2*(math.cos(z2-g))))*math.sin(g))/(m1+m2))+(v1*(math.sin(z1-g))*(math.sin(g+(math.pi/2)))) v2_x = ((((v2*math.cos(z2-g)*(m2-m1))+(2*m1*v1*(math.cos(z1-g))))*math.cos(g))/(m1+m2))+(v2*(math.sin(z2-g))*(math.cos(g+(math.pi/2)))) v2_y = ((((v2*math.cos(z2-g)*(m2-m1))+(2*m1*v1*(math.cos(z1-g))))*math.sin(g))/(m1+m2))+(v2*(math.sin(z2-g))*(math.sin(g+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330392421 229 (2021-01-28 22:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) cos1 = v1x/v1 sin1 = v1y/v1 cos2 = v2x/v2 sin2 = v2y/v2 if x1-x2 == 0: phi = math.pi/2 else: phi = math.atan2(y2-y1, x2-x1) cosphi = math.cos(phi) sinphi = math.sin(phi) v1x = (v1*(cos1*cosphi+sin1*sinphi)*(m1-m2) + 2*m2*v2*(cos2*cosphi+sin2*sinphi))*cosphi/(m1+m2) +v1*(sin1*cosphi-cos1*sinphi)*math.cos(phi + (math.pi)/2) v1y = (v1*(cos1*cosphi+sin1*sinphi)*(m1-m2) + 2*m2*v2*(cos2*cosphi+sin2*sinphi))*sinphi/(m1+m2) +v1*(sin1*cosphi-cos1*sinphi)*math.sin(phi + (math.pi)/2) v2x = (v2*(cos2*cosphi+sin2*sinphi)*(m2-m1) + 2*m1*v1*(cos1*cosphi+sin1*sinphi))*cosphi/(m1+m2) +v2*(sin2*cosphi-cos2*sinphi)*math.cos(phi + (math.pi)/2) v2y = (v2*(cos2*cosphi+sin2*sinphi)*(m2-m1) + 2*m1*v1*(cos1*cosphi+sin1*sinphi))*sinphi/(m1+m2) +v2*(sin2*cosphi-cos2*sinphi)*math.sin(phi + (math.pi)/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330393021 230 (2021-02-01 20:57) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) a = theta1-phi b = theta2-phi c = phi + (math.pi/2) v1p = ((v1*math.cos(a)*(m1-m2)+2*m2*v2*math.cos(b))/(m1+m2)) v1x = (v1p*math.cos(phi))+(v1*math.sin(a)*math.cos(c)) v1y = (v1p*math.sin(phi))+(v1*math.sin(a)*math.sin(c)) v2p = ((v2*math.cos(b)*(m2-m1)+2*m1*v1*math.cos(a))/(m1+m2)) v2x = (v2p*math.cos(phi))+(v2*math.sin(b)*math.cos(c)) v2y = (v2p*math.sin(phi))+(v2*math.sin(b)*math.sin(c)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330394721 231 (2021-01-31 06:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 a2=math.atan2(v2y,v2x) a1=math.atan2(v1y,v1x) b=math.atan2((y2-y1),(x2-x1)) v2=(v2x**2+v2y**2)**0.5 v1=(v1x**2+v1y**2)**0.5 v1_x = (math.cos(a1-b)*v1*(m1-m2)+2*m2*v2*math.cos(a2-b))*math.cos(b)/(m1+m2)+v1*math.sin(a1-b)*math.cos(b+math.pi/2) v1_y = (math.cos(a1-b)*v1*(m1-m2)+2*m2*v2*math.cos(a2-b))*math.sin(b)/(m1+m2)+v1*math.sin(a1-b)*math.sin(b+math.pi/2) v2_x = (math.cos(a2-b)*v2*(m2-m1)+2*m1*v1*math.cos(a1-b))*math.cos(b)/(m1+m2)+v2*math.sin(a2-b)*math.cos(b+math.pi/2) v2_y = (math.cos(a2-b)*v2*(m2-m1)+2*m1*v1*math.cos(a1-b))*math.sin(b)/(m1+m2)+v2*math.sin(a2-b)*math.sin(b+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330395321 232 (2021-01-30 20:40) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) phi = math.atan((y1-y2)/(x1-x2)) v1x = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.cos(phi) + v1*math.sin(seta1-phi)*math.cos(phi+math.pi/2) v1y = ((v1*math.cos(seta1-phi)*(m1-m2) + 2*m2*v2*math.cos(seta2-phi))/(m1+m2))*math.sin(phi) + v1*math.sin(seta1-phi)*math.sin(phi+math.pi/2) v2x = ((v2*math.cos(seta2-phi)*(m2-m1) + 2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.cos(phi) + v2*math.sin(seta2-phi)*math.cos(phi+math.pi/2) v2y = ((v2*math.cos(seta2-phi)*(m2-m1) + 2*m1*v1*math.cos(seta1-phi))/(m1+m2))*math.sin(phi) + v2*math.sin(seta2-phi)*math.sin(phi+math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330396021 233 (2021-01-31 14:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) ca = math.atan2((y2-y1),(x2-x1)) #contact angle m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1x = ((v1*(math.cos(a1-ca))*(m1-m2)+2*m2*v2*math.cos(a2-ca))/(m1+m2))*math.cos(ca)+v1*math.sin(a1-ca)*math.cos(ca+math.pi/2) v1y = ((v1*(math.cos(a1-ca))*(m1-m2)+2*m2*v2*math.cos(a2-ca))/(m1+m2))*math.sin(ca)+v1*math.sin(a1-ca)*math.sin(ca+math.pi/2) v2x = ((v2*(math.cos(a2-ca))*(m2-m1)+2*m1*v1*math.cos(a1-ca))/(m1+m2))*math.cos(ca)+v2*math.sin(a2-ca)*math.cos(ca+math.pi/2) v2y = ((v2*(math.cos(a2-ca))*(m2-m1)+2*m1*v1*math.cos(a1-ca))/(m1+m2))*math.sin(ca)+v2*math.sin(a2-ca)*math.sin(ca+math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330397621 234 (2021-02-01 23:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r1**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) p = math.atan2(y2-y1,x2-x1) v1_x = (((v1*(math.cos(t1-p))*(m1-m2))+(2*(m2*v2*(math.cos(t2-p)))))/(m1+m2))*((math.cos(p))+((((v1*math.sin(t1-p))*((math.cos(p+math.pi/2))))))) v1_y = (((v1*(math.cos(t1-p))*(m1-m2))+(2*(m2*v2*(math.cos(t2-p)))))/(m1+m2))*((math.sin(p))+((((v1*math.sin(t1-p))*((math.sin(p+math.pi/2))))))) v2_x = (((v2*(math.cos(t2-p))*(m2-m1))+(2*(m1*v1*(math.cos(t1-p)))))/(m1+m2))*((math.cos(p))+((((v2*math.sin(t2-p))*((math.cos(p+math.pi/2))))))) v2_y = (((v2*(math.cos(t2-p))*(m2-m1))+(2*(m1*v1*(math.cos(t1-p)))))/(m1+m2))*((math.sin(p))+((((v2*math.sin(t2-p))*((math.sin(p+math.pi/2))))))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330398221 235 (2021-01-30 20:58) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) ang1=math.atan2(v1y,v1x) #เซต้า1 ang2=math.atan2(v2y,v2x) #เซต้า2 phi=math.atan2(y2-y1,x2-x1) #มุมฟี v1_x = ((((v1*math.cos(ang1-phi)*(m1-m2))+(2*m2*v2*math.cos(ang2-phi)))/(m1+m2))*math.cos(phi))+(v1*math.sin(ang1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(ang1-phi)*(m1-m2))+(2*m2*v2*math.cos(ang2-phi)))/(m1+m2))*math.sin(phi))+(v1*math.sin(ang1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(ang2-phi)*(m2-m1))+(2*m1*v1*math.cos(ang1-phi)))/(m1+m2))*math.cos(phi))+(v2*math.sin(ang2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(ang2-phi)*(m2-m1))+(2*m1*v1*math.cos(ang1-phi)))/(m1+m2))*math.sin(phi))+(v2*math.sin(ang2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330399921 236 (2021-01-28 22:08) def update_v(x1, y1, r1, v1x, v1y,x2, y2, r2, v2x, v2y): # insert your code here v1_x = v1x v1_y = v1y v1= math.sqrt(v1_x**2 + v1_y**2) angle1 = math.atan2(v1_y,v1_x) m1 = r1**2 m2 = r2**2 v2_x = v2x v2_y = v2y v2= math.sqrt(v2_x**2 + v2_y**2) angle2 = math.atan2(v2_y,v2_x) fi = math.atan2(y1-y2,x1-x2) sum_m = m1 + m2 diff_m1 = m1 - m2 diff_m2 = m2 - m1 v1_x = (v1*math.cos(angle1-fi)*diff_m1 + 2* m2 *v2* math.cos(angle2-fi))*math.cos(fi)/sum_m + v1*math.sin(angle1-fi)*math.cos(fi+math.pi/2) v1_y = (v1*math.cos(angle1-fi)*diff_m1 + 2* m2 *v2* math.cos(angle2-fi))*math.sin(fi)/sum_m + v1*math.sin(angle1-fi)*math.sin(fi+math.pi/2) v2_x = (v2*math.cos(angle2-fi)*diff_m2 + 2* m1 *v1* math.cos(angle1-fi))*math.cos(fi)/sum_m + v2*math.sin(angle2-fi)*math.cos(fi+math.pi/2) v2_y = (v2*math.cos(angle2-fi)*diff_m2 + 2* m1 *v1* math.cos(angle1-fi))*math.sin(fi)/sum_m + v2*math.sin(angle2-fi)*math.sin(fi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330400821 237 (2021-01-30 11:18) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1 ** 2 m2 = r2 ** 2 s1 = (math.atan2(v1y, v1x)) s2 = (math.atan2(v2y, v2x)) Q = math.atan2((y1 - y2), (x1 - x2)) v1 = (math.sqrt(v1x ** 2 + v1y ** 2)) v2 = (math.sqrt(v2x ** 2 + v2y ** 2)) v1_x = (((v1 * (m1 - m2) * math.cos(s1 - Q) + 2 * m2 * v2 * math.cos(s2 - Q))) / (m1 + m2)) * math.cos(Q) + (v1 * math.sin(s1 - Q) * math.cos(Q + (math.pi / 2))) v1_y = ((v1 * (m1 - m2) * math.cos(s1 - Q) + (2 * m2 * v2 * math.cos(s2 - Q))) / (m1 + m2)) * math.sin(Q) + (v1 * math.sin(s1 - Q) * math.sin(Q + (math.pi / 2))) v2_x = (((v2 * (m2 - m1) * math.cos(s2 - Q) + 2 * m1 * v1 * math.cos(s1 - Q))) / (m1 + m2)) * math.cos(Q) + (v2 * math.sin(s2 - Q) * math.cos(Q + (math.pi / 2))) v2_y = ((v2 * (m2 - m1) * math.cos(s2 - Q) + (2 * m1 * v1 * math.cos(s1 - Q))) / (m1 + m2)) * math.sin(Q) + (v2 * math.sin(s2 - Q) * math.sin(Q + (math.pi / 2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330401421 238 (2021-01-31 14:25) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan2((y1-y2),(x1-x2)) o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 u1 = math.sqrt(v1x**2+v1y**2) u2 = math.sqrt(v2x**2+v2y**2) v1_x = (u1*math.cos(o1-a)*(m1-m2)+2*m2*u2*math.cos(o2-a))/(m1+m2)*math.cos(a) + u1*math.sin(o1-a)*math.cos(a+math.pi/2) v1_y = (u1*math.cos(o1-a)*(m1-m2)+2*m2*u2*math.cos(o2-a))/(m1+m2)*math.sin(a) + u1*math.sin(o1-a)*math.sin(a+math.pi/2) v2_x = (u2*math.cos(o2-a)*(m2-m1)+2*m1*u1*math.cos(o1-a))/(m2+m1)*math.cos(a) + u2*math.sin(o2-a)*math.cos(a+math.pi/2) v2_y = (u2*math.cos(o2-a)*(m2-m1)+2*m1*u1*math.cos(o1-a))/(m2+m1)*math.sin(a) + u2*math.sin(o2-a)*math.sin(a+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330402021 239 (2021-01-31 00:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(theta1-phi)*(m1-m2)) + (2*(m2)*v2*math.cos(theta2-phi)))*((math.cos(phi))/(m1+m2)))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2)) + (2*(m2)*v2*math.cos(theta2-phi)))*((math.sin(phi))/(m1+m2)))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1)) + (2*(m1)*v1*math.cos(theta1-phi)))*((math.cos(phi))/(m1+m2)))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1)) + (2*(m1)*v1*math.cos(theta1-phi)))*((math.sin(phi))/(m1+m2)))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330403721 240 (2021-01-31 18:41) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 θ1 = math.atan2(v1y, v1x) θ2 = math.atan2(v2y, v2x) ψ = math.atan2(y1-y2, x1-x2) a = (v1 * math.cos(θ1 - ψ) *(m1 - m2) + 2 * m2 * v2 * math.cos(θ2 - ψ)) * math.cos(ψ) / (m1 + m2) b = v1 * math.sin(θ1 - ψ) * math.cos(ψ + math.pi / 2) c = (v1 * math.cos(θ1 - ψ) *(m1 - m2) + 2 * m2 * v2 * math.cos(θ2 - ψ)) * math.sin(ψ) / (m1 + m2) d = v1 * math.sin(θ1 - ψ) * math.sin(ψ + math.pi / 2) e = (v2 * math.cos(θ2 - ψ) *(m2 - m1) + 2 * m1 * v1 * math.cos(θ1 - ψ)) * math.cos(ψ) / (m1 + m2) f = v2 * math.sin(θ2 - ψ) * math.cos(ψ + math.pi / 2) g = (v2 * math.cos(θ2 - ψ) *(m2 - m1) + 2 * m1 * v1 * math.cos(θ1 - ψ)) * math.sin(ψ) / (m1 + m2) h = v2 * math.sin(θ2 - ψ) * math.sin(ψ + math.pi / 2) v1_x = a + b v1_y = c + d v2_x = e + f v2_y = g + h return (v1_x, v1_y), (v2_x, v2_y) |
# 6330404321 241 (2021-01-31 23:01) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 theta = math.atan2((y2-y1),(x2-x1)) zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1_x = (v1*math.cos(zeta1-theta)*(m1-m2)+2*m2*v2*math.cos(zeta2-theta))/(m1+m2)*math.cos(theta)+v1*math.sin(zeta1-theta)*math.cos(theta+math.pi/2) v1_y = (v1*math.cos(zeta1-theta)*(m1-m2)+2*m2*v2*math.cos(zeta2-theta))/(m1+m2)*math.sin(theta)+v1*math.sin(zeta1-theta)*math.sin(theta+math.pi/2) v2_x = (v1*math.cos(zeta2-theta)*(m2-m1)+2*m1*v1*math.cos(zeta1-theta))/(m1+m2)*math.cos(theta)+v1*math.sin(zeta2-theta)*math.cos(theta+math.pi/2) v2_y = (v1*math.cos(zeta2-theta)*(m2-m1)+2*m1*v1*math.cos(zeta1-theta))/(m1+m2)*math.cos(theta)+v1*math.sin(zeta2-theta)*math.sin(theta+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330405021 242 (2021-02-01 19:20) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): import math as m m1=r1**2 m2=r2**2 v1=m.sqrt(v1x**2+v1y**2) v2=m.sqrt(v2x**2+v2y**2) Φ=m.atan2(y2-y1,x2-x1) θ1=m.atan2(v1y,v1x) θ2=m.atan2(v2y,v2x) v1_x = (v1*m.cos(θ1-Φ)*(m1-m2)+2*m2*v2*m.cos(θ2-Φ))*m.cos(Φ)/(m1+m2)+v1*m.sin(θ1-Φ)*m.cos(Φ+math.pi/2) v1_y = (v1*m.cos(θ1-Φ)*(m1-m2)+2*m2*v2*m.cos(θ2-Φ))*m.sin(Φ)/(m1+m2)+v1*m.sin(θ1-Φ)*m.sin(Φ+math.pi/2) v2_x = (v2*m.cos(θ2-Φ)*(m2-m1)+2*m1*v1*m.cos(θ1-Φ))*m.cos(Φ)/(m1+m2)+v2*m.sin(θ2-Φ)*m.cos(Φ+math.pi/2) v2_y = (v2*m.cos(θ2-Φ)*(m2-m1)+2*m1*v1*m.cos(θ1-Φ))*m.sin(Φ)/(m1+m2)+v2*m.sin(θ2-Φ)*m.sin(Φ+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330406621 243 (2021-01-31 20:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 phi = math.atan2((y2-y1), (x2-x1)) v1_x = (((v1*(math.cos(theta1-phi))*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi))+(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = (((v1*(math.cos(theta1-phi))*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi))+(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = (((v2*(math.cos(theta2-phi))*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi))+(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = (((v2*(math.cos(theta2-phi))*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi))+(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330407221 244 (2021-01-30 22:23) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan((y2-y1)/(x2-x1)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(theta1-a)*(m1-m2))+(2*m2*v2*math.cos(theta2-a)))/(m1+m2))*math.cos(a))+((v1*math.sin(theta1-a))*(math.cos(a+math.pi/2))) v1_y = ((((v1*math.cos(theta1-a)*(m1-m2))+(2*m2*v2*math.cos(theta2-a)))/(m1+m2))*math.sin(a))+((v1*math.sin(theta1-a))*(math.sin(a+math.pi/2))) v2_x = ((((v2*math.cos(theta2-a)*(m2-m1))+(2*m1*v1*math.cos(theta1-a)))/(m1+m2))*math.cos(a))+((v2*math.sin(theta2-a))*(math.cos(a+math.pi/2))) v2_y = ((((v2*math.cos(theta2-a)*(m2-m1))+(2*m1*v1*math.cos(theta1-a)))/(m1+m2))*math.sin(a))+((v2*math.sin(theta2-a))*(math.sin(a+math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330408921 245 (2021-01-30 11:01) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = ((v1x ** 2) + (v1y ** 2)) ** 0.5 v2 = ((v2x ** 2) + (v2y ** 2)) ** 0.5 alpha = math.atan2((y1-y2), (x1-x2)) theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) m1 = r1**2 m2 = r2**2 v1x = (((v1 * math.cos(theta1 - alpha) * (m1 - m2) + (2 * m2 * v2 * math.cos(theta2 - alpha))) / ( m1 + m2)) * math.cos(alpha)) + v1 * math.sin(theta1 - alpha) * math.cos(alpha + (math.pi / 2)) v1y = (((v1 * math.cos(theta1 - alpha) * (m1 - m2) + (2 * m2 * v2 * math.cos(theta2 - alpha))) / ( m1 + m2)) * math.sin(alpha)) + v1 * math.sin(theta1 - alpha) * math.sin(alpha + (math.pi / 2)) v2x = (((v2 * math.cos(theta2 - alpha) * (m2 - m1) + (2 * m1 * v1 * math.cos(theta1 - alpha))) / ( m1 + m2)) * math.cos(alpha)) + v2 * math.sin(theta2 - alpha) * math.cos(alpha + (math.pi / 2)) v2y = (((v2 * math.cos(theta2 - alpha) * (m2 - m1) + (2 * m1 * v1 * math.cos(theta1 - alpha))) / ( m1 + m2)) * math.sin(alpha)) + v2 * math.sin(theta2 - alpha) * math.sin(alpha + (math.pi / 2)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330409521 246 (2021-02-01 11:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = g.sqrt((v1x**2)+(v1y**2)) v2 = g.sqrt((v2x**2)+(v2y**2)) o1 = g.atan2(v1y,v1x) o2 = g.atan2(v2y,v2x) o3 = g.atan2((y2-y1),(x2-x1)) v1_x = ((((v1*g.cos(o1-o3)*(m1-m2))+(2*m2*v2*g.cos(o2-o3)))/(m1+m2))*(g.cos(o3)))+(v1*g.sin(o1-o3)*g.cos(o3+(g.pi/2))) v1_y = ((((v1*g.cos(o1-o3)*(m1-m2))+(2*m2*v2*g.cos(o2-o3)))/(m1+m2))*(g.sin(o3)))+(v1*g.sin(o1-o3)*g.sin(o3+(g.pi/2))) v2_x = ((((v2*g.cos(o2-o3)*(m2-m1))+(2*m1*v1*g.cos(o1-o3)))/(m1+m2))*(g.cos(o3)))+(v2*g.sin(o2-o3)*g.cos(o3+(g.pi/2))) v2_y = ((((v2*g.cos(o2-o3)*(m2-m1))+(2*m1*v1*g.cos(o1-o3)))/(m1+m2))*(g.sin(o3)))+(v2*g.sin(o2-o3)*g.sin(o3+(g.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330410021 247 (2021-01-30 22:25) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt((v1x)**2+(v1y)**2) v2 = math.sqrt((v2x)**2+(v2y)**2) v1_x = ((v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y1-y2),(x1-x2)))*(((r1)**2)-((r2)**2))+2*((r2)**2)*v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y1-y2),(x1-x2))))/(((r1)**2)+((r2)**2)))*math.cos(math.atan2((y1-y2),(x1-x2)))+v1*math.sin(math.atan2(v1y,v1x)-math.atan2((y1-y2),(x1-x2)))*math.cos(math.atan2((y1-y2),(x1-x2))+math.pi/2) v1_y = ((v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y1-y2),(x1-x2)))*(((r1)**2)-((r2)**2))+2*((r2)**2)*v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y1-y2),(x1-x2))))/(((r1)**2)+((r2)**2)))*math.sin(math.atan2((y1-y2),(x1-x2)))+v1*math.sin(math.atan2(v1y,v1x)-math.atan2((y1-y2),(x1-x2)))*math.sin(math.atan2((y1-y2),(x1-x2))+math.pi/2) v2_x = ((v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y1-y2),(x1-x2)))*(((r2)**2)-((r1)**2))+2*((r1)**2)*v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y1-y2),(x1-x2))))/(((r1)**2)+((r2)**2)))*math.cos(math.atan2((y1-y2),(x1-x2)))+v2*math.sin(math.atan2(v2y,v2x)-math.atan2((y1-y2),(x1-x2)))*math.cos(math.atan2((y1-y2),(x1-x2))+math.pi/2) v2_y = ((v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y1-y2),(x1-x2)))*(((r2)**2)-((r1)**2))+2*((r1)**2)*v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y1-y2),(x1-x2))))/(((r1)**2)+((r2)**2)))*math.sin(math.atan2((y1-y2),(x1-x2)))+v2*math.sin(math.atan2(v2y,v2x)-math.atan2((y1-y2),(x1-x2)))*math.sin(math.atan2((y1-y2),(x1-x2))+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330411721 248 (2021-01-30 12:15) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) angle1 = math.atan2(v1y,v1x) angle2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = (v1*math.cos(angle1-phi)*(m1-m2)+2*m2*v2*math.cos(angle2-phi))*math.cos(phi)/(m1+m2) + v1*math.sin(angle1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(angle1-phi)*(m1-m2)+2*m2*v2*math.cos(angle2-phi))*math.sin(phi)/(m1+m2) + v1*math.sin(angle1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(angle2-phi)*(m2-m1)+2*m1*v1*math.cos(angle1-phi))*math.cos(phi)/(m1+m2) + v2*math.sin(angle2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(angle2-phi)*(m2-m1)+2*m1*v1*math.cos(angle1-phi))*math.sin(phi)/(m1+m2) + v2*math.sin(angle2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330412321 249 (2021-01-31 00:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) m1=r1**2 m2=r2**2 T1=math.atan2(v1y,v1x) T2=math.atan2(v2y,v2x) t=math.atan((y2-y1)/(x2-x1)) v1_x =((((v1*math.cos(T1-t)*(m1-m2))+(2*m2*v2*math.cos(T2-t)))/(m1+m2))*math.cos(t))+(v1*math.sin(T1-t)*math.cos(t+(math.pi/2))) v1_y =((((v1*math.cos(T1-t)*(m1-m2))+(2*m2*v2*math.cos(T2-t)))/(m1+m2))*math.sin(t))+(v1*math.sin(T1-t)*math.sin(t+(math.pi/2))) v2_x =((((v2*math.cos(T2-t)*(m2-m1))+(2*m1*v1*math.cos(T1-t)))/(m1+m2))*math.cos(t))+(v2*math.sin(T2-t)*math.cos(t+(math.pi/2))) v2_y =((((v2*math.cos(T2-t)*(m2-m1))+(2*m1*v1*math.cos(T1-t)))/(m1+m2))*math.sin(t))+(v2*math.sin(T2-t)*math.sin(t+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330413021 250 (2021-01-30 14:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here pi = math.pi dx = x1-x2 dy = y1-y2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) psi = math.atan2(dy,dx) v1_x = (v1*math.cos(theta1-psi)*(r1**2-r2**2)+2*(r2**2)*(v2)*(math.cos(theta2-psi)))*(math.cos(psi)/(r1**2+r2**2))+(v1)*(math.sin(theta1-psi))*(math.cos(psi+pi/2)) v1_y = (v1*math.cos(theta1-psi)*(r1**2-r2**2)+2*(r2**2)*(v2)*(math.cos(theta2-psi)))*(math.sin(psi)/(r1**2+r2**2))+(v1)*(math.sin(theta1-psi))*(math.sin(psi+pi/2)) v2_x = (v2*math.cos(theta2-psi)*(r2**2-r1**2)+2*(r1**2)*(v1)*(math.cos(theta1-psi)))*(math.cos(psi)/(r1**2+r2**2))+(v2)*(math.sin(theta2-psi))*(math.cos(psi+pi/2)) v2_y = (v2*math.cos(theta2-psi)*(r2**2-r1**2)+2*(r1**2)*(v1)*(math.cos(theta1-psi)))*(math.sin(psi)/(r1**2+r2**2))+(v2)*(math.sin(theta2-psi))*(math.sin(psi+pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330415221 251 (2021-01-29 09:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here o1 = math.atan2(v1y,v1x) o2 = math.atan2(v2y,v2x) w = math.atan2((y1-y2),(x2-x1)) v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 m1 = r1**2 m2 = r2**2 v1_x = ((v1*(math.cos(o1-w))*(m1-m2) + 2*m2*v2*math.cos(o2-w))/(m1+m2))*math.cos(w) + v1*(math.sin(o1-w))*math.cos(w+math.pi/2) v1_y = ((v1*(math.cos(o1-w))*(m1-m2) + 2*m2*v2*math.cos(o2-w))/(m1+m2))*math.sin(w) + v1*(math.sin(o1-w))*math.sin(w+math.pi/2) v2_x = ((v2*(math.cos(o2-w))*(m2-m1) + 2*m1*v1*math.cos(o1-w))/(m1+m2))*math.cos(w) + v2*(math.sin(o2-w))*math.cos(w+math.pi/2) v2_y = ((v2*(math.cos(o2-w))*(m2-m1) + 2*m1*v1*math.cos(o1-w))/(m1+m2))*math.sin(w) + v2*(math.sin(o2-w))*math.sin(w+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330416921 252 (2021-01-29 16:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 z1=math.atan2(v1y,v1x) z2=math.atan2(v2y,v2x) f=math.atan((y1-y2)/(x1-x2)) v1_x = (((v1*math.cos(z1-f)*(m1-m2))+(2*m2*v2*math.cos(z2-f)))/(m1+m2))*math.cos(f)+(v1*math.sin(z1-f)*math.cos(f+(math.pi/2))) v1_y = (((v1*math.cos(z1-f)*(m1-m2))+(2*m2*v2*math.cos(z2-f)))/(m1+m2))*math.sin(f)+(v1*math.sin(z1-f)*math.sin(f+(math.pi/2))) v2_x = (((v2*math.cos(z2-f)*(m2-m1))+(2*m1*v1*math.cos(z1-f)))/(m2+m1))*math.cos(f)+(v2*math.sin(z2-f)*math.cos(f+(math.pi/2))) v2_y = (((v2*math.cos(z2-f)*(m2-m1))+(2*m1*v1*math.cos(z1-f)))/(m2+m1))*math.sin(f)+(v2*math.sin(z2-f)*math.sin(f+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330417521 253 (2021-02-01 14:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan((y2-y1)/(x2-x1)) v1_x = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.cos(phi)+(v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.sin(phi)+(v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.cos(phi)+(v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.sin(phi)+(v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330418121 254 (2021-01-30 22:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(theta1-phi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.cos(phi))+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((((v1*math.cos(theta1-phi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.sin(phi))+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((((v2*math.cos(theta2-phi)*(m2-m1)) + (2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.cos(phi))+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((((v2*math.cos(theta2-phi)*(m2-m1)) + (2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.sin(phi))+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330420321 255 (2021-01-28 20:14) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y,): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) Ze1 = math.degrees(math.atan2(v1y,v1x)) Ze2 = math.degrees(math.atan2(v2y,v2x)) phi = math.degrees(math.atan2((y2-y1),(x2-x1))) v1_x = ((((v1 * math.cos(math.radians(Ze1-phi))*(m1-m2)) + (2*m2*v2*math.cos(math.radians(Ze2-phi))))/(m1+m2))*math.cos(math.radians(phi)))+v1*math.sin(math.radians(Ze1-phi))*math.cos(math.radians(phi)+(math.pi/2)) v1_y = ((((v1 * math.cos(math.radians(Ze1-phi))*(m1-m2)) + (2*m2*v2*math.cos(math.radians(Ze2-phi))))/(m1+m2))*math.sin(math.radians(phi)))+v1*math.sin(math.radians(Ze1-phi))*math.sin(math.radians(phi)+(math.pi/2)) v2_x = ((((v2 * math.cos(math.radians(Ze2-phi))*(m2-m1)) + (2*m1*v1*math.cos(math.radians(Ze1-phi))))/(m1+m2))*math.cos(math.radians(phi)))+v2*math.sin(math.radians(Ze2-phi))*math.cos(math.radians(phi)+(math.pi/2)) v2_y = ((((v2 * math.cos(math.radians(Ze2-phi))*(m2-m1)) + (2*m1*v1*math.cos(math.radians(Ze1-phi))))/(m1+m2))*math.sin(math.radians(phi)))+v2*math.sin(math.radians(Ze2-phi))*math.sin(math.radians(phi)+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330422621 256 (2021-01-31 08:59) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here fee = math.atan2((y1 - y2), (x1 - x2)) s1 = math.atan2(v1y, v1x) s2 = math.atan2(v2y, v2x) m1 = (r1)**2 m2 = (r2)**2 v1 = math.sqrt((v1x)**2 + (v1y)**2) v2 = math.sqrt((v2x)**2 + (v2y)**2) v1_x = (((v1*math.cos(s1-fee))*(m1 - m2)+(2*(m2)*v2*math.cos(s2-fee)))/(m1 + m2))*(math.cos(fee))+(v1*math.sin(s1-fee)*math.cos(fee + (math.pi)/2)) v1_y = (((v1*math.cos(s1-fee))*(m1 - m2)+(2*(m2)*v2*math.cos(s2-fee)))/(m1 + m2))*(math.sin(fee))+(v1*math.sin(s1-fee)*math.sin(fee + (math.pi)/2)) v2_x = (((v2*math.cos(s2-fee))*(m2 - m1)+(2*(m1)*v1*math.cos(s1-fee)))/(m1 + m2))*(math.cos(fee))+(v2*math.sin(s2-fee)*math.cos(fee + (math.pi)/2)) v2_y = (((v2*math.cos(s2-fee))*(m2 - m1)+(2*(m1)*v1*math.cos(s1-fee)))/(m1 + m2))*(math.sin(fee))+(v2*math.sin(s2-fee)*math.sin(fee + (math.pi)/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330423221 257 (2021-01-31 22:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi=math.atan2(y1-y2,x1-x2) theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) v1=(v1x**2+v1y**2)**0.5 v2=(v2x**2+v2y**2)**0.5 m1=r1**2 m2=r2**2 v1_x = (((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi))+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi)/2) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi))+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi)/2) v2_x = (((v2*math.cos(theta1-phi)*(m1-m2)+2*m1*v1*math.cos(theta2-phi))/(m1+m2))*math.cos(phi))+v2*math.sin(theta1-phi)*math.cos(phi+(math.pi)/2) v2_y = (((v2*math.cos(theta1-phi)*(m1-m2)+2*m1*v1*math.cos(theta2-phi))/(m1+m2))*math.sin(phi))+v2*math.sin(theta1-phi)*math.sin(phi+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330424921 258 (2021-01-28 17:58) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 c1 = math.acos(v1x/v1) c2 = math.acos(v2x/v2) ƒ = math.atan((y1-y2)/(x2-x1)) v1_x = ((v1*math.cos(c1-ƒ)*(m1-m2)+2*m2*v2*math.cos(c2-ƒ))/(m1+m2))*math.cos(ƒ)+v1*math.sin(c1-ƒ)*math.cos(ƒ+math.pi/2) v1_y = ((v1*math.cos(c1-ƒ)*(m1-m2)+2*m2*v2*math.cos(c2-ƒ))/(m1+m2))*math.sin(ƒ)+v1*math.sin(c1-ƒ)*math.sin(ƒ+math.pi/2) v2_x = ((v2*math.cos(c2-ƒ)*(m1-m2)+2*m1*v1*math.cos(c1-ƒ))/(m1+m2))*math.cos(ƒ)+v2*math.sin(c2-ƒ)*math.cos(ƒ+math.pi/2) v2_y = ((v2*math.cos(c2-ƒ)*(m1-m2)+2*m1*v1*math.cos(c1-ƒ))/(m1+m2))*math.sin(ƒ)+v2*math.sin(c2-ƒ)*math.sin(ƒ+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330425521 259 (2021-02-01 08:37) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y m1 = r1**2 m2 = r2**2 v1 = math.hypot(v1_x,v1_y) angleA = math.atan2(v1_y,v1_x) v2 = math.hypot(v2_x,v2_y) angleB = math.atan2(v2_y,v2_x) fi = math.atan2((y2-y1),(x2-x1)) sum_m = m1 + m2 dm_m1 = m1 - m2 dm_m2 = m2 - m1 v1_x = (((v1*math.cos(angleA-fi)*(dm_m1)) + (2*m2*v2*math.cos(angleB-fi)))*(math.cos(fi)/sum_m))+v1*math.sin(angleA-fi)*math.cos(fi+(math.pi/2)) v1_y = (((v1*math.cos(angleA-fi)*(dm_m1)) + (2*m2*v2*math.cos(angleB-fi)))*(math.sin(fi)/sum_m))+v1*math.sin(angleA-fi)*math.sin(fi+(math.pi/2)) v2_x = (((v2*math.cos(angleB-fi)*(dm_m2)) + (2*m1*v1*math.cos(angleA-fi)))*(math.cos(fi)/sum_m))+v2*math.sin(angleB-fi)*math.cos(fi+(math.pi/2)) v2_y = (((v2*math.cos(angleB-fi)*(dm_m2)) + (2*m1*v1*math.cos(angleA-fi)))*(math.sin(fi)/sum_m))+v2*math.sin(angleB-fi)*math.sin(fi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330426121 260 (2021-01-29 23:14) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 p = math.atan((y2-y1)/(x2-x1)) v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 e1 = math.atan2(v1y,v1x) e2 = math.atan2(v2y,v2x) v1_x = ((v1*math.cos(e1-p)*(m1-m2) + 2*m2*v2*math.cos(e2-p))/(m1+m2))*math.cos(p) + v1*math.sin(e1-p)*math.cos(p+ math.pi/2) v1_y = ((v1*math.cos(e1-p)*(m1-m2) + 2*m2*v2*math.cos(e2-p))/(m1+m2))*math.sin(p) + v1*math.sin(e1-p)*math.sin(p+ math.pi/2) v2_x = ((v2*math.cos(e2-p)*(m2-m1) + 2*m1*v1*math.cos(e1-p))/(m1+m2))*math.cos(p) + v2*math.sin(e2-p)*math.cos(p+ math.pi/2) v2_y = ((v2*math.cos(e2-p)*(m2-m1) + 2*m1*v1*math.cos(e1-p))/(m1+m2))*math.sin(p) + v2*math.sin(e2-p)*math.sin(p+ math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330427821 261 (2021-02-01 00:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def mass(r): return r**2 m1 = mass(r1) m2 = mass(r2) def velocity(v1,v2): return math.sqrt(v1**2+v2**2) v1 = velocity(v1x,v1y) v2 = velocity(v2x,v2y) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan((y2-y1)/(x2-x1)) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi)))/(m2+m1))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi)))/(m2+m1))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330428421 262 (2021-02-01 15:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) phi=math.atan2((y1-y2),(x1-x2)) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) #v2=v2x/math.cos(theta2) v1_x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) #print(theta1) #print(theta2) #print(phi) #print(v1_x) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330429021 263 (2021-01-29 00:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision se1 = math.atan2(v1y, v1x) se2 = math.atan2(v2y, v2x) fi = math.atan2(y2-y1, x2-x1) m1 = r1 ** 2 m2 = r2 ** 2 v1 = (v1x ** 2 + v1y ** 2) ** 0.5 v2 = (v2x ** 2 + v2y ** 2) ** 0.5 v1_x = (v1 * math.cos(se1 - fi) * (m1 - m2) + 2 * m2 * v2 * math.cos(se2 - fi)) * math.cos(fi) / ( m1 + m2) + v1 * math.sin(se1 - fi) * math.cos(fi + math.pi / 2) v1_y = (v1 * math.cos(se1 - fi) * (m1 - m2) + 2 * m2 * v2 * math.cos(se2 - fi)) * math.sin(fi) / ( m1 + m2) + v1 * math.sin(se1 - fi) * math.sin(fi + math.pi / 2) v2_x = (v2 * math.cos(se2 - fi) * (m2 - m1) + 2 * m1 * v1 * math.cos(se1 - fi)) * math.cos(fi) / ( m1 + m2) + v2 * math.sin(se2 - fi) * math.cos(fi + math.pi / 2) v2_y = (v2 * math.cos(se2 - fi) * (m2 - m1) + 2 * m1 * v1 * math.cos(se1 - fi)) * math.sin(fi) / ( m1 + m2) + v2 * math.sin(se2 - fi) * math.sin(fi + math.pi / 2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330430621 264 (2021-01-31 21:41) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 z1 = math.atan2(v1y,v1x) z2 = math.atan2(v2y,v2x) u = (y2-y1) p = (x2-x1) s = math.atan2(u,p) u1 = math.sqrt(v1x**2+v1y**2) u2 = math.sqrt(v2x**2+v2y**2) v1_x = (((u1*math.cos(z1-s)*(m1-m2))+(2*m2*u2*math.cos(z2-s)))*((math.cos(s))/(m1+m2)))+(u1*math.sin(z1-s)*math.cos(s+((math.pi)/2))) v1_y = (((u1*math.cos(z1-s)*(m1-m2))+(2*m2*u2*math.cos(z2-s)))*((math.sin(s))/(m1+m2)))+(u1*math.sin(z1-s)*math.sin(s+((math.pi)/2))) v2_x = ((m1/m2)*((v1x)-(v1_x)))+v2x v2_y = ((m1/m2)*((v1y)-(v1_y)))+v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330431221 265 (2021-01-31 01:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1 = ((v1x**2+v1y**2))**(0.5) v2 = ((v2x**2+v2y**2))**(0.5) v1_x = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330432921 266 (2021-01-31 19:01) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) m1 = (r1)**2 m2 = (r2)**2 v1_x = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.cos(phi)+(v1*math.sin(theta1-phi)*math.cos(phi+((math.pi)/2))) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.sin(phi)+(v1*math.sin(theta1-phi)*math.sin(phi+((math.pi)/2))) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m2+m1))*math.cos(phi)+(v2*math.sin(theta2-phi)*math.cos(phi+((math.pi)/2))) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m2+m1))*math.sin(phi)+(v2*math.sin(theta2-phi)*math.sin(phi+((math.pi)/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330433521 267 (2021-01-31 16:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here c1 = math.atan2(v1y,v1x) c2 = math.atan2(v2y,v2x) p = math.atan2(y1-y2,x1-x2) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 v1_x = (((v1*(math.cos(c1-p))*(m1-m2) + 2*m2*v2*math.cos(c2-p))*math.cos(p)) / (m1+m2)) + v1*math.sin(c1-p)*math.cos(p-math.pi/2) v1_y = (((v1*(math.cos(c1-p))*(m1-m2) + 2*m2*v2*math.cos(c2-p))*math.sin(p)) / (m1+m2)) + v1*math.sin(c1-p)*math.sin(p-math.pi/2) v2_x = (((v2*(math.cos(c2-p))*(m2-m1) + 2*m1*v1*math.cos(c1-p))*math.cos(p)) / (m2+m1)) + v2*math.sin(c2-p)*math.cos(p-math.pi/2) v2_y = (((v2*(math.cos(c2-p))*(m1-m2) + 2*m1*v1*math.cos(c1-p))*math.sin(p)) / (m1+m2)) + v2*math.sin(c2-p)*math.sin(p-math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330434121 268 (2021-01-28 23:03) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt((v1x ** 2) + (v1y ** 2)) v2 = math.sqrt((v2x ** 2) + (v2y ** 2)) m1 = r1 ** 2 m2 = r2 ** 2 t1 = math.atan2(v1y, v1x) t2 = math.atan2(v2y, v2x) phi = math.atan2((y1- y2), (x1- x2)) v1_x = ((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*math.cos(t2-phi))*math.cos(phi)/(m1+m2))+(v1*math.sin(t1-phi)*math.cos(phi+math.pi/2)) v1_y = ((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*math.cos(t2-phi))*math.sin(phi)/(m1+m2))+(v1*math.sin(t1-phi)*math.sin(phi+math.pi/2)) v2_x = ((v2*math.cos(t2-phi)*(m2-m1)+2*m1*v1*math.cos(t1-phi))*math.cos(phi)/(m1+m2))+(v2*math.sin(t2-phi)*math.cos(phi+math.pi/2)) v2_y = ((v2*math.cos(t2-phi)*(m2-m1)+2*m1*v1*math.cos(t1-phi))*math.sin(phi)/(m1+m2))+(v2*math.sin(t2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330435821 269 (2021-01-28 21:32) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=(v1x**2+v1y**2)**0.5 v2 = (v2x ** 2 + v2y ** 2) ** 0.5 Mass1_InitialAngle=math.atan2(v1y,v1x) Mass2_InitialAngle = math.atan2(v2y, v2x) CONTACT_ANGLE=math.atan2((y1-y2),(x1-x2)) v1_Component=((v1*math.cos(Mass1_InitialAngle-CONTACT_ANGLE)*(r1**2-r2**2)+2*(r2**2)*v2*math.cos(Mass2_InitialAngle-CONTACT_ANGLE))/(r1**2+r2**2)) v1_x = v1_Component*math.cos(CONTACT_ANGLE)+v1*math.sin(Mass1_InitialAngle-CONTACT_ANGLE)*math.cos(CONTACT_ANGLE+math.pi/2) v1_y = v1_Component*math.sin(CONTACT_ANGLE)+v1*math.sin(Mass1_InitialAngle-CONTACT_ANGLE)*math.sin(CONTACT_ANGLE+math.pi/2) v2_x = ((r1**2)/(r2**2))*(v1x-v1_x)+v2x v2_y = ((r1**2)/(r2**2))*(v1y-v1_y)+v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330436421 270 (2021-02-01 21:26) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here fee = math.atan2((y2-y1),(x2-x1)) A = math.cos(fee) B = math.sin(fee) af = ((v1x*A+v1y*B)*((r1**2)-(r2**2))+(2*(r2**2))*(v2x*A+v2y*B)) aby = A+(v1y*A-v1x*B)*(math.cos(fee+math.pi/2)) bf = ((v1x*A+v1y*B)*((r1**2)-(r2**2))+(2*(r2**2))*(v2x*A+v2y*B)) bby = B+(v1y*A-v1x*B)*(math.sin(fee+math.pi/2)) cf = ((v2x*A+v2y*B)*((r1**2)-(r2**2))+(2*(r1**2))*(v1x*A+v1y*B)) cby = A+(v2y*A-v2x*B)*(math.cos(fee+math.pi/2)) df = ((v1x*A+v1y*B)*((r1**2)-(r2**2))+(2*(r1**2))*(v1x*A+v2y*B)) dby = B+(v2y*A-v2x*B)*(math.sin(fee+math.pi/2)) m = (r1**2)+(r2**2) v1_x = (af*math.cos(fee)/m) + aby v1_y = (bf*math.sin(fee)/m) + bby v2_x = (cf*math.cos(fee)/m) + cby v2_y = (df*math.sin(fee)/m) + dby return (v1_x, v1_y), (v2_x, v2_y) |
# 6330437021 271 (2021-02-01 02:57) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here M1 = r1**2 M2 = r2**2 dy = y1-y2 dx = x1-x2 V1 = math.sqrt(v1x**2+v1y**2) V2 = math.sqrt(v2x**2+v2y**2) S = math.atan2(dy,dx) S1 = math.atan2(v1y,v1x) S2 = math.atan2(v2y,v2x) v1_x = (((V1*math.cos(S1-S)*(M1-M2))+(2*M2*V2*math.cos(S2-S)))*math.cos(S)/(M1+M2))+V1*math.sin(S1-S)*math.cos(S+(math.pi/2)) v1_y = (((V1*math.cos(S1-S)*(M1-M2))+(2*M2*V2*math.cos(S2-S)))*math.sin(S)/(M1+M2))+V1*math.sin(S1-S)*math.sin(S+(math.pi/2)) v2_x = (((V2*math.cos(S2-S)*(M2-M1))+(2*M1*V1*math.cos(S1-S)))*math.cos(S)/(M1+M2))+V2*math.sin(S2-S)*math.cos(S+(math.pi/2)) v2_y = (((V2*math.cos(S2-S)*(M2-M1))+(2*M1*V1*math.cos(S1-S)))*math.sin(S)/(M1+M2))+V2*math.sin(S2-S)*math.sin(S+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330438721 272 (2021-01-31 12:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 def v(vx,vy): v = (vx**2 + vy**2)**0.5 return v v1 = v(v1x,v1y) v2 = v(v2x,v2y) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan((y1-y2)/(x1-x2)) v1x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2) + v1*math.sin(theta1-phi)*math.cos(phi+(math.pi)/2) v1y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2) + v1*math.sin(theta1-phi)*math.sin(phi+(math.pi)/2) v2x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2) + v2*math.sin(theta2-phi)*math.cos(phi+(math.pi)/2) v2y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2) + v2*math.sin(theta2-phi)*math.sin(phi+(math.pi)/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330439321 273 (2021-01-31 14:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2((y2-y1), (x2-x1)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)) + 2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2) + v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)) + 2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2) + v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)) + 2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2) + v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)) + 2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2) + v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330440921 274 (2021-01-29 21:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision m1 = r1**2 m2 = r2**2 phi = math.atan2((y2 - y1), (x2 - x1)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) # zeta1 = math.acos(v1x/v1) # zeta2 = math.acos(v2x/v2) zeta1 = math.atan2(v1y, v1x) zeta2 = math.atan2(v2y, v2x) # if v1x == 0: # zeta1 = math.pi/2 # math.radians(90) # else: # zeta1 = math.atan(v1y/v1x) # if v2x == 0: # zeta2 = math.pi/2 # else: # zeta2 = math.atan(v2y/v2x) v1_x = (v1*math.cos(zeta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(zeta2 - phi))/(m1 + m2)*math.cos(phi) + v1*(math.sin(zeta1 - phi))*math.cos(phi + math.pi/2) v1_y = (v1*math.cos(zeta1 - phi)*(m1 - m2) + 2*m2*v2*math.cos(zeta2 - phi))/(m1 + m2)*math.sin(phi) + v1*(math.sin(zeta1 - phi))*math.sin(phi + math.pi/2) v2_x = (v2*math.cos(zeta2 - phi)*(m2 - m1) + 2*m1*v1*math.cos(zeta1 - phi))/(m1 + m2)*math.cos(phi) + v2*(math.sin(zeta2 - phi))*math.cos(phi + math.pi/2) v2_y = (v2*math.cos(zeta2 - phi)*(m2 - m1) + 2*m1*v1*math.cos(zeta1 - phi))/(m1 + m2)*math.sin(phi) + v2*(math.sin(zeta2 - phi))*math.sin(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330441521 275 (2021-01-30 15:48) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) p = math.atan2((y1-y2),(x1-x2)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(t1-p)*(m1-m2)+2*m2*v2*math.cos(t2-p))*math.cos(p)/(m1+m2))+v1*math.sin(t1-p)*math.cos(p+math.pi/2) v1_y = ((v1*math.cos(t1-p)*(m1-m2)+2*m2*v2*math.cos(t2-p))*math.sin(p)/(m1+m2))+v1*math.sin(t1-p)*math.sin(p+math.pi/2) v2_x = ((v2*math.cos(t2-p)*(m2-m1)+2*m1*v1*math.cos(t1-p))*math.cos(p)/(m1+m2))+v2*math.sin(t2-p)*math.cos(p+math.pi/2) v2_y = ((v2*math.cos(t2-p)*(m2-m1)+2*m1*v1*math.cos(t1-p))*math.sin(p)/(m1+m2))+v2*math.sin(t2-p)*math.sin(p+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330443821 276 (2021-01-30 20:00) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # insert your code here a1 = math.atan2(v1y, (v1x)) a2 = math.atan2(v2y, (v2x)) b = math.atan2((y1-y2), (x1-x2)) m1 = r1**2 m2 = r2**2 v1 = ((v1x**2+v1y**2)**0.5) v2 = ((v2x**2+v2y**2)**0.5) v1_x = ((v1*math.cos(a1-b)*(m1-m2) + 2*m2*v2*math.cos(a2-b))/(m1+m2))*math.cos(b)+v1*math.sin(a1-b)*math.cos(b+((math.pi)/2)) v1_y = ((v1*math.cos(a1-b)*(m1-m2) + 2*m2*v2*math.cos(a2-b))/(m1+m2))*math.sin(b)+v1*math.sin(a1-b)*math.sin(b+((math.pi)/2)) v2_x = ((v2*math.cos(a2-b)*(m2-m1) + 2*m1*v1*math.cos(a1-b))/(m1+m2))*math.cos(b)+v2*math.sin(a2-b)*math.cos(b+((math.pi)/2)) v2_y = ((v2*math.cos(a2-b)*(m2-m1) + 2*m1*v1*math.cos(a1-b))/(m1+m2))*math.sin(b)+v2*math.sin(a2-b)*math.sin(b+((math.pi))/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330445021 277 (2021-02-01 01:33) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here T1 = math.atan2(v1y,v1x) T2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 sm = m1 + m2 P = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) def formula(m,T,t,V,v): return (V*math.cos(T-P)*(sm-2*m) + 2*m*v*math.cos(t-P))/sm v1_x = formula(m2,T1,T2,v1,v2)*math.cos(P) + v1*math.sin(T1-P)*math.cos(P+math.pi/2) v1_y = formula(m2,T1,T2,v1,v2)*math.sin(P) + v1*math.sin(T1-P)*math.sin(P+math.pi/2) v2_x = formula(m1,T2,T1,v2,v1)*math.cos(P) + v2*math.sin(T2-P)*math.cos(P+math.pi/2) v2_y = formula(m1,T2,T1,v2,v1)*math.sin(P) + v2*math.sin(T2-P)*math.sin(P+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330446721 278 (2021-01-30 22:27) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = (r1)**2 m2 = (r2)**2 tetha1 = math.atan2(v1y,v1x) tetha2 = math.atan2(v2y,v2x) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) phi = math.atan2((y2-y1),(x2-x1)) v1_x = (((((v1*math.cos(tetha1-phi))*(m1-m2))+(2*m2*v2*math.cos(tetha2-phi)))/(m1+m2)*math.cos(phi)))+(v1*math.sin(tetha1-phi)*(math.cos(phi+(math.pi/2)))) v1_y = (((((v1*math.cos(tetha1-phi))*(m1-m2))+(2*m2*v2*math.cos(tetha2-phi)))/(m1+m2)*math.sin(phi)))+(v1*math.sin(tetha1-phi)*(math.sin(phi+(math.pi/2)))) v2_x = (((((v2*math.cos(tetha2-phi))*(m2-m1))+(2*m1*v1*math.cos(tetha1-phi)))/(m1+m2)*math.cos(phi)))+(v2*math.sin(tetha2-phi)*(math.cos(phi+(math.pi/2)))) v2_y = (((((v2*math.cos(tetha2-phi))*(m2-m1))+(2*m1*v1*math.cos(tetha1-phi)))/(m1+m2)*math.sin(phi)))+(v2*math.sin(tetha2-phi)*(math.sin(phi+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330447321 279 (2021-01-30 18:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) phi=math.atan2(y2-y1,x2-x1) m1=r1**2 m2=r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) v1_x = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*(math.cos(theta2-phi))))/(m1+m2))*(math.cos(phi)))+(v1*(math.sin(theta1-phi))*(math.cos(phi+((math.pi)/2)))) v1_y = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*(math.cos(theta2-phi))))/(m1+m2))*(math.sin(phi)))+(v1*(math.sin(theta1-phi))*(math.sin(phi+((math.pi)/2)))) v2_x = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*(math.cos(theta1-phi))))/(m1+m2))*(math.cos(phi)))+(v2*(math.sin(theta2-phi))*(math.cos(phi+((math.pi)/2)))) v2_y = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*(math.cos(theta1-phi))))/(m1+m2))*(math.sin(phi)))+(v2*(math.sin(theta2-phi))*(math.sin(phi+((math.pi)/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330448021 280 (2021-01-30 22:08) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 theta1 = math.acos(v1x/v1) theta2 = math.acos(v2x/v2) phi = math.atan((y2-y1)/(x2-x1)) m1 = r1**2 m2 = r2**2 v1_x = math.cos(phi)*(v1*(m1-m2)*math.cos(theta1-phi) + 2*m2*v2*math.cos(theta2 - phi))/(m1+m2) + v1*math.sin(theta1 - phi)*math.cos(phi + math.pi/2) v1_y = math.sin(phi)*(v1*(m1-m2)*math.cos(theta1-phi) + 2*m2*v2*math.cos(theta2 - phi))/(m1+m2) + v1*math.sin(theta1 - phi)*math.sin(phi + math.pi/2) v2_x = math.cos(phi)*(v2*(m2-m1)*math.cos(theta2-phi) + 2*m1*v1*math.cos(theta1 - phi))/(m1+m2) + v2*math.sin(theta2 - phi)*math.cos(phi + math.pi/2) v2_y = math.sin(phi)*(v2*(m2-m1)*math.cos(theta2-phi) + 2*m1*v1*math.cos(theta1 - phi))/(m1+m2) + v2*math.sin(theta2 - phi)*math.sin(phi + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330449621 281 (2021-01-30 17:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) m1 = r1**2 m2 = r2**2 a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*math.cos(a1-phi)*(m1-m2)+2*m2*v2*math.cos(a2-phi))/(m1+m2))*math.cos(phi))+v1*math.sin(a1-phi)*math.cos(phi-math.pi/2) v1_y = (((v1*math.cos(a1-phi)*(m1-m2)+2*m2*v2*math.cos(a2-phi))/(m1+m2))*math.sin(phi))+v1*math.sin(a1-phi)*math.sin(phi-math.pi/2) v2_x = (((v2*math.cos(a2-phi)*(m2-m1)+2*m1*v1*math.cos(a1-phi))/(m1+m2))*math.cos(phi))+v2*math.sin(a2-phi)*math.cos(phi-math.pi/2) v2_y = (((v2*math.cos(a2-phi)*(m2-m1)+2*m1*v1*math.cos(a1-phi))/(m1+m2))*math.sin(phi))+v2*math.sin(a2-phi)*math.sin(phi-math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330450121 282 (2021-01-30 20:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here ceta0=math.atan2((y1-y2),(x1-x2)) ceta1=math.atan2(v1y,v1x) ceta2=math.atan2(v2y,v2x) velocity1=math.sqrt((v1x**2)+(v1y**2)) velocity2=math.sqrt((v2x**2)+(v2y**2)) mass1=r1**2 mass2=r2**2 fx1=(velocity1*(math.cos(ceta1-ceta0))*(mass1-mass2)) fx2=(2*mass2*velocity2*(math.cos(ceta2-ceta0))) fx3=((math.cos(ceta0))/(mass1+mass2)) fx4=velocity1*(math.sin(ceta1-ceta0))*(math.cos(ceta0+(math.pi/2))) fx1xtotal=((fx1+fx2)*fx3)+fx4 fx1=(velocity1*(math.cos(ceta1-ceta0))*(mass1-mass2)) fx2=(2*mass2*velocity2*(math.cos(ceta2-ceta0))) fx3=((math.sin(ceta0))/(mass1+mass2)) fx4=velocity1*(math.sin(ceta1-ceta0))*(math.sin(ceta0+(math.pi/2))) fx1ytotal=((fx1+fx2)*fx3)+fx4 #for second one fx1=(velocity2*(math.cos(ceta2-ceta0))*(mass2-mass1)) fx2=(2*mass1*velocity1*(math.cos(ceta1-ceta0))) fx3=((math.cos(ceta0))/(mass1+mass2)) fx4=velocity2*(math.sin(ceta2-ceta0))*(math.cos(ceta0+(math.pi/2))) fx2xtotal=((fx1+fx2)*fx3)+fx4 fx1=(velocity2*(math.cos(ceta2-ceta0))*(mass2-mass1)) fx2=(2*mass1*velocity1*(math.cos(ceta1-ceta0))) fx3=((math.sin(ceta0))/(mass1+mass2)) fx4=velocity2*(math.sin(ceta2-ceta0))*(math.sin(ceta0+(math.pi/2))) fx2ytotal=((fx1+fx2)*fx3)+fx4 v1_x = fx1xtotal v1_y = fx1ytotal v2_x = fx2xtotal v2_y = fx2ytotal return (v1_x, v1_y), (v2_x, v2_y) |
# 6330452421 283 (2021-01-29 22:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): a1 = math.atan2(v1y,(v1x)) a2 = math.atan2(v2y,(v2x)) phi = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1, v2 = math.sqrt((v1y)**2+(v1x)**2), math.sqrt((v2y)**2+(v2x)**2) v1_x = ((((v1*(math.cos(a1-phi))*(m1-m2))+(2*m2*v2*math.cos(a2-phi)))*math.cos(phi))/(m1+m2))+((v1*math.sin((a1-phi)))*(math.cos(phi+(math.pi)/2))) v1_y = ((((v1*(math.cos(a1-phi))*(m1-m2))+(2*m2*v2*math.cos(a2-phi)))*math.sin(phi))/(m1+m2))+((v1*math.sin((a1-phi)))*(math.sin(phi+(math.pi)/2))) v2_x = ((((v2*(math.cos(a2-phi))*(m2-m1))+(2*m1*v1*math.cos(a1-phi)))*math.cos(phi))/(m1+m2))+((v2*math.sin((a2-phi)))*(math.cos(phi+(math.pi)/2))) v2_y = ((((v2*(math.cos(a2-phi))*(m2-m1))+(2*m1*v1*math.cos(a1-phi)))*math.sin(phi))/(m1+m2))+((v2*math.sin((a2-phi)))*(math.sin(phi+(math.pi)/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330453021 284 (2021-01-31 16:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) th1 = math.atan2(v1y,v1x) th2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1_x = (((v1*math.cos(th1-phi)*(m1-m2))+(2*m2*v2*math.cos(th2-phi)))/(m1+m2))*math.cos(phi)+v1*math.sin(th1-phi)*math.cos(phi+math.pi/2) v1_y = (((v1*math.cos(th1-phi)*(m1-m2))+(2*m2*v2*math.cos(th2-phi)))/(m1+m2))*math.sin(phi)+v1*math.sin(th1-phi)*math.sin(phi+math.pi/2) v2_x = (((v2*math.cos(th2-phi)*(m2-m1))+(2*m1*v1*math.cos(th1-phi)))/(m1+m2))*math.cos(phi)+v2*math.sin(th2-phi)*math.cos(phi+math.pi/2) v2_y = (((v2*math.cos(th2-phi)*(m2-m1))+(2*m1*v1*math.cos(th1-phi)))/(m1+m2))*math.sin(phi)+v2*math.sin(th2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330454721 285 (2021-01-31 22:45) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) v1_x = ((((v1 * math.cos(theta1-phi) * (r1**2 - r2**2)) + 2*(r2**2)*v2*math.cos(theta2-phi))/(r1**2 + r2**2))*math.cos(phi)) + (v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2)) v1_y = ((((v1 * math.cos(theta1-phi) * (r1**2 - r2**2)) + 2*(r2**2)*v2*math.cos(theta2-phi))/(r1**2 + r2**2))*math.sin(phi)) + (v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2)) v2_x = ((((v2 * math.cos(theta2-phi) * (r2**2 - r1**2)) + 2*(r1**2)*v1*math.cos(theta1-phi))/(r1**2 + r2**2))*math.cos(phi)) + (v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2)) v2_y = ((((v2 * math.cos(theta2-phi) * (r2**2 - r1**2)) + 2*(r1**2)*v1*math.cos(theta1-phi))/(r1**2 + r2**2))*math.sin(phi)) + (v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330455321 286 (2021-01-31 16:20) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): O1 = math.atan2(v1y,v1x) O2 = math.atan2(v2y,v2x) Y = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (((v1*math.cos(O1-Y)*(m1-m2))+2*m2*v2*math.cos(O2-Y))/(m1+m2)*(math.cos(Y)))+v1*math.sin(O1-Y)*math.cos(Y+(math.pi/2)) v1_y = (((v1*math.cos(O1-Y)*(m1-m2))+2*m2*v2*math.cos(O2-Y))/(m1+m2)*(math.sin(Y)))+v1*math.sin(O1-Y)*math.sin(Y+(math.pi/2)) v2_x = (((v2*math.cos(O2-Y)*(m2-m1))+2*m1*v1*math.cos(O1-Y))/(m1+m2)*(math.cos(Y)))+v2*math.sin(O2-Y)*math.cos(Y+(math.pi/2)) v2_y = (((v2*math.cos(O2-Y)*(m2-m1))+2*m1*v1*math.cos(O1-Y))/(m1+m2)*(math.sin(Y)))+v2*math.sin(O2-Y)*math.sin(Y+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330456021 287 (2021-01-28 18:08) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code m1=r1**2 m2=r2**2 m12=m1+m2 b1_angle = math.atan2(v1y,v1x) b2_angle = math.atan2(v2y,v2x) vA = math.sqrt(v1x**2+v1y**2)#v1x/math.cos(b1_angle) vB = math.sqrt(v2x**2+v2y**2)#v2x/math.cos(b2_angle) b12_An = math.atan2(y1-y2,x1-x2) diff_angle1 = b1_angle-b12_An diff_angle2 = b2_angle-b12_An left1 = (vA*math.cos(diff_angle1)*(m1-m2)+2*m2*vB*math.cos(diff_angle2))*(math.cos(b12_An)/(m1+m2)) v1_x =left1+vA*math.sin(diff_angle1)*math.cos(b12_An+math.pi/2)#v1x v1_y = (vA*math.cos(diff_angle1)*(m1-m2)+2*m2*vB*math.cos(diff_angle2))*(math.sin(b12_An)/(m1+m2))+vA*math.sin(diff_angle1)*math.sin(b12_An+math.pi/2)#v1y v2_x = (vB*math.cos(diff_angle2)*(m2-m1)+2*m1*vA*math.cos(diff_angle1))*(math.cos(b12_An)/(m1+m2))+vB*math.sin(diff_angle2)*math.cos(b12_An+math.pi/2)#v2x v2_y = (vB*math.cos(diff_angle2)*(m2-m1)+2*m1*vA*math.cos(diff_angle1))*(math.sin(b12_An)/(m1+m2))+vB*math.sin(diff_angle2)*math.sin(b12_An+math.pi/2)#v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330458221 288 (2021-01-28 23:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) ct1 = math.atan2(v1y,v1x) ct2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) v1_x = (((v1*math.cos(ct1-phi)*(m1-m2)+2*m2*v2*math.cos(ct2-phi))/(m1+m2))*math.cos(phi))+(v1*math.sin(ct1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((v1*math.cos(ct1-phi)*(m1-m2)+2*m2*v2*math.cos(ct2-phi))/(m1+m2))*math.sin(phi))+(v1*math.sin(ct1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((v2*math.cos(ct2-phi)*(m2-m1)+2*m1*v1*math.cos(ct1-phi))/(m1+m2))*math.cos(phi))+(v2*math.sin(ct2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((v2*math.cos(ct2-phi)*(m2-m1)+2*m1*v1*math.cos(ct1-phi))/(m1+m2))*math.sin(phi))+(v2*math.sin(ct2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330459921 289 (2021-01-29 22:50) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = ((v1*(math.cos(theta1-phi))*(m1-m2)+2*m2*v2*(math.cos(theta2-phi)))*(math.cos(phi)/(m1+m2)))+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*(math.cos(theta1-phi))*(m1-m2)+2*m2*v2*(math.cos(theta2-phi)))*(math.sin(phi)/(m1+m2)))+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*(math.cos(theta2-phi))*(m2-m1)+2*m1*v1*(math.cos(theta1-phi)))*(math.cos(phi)/(m1+m2)))+v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*(math.cos(theta2-phi))*(m2-m1)+2*m1*v1*(math.cos(theta1-phi)))*(math.sin(phi)/(m1+m2)))+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330460421 290 (2021-01-30 00:07) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here ang1 = math.atan2(v1y,v1x) ang2 = math.atan2(v2y,v2x) phy = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (((((v1*math.cos(ang1 - phy))*(r1**2-r2**2)) + 2*(r2**2)*v2*math.cos(ang2 - phy))/(r1**2 + r2**2))*math.cos(phy)) + v1*math.sin(ang1 - phy)*math.cos(phy + math.pi/2) v1_y = (((((v1*math.cos(ang1 - phy))*(r1**2-r2**2)) + 2*(r2**2)*v2*math.cos(ang2 - phy))/(r1**2 + r2**2))*math.sin(phy)) + v1*math.sin(ang1 - phy)*math.sin(phy + math.pi/2) v2_x = (((((v2*math.cos(ang2 - phy))*(r2**2-r1**2)) + 2*(r1**2)*v1*math.cos(ang1 - phy))/(r1**2 + r2**2))*math.cos(phy)) + v2*math.sin(ang2 - phy)*math.cos(phy + math.pi/2) v2_y = (((((v2*math.cos(ang2 - phy))*(r2**2-r1**2)) + 2*(r1**2)*v1*math.cos(ang1 - phy))/(r1**2 + r2**2))*math.sin(phy)) + v2*math.sin(ang2 - phy)*math.sin(phy + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330461021 291 (2021-01-31 22:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 def angle_between_ball(xa, ya, xb, yb) : return math.atan2(yb-ya,xb-xa) def angle_of_velocity(vy,vx): return math.atan2(vy,vx) phi = angle_between_ball(x1, y1, x2, y2) theta_1 = angle_of_velocity(v1y, v1x) theta_2 = angle_of_velocity(v2y, v2x) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = (((v1*(m1-m2)*math.cos(theta_1-phi)+(2*m2*v2*math.cos(theta_2-phi)))*math.cos(phi))/(m1+m2)) + (v1*math.sin(theta_1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((v1*(m1-m2)*math.cos(theta_1-phi)+(2*m2*v2*math.cos(theta_2-phi)))*math.sin(phi))/(m1+m2)) + (v1*math.sin(theta_1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((v2*(m2-m1)*math.cos(theta_2-phi)+(2*m1*v1*math.cos(theta_1-phi)))*math.cos(phi))/(m1+m2)) + (v2*math.sin(theta_2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((v2*(m2-m1)*math.cos(theta_2-phi)+(2*m1*v1*math.cos(theta_1-phi)))*math.sin(phi))/(m1+m2)) + (v2*math.sin(theta_2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330462721 292 (2021-02-01 10:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi))/(m1+m2))+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi))/(m1+m2))+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi))/(m1+m2))+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi))/(m1+m2))+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330463321 293 (2021-01-30 21:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1 ** 2 m2 = r2 ** 2 v1 = (v1x ** 2 + v1y ** 2) ** 0.5 v2 = (v2x ** 2 + v2y ** 2) ** 0.5 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2((y1-y2), (x1-x2)) v1_x = ((v1 * math.cos(theta1-phi)*(m1-m2)+ 2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1 * math.cos(theta1-phi)*(m1-m2)+ 2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2 * math.cos(theta2-phi)*(m2-m1)+ 2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2 * math.cos(theta2-phi)*(m2-m1)+ 2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330464021 294 (2021-02-01 02:53) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here p = math.atan2 (y2-y1,x2-x1) s1 = math.atan2 (v1y,v1x) s2 = math.atan2 (v2y,v2x) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = (v1*math.cos(s1-p)*((r1)**2-(r2)**2) + 2*((r2)**2)*v2*math.cos(s2-p))/((r1)**2 + (r2)**2)*math.cos(p) + v1*math.sin(s1-p)*math.cos(p + math.pi/2) v1_y = (v1*math.cos(s1-p)*((r1)**2-(r2)**2) + 2*((r2)**2)*v2*math.cos(s2-p))/((r1)**2 + (r2)**2)*math.sin(p) + v1*math.sin(s1-p)*math.sin(p + math.pi/2) v2_x = (v2*math.cos(s2-p)*((r2)**2-(r1)**2) + 2*((r1)**2)*v1*math.cos(s1-p))/((r1)**2 + (r2)**2)*math.cos(p) + v2*math.sin(s2-p)*math.cos(p + math.pi/2) v2_y = (v2*math.cos(s2-p)*((r2)**2-(r1)**2) + 2*((r1)**2)*v1*math.cos(s1-p))/((r1)**2 + (r2)**2)*math.sin(p) + v2*math.sin(s2-p)*math.sin(p + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330465621 295 (2021-01-28 21:46) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) c1 = math.atan2(v1y,v1x) c2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) z1 = c1 - phi z2 = c2 - phi z3 = phi + (math.pi/2) # insert your code here v1_x = ((v1*math.cos(z1)*(m1-m2) + 2*m2*v2*math.cos(z2))/(m1+m2))*math.cos(phi) + v1*math.sin(z1)*math.cos(z3) v1_y = ((v1*math.cos(z1)*(m1-m2) + 2*m2*v2*math.cos(z2))/(m1+m2))*math.sin(phi) + v1*math.sin(z1)*math.sin(z3) v2_x = ((v2*math.cos(z2)*(m2-m1) + 2*m1*v1*math.cos(z1))/(m1+m2))*math.cos(phi) + v2*math.sin(z2)*math.cos(z3) v2_y = ((v2*math.cos(z2)*(m2-m1) + 2*m1*v1*math.cos(z1))/(m1+m2))*math.sin(phi) + v2*math.sin(z2)*math.sin(z3) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330466221 296 (2021-02-01 16:19) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here from math import cos,sin,tan,atan,acos,asin,sqrt,pi,atan2 phi = atan((y2-y1)/(x2-x1)) m1 = r1**2 m2 = r2**2 v1 = sqrt(v1x**2 + v1y**2) v2 = sqrt(v2x**2 + v2y**2) theta1 = atan2(v1y,v1x) theta2 = atan2(v2y,v2x) M = m1 + m2 v1_x = (((v1*cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*cos(theta2 - phi))*(cos(phi)/M)) + v1*sin(theta1 - phi)*cos(phi + pi/2)) v1_y = (((v1*cos(theta1 - phi)*(m1 - m2) + 2*m2*v2*cos(theta2 - phi))*(sin(phi)/M)) + v1*sin(theta1 - phi)*sin(phi + pi/2)) v2_x = (((v2*cos(theta2 - phi)*(m2 - m1) + 2*m1*v1*cos(theta1 - phi))*(cos(phi)/M)) + v2*sin(theta2 - phi)*cos(phi + pi/2)) v2_y = (((v2*cos(theta2 - phi)*(m2 - m1) + 2*m1*v1*cos(theta1 - phi))*(sin(phi)/M)) + v2*sin(theta2 - phi)*sin(phi + pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330467921 297 (2021-01-30 04:44) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 phi = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) se1 = math.atan2(v1y,v1x) se2 = math.atan2(v2y,v2x) v1_x = ((((v1*math.cos(se1-phi)*(m1-m2))+(2*m2*v2*math.cos(se2-phi)))/(m1+m2))*math.cos(phi))+v1*math.sin(se1-phi)*math.cos(phi+math.pi/2) v1_y = ((((v1*math.cos(se1-phi)*(m1-m2))+(2*m2*v2*math.cos(se2-phi)))/(m1+m2))*math.sin(phi))+v1*math.sin(se1-phi)*math.sin(phi+math.pi/2) v2_x = ((((v2*math.cos(se2-phi)*(m2-m1))+(2*m1*v1*math.cos(se1-phi)))/(m1+m2))*math.cos(phi))+v2*math.sin(se2-phi)*math.cos(phi+math.pi/2) v2_y = ((((v2*math.cos(se2-phi)*(m2-m1))+(2*m1*v1*math.cos(se1-phi)))/(m1+m2))*math.sin(phi))+v2*math.sin(se2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330468521 298 (2021-01-31 23:02) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2((y2-y1), (x2-x1)) m1 = r1**2 m2 = r2**2 seta1 = math.atan2(v1y, v1x) seta2 = math.atan2(v2y, v2x) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = ((((v1*math.cos(seta1-phi)*(m1-m2))+(2*m2*v2*math.cos(seta2-phi)))/(m1+m2))*math.cos(phi)) + (v1*math.sin(seta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(seta1-phi)*(m1-m2))+(2*m2*v2*math.cos(seta2-phi)))/(m1+m2))*math.sin(phi)) + (v1*math.sin(seta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(seta2-phi)*(m2-m1))+(2*m1*v1*math.cos(seta1-phi)))/(m1+m2))*math.cos(phi)) + (v2*math.sin(seta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(seta2-phi)*(m2-m1))+(2*m1*v1*math.cos(seta1-phi)))/(m1+m2))*math.sin(phi)) + (v2*math.sin(seta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330469121 299 (2021-01-30 04:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): a1=math.atan2(v1y,v1x) a2=math.atan2(v2y,v2x) b=math.atan2((y2-y1),(x2-x1)) m1=r1**2 m2=r2**2 v1=((v1x**2)+(v1y**2))**0.5 v2=((v2x**2)+(v2y**2))**0.5 v1x=(v1*math.cos(a1-b)*(m1-m2)+2*m2*v2*math.cos(a2-b))*math.cos(b)/(m1+m2)+v1*math.sin(a1-b)*math.cos(b+math.pi/2) v1y=(v1*math.cos(a1-b)*(m1-m2)+2*m2*v2*math.cos(a2-b))*math.sin(b)/(m1+m2)+v1*math.sin(a1-b)*math.sin(b+math.pi/2) v2x=(v2*math.cos(a2-b)*(m2-m1)+2*m1*v1*math.cos(a1-b))*math.cos(b)/(m1+m2)+v2*math.sin(a2-b)*math.cos(b+math.pi/2) v2y=(v2*math.cos(a2-b)*(m2-m1)+2*m1*v1*math.cos(a1-b))*math.sin(b)/(m1+m2)+v2*math.sin(a2-b)*math.sin(b+math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330470721 300 (2021-01-30 21:58) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(abs(y1-y2),abs(x1-x2)) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330471321 301 (2021-01-30 16:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) t1 = math.atan2(v1y , v1x) t2 = math.atan2(v2y , v2x) psi = math.atan2(y1 - y2,x1 - x2) #v1_x = v1x* # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = ((((v1*math.cos(t1-psi)*(m1-m2))+(2*m2*v2*math.cos(t2-psi)))/(m1+m2))*(math.cos(psi)))+(v1*(math.sin(t1-psi))*(math.cos(psi+(math.pi/2)))) v1_y = ((((v1*math.cos(t1-psi)*(m1-m2))+(2*m2*v2*math.cos(t2-psi)))/(m1+m2))*(math.sin(psi)))+(v1*(math.sin(t1-psi))*(math.sin(psi+(math.pi/2)))) v2_x = ((((v2*math.cos(t2-psi)*(m2-m1))+(2*m1*v1*math.cos(t1-psi)))/(m2+m1))*(math.cos(psi)))+(v2*(math.sin(t2-psi))*(math.cos(psi+(math.pi/2)))) v2_y = ((((v2*math.cos(t2-psi)*(m2-m1))+(2*m1*v1*math.cos(t1-psi)))/(m2+m1))*(math.sin(psi)))+(v2*(math.sin(t2-psi))*(math.sin(psi+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330472021 302 (2021-01-29 22:06) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1=r1**2 m2=r2**2 theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x =((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.cos(phi))+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y =((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.sin(phi))+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x =((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m2+m1)*math.cos(phi))+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y =((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m2+m1)*math.sin(phi))+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330473621 303 (2021-01-30 21:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2(y1-y2, x1-x2) v1 = ((v1x)**2+(v1y)**2)**0.5 v2 = ((v2x)**2+(v2y)**2)**0.5 m1 = r1**2 m2 = r2**2 v1_x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330474221 304 (2021-02-01 18:41) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): b=math.atan2((y2-y1),(x2-x1)) a2=math.atan2(v2y,v2x) a1=math.atan2(v1y,v1x) v1=v1x/math.cos(a1) v1=v1y/math.sin(a1) v2=v2x/math.cos(a2) v2=v2y/math.sin(a2) m1=r1**2 m2=r2**2 v1_x = ((v1*math.cos(a1-b)*(m1-m2)+2*m2*v2*math.cos(a2-b))*math.cos(b))/(m1+m2)+v1*math.sin(a1-b)*math.cos(b+(math.pi/2)) v1_y = ((v1*math.cos(a1-b)*(m1-m2)+2*m2*v2*math.cos(a2-b))*math.sin(b))/(m1+m2)+v1*math.sin(a1-b)*math.sin(b+(math.pi/2)) v2_x = ((v2*math.cos(a2-b)*(m2-m1)+2*m1*v1*math.cos(a1-b))*math.cos(b))/(m1+m2)+v2*math.sin(a2-b)*math.cos(b+(math.pi/2)) v2_y = ((v2*math.cos(a2-b)*(m2-m1)+2*m1*v1*math.cos(a1-b))*math.sin(b))/(m1+m2)+v2*math.sin(a2-b)*math.sin(b+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330475921 305 (2021-02-01 14:22) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) zeta1=math.atan2(v1y,v1x) zeta2=math.atan2(v2y,v2x) fi=math.atan2((y2-y1),(x2-x1)) a=v1*math.cos(zeta1-fi)*(m1-m2)+(2*m2*v2*math.cos(zeta2-fi)) b=v1*math.sin(zeta1-fi)*math.cos(fi+(math.pi)/2) c=v1*math.sin(zeta1-fi)*math.sin(fi+(math.pi)/2) d=v2*math.cos(zeta2-fi)*(m2-m1)+(2*m1*v1*math.cos(zeta1-fi)) e=v2*math.sin(zeta2-fi)*math.cos(fi+(math.pi)/2) f=v2*math.sin(zeta2-fi)*math.sin(fi+(math.pi)/2) v1_x = ((a*math.cos(fi))/(m1+m2))+b v1_y = ((a*math.sin(fi))/(m1+m2))+c v2_x = ((d*math.cos(fi))/(m1+m2))+e v2_y = ((d*math.sin(fi))/(m1+m2))+f return (v1_x, v1_y), (v2_x, v2_y) |
# 6330476521 306 (2021-01-31 20:59) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) phi= math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*math.cos(t2-phi))*math.cos(phi)/(m1+m2))+(v1*math.sin(t1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((v1*math.cos(t1-phi)*(m1-m2)+2*m2*v2*math.cos(t2-phi))*math.sin(phi)/(m1+m2))+(v1*math.sin(t1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((v2*math.cos(t2-phi)*(m1-m2)+2*m1*v1*math.cos(t1-phi))*math.cos(phi)/(m1+m2))+(v2*math.sin(t2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((v2*math.cos(t2-phi)*(m1-m2)+2*m1*v1*math.cos(t1-phi))*math.sin(phi)/(m1+m2))+(v2*math.sin(t2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330478821 307 (2021-02-01 19:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 m12=m1+m2 b1_iron=math.atan2(v1y,v1x) b2_iron=math.atan2(v2y,v2x) vp=math.sqrt(v1x**2+v1y**2) vq=math.sqrt(v2x**2+v2y**2) b12_im=math.atan2(y1-y2,x1-x2) diff_iron1=b1_iron-b12_im diff_iron2=b2_iron-b12_im v1_x = (vp*math.cos(diff_iron1)*(m1-m2)+2*m2*vq*math.cos(diff_iron2))*math.cos(b12_im)/(m1+m2)+vp*math.sin(diff_iron1)*math.cos(b12_im+math.pi/2) v1_y = (vp*math.cos(diff_iron1)*(m1-m2)+2*m2*vq*math.cos(diff_iron2))*math.sin(b12_im)/(m1+m2)+vp*math.sin(diff_iron1)*math.sin(b12_im+math.pi/2) v2_x = (vq*math.cos(diff_iron2)*(m2-m1)+2*m1*vp*math.cos(diff_iron1))*math.cos(b12_im)/(m1+m2)+vq*math.sin(diff_iron2)*math.cos(b12_im+math.pi/2) v2_y = (vq*math.cos(diff_iron2)*(m2-m1)+2*m1*vp*math.cos(diff_iron1))*math.sin(b12_im)/(m1+m2)+vq*math.sin(diff_iron2)*math.sin(b12_im+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330481621 308 (2021-01-29 22:39) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # insert your code here a=math.atan2((y2-y1),(x2-x1)) s1=math.atan2(v1y,v1x) s2=math.atan2(v2y,v2x) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(s1-a)*((r1**2)-(r2**2))+2*(r2**2)*v2*math.cos(s2-a))/(r1**2+r2**2))*math.cos(a)+v1*math.sin(s1-a)*math.cos(a+math.pi/2) v1_y = ((v1*math.cos(s1-a)*((r1**2)-(r2**2))+2*(r2**2)*v2*math.cos(s2-a))/(r1**2+r2**2))*math.sin(a)+v1*math.sin(s1-a)*math.sin(a+math.pi/2) v2_x = ((v2*math.cos(s2-a)*((r2**2)-(r1**2))+2*(r1**2)*v1*math.cos(s1-a))/(r1**2+r2**2))*math.cos(a)+v2*math.sin(s2-a)*math.cos(a+math.pi/2) v2_y = ((v2*math.cos(s2-a)*((r2**2)-(r1**2))+2*(r1**2)*v1*math.cos(s1-a))/(r1**2+r2**2))*math.sin(a)+v2*math.sin(s2-a)*math.sin(a+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330482221 309 (2021-01-29 22:53) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here h1 = math.atan2(v1y, v1x) h2 = math.atan2(v2y, v2x) p = math.atan2((y2 - y1), (x2 - x1)) m1 = r1 ** 2 m2 = r2 ** 2 v1 = math.sqrt((v1x ** 2) + (v1y ** 2)) v2 = math.sqrt((v2x ** 2) + (v2y ** 2)) v1_x = ((v1*math.cos(h1-p)*(m1-m2)+(2*m2*v2*math.cos(h2-p)))*((math.cos(p))/(m1+m2)))+v1*math.sin(h1-p)*math.cos(p+(math.pi)/2) v1_y = ((v1*math.cos(h1-p)*(m1-m2)+(2*m2*v2*math.cos(h2-p)))*((math.sin(p))/(m1+m2)))+v1*math.sin(h1-p)*math.sin(p+(math.pi)/2) v2_x = ((v2*math.cos(h2-p)*(m2-m1)+(2*m1*v1*math.cos(h1-p)))*((math.cos(p))/(m1+m2)))+v2*math.sin(h2-p)*math.cos(p+(math.pi)/2) v2_y = ((v2*math.cos(h2-p)*(m2-m1)+(2*m1*v1*math.cos(h1-p)))*((math.sin(p))/(m1+m2)))+v2*math.sin(h2-p)*math.sin(p+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330483921 310 (2021-02-01 17:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here φ=math.atan2((y2-y1),(x2-x1)) θ1=math.atan2(v1y,v1x) θ2=math.atan2(v2y,v2x) v1=v1x/math.cos(θ1) v1=v1y/math.sin(θ1) v2=v2x/math.cos(θ2) v2=v2y/math.sin(θ2) m1=r1**2 m2=r2**2 v1_x = ((v1*math.cos(θ1-φ)*(m1-m2)+2*m2*v2*math.cos(θ2-φ)) *math.cos(φ)/(m1+m2))+v1*math.sin(θ1-φ)*math.cos(φ+(math.pi/2)) v1_y = ((v1*math.cos(θ1-φ)*(m1-m2)+2*m2*v2*math.cos(θ2-φ)) *math.sin(φ)/(m1+m2))+v1*math.sin(θ1-φ)*math.sin(φ+(math.pi/2)) v2_x = ((v2*math.cos(θ2-φ)*(m2-m1)+2*m1*v1*math.cos(θ1-φ)) *math.cos(φ)/(m1+m2))+v2*math.sin(θ2-φ)*math.cos(φ+(math.pi/2)) v2_y = ((v2*math.cos(θ2-φ)*(m2-m1)+2*m1*v1*math.cos(θ1-φ)) *math.sin(φ)/(m1+m2))+v2*math.sin(θ2-φ)*math.sin(φ+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330484521 311 (2021-02-01 23:57) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): if(v2x ==0 and v2y<0): s2=(-math.pi/2) elif(v2x ==0 and v2y>=0): s2=(math.pi/2) else: s2=math.atan(v2y/v2x) if(v1x ==0 and v1y<0): s1=(-math.pi/2) elif(v1x ==0 and v1y>=0): s1=(math.pi/2) else: s1=math.atan(v1y/v1x) a=math.sqrt(v1x**2 + v1y**2) z=math.sqrt(v2x**2 + v2y**2) c=math.cos(s1-math.atan2((y1-y2),(x2-x1))) d=math.cos(s2-math.atan2((y1-y2),(x2-x1))) e=r1**2-r2**2 f=r2**2-r1**2 g=math.sin(math.atan2((y1-y2),(x2-x1))) h=math.cos(math.atan2((y1-y2),(x2-x1))) q=math.sin(s1-math.atan2((y1-y2),(x2-x1))) j=math.sin(s2-math.atan2((y1-y2),(x2-x1))) k=math.cos(math.atan2((y1-y2),(x2-x1))+math.radians(90)) l=math.sin(math.atan2((y1-y2),(x2-x1))+math.radians(90)) v1_x= ((a*c*e + 2*(r2**2)*z*d)/(r1**2+r2**2))*h +a*q*k v1_y= ((a*c*e + 2*(r2**2)*z*d)/(r1**2+r2**2))*g +a*q*l v2_x= ((z*d*f+2*(r1**2)*a*c)/(r1**2+r2**2))*h +z*j*k v2_y= ((z*d*f+2*(r1**2)*a*c)/(r1**2+r2**2))*g +z*j*l return (v1_x, v1_y), (v2_x, v2_y) |
# 6330485121 312 (2021-01-31 13:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan2(v1y,v1x) b = math.atan2(v2y,v2x) c = math.atan2(y2-y1,x2-x1) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(a-c)*(m1-m2)+2*m2*v2*math.cos(b-c))/(m1+m2))*math.cos(c)+v1*math.sin(a-c)*math.cos(c+math.pi/2) v1_y = ((v1*math.cos(a-c)*(m1-m2)+2*m2*v2*math.cos(b-c))/(m1+m2))*math.sin(c)+v1*math.sin(a-c)*math.sin(c+math.pi/2) v2_x = ((v2*math.cos(b-c)*(m2-m1)+2*m1*v1*math.cos(a-c))/(m2+m1))*math.cos(c)+v2*math.sin(b-c)*math.cos(c+math.pi/2) v2_y = ((v2*math.cos(b-c)*(m2-m1)+2*m1*v1*math.cos(a-c))/(m2+m1))*math.sin(c)+v2*math.sin(b-c)*math.sin(c+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330486821 313 (2021-01-29 22:06) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) a = math.atan2((y1-y2),(x1-x2)) v1_x = ((v1*math.cos(t1-a)*(m1-m2) + 2*m2*v2*math.cos(t2-a))/(m1+m2))*math.cos(a) + v1*math.sin(t1-a)*math.cos(a+(math.pi/2)) v1_y = ((v1*math.cos(t1-a)*(m1-m2) + 2*m2*v2*math.cos(t2-a))/(m1+m2))*math.sin(a) + v1*math.sin(t1-a)*math.sin(a+(math.pi/2)) v2_x = ((v2*math.cos(t2-a)*(m2-m1) + 2*m1*v1*math.cos(t1-a))/(m1+m2))*math.cos(a) + v2*math.sin(t2-a)*math.cos(a+(math.pi/2)) v2_y = ((v2*math.cos(t2-a)*(m2-m1) + 2*m1*v1*math.cos(t1-a))/(m1+m2))*math.sin(a) + v2*math.sin(t2-a)*math.sin(a+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330487421 314 (2021-01-31 15:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=pow(r1,2) m2=pow(r2,2) seta1=math.atan2(v1y,v1x) seta2=math.atan2(v2y,v2x) p=math.atan2((y2-y1),(x2-x1)) v1=math.sqrt(pow(v1x,2)+pow(v1y,2)) v2=math.sqrt(pow(v2x,2)+pow(v2y,2)) v1_x = ((v1*math.cos(seta1-p)*(m1-m2)+2*m2*v2*math.cos(seta2-p))/(m1+m2))*math.cos(p)+v1*math.sin(seta1-p)*math.cos(p+math.pi /2) v1_y = ((v1*math.cos(seta1-p)*(m1-m2)+2*m2*v2*math.cos(seta2-p))/(m1+m2))*math.sin(p)+v1*math.sin(seta1-p)*math.sin(p+math.pi /2) v2_x = ((v2*math.cos(seta2-p)*(m2-m1)+2*m1*v1*math.cos(seta1-p))/(m1+m2))*math.cos(p)+v2*math.sin(seta2-p)*math.cos(p+math.pi /2) v2_y = ((v2*math.cos(seta2-p)*(m2-m1)+2*m1*v1*math.cos(seta1-p))/(m1+m2))*math.sin(p)+v2*math.sin(seta2-p)*math.sin(p+math.pi /2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330488021 315 (2021-01-29 02:26) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 phi = math.atan2(y2-y1,x2-x1) s1=v1*math.cos(a1-phi)*(m1-m2) s2=2*m2*v2*math.cos(a2-phi) sum_m=m1+m2 v1_x= (((s1+s2)/sum_m)*math.cos(phi)) +(v1*math.sin(a1-phi)*math.cos(phi+(math.pi/2))) v1_y= (((s1+s2)/sum_m)*math.sin(phi)) +(v1*math.sin(a1-phi)*math.sin(phi+(math.pi/2))) p1=v2*math.cos(a2-phi)*(m2-m1) p2=2*m1*v1*math.cos(a1-phi) v2_x=(((p1+p2)/sum_m)*math.cos(phi)) +(v2*math.sin(a2-phi)*math.cos(phi+(math.pi/2))) v2_y=(((p1+p2)/sum_m)*math.sin(phi)) +(v2*math.sin(a2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330489721 316 (2021-01-30 20:25) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here A=math.atan2(v1y,v1x) B=math.atan2(v2y,v2x) C=math.atan2(y2-y1,x2-x1) M=r1**2 m=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x = (v1*math.cos(A-C)*(M-m)+2*m*v2*(math.cos(B-C)))*math.cos(C)/(M+m) + v1*math.sin(A-C)*math.cos(C+math.pi/2) v1_y = (v1*math.cos(A-C)*(M-m)+2*m*v2*(math.cos(B-C)))*math.sin(C)/(M+m) + v1*math.sin(A-C)*math.sin(C+math.pi/2) v2_x = (v2*math.cos(B-C)*(m-M)+2*M*v1*(math.cos(A-C)))*math.cos(C)/(M+m) + v2*math.sin(B-C)*math.cos(C+math.pi/2) v2_y = (v2*math.cos(B-C)*(m-M)+2*M*v1*(math.cos(A-C)))*math.sin(C)/(M+m) + v2*math.sin(B-C)*math.sin(C+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330491921 317 (2021-01-29 22:08) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) p1 = math.atan2((y2-y1),(x2-x1)) v1_x = ((v1*math.cos(a1-p1)*(m1-m2)+2*m2*v2*math.cos(a2-p1))/(m1+m2))*math.cos(p1)+v1*math.sin(a1-p1)*math.cos(p1+(math.pi)/2) v1_y = ((v1*math.cos(a1-p1)*(m1-m2)+2*m2*v2*math.cos(a2-p1))/(m1+m2))*math.sin(p1)+v1*math.sin(a1-p1)*math.sin(p1+(math.pi)/2) v2_x = ((v2*math.cos(a2-p1)*(m2-m1)+2*m1*v1*math.cos(a1-p1))/(m1+m2))*math.cos(p1)+v2*math.sin(a2-p1)*math.cos(p1+(math.pi)/2) v2_y = ((v2*math.cos(a2-p1)*(m2-m1)+2*m1*v1*math.cos(a1-p1))/(m1+m2))*math.sin(p1)+v2*math.sin(a2-p1)*math.sin(p1+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330492521 318 (2021-01-30 16:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) f = math.atan2((y2-y1),(x2-x1)) m1=r1**2 m2=r2**2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = ((v1*math.cos(t1-f)*(m1-m2)+2*m2*v2*math.cos(t2-f))/(m1+m2))*math.cos(f)+v1*math.sin(t1-f)*math.cos(f+(math.pi)/2) v1_y = ((v1*math.cos(t1-f)*(m1-m2)+2*m2*v2*math.cos(t2-f))/(m1+m2))*math.sin(f)+v1*math.sin(t1-f)*math.sin(f+(math.pi)/2) v2_x = ((m1*v1x+m2*v2x)-m1*v1_x)/m2 v2_y = ((m1*v1y+m2*v2y)-m1*v1_y)/m2 print('V1=',v1) print('V2=',v2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330494821 319 (2021-01-29 10:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def a(x,y): o=math.atan2(y,x) return o def b(a,b,c,d): w=math.atan2(math.fabs(d-b),math.fabs(c-a)) return w def d(x,y,z): d=x/math.cos(a(y,z)) return d v1_x = ((d(v1x,v1x,v1y)*math.cos(a(v1x,v1y)-b(x1,y1,x2,y2))*(r1**2-r2**2)+2*(r2**2)*d(v2x,v2x,v2y)*math.cos(a(v2x,v2y)-b(x1,y1,x2,y2)))*math.cos(b(x1,y1,x2,y2))/(r1**2+r2**2)+d(v1x,v1x,v1y)*math.sin(a(v1x,v1y)-b(x1,y1,x2,y2))*math.cos(b(x1,y1,x2,y2)+math.pi/2)) v1_y = ((d(v1x,v1x,v1y)*math.cos(a(v1x,v1y)-b(x1,y1,x2,y2))*(r1**2-r2**2)+2*(r2**2)*d(v2x,v2x,v2y)*math.cos(a(v2x,v2y)-b(x1,y1,x2,y2)))*math.sin(b(x1,y1,x2,y2))/(r1**2+r2**2)+d(v1x,v1x,v1y)*math.sin(a(v1x,v1y)-b(x1,y1,x2,y2))*math.sin(b(x1,y1,x2,y2)+math.pi/2)) v2_x = (r1**2*(v1x-((d(v1x,v1x,v1y)*math.cos(a(v1x,v1y)-b(x1,y1,x2,y2))*(r1**2-r2**2)+2*(r2**2)*d(v2x,v2x,v2y)*math.cos(a(v2x,v2y)-b(x1,y1,x2,y2)))*math.cos(b(x1,y1,x2,y2))/(r1**2+r2**2)+d(v1x,v1x,v1y)*math.sin(a(v1x,v1y)-b(x1,y1,x2,y2))*math.cos(b(x1,y1,x2,y2)+math.pi/2)))+r2**2*v2x)/r2**2 v2_y = (r1**2*(v1y-((d(v1x,v1x,v1y)*math.cos(a(v1x,v1y)-b(x1,y1,x2,y2))*(r1**2-r2**2)+2*(r2**2)*d(v2x,v2x,v2y)*math.cos(a(v2x,v2y)-b(x1,y1,x2,y2)))*math.sin(b(x1,y1,x2,y2))/(r1**2+r2**2)+d(v1x,v1x,v1y)*math.sin(a(v1x,v1y)-b(x1,y1,x2,y2))*math.sin(b(x1,y1,x2,y2)+math.pi/2)))+r2**2*v2y)/r2**2 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330495421 320 (2021-01-30 12:46) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) m1=r1**2 m2=r2**2 phi=math.atan((y1-y2)/(x1-x2)) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x =((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y =((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x =((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m2+m1))*math.cos(phi)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y =((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m2+m1))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330496021 321 (2021-01-30 22:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): z1 = math.atan2(v1y,v1x) z2 = math.atan2(v2y,v2x) f = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((((v1)*(math.cos(z1-f))*(m1-m2))+((2*m2*v2*math.cos(z2-f))))/(m1+m2))*math.cos(f)+(v1*math.sin(z1-f)*math.cos(f+math.pi/2)) v1_y = ((((v1)*(math.cos(z1-f))*(m1-m2))+((2*m2*v2*math.cos(z2-f))))/(m1+m2))*math.sin(f)+(v1*math.sin(z1-f)*math.sin(f+math.pi/2)) v2_x = ((((v2)*(math.cos(z2-f))*(m2-m1))+((2*m1*v1*math.cos(z1-f))))/(m1+m2))*math.cos(f)+(v2*math.sin(z2-f)*math.cos(f+math.pi/2)) v2_y = ((((v2)*(math.cos(z2-f))*(m2-m1))+((2*m1*v1*math.cos(z1-f))))/(m1+m2))*math.sin(f)+(v2*math.sin(z2-f)*math.sin(f+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330497721 322 (2021-01-30 13:50) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 if x1==x2: phi=math.radians(90) else: phi=math.atan((y1-y2)/(x1-x2)) if v1x==0: rad1=math.radians(90) else: rad1=math.atan(v1y/v1x) v1=v1y/math.sin(rad1) if v2x==0: rad2=math.radians(90) else: rad2=math.atan(v2y/v2x) v2=v2y/math.sin(rad2) v1_x = ((v1*math.cos(rad1-phi)*(m1-m2))+(2*(m2)*v2*math.cos(rad2-phi)))*math.cos(phi)/(m1+m2)+\ (v1*math.sin(rad1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((v1*math.cos(rad1-phi)*(m1-m2))+(2*(m2)*v2*math.cos(rad2-phi)))*math.sin(phi)/(m1+m2)+\ (v1*math.sin(rad1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((v2*math.cos(rad2-phi)*(m2-m1))+(2*(m1)*v1*math.cos(rad1-phi)))*math.cos(phi)/(m1+m2)+\ (v2*math.sin(rad2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((v2*math.cos(rad2-phi)*(m2-m1))+(2*(m1)*v1*math.cos(rad1-phi)))*math.sin(phi)/(m1+m2)+\ (v2*math.sin(rad2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330498321 323 (2021-01-28 20:23) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here delx = (x2 - x1) dely = (y2 - y1) pi = math.pi theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2(dely, delx) v1 = math.sqrt((v1x**2) + (v1y**2)) v2 = math.sqrt((v2x**2) + (v2y**2)) m1 = r1**2 m2 = r2**2 cos1 = math.cos(theta1 - phi) cos2 = math.cos(theta2 - phi) sin1 = math.sin(theta1 - phi) sin2 = math.sin(theta2 - phi) sm = m1 + m2 del12 = m1 - m2 del21 = m2 - m1 cosphi = math.cos(phi) sinphi = math.sin(phi) rear1 = v1 * sin1 * math.cos(phi + (pi / 2)) rear2 = v2 * sin2 * math.cos(phi + (pi / 2)) rear3 = v1 * sin1 * math.sin(phi + pi / 2) rear4 = v2 * sin2 * math.sin(phi + pi / 2) f1 = cosphi / sm f2 = sinphi / sm v1_x = ((v1 * cos1 * del12 + 2 * m2 * v2 * cos2)) * f1 + rear1 v1_y = ((v1 * cos1 * del12 + 2 * m2 * v2 * cos2)) * f2 + rear3 v2_x = ((v2 * cos2 * del21 + 2 * m1 * v1 * cos1)) * f1 + rear2 v2_y = ((v2 * cos2 * del21 + 2 * m1 * v1 * cos1)) * f2 + rear4 return (v1_x, v1_y), (v2_x, v2_y) |
# 6330499021 324 (2021-01-31 00:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y m1=(r1)**2 m2=(r2)**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) # a=theta1 # b=theta2 a=math.atan2(v1y,v1x) b=math.atan2(v2y,v2x) #p=phi p=math.atan2(y1-y2,x1-x2) v1_x=((v1*math.cos(a-p)*(m1-m2)+(2*m2*v2*math.cos(b-p))))*math.cos(p)/(m1+m2)+(v1*math.sin(a-p)*math.cos(p+(math.pi/2))) v1_y=((v1*math.cos(a-p)*(m1-m2)+(2*m2*v2*math.cos(b-p))))*math.sin(p)/(m1+m2)+(v1*math.sin(a-p)*math.sin(p+(math.pi/2))) v2_x=((v2*math.cos(b-p)*(m2-m1)+(2*m1*v1*math.cos(a-p))))*math.cos(p)/(m1+m2)+(v2*math.sin(b-p)*math.cos(p+(math.pi/2))) v2_y=((v2*math.cos(b-p)*(m2-m1)+(2*m1*v1*math.cos(a-p))))*math.sin(p)/(m1+m2)+(v2*math.sin(b-p)*math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330500921 325 (2021-02-01 01:59) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision tetha1=math.atan2(v1y,v1x) tetha2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) def speed_ball_vx(v1, v2, m1, m2, tetha1, tetha2, phi): vx=(((v1*math.cos(tetha1-phi)*(m1-m2))+(2*m2*v2*math.cos(tetha2-phi)))/(m1+m2))*math.cos(phi)+(v1*math.sin(tetha1-phi)*math.cos(phi+math.pi/2)) return vx tetha1=math.atan2(v1y,v1x) tetha2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) def speed_ball_vy(v1, v2, m1, m2, tetha1, tetha2, phi): vy=(((v1*math.cos(tetha1-phi)*(m1-m2))+(2*m2*v2*math.cos(tetha2-phi)))/(m1+m2))*math.sin(phi)+(v1*math.sin(tetha1-phi)*math.sin(phi+math.pi/2)) return vy v1_x = speed_ball_vx(v1, v2, m1, m2, tetha1, tetha2, phi) v1_y = speed_ball_vy(v1, v2, m1, m2, tetha1, tetha2, phi) v2_x = speed_ball_vx(v2, v1, m2, m1, tetha2, tetha1, phi) v2_y = speed_ball_vy(v2, v1, m2, m1, tetha2, tetha1, phi) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330501521 326 (2021-01-31 09:45) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 theta1=math.atan2(v1y,v1x) theta2=math.atan2(v2y,v2x) phi=math.atan((y2-y1)/(x2-x1)) v1=math.sqrt((v1y**2)+(v1x**2)) v2=math.sqrt((v2y**2)+(v2x**2)) v1_x =((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi))/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y =((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi))/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x =((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi))/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y =((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi))/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330502121 327 (2021-01-31 00:45) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here dy=(y2-y1) dx=(x2-x1) fi = math.atan(dy/dx) seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 m1 = r1**2 m2 = r2**2 v1_x = ((v1*math.cos(seta1-fi)*(m1-m2)+2*m2*v2*math.cos(seta2-fi))/(m1+m2))*math.cos(fi)+v1*math.sin(seta1-fi)*math.cos(fi+math.pi/2) v1_y = ((v1*math.cos(seta1-fi)*(m1-m2)+2*m2*v2*math.cos(seta2-fi))/(m1+m2))*math.sin(fi)+v1*math.sin(seta1-fi)*math.sin(fi+math.pi/2) v2_x = ((v2*math.cos(seta2-fi)*(m2-m1)+2*m1*v1*math.cos(seta1-fi))/(m1+m2))*math.cos(fi)+v2*math.sin(seta2-fi)*math.cos(fi+math.pi/2) v2_y = ((v2*math.cos(seta2-fi)*(m2-m1)+2*m1*v1*math.cos(seta1-fi))/(m1+m2))*math.sin(fi)+v2*math.sin(seta2-fi)*math.sin(fi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330503821 328 (2021-01-31 01:14) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 cheta1 = math.atan2(v1y, v1x) cheta2 = math.atan2(v2y, v2x) phi = math.atan2(y2-y1, x2-x1) v1 = ((v1x**2 + v1y**2)**(1/2)) v2 = ((v2x**2 + v2y**2)**(1/2)) v1_x = ((v1*math.cos(cheta1-phi)*(m1-m2)+2*m2*v2*math.cos(cheta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(cheta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(cheta1-phi)*(m1-m2)+2*m2*v2*math.cos(cheta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(cheta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(cheta2-phi)*(m2-m1)+2*m1*v1*math.cos(cheta1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(cheta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(cheta2-phi)*(m2-m1)+2*m1*v1*math.cos(cheta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(cheta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330504421 329 (2021-01-29 00:40) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan((y2-y1)/(x2-x1)) v1_x = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*(math.cos(theta2-phi))))/(m1+m2))*math.cos(phi))+(v1*(math.sin(theta1-phi))*(math.cos(phi+(math.pi/2)))) v1_y = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*(math.cos(theta2-phi))))/(m1+m2))*math.sin(phi))+(v1*(math.sin(theta1-phi))*(math.sin(phi+(math.pi/2)))) v2_x = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*(math.cos(theta1-phi))))/(m2+m1))*math.cos(phi))+(v2*(math.sin(theta2-phi))*(math.cos(phi+(math.pi/2)))) v2_y = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*(math.cos(theta1-phi))))/(m2+m1))*math.sin(phi))+(v2*(math.sin(theta2-phi))*(math.sin(phi+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330505021 330 (2021-01-31 16:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math m1 = r1**2 m2 = r2**2 phi = math.atan2(y2 - y1,x2 - x1) z1 = math.atan2(v1y,v1x) z2 = math.atan2(v2y,v2x) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) a = (v1*math.cos(z1-phi)*(m1-m2) + 2*m2*v2*math.cos(z2-phi)) / (m1 + m2) k = v1*math.sin(z1-phi)*math.cos(phi + (math.pi/2)) c = math.cos(phi) d = math.sin(phi) e = v1*math.sin(z1-phi)*math.sin(phi + (math.pi/2)) f = (v2*math.cos(z2-phi)*(m2-m1) + 2*m1*v1*math.cos(z1-phi)) / (m1 + m2) g = v2*math.sin(z2-phi)*math.cos(phi + (math.pi/2)) h = v2*math.sin(z2-phi)*math.sin(phi + (math.pi/2)) v1_x = (a*c) + k v1_y = (a*d) + e v2_x = (f*c) + g v2_y = (f*d) + h return (v1_x, v1_y), (v2_x, v2_y) |
# 6330507321 331 (2021-01-30 22:15) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 a=math.atan2(v1y,v1x) b=math.atan2(v2y,v2x) c=math.atan2((y1-y2),(x1-x2)) v1=(v1x**2+v1y**2)**0.5 v2=(v2x**2+v2y**2)**0.5 v1_x = (v1*math.cos(a-c)*(m1-m2)+2*m2*v2*math.cos(b-c))/(m1+m2)*math.cos(c)+v1*math.sin(a-c)*math.cos(c+math.pi/2) v1_y = (v1*math.cos(a-c)*(m1-m2)+2*m2*v2*math.cos(b-c))/(m1+m2)*math.sin(c)+v1*math.sin(a-c)*math.sin(c+math.pi/2) v2_x = (v2*math.cos(b-c)*(m2-m1)+2*m1*v1*math.cos(a-c))/(m1+m2)*math.cos(c)+v2*math.sin(b-c)*math.cos(c+math.pi/2) v2_y = (v2*math.cos(b-c)*(m2-m1)+2*m1*v1*math.cos(a-c))/(m1+m2)*math.sin(c)+v2*math.sin(b-c)*math.sin(c+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330508021 332 (2021-01-30 22:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 c1 = math.atan2(v1y, v1x) c2 = math.atan2(v2y, v2x) f = math.atan2((y2-y1), (x2-x1)) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) v1_x = (v1*math.cos(c1-f)*(m1-m2) + 2*m2*v2*math.cos(c2-f)) / (m1+m2) * math.cos(f) + v1*math.sin(c1-f)*math.cos(f+(math.pi/2)) v1_y = (v1*math.cos(c1-f)*(m1-m2) + 2*m2*v2*math.cos(c2-f)) / (m1+m2) * math.sin(f) + v1*math.sin(c1-f)*math.sin(f+(math.pi/2)) v2_x = (v2*math.cos(c2-f)*(m2-m1) + 2*m1*v1*math.cos(c1-f)) / (m1+m2) * math.cos(f) + v2*math.sin(c2-f)*math.cos(f+(math.pi/2)) v2_y = (v2*math.cos(c2-f)*(m2-m1) + 2*m1*v1*math.cos(c1-f)) / (m1+m2) * math.sin(f) + v2*math.sin(c2-f)*math.sin(f+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330509621 333 (2021-01-30 18:33) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here dx = x1-x2 dy = y1-y2 m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(dy,dx) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m2+m1))*math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))/(m2+m1))*math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330510121 334 (2021-02-01 22:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def v(vx,vy): v = math.sqrt(vx**2 + vy**2) return v v1 = v(v1x,v1y) v2 = v(v2x,v2y) def m(r) : m = r**2 return m m1 = m(r1) m2 = m(r2) def zeta(vx,vy): z = math.atan2(vy,vx) return z z1 = zeta(v1x,v1y) z2 = zeta(v2x,v2y) p=math.atan2((y2-y1),(x2-x1)) v1_x =(v1*math.cos(z1-p)*(m1-m2)+2*m2*v2*math.cos(z2-p))*math.cos(p)/(m1+m2)+v1*math.sin(z1-p)*math.cos(p+math.pi/2) v1_y =(v1*math.cos(z1-p)*(m1-m2)+2*m2*v2*math.cos(z2-p))*math.sin(p)/(m1+m2)+v1*math.sin(z1-p)*math.sin(p+math.pi/2) v2_x =(v2*math.cos(z2-p)*(m2-m1)+2*m1*v1*math.cos(z1-p))*math.cos(p)/(m2+m1)+v2*math.sin(z2-p)*math.cos(p+math.pi/2) v2_y =(v2*math.cos(z2-p)*(m2-m1)+2*m1*v1*math.cos(z1-p))*math.sin(p)/(m2+m1)+v2*math.sin(z2-p)*math.sin(p+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330511821 335 (2021-01-29 23:22) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=(r1)**2 m2=(r2)**2 a1=math.sqrt((v1x)**2+(v1y)**2) theta1=math.atan2(v1y,v1x) a2=math.sqrt((v2x)**2+(v2y)**2) theta2=math.atan2(v2y,v2x) phi=math.atan((y2-y1)/(x2-x1)) b1=(a1*math.cos(theta1-phi)*(m1-m2)+2*m2*a2*math.cos(theta2-phi))/(m1+m2) b2=(a2*math.cos(theta2-phi)*(m2-m1)+2*m1*a1*math.cos(theta1-phi))/(m1+m2) v1_x = b1*math.cos(phi)+a1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = b1*math.sin(phi)+a1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = b2*math.cos(phi)+a2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) v2_y = b2*math.sin(phi)+a2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330512421 336 (2021-02-01 20:21) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y dx = x2-x1 dy = y2-y1 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) gramma = math.atan2(dy,dx) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 op1r = (v1*math.cos(theta1-gramma)*(m1-m2)+2*m2*v2*math.cos(theta2-gramma))/(m1+m2) op2r = (v2*math.cos(theta2-gramma)*(m2-m1)+2*m1*v1*math.cos(theta1-gramma))/(m1+m2) v1_x = op1r*(math.cos(gramma))+v1*math.sin(theta1-gramma)*math.cos(gramma+(math.pi/2)) v1_y = op1r*math.sin(gramma)+v1*math.sin(theta1-gramma)*math.sin(gramma+math.pi/2) v2_x = op2r*math.cos(gramma)+v2*math.sin(theta2-gramma)*math.cos(gramma+math.pi/2) v2_y = op2r*math.sin(gramma)+v2*math.sin(theta2-gramma)*math.sin(gramma+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330513021 337 (2021-01-29 08:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=((v1x**2)+(v1y)**2)**0.5 v2=((v2x**2)+(v2y)**2)**0.5 L =(math.atan2(y1-y2,x1-x2)) a = math.cos((math.atan2(v1y,v1x))-(math.atan2((y1-y2),(x1-x2)))) b = math.cos((math.atan2(v2y,v2x))-(math.atan2((y1-y2),(x1-x2)))) c = math.sin((math.atan2(v1y,v1x))-(math.atan2((y1-y2),(x1-x2)))) d = math.sin((math.atan2(v2y,v2x))-(math.atan2((y1-y2),(x1-x2)))) e = math.cos(L+(math.pi/2)) f = math.sin(L+(math.pi/2)) v1_x =((v1*a*(m1-m2)+2*m2*v2*b)*math.cos(L)/(m1+m2))+(v1*c*e) v1_y =((v1*a*(m1-m2)+2*m2*v2*b)*math.sin(L)/(m1+m2))+(v1*c*f) v2_x =((v2*b*(m2-m1)+2*m1*v1*a)*math.cos(L)/(m1+m2))+(v2*d*e) v2_y =((v2*b*(m2-m1)+2*m1*v1*a)*math.sin(L)/(m1+m2))+(v2*d*f) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330514721 338 (2021-01-31 16:33) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1=r1**2 m2=r2**2 a1=math.atan2(v1y,v1x) a2=math.atan2(v2y,v2x) v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) z=math.atan((y2-y1)/(x2-x1)) v1_x =((((v1*(math.cos(a1-z))*(m1-m2))+(2*m2*v2*(math.cos(a2-z))))/(m1+m2))*(math.cos(z)))+(v1*(math.sin(a1-z))*(math.cos(z+((math.pi)/2)))) v1_y =((((v1*(math.cos(a1-z))*(m1-m2))+(2*m2*v2*(math.cos(a2-z))))/(m1+m2))*(math.sin(z)))+(v1*(math.sin(a1-z))*(math.sin(z+((math.pi)/2)))) v2_x =((((v2*(math.cos(a2-z))*(m2-m1))+(2*m1*v1*(math.cos(a1-z))))/(m2+m1))*(math.cos(z)))+(v2*(math.sin(a2-z))*(math.cos(z+((math.pi)/2)))) v2_y =((((v2*(math.cos(a2-z))*(m2-m1))+(2*m1*v1*(math.cos(a1-z))))/(m2+m1))*(math.sin(z)))+(v2*(math.sin(a2-z))*(math.sin(z+((math.pi)/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330515321 339 (2021-01-29 21:39) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) b = math.atan2(y2-y1,x2-x1) v1 = (v1x**2+v1y**2)**(0.5) v2 = (v2x**2+v2y**2)**(0.5) v1_x = (((((v1)*math.cos(a1-b)*(m1-m2))+((2)*(m2)*(v2)*(math.cos(a2-b))))*(math.cos(b)))+((v1)*(math.sin(a1-b))*(math.cos(b+(math.pi/2)))*(m1+m2)))/(m1+m2) v1_y = (((((v1)*math.cos(a1-b)*(m1-m2))+((2)*(m2)*(v2)*(math.cos(a2-b))))*(math.sin(b)))+((v1)*(math.sin(a1-b))*(math.sin(b+(math.pi/2)))*(m1+m2)))/(m1+m2) v2_x = (((((v2)*math.cos(a2-b)*(m2-m1))+((2)*(m1)*(v1)*(math.cos(a1-b))))*(math.cos(b)))+((v2)*(math.sin(a2-b))*(math.cos(b+(math.pi/2)))*(m1+m2)))/(m1+m2) v2_y = (((((v2)*math.cos(a2-b)*(m2-m1))+((2)*(m1)*(v1)*(math.cos(a1-b))))*(math.sin(b)))+((v2)*(math.sin(a2-b))*(math.sin(b+(math.pi/2)))*(m1+m2)))/(m1+m2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330516021 340 (2021-01-30 15:05) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here z1=math.atan2(v1y,v1x) z2=math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) m1=r1**2 m2=r2**2 v1=(v1y**2+v1x**2)**0.5 v2=(v2y**2+v2x**2)**0.5 v1_x = ((v1*math.cos(z1-phi)*(m1-m2)+2*m2*v2*math.cos(z2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(z1-phi)*math.cos(phi+math.pi/2) v1_y = ((v1*math.cos(z1-phi)*(m1-m2)+2*m2*v2*math.cos(z2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(z1-phi)*math.sin(phi+math.pi/2) v2_x = ((v2*math.cos(z2-phi)*(m2-m1)+2*m1*v1*math.cos(z1-phi))/(m1+m2))*math.cos(phi)+v2*math.sin(z2-phi)*math.cos(phi+math.pi/2) v2_y = ((v2*math.cos(z2-phi)*(m2-m1)+2*m1*v1*math.cos(z1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(z2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330517621 341 (2021-01-28 16:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = (r1)**2 m2 = (r2)**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) ang1 = math.atan2(v1y,v1x) ang2 = math.atan2(v2y,v2x) psi = math.atan((y1-y2)/(x1-x2)) v1_x = ((((v1*math.cos(ang1-psi)*(m1-m2))+(2*m2*v2*math.cos(ang2-psi)))/(m1+m2))*(math.cos(psi)))+(v1*math.sin(ang1-psi)*math.cos(psi+(math.pi/2))) v1_y = ((((v1*math.cos(ang1-psi)*(m1-m2))+(2*m2*v2*math.cos(ang2-psi)))/(m1+m2))*(math.sin(psi)))+(v1*math.sin(ang1-psi)*math.sin(psi+(math.pi/2))) v2_x = ((((v2*math.cos(ang2-psi)*(m2-m1))+(2*m1*v1*math.cos(ang1-psi)))/(m1+m2))*(math.cos(psi)))+(v2*math.sin(ang2-psi)*math.cos(psi+(math.pi/2))) v2_y = ((((v2*math.cos(ang2-psi)*(m2-m1))+(2*m1*v1*math.cos(ang1-psi)))/(m1+m2))*(math.sin(psi)))+(v2*math.sin(ang2-psi)*math.sin(psi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330518221 342 (2021-01-28 21:44) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): phi = math.atan((y1-y2)/(x1-x2)) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) zetha1 = math.atan2(v1y, v1x) zetha2 = math.atan2(v2y, v2y) v1_x = (v1*math.cos(zetha1-phi)*(m1-m2)+2*m2*v2*math.cos(zetha2-phi)) v1_x *= math.cos(phi)/(m1+m2) v1_x += v1*math.sin(zetha1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(zetha1-phi)*(m1-m2)+2*m2*v2*math.cos(zetha2-phi)) v1_y *= math.sin(phi)/(m1+m2) v1_y += v1*math.sin(zetha1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(zetha2-phi)*(m2-m1)+2*m1*v1*math.cos(zetha1-phi)) v2_x *= math.cos(phi)/(m2+m1) v2_x += v2*math.sin(zetha2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(zetha2-phi)*(m2-m1)+2*m1*v1*math.cos(zetha1-phi)) v2_y *=math.sin(phi)/(m2+m1) v2_y += v2*math.sin(zetha2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330519921 343 (2021-02-01 18:58) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1a=math.sqrt(v1x**2+v1y**2) v2a=math.sqrt(v2x**2+v2y**2) zeta1=math.atan2(v1y,v1x) zeta2=math.atan2(v2y,v2x) beta=math.atan2((y2-y1),(x2-x1)) v1_x = ((v1a*math.cos(zeta1-beta)*((r1)**2-(r1)**2)+(2*((r2)**2)*v2a*(math.cos(zeta2-beta))*math.cos(beta)))/(((r1)**2)+((r2)**2)))+(v1a*(math.sin(zeta1-beta))*math.cos(beta+math.pi/2)) v1_y = ((v1a*math.cos(zeta1-beta)*((r1)**2-(r1)**2)+(2*((r2)**2)*v2a*(math.cos(zeta2-beta))*math.sin(beta)))/(((r1)**2)+((r2)**2)))+(v1a*(math.sin(zeta1-beta))*math.sin(beta+math.pi/2)) v2_x = ((v2a*math.cos(zeta2-beta)*((r2)**2-(r1)**2)+(2*((r1)**2)*v1a*(math.cos(zeta1-beta))*math.cos(beta)))/(((r2)**2)+((r1)**2)))+(v2a*(math.sin(zeta2-beta))*math.cos(beta+math.pi/2)) v2_y = ((v2a*math.cos(zeta2-beta)*((r2)**2-(r1)**2)+(2*((r1)**2)*v1a*(math.cos(zeta1-beta))*math.sin(beta)))/(((r2)**2)+((r1)**2)))+(v2a*(math.sin(zeta2-beta))*math.sin(beta+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330521021 344 (2021-01-30 17:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) phi = math.atan2(y2 - y1,x2 - x1) v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 v1_x = ((((v1*math.cos(zeta1-phi)*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))/(m1+m2))*math.cos(phi))+(v1*math.sin(zeta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(zeta1-phi)*(m1-m2))+(2*m2*v2*math.cos(zeta2-phi)))/(m1+m2))*math.sin(phi))+(v1*math.sin(zeta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(zeta2-phi)*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))/(m1+m2))*math.cos(phi))+(v2*math.sin(zeta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(zeta2-phi)*(m2-m1))+(2*m1*v1*math.cos(zeta1-phi)))/(m1+m2))*math.sin(phi))+(v2*math.sin(zeta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330522721 345 (2021-02-01 20:25) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) v1x = ( v1 * math.cos(theta1-phi) * (m1-m2) + 2*m2*v2 *math.cos(theta2-phi) )/(m1+m2) * math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1y = ( v1 * math.cos(theta1-phi) * (m1-m2) + 2*m2*v2 *math.cos(theta2-phi) )/(m1+m2) * math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2x = ( v2 * math.cos(theta2-phi) * (m2-m1) + 2*m1*v1 *math.cos(theta1-phi) )/(m1+m2) * math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2y = ( v2 * math.cos(theta2-phi) * (m2-m1) + 2*m1*v1 *math.cos(theta1-phi) )/(m1+m2) * math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) # # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330523321 346 (2021-01-29 01:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan((y2-y1)/(x2-x1)) zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) v1 = (((v1x)**2)+((v1y)**2))**(1/2) v2 = (((v2x)**2)+((v2y)**2))**(1/2) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(zeta1-a)*(m1-m2))+(2*m2*v2*math.cos(zeta2-a)))/(m1+m2))*math.cos(a))+((v1*math.sin(zeta1-a)*math.cos(a+(math.pi/2)))) v1_y = ((((v1*math.cos(zeta1-a)*(m1-m2))+(2*m2*v2*math.cos(zeta2-a)))/(m1+m2))*math.sin(a))+((v1*math.sin(zeta1-a)*math.sin(a+(math.pi/2)))) v2_x = ((((v2*math.cos(zeta2-a)*(m2-m1))+(2*m1*v1*math.cos(zeta1-a)))/(m1+m2))*math.cos(a))+((v2*math.sin(zeta2-a)*math.cos(a+(math.pi/2)))) v2_y = ((((v2*math.cos(zeta2-a)*(m2-m1))+(2*m1*v1*math.cos(zeta1-a)))/(m1+m2))*math.sin(a))+((v2*math.sin(zeta2-a)*math.sin(a+(math.pi/2)))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330524021 347 (2021-01-31 10:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here f = math.atan2(y1-y2,x1-x2) c1 = math.atan2(v1y,v1x) c2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = (((v1*math.cos(c1-f)*(m1-m2)+2*m2*v2*math.cos(c2-f))/(m1+m2))*math.cos(f))+(v1*math.sin(c1-f)*math.cos(f+(math.pi)/2)) v1_y = (((v1*math.cos(c1-f)*(m1-m2)+2*m2*v2*math.cos(c2-f))/(m1+m2))*math.sin(f))+(v1*math.sin(c1-f)*math.sin(f+(math.pi)/2)) v2_x = (((v2*math.cos(c2-f)*(m2-m1)+2*m1*v1*math.cos(c1-f))/(m1+m2))*math.cos(f))+(v2*math.sin(c2-f)*math.cos(f+(math.pi)/2)) v2_y = (((v2*math.cos(c2-f)*(m2-m1)+2*m1*v1*math.cos(c1-f))/(m1+m2))*math.sin(f))+(v2*math.sin(c2-f)*math.sin(f+(math.pi)/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330525621 348 (2021-02-01 23:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) ceta1=math.atan(v1x/v1y) ceta2=math.atan(v2x/v2y) gamma=math.atan((x2-x1)/(y1-y2)) v1_x = (((((v1*math.cos(ceta1-gamma))*(m1-m2))+(2*m2*(v2*math.cos(ceta2-gamma))))/(m1+m2))*math.cos(gamma))+(v1*math.sin(ceta1-gamma)*math.cos(gamma+(math.pi/2))) v1_y = (((((v1*math.cos(ceta1-gamma))*(m1-m2))+(2*m2*(v2*math.cos(ceta2-gamma))))/(m1+m2))*math.sin(gamma))+(v1*math.sin(ceta1-gamma)*math.sin(gamma+(math.pi/2))) v2_x = (((((v2*math.cos(ceta2-gamma))*(m1-m2))+(2*m1*(v1*math.cos(ceta1-gamma))))/(m1+m2))*math.cos(gamma))+(v2*math.sin(ceta2-gamma)*math.cos(gamma+(math.pi/2))) v2_y = (((((v2*math.cos(ceta2-gamma))*(m1-m2))+(2*m1*(v1*math.cos(ceta1-gamma))))/(m1+m2))*math.sin(gamma))+(v2*math.sin(ceta2-gamma)*math.sin(gamma+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330526221 349 (2021-01-29 23:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def mass(r) : M = r**2 return M def phi(x1, x2, y1, y2) : P = math.atan2((y1-y2),(x1-x2)) return P def velocity(v1x, v1y): V = math.sqrt((v1x**2)+(v1y**2)) return V def theta(v1x, v1y): T = math.atan2(v1y,v1x) return T m1 = mass(r1) m2 = mass(r2) p = phi(x1, x2, y1, y2) V1 = velocity(v1x, v1y) V2 = velocity(v2x, v2y) t1 = theta(v1x, v1y) t2 = theta(v2x, v2y) v1_x = (((V1*math.cos((t1)-p)*(m1-m2))+(2*m2*V2*math.cos((t2)-p)))/(m1+m2)) * (math.cos(p))+((V1)*math.sin((t1)-p))*(math.cos(p+(math.pi/2))) v1_y = (((V1*math.cos((t1)-p)*(m1-m2))+(2*m2*V2*math.cos((t2)-p)))/(m1+m2)) * (math.sin(p))+((V1)*math.sin((t1)-p))*(math.sin(p+(math.pi/2))) v2_x = (((V2*math.cos((t2)-p)*(m2-m1))+(2*m1*V1*math.cos((t1)-p)))/(m1+m2)) * (math.cos(p))+((V2)*math.sin((t2)-p))*(math.cos(p+(math.pi/2))) v2_y = (((V2*math.cos((t2)-p)*(m2-m1))+(2*m1*V1*math.cos((t1)-p)))/(m1+m2)) * (math.sin(p))+((V2)*math.sin((t2)-p))*(math.sin(p+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330527921 350 (2021-01-31 17:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) angle1 = math.atan2(v1y,v1x) angle2 = math.atan2(v2y,v2x) ph = math.atan2(y2-y1,x2-x1) v1_x = (v1*math.cos(angle1-ph)*(m1-m2)+2*m2*v2*math.cos(angle2-ph))/(m1+m2)*math.cos(ph)+v1*math.sin(angle1-ph)*math.cos(ph+math.pi/2) v1_y = (v1*math.cos(angle1-ph)*(m1-m2)+2*m2*v2*math.cos(angle2-ph))/(m1+m2)*math.sin(ph)+v1*math.sin(angle1-ph)*math.sin(ph+math.pi/2) v2_x = (v2*math.cos(angle2-ph)*(m2-m1)+2*m1*v1*math.cos(angle1-ph))/(m1+m2)*math.cos(ph)+v2*math.sin(angle2-ph)*math.cos(ph+math.pi/2) v2_y = (v2*math.cos(angle2-ph)*(m2-m1)+2*m1*v1*math.cos(angle1-ph))/(m1+m2)*math.sin(ph)+v2*math.sin(angle2-ph)*math.sin(ph+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330528521 351 (2021-01-30 22:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 Q1=math.atan2(v1y,v1x) Q2=math.atan2(v2y,v2x) Q3=math.atan2(y1-y2,x1-x2) v1=(v1x**2+v1y**2)**(1/2) v2=(v2x**2+v2y**2)**(1/2) v1_x = (((v1*math.cos(Q1-Q3)*(m1-m2))+2*m2*v2*math.cos(Q2-Q3))/(m1+m2))*(math.cos(Q3))+v1*math.sin(Q1-Q3)*math.cos(Q3+(math.pi)/2) v1_y = (((v1*math.cos(Q1-Q3)*(m1-m2))+2*m2*v2*math.cos(Q2-Q3))/(m1+m2))*(math.sin(Q3))+v1*math.sin(Q1-Q3)*math.sin(Q3+(math.pi)/2) v2_x = (((v2*math.cos(Q2-Q3)*(m2-m1))+2*m1*v1*math.cos(Q1-Q3))/(m1+m2))*(math.cos(Q3))+v2*math.sin(Q2-Q3)*math.cos(Q3+(math.pi)/2) v2_y = (((v2*math.cos(Q2-Q3)*(m2-m1))+2*m1*v1*math.cos(Q1-Q3))/(m1+m2))*(math.sin(Q3))+v2*math.sin(Q2-Q3)*math.sin(Q3+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330529121 352 (2021-01-30 08:52) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) alp = math.atan2(v1y , v1x) bet = math.atan2(v2y , v2x) gam = math.atan2( (y2-y1) , (x2-x1) ) # insert your code here v1_x = (((v1 * math.cos(alp-gam)*(r1**2-r2**2) + 2 * (r2**2) * v2 * math.cos(bet-gam))/(r1**2+r2**2)) * math.cos(gam)) + v1*math.sin(alp-gam)*math.cos(gam + math.radians(90)) v1_y = (((v1 * math.cos(alp-gam)*(r1**2-r2**2) + 2 * (r2**2) * v2 * math.cos(bet-gam))/(r1**2+r2**2)) * math.sin(gam)) + v1*math.sin(alp-gam)*math.sin(gam + math.radians(90)) v2_x = (((v2 * math.cos(bet-gam)*(r2**2-r1**2) + 2 * (r1**2) * v1 * math.cos(alp-gam))/(r1**2+r2**2)) * math.cos(gam)) + v2*math.sin(bet-gam)*math.cos(gam + math.radians(90)) v2_y = (((v2 * math.cos(bet-gam)*(r2**2-r1**2) + 2 * (r1**2) * v1 * math.cos(alp-gam))/(r1**2+r2**2)) * math.sin(gam)) + v2*math.sin(bet-gam)*math.sin(gam + math.radians(90)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330530721 353 (2021-01-31 22:24) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here s1=math.atan2(v1y,v1x) s2=math.atan2(v2y,v2x) g=math.atan2(y2-y1,x2-x1) m1=r1**2 m2=r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) v1_x = ((((v1*math.cos(s1-g)*(m1-m2))+(2*m2*v2*math.cos(s2-g)))/(m1+m2))*math.cos(g))+(v1*math.sin(s1-g)*math.cos(g+(math.pi/2))) v1_y = ((((v1*math.cos(s1-g)*(m1-m2))+(2*m2*v2*math.cos(s2-g)))/(m1+m2))*math.sin(g))+(v1*math.sin(s1-g)*math.sin(g+(math.pi/2))) v2_x = ((((v2*math.cos(s2-g)*(m2-m1))+(2*m1*v1*math.cos(s1-g)))/(m1+m2))*math.cos(g))+(v2*math.sin(s2-g)*math.cos(g+(math.pi/2))) v2_y = ((((v2*math.cos(s2-g)*(m2-m1))+(2*m1*v1*math.cos(s1-g)))/(m1+m2))*math.sin(g))+(v2*math.sin(s2-g)*math.sin(g+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330531321 354 (2021-01-28 23:45) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = (v1x**2 + v1y**2)**0.5 v2 = (v2x**2 + v2y**2)**0.5 zetar1 = math.atan2(v1y,v1x) zetar2 = math.atan2(v2y,v2x) perfume = math.atan((y1-y2)/(x1-x2)) v1x = ((v1*math.cos(zetar1-perfume)*(m1-m2) + 2*m2*v2*math.cos(zetar2-perfume))/(m1+m2))*math.cos(perfume)+v1*math.sin(zetar1-perfume)*math.cos(perfume+math.pi/2) v1y = ((v1*math.cos(zetar1-perfume)*(m1-m2) + 2*m2*v2*math.cos(zetar2-perfume))/(m1+m2))*math.sin(perfume)+v1*math.sin(zetar1-perfume)*math.sin(perfume+math.pi/2) v2x = ((v2*math.cos(zetar2-perfume)*(m2-m1) + 2*m1*v1*math.cos(zetar1-perfume))/(m1+m2))*math.cos(perfume)+v2*math.sin(zetar2-perfume)*math.cos(perfume+math.pi/2) v2y = ((v2*math.cos(zetar2-perfume)*(m2-m1) + 2*m1*v1*math.cos(zetar1-perfume))/(m1+m2))*math.sin(perfume)+v2*math.sin(zetar2-perfume)*math.sin(perfume+math.pi/2) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330532021 355 (2021-01-30 03:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision d1 = math.atan2(v1y,v1x) d2 = math.atan2(v2y,v2x) s = math.atan2(y2-y1,x2-x1) m1 = r1**2 m2 = r2**2 v1 = (v1x**2+v1y**2)**0.5 v2 = (v2x**2+v2y**2)**0.5 v1_x = (((v1*math.cos(d1-s)*(m1-m2)+2*m2*v2*math.cos(d2-s))*math.cos(s))/(m1+m2))+v1*math.sin(d1-s)*math.cos(s+(math.pi/2)) v1_y = (((v1*math.cos(d1-s)*(m1-m2)+2*m2*v2*math.cos(d2-s))*math.sin(s))/(m1+m2))+v1*math.sin(d1-s)*math.sin(s+(math.pi/2)) v2_x = (((v2*math.cos(d2-s)*(m2-m1)+2*m1*v1*math.cos(d1-s))*math.cos(s))/(m1+m2))+v2*math.sin(d2-s)*math.cos(s+(math.pi/2)) v2_y = (((v2*math.cos(d2-s)*(m2-m1)+2*m1*v1*math.cos(d1-s))*math.sin(s))/(m1+m2))+v2*math.sin(d2-s)*math.sin(s+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330533621 356 (2021-01-30 16:36) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = (r1**2) m2 = (r2**2) dy = y1 - y2 dx = x1 - x2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) s1 = math.atan2(v1y,v1x) s2 = math.atan2(v2y,v2x) phi = math.atan2(dy,dx) v1_x = ( v1*math.cos(s1-phi)*(m1-m2)+2*m2*v2*math.cos(s2-phi) )/(m1+m2)* math.cos (phi)+v1*math.sin(s1-phi)*math.cos (phi+math.pi/2) v1_y = ( v1*math.cos(s1-phi)*(m1-m2)+2*m2*v2*math.cos(s2-phi) )/(m1+m2)* math.sin (phi)+v1*math.sin(s1-phi)*math.sin (phi+math.pi/2) v2_x = ( v2*math.cos(s2-phi)*(m2-m1)+2*m1*v1*math.cos(s1-phi) )/(m1+m2)* math.cos (phi)+v2*math.sin(s2-phi)*math.cos (phi+math.pi/2) v2_y = ( v2*math.cos(s2-phi)*(m2-m1)+2*m1*v1*math.cos(s1-phi) )/(m1+m2)* math.sin (phi)+v2*math.sin(s2-phi)*math.sin (phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330534221 357 (2021-01-31 22:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def tan(x,y): a=math.atan2(x/y) return a def m(x): a=x**2 return a seta1=math.atan2(v1y,v1x) seta2=math.atan2(v2y,v2x) fee=math.atan2(y1-y2,x1-x2) v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) m1=m(r1) m2=m(r2) v1_x = ((v1*math.cos(seta1-fee)*(m1-m2)+2*m2*v2*math.cos(seta2-fee))/(m1+m2))*math.cos(fee)+v1*math.sin(seta1-fee)*math.cos(fee+(math.pi/2)) v1_y = ((v1*math.cos(seta1-fee)*(m1-m2)+2*m2*v2*math.cos(seta2-fee))/(m1+m2))*math.sin(fee)+v1*math.sin(seta1-fee)*math.sin(fee+(math.pi/2)) v2_x = ((v2*math.cos(seta2-fee)*(m2-m1)+2*m1*v1*math.cos(seta1-fee))/(m2+m1))*math.cos(fee)+v2*math.sin(seta2-fee)*math.cos(fee+(math.pi/2)) v2_y = ((v2*math.cos(seta2-fee)*(m2-m1)+2*m1*v1*math.cos(seta1-fee))/(m2+m1))*math.sin(fee)+v2*math.sin(seta2-fee)*math.sin(fee+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330535921 358 (2021-02-01 00:50) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): def mass(r): m = r**2 return m def speed(vx,vy): v = math.sqrt(vx**2 + vy**2) return v def poseidon(x1,y1,x2,y2): phi = math.atan((y2-y1)/(x2-x1)) return phi def theta(vx,vy): theta = math.atan2(vy,vx) return theta def culculateVx(v1,v2,theta1,theta2,phi,m1,m2): Vx = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) return Vx def culculateVy(v1,v2,theta1,theta2,phi,m1,m2): Vy = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) return Vy m1 = mass(r1) m2 = mass(r2) v1 = speed(v1x,v1y) v2 = speed(v2x,v2y) theta1 = theta(v1x,v1y) theta2 = theta(v2x,v2y) phi = poseidon(x1,y1,x2,y2) v1_x = culculateVx(v1,v2,theta1,theta2,phi,m1,m2) v1_y = culculateVy(v1,v2,theta1,theta2,phi,m1,m2) v2_x = culculateVx(v2,v1,theta2,theta1,phi,m2,m1) v2_y = culculateVy(v2,v1,theta2,theta1,phi,m2,m1) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330536521 359 (2021-01-29 12:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1=r1**2 m2=r2**2 phi=math.atan((y1-y2)/(x1-x2)) v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) ang1=math.atan2(v1y,v1x) ang2=math.atan2(v2y,v2x) v1x=(v1*math.cos(ang1-phi)*(m1-m2)+2*m2*v2*math.cos(ang2-phi))/(m1+m2)*math.cos(phi)+v1*math.sin(ang1-phi)*math.cos((phi)+(math.pi/2)) v1y=(v1*math.cos(ang1-phi)*(m1-m2)+2*m2*v2*math.cos(ang2-phi))/(m1+m2)*math.sin(phi)+v1*math.sin(ang1-phi)*math.sin((phi)+(math.pi/2)) v2x=(v2*math.cos(ang2-phi)*(m2-m1)+2*m1*v1*math.cos(ang1-phi))/(m1+m2)*math.cos(phi)+v2*math.sin(ang2-phi)*math.cos((phi)+(math.pi/2)) v2y=(v2*math.cos(ang2-phi)*(m2-m1)+2*m1*v1*math.cos(ang1-phi))/(m1+m2)*math.sin(phi)+v2*math.sin(ang2-phi)*math.sin((phi)+(math.pi/2)) v1_x=v1x v1_y=v1y v2_x=v2x v2_y=v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330537121 360 (2021-01-31 20:11) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision m1 = r1 ** 2 m2 = r2 ** 2 k1 = math.atan2(v1y,v1x) k2 = math.atan2(v2y,v2x) k3 = math.atan2((y1-y2),(x1-x2)) v1 = abs(((v1x ** 2) + (v1y ** 2)) ** (1/2)) v2 = abs(((v2x ** 2) + (v2y ** 2)) ** (1/2)) v1_x = ((( v1 * math.cos(k1-k3) * (m1-m2) + 2 * m2 * v2 * math.cos(k2-k3)) * math.cos(k3))/(m1+m2)) + v1*(math.sin(k1-k3))*(math.cos(k3+math.pi/2)) v1_y = ((( v1 * math.cos(k1-k3) * (m1-m2) + 2 * m2 * v2 * math.cos(k2-k3)) * math.sin(k3))/(m1+m2)) + v1*(math.sin(k1-k3))*(math.sin(k3+math.pi/2)) v2_x = ((( v2 * math.cos(k2-k3) * (m2-m1) + 2 * m1 * v1 * math.cos(k1-k3)) * math.cos(k3))/(m1+m2)) + v2*(math.sin(k2-k3))*(math.cos(k3+math.pi/2)) v2_y = ((( v2 * math.cos(k2-k3) * (m2-m1) + 2 * m1 * v1 * math.cos(k1-k3)) * math.sin(k3))/(m1+m2)) + v2*(math.sin(k2-k3))*(math.sin(k3+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330538821 361 (2021-01-31 19:05) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here def ag(vy,vx) : ag=math.atan2(vy,vx) return ag def v(vxx,vyy) : v=(vxx**2 + vyy**2)**0.5 return v def m(r) : m=r**2 return m ag1=ag(v1y,v1x) ag2=ag(v2y,v2x) v1=v(v1x,v1y) v2=v(v2x,v2y) m1=m(r1) m2=m(r2) ph=math.atan2((y1-y2),(x1-x2)) v1_x = (v1*math.cos(ag1-ph) *(m1-m2)+2*m2*v2*math.cos(ag2-ph))*math.cos(ph)/(m1+m2)+v1*math.sin(ag1-ph)*math.cos(ph+math.pi/2) v1_y = (v1*math.cos(ag1-ph) *(m1-m2)+2*m2*v2*math.cos(ag2-ph))*math.sin(ph)/(m1+m2)+v1*math.sin(ag1-ph)*math.sin(ph+math.pi/2) v2_x = (v2*math.cos(ag2-ph) *(m2-m1)+2*m1*v1*math.cos(ag1-ph))*math.cos(ph)/(m1+m2)+v2*math.sin(ag2-ph)*math.cos(ph+math.pi/2) v2_y = (v2*math.cos(ag2-ph) *(m2-m1)+2*m1*v1*math.cos(ag1-ph))*math.sin(ph)/(m1+m2)+v2*math.sin(ag2-ph)*math.sin(ph+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330539421 362 (2021-01-30 23:16) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) a3 = math.atan2((y2-y1),(x2-x1)) v1_x = ((v1*(m1-m2)*math.cos(a1-a3)+2*m2*v2*math.cos(a2-a3))/(m1+m2))*math.cos(a3)+(v1*math.sin(a1-a3)*math.cos(a3+math.pi*0.5)) v1_y = ((v1*(m1-m2)*math.cos(a1-a3)+2*m2*v2*math.cos(a2-a3))/(m1+m2))*math.sin(a3)+(v1*math.sin(a1-a3)*math.sin(a3+math.pi*0.5)) v2_x = ((v2*(m2-m1)*math.cos(a2-a3)+2*m1*v1*math.cos(a1-a3))/(m1+m2))*math.cos(a3)+(v2*math.sin(a2-a3)*math.cos(a3+math.pi*0.5)) v2_y = ((v2*(m2-m1)*math.cos(a2-a3)+2*m1*v1*math.cos(a1-a3))/(m1+m2))*math.sin(a3)+(v2*math.sin(a2-a3)*math.sin(a3+math.pi*0.5)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330540021 363 (2021-01-29 13:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here phi = math.atan2(y2-y1,x2-x1) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) va = math.sqrt((v1x)**2+(v1y)**2) vb = math.sqrt((v2x)**2+(v2y)**2) m1 = r1**2 m2 = r2**2 v1_x =(va*math.cos(theta1-phi)*(m1-m2)+2*m2*vb*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+va*math.sin(theta1-phi)*math.cos(phi+(math.pi)/2) v1_y =(va*math.cos(theta1-phi)*(m1-m2)+2*m2*vb*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+va*math.sin(theta1-phi)*math.sin(phi+(math.pi)/2) v2_x =(vb*math.cos(theta2-phi)*(m2-m1)+2*m1*va*math.cos(theta1-phi))*math.cos(phi)/(m1+m2)+vb*math.sin(theta2-phi)*math.cos(phi+(math.pi)/2) v2_y =(vb*math.cos(theta2-phi)*(m2-m1)+2*m1*va*math.cos(theta1-phi))*math.sin(phi)/(m1+m2)+vb*math.sin(theta2-phi)*math.sin(phi+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330541621 364 (2021-02-01 12:29) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*(math.cos(phi))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*(math.sin(phi))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((v2*math.cos(theta2-phi)*(m1-m2))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*(math.cos(phi))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((v2*math.cos(theta2-phi)*(m1-m2))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2))*(math.sin(phi))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330542221 365 (2021-01-30 01:56) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here zeta1 = math.atan2(v1y,v1x) zeta2 = math.atan2(v2y,v2x) fi = math.atan2(y2-y1,x2-x1) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) av1 = (v1*math.cos(zeta1-fi)*(m1-m2)+2*m2*v2*math.cos(zeta2-fi))/(m1+m2) av2 = (v2*math.cos(zeta2-fi)*(m2-m1)+2*m1*v1*math.cos(zeta1-fi))/(m1+m2) v1_x = av1*math.cos(fi)+v1*math.sin(zeta1-fi)*math.cos(fi+math.radians(90)) v1_y = av1*math.sin(fi)+v1*math.sin(zeta1-fi)*math.sin(fi+math.radians(90)) v2_x = av2*math.cos(fi)+v2*math.sin(zeta2-fi)*math.cos(fi+math.radians(90)) v2_y = av2*math.sin(fi)+v2*math.sin(zeta2-fi)*math.sin(fi+math.radians(90)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330543921 366 (2021-01-28 16:22) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here se1 = math.atan2(v1y,v1x) se2 = math.atan2(v2y,v2x) v1 = ((v1x**2)+(v1y**2))**(1/2) v2 = ((v2x**2)+(v2y**2))**(1/2) phi = math.atan2(y2-y1,x2-x1) a1 = se1-phi a2 = se2-phi v1_x = ((((v1*math.cos(a1)*((r1**2)-(r2**2)))+(2*(r2**2)*v2*math.cos(a2)))/((r1**2)+(r2**2)))*(math.cos(phi)))+(v1*math.sin(a1)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(a1)*((r1**2)-(r2**2)))+(2*(r2**2)*v2*math.cos(a2)))/((r1**2)+(r2**2)))*(math.sin(phi)))+(v1*math.sin(a1)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(a2)*((r2**2)-(r1**2)))+(2*(r1**2)*v1*math.cos(a1)))/((r2**2)+(r1**2)))*(math.cos(phi)))+(v2*math.sin(a2)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(a2)*((r2**2)-(r1**2)))+(2*(r1**2)*v1*math.cos(a1)))/((r2**2)+(r1**2)))*(math.sin(phi)))+(v2*math.sin(a2)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330544521 367 (2021-01-28 16:18) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here ceta1 = math.atan2(v1y,v1x) ceta2 = math.atan2(v2y,v2x) phi = math.atan2((y2-y1),(x2-x1)) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) m1 = r1**2 m2 = r2**2 angle1 = ceta1-phi angle2 = ceta2-phi v1_x = ((((v1*math.cos(angle1)*(m1-m2))+(2*m2*v2*math.cos(angle2)))/(m1+m2))*math.cos(phi))+(v1*math.sin(angle1)*math.cos(phi+math.pi/2)) v1_y = ((((v1*math.cos(angle1)*(m1-m2))+(2*m2*v2*math.cos(angle2)))/(m1+m2))*math.sin(phi))+(v1*math.sin(angle1)*math.sin(phi+math.pi/2)) v2_x = ((((v2*math.cos(angle2)*(m2-m1))+(2*m1*v1*math.cos(angle1)))/(m1+m2))*math.cos(phi))+(v2*math.sin(angle2)*math.cos(phi+math.pi/2)) v2_y = ((((v2*math.cos(angle2)*(m2-m1))+(2*m1*v1*math.cos(angle1)))/(m1+m2))*math.sin(phi))+(v2*math.sin(angle2)*math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330545121 368 (2021-01-31 16:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y ρ = math.atan2((y2-y1),(x2-x1)) θ1 = math.atan2(v1y,v1x) θ2 = math.atan2(v2y,v2x) m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2) + (v1y**2)) v2 = math.sqrt((v2x**2) + (v2y**2)) v1_x = ((v1*math.cos(θ1 - ρ)*(m1-m2)+(2*m2*v2*math.cos(θ2 - ρ)))*math.cos(ρ)/(m1+m2)) + v1*math.sin((θ1 - ρ))*math.cos(ρ + math.pi/2) v1_y = (v1*math.cos(θ1 - ρ)*(m1-m2)+(2*m2*v2*math.cos(θ2 - ρ)))*math.sin(ρ)/(m1+m2) + v1*math.sin((θ1 - ρ))*math.sin(ρ + math.pi/2) v2_x = ((v2*math.cos(θ2 - ρ)*(m2-m1)+(2*m1*v1*math.cos(θ1 - ρ)))*math.cos(ρ)/(m1+m2)) + v2*math.sin((θ2 - ρ))*math.cos(ρ + math.pi/2) v2_y = (v2*math.cos(θ2 - ρ)*(m2-m1)+(2*m1*v1*math.cos(θ1 - ρ)))*math.sin(ρ)/(m1+m2) + v2*math.sin((θ2 - ρ))*math.sin(ρ + math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330547421 369 (2021-01-31 14:22) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.cos(phi))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2))*math.sin(phi))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m2+m1))*math.cos(phi))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m2+m1))*math.sin(phi))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330548021 370 (2021-01-31 16:15) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = ((v1x**2)+(v1y**2))**(0.5) v2 = ((v2x**2)+(v2y**2))**(0.5) T1 = math.atan2(v1y,v1x) T2 = math.atan2(v2y,v2x) Ph = math.atan2((y2-y1),(x2-x1)) v1_x = ( ( ((v1*math.cos(T1-Ph)*(m1-m2)) + (2*m2*v2*math.cos(T2-Ph)) ) / (m1+m2) ) *math.cos(Ph))+(v1*math.sin(T1-Ph)*math.cos(Ph+(math.pi/2))) v1_y = ( ( ((v1*math.cos(T1-Ph)*(m1-m2)) + (2*m2*v2*math.cos(T2-Ph)) ) / (m1+m2) ) *math.sin(Ph))+(v1*math.sin(T1-Ph)*math.sin(Ph+(math.pi/2))) v2_x = ( ( ((v2*math.cos(T2-Ph)*(m2-m1)) + (2*m1*v1*math.cos(T1-Ph)) ) / (m2+m1) ) *math.cos(Ph))+(v2*math.sin(T2-Ph)*math.cos(Ph+(math.pi/2))) v2_y = ( ( ((v2*math.cos(T2-Ph)*(m2-m1)) + (2*m1*v1*math.cos(T1-Ph)) ) / (m2+m1) ) *math.sin(Ph))+(v2*math.sin(T2-Ph)*math.sin(Ph+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330549721 371 (2021-01-30 18:53) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a = math.atan2(v1y,v1x) j = math.atan((y2-y1)/(x2-x1)) c = math.atan2(v2y,v2x) m1 = math.pow(r1,2) m2 = math.pow(r2,2) v1 = v1x/math.cos(a) v2 = v2x/math.cos(c) l = (v1*(m1-m2)*math.cos(a-j)+2*m2*v2*math.cos(c-j))/(m1+m2) k = (v2*(m2-m1)*math.cos(c-j)+2*m1*v1*math.cos(a-j))/(m1+m2) v1_x = l*math.cos(j)+v1*math.sin(a-j)*math.cos(j+math.pi/2) v1_y = l*math.sin(j)+v1*math.sin(a-j)*math.sin(j+math.pi/2) v2_x = k*math.cos(j)+v2*math.sin(c-j)*math.cos(j+math.pi/2) v2_y = k*math.sin(j)+v2*math.sin(c-j)*math.sin(j+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330550221 372 (2021-01-29 22:38) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here fine = math.atan2((y2-y1), (x2-x1)) seta1 = math.atan2(v1y, v1x) seta2 = math.atan2(v2y, v2x) m1 = (r1)**2 m2 = (r2)**2 v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) v1_x = (((((v1*(math.cos(seta1-fine))*(m1-m2))+2*m2*v2*math.cos(seta2-fine))/(m1+m2))*(math.cos(fine))))+((v1*math.sin(seta1-fine))*math.cos(fine+(math.pi/2))) v1_y = (((((v1*(math.cos(seta1-fine))*(m1-m2))+2*m2*v2*math.cos(seta2-fine))/(m1+m2))*(math.sin(fine))))+((v1*math.sin(seta1-fine))*math.sin(fine+(math.pi/2))) v2_x = (((((v2*(math.cos(seta2-fine))*(m2-m1))+2*m1*v1*math.cos(seta1-fine))/(m1+m2))*(math.cos(fine))))+((v2*math.sin(seta2-fine))*math.cos(fine+(math.pi/2))) v2_y = (((((v2*(math.cos(seta2-fine))*(m2-m1))+2*m1*v1*math.cos(seta1-fine))/(m1+m2))*(math.sin(fine))))+((v2*math.sin(seta2-fine))*math.sin(fine+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330551921 373 (2021-01-29 23:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt(math.pow(v1x,2)+math.pow(v1y,2)) v2 = math.sqrt(math.pow(v2x,2)+math.pow(v2y,2)) ceta1 = math.acos(v1x/v1) ceta2 = math.acos(v2x/v2) m1 = math.pow(r1,2) m2 = math.pow(r2,2) free = math.atan((y1-y2)/(x2-x1)) v1_x = (((v1*(math.cos(ceta1-free))*(m1-m2)) +\ (2*m2*v2*(math.cos(ceta2-free)))) / (m1+m2)) \ * (math.cos(free)) + \ (v1*math.sin(ceta1-free)*math.cos(free+(math.pi/2))) v1_y = (((v1*(math.cos(ceta1-free))*(m1-m2)) +\ (2*m2*v2*(math.cos(ceta2-free)))) / (m1+m2)) \ * (math.sin(free)) + \ (v1*math.sin(ceta1-free)*math.sin(free+(math.pi/2))) v2_x = (((v2*(math.cos(ceta2-free))*(m1-m2)) +\ (2*m1*v1*(math.cos(ceta1-free)))) / (m1+m2)) \ * (math.cos(free)) + \ (v2*math.sin(ceta2-free)*math.cos(free+(math.pi/2))) v2_y = (((v2*(math.cos(ceta2-free))*(m1-m2)) +\ (2*m1*v1*(math.cos(ceta1-free)))) / (m1+m2)) \ * (math.sin(free)) + \ (v2*math.sin(ceta2-free)*math.sin(free+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330552521 374 (2021-01-31 16:20) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision m1 = r1**2 m2 = r2**2 t1 = math.atan2(v1y, v1x) t2 = math.atan2(v2y, v2x) fi = math.atan2(y2 - y1, x2 - x1) v1 = math.sqrt((v1x**2) + (v1y**2)) v2 = math.sqrt((v2x**2) + (v2y**2)) v1_x = (((v1*math.cos(t1 - fi)*(m1 - m2)) + (2*m2*v2*math.cos(t2 - fi))) / (m1 + m2))*(math.cos(fi)) + (v1*math.sin(t1 - fi)*math.cos(fi +(math.pi / 2))) v1_y = (((v1*math.cos(t1 - fi)*(m1 - m2)) + (2*m2*v2*math.cos(t2 - fi))) / (m1 + m2))*(math.sin(fi)) + (v1*math.sin(t1 - fi)*math.sin(fi +(math.pi / 2))) v2_x = (((v2*math.cos(t2 - fi)*(m2 - m1)) + (2*m1*v1*math.cos(t1 - fi))) / (m1 + m2))*(math.cos(fi)) + (v2*math.sin(t2 - fi)*math.cos(fi +(math.pi / 2))) v2_y = (((v2*math.cos(t2 - fi)*(m2 - m1)) + (2*m1*v1*math.cos(t1 - fi))) / (m1 + m2))*(math.sin(fi)) + (v2*math.sin(t2 - fi)*math.sin(fi +(math.pi / 2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330553121 375 (2021-01-31 21:16) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) #------------------------- up_fr1 = v1*math.cos(theta1-phi)*(m1-m2) up_bk1 = 2*m2*v2*math.cos(theta2-phi) frterm1 = (up_fr1+up_bk1)/(m1+m2) #------------- up_fr2 = v2*math.cos(theta2-phi)*(m2-m1) up_bk2 = 2*m1*v1*math.cos(theta1-phi) frterm2 = (up_fr2+up_bk2)/(m1+m2) #------------------------- v1x = (frterm1*math.cos(phi))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1y = (frterm1*math.sin(phi))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2x = (frterm2*math.cos(phi))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2y = (frterm2*math.sin(phi))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330554821 376 (2021-01-31 14:00) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) dy = y1-y2 dx = x1-x2 theta1 = math.asin(v1y/v1) theta2 = math.asin(v2y/v2) phi = math.atan2(dy,dx) m1 = r1**2 m2 = r2**2 a = ((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2) B = math.cos(phi) c = v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) d = math.sin(phi) e = v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) f = ((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2) g = v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2)) h = v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) v1_x = (a*B)+c v1_y = (a*d)+e v2_x = (f*B)+g v2_y = (f*d)+h return (v1_x, v1_y), (v2_x, v2_y) |
# 6330555421 377 (2021-02-01 11:29) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 delta1 = math.atan2(v1y,v1x) delta2 = math.atan2(v2y,v2x) v1 = v1x/math.cos(delta1) v2 = v2x/math.cos(delta2) phi = math.atan((y1-y2)/(x1-x2)) v1_x = (((v1 * math.cos(delta1-phi) * (m1-m2)) + (2 * m2 * v2 * math.cos(delta2-phi))) * math.cos(phi) / (m1+m2)) + v1 * math.sin(delta1-phi) * math.cos(phi+(math.pi)/2) v1_y = (((v1 * math.cos(delta1-phi) * (m1-m2)) + (2 * m2 * v2 * math.cos(delta2-phi))) * math.sin(phi) / (m1+m2)) + v1 * math.sin(delta1-phi) * math.sin(phi+(math.pi)/2) v2_x = (((v2 * math.cos(delta2-phi) * (m2-m1)) + (2 * m1 * v1 * math.cos(delta1-phi))) * math.cos(phi) / (m1+m2)) + v2 * math.sin(delta2-phi) * math.cos(phi+(math.pi)/2) v2_y = (((v2 * math.cos(delta2-phi) * (m2-m1)) + (2 * m1 * v1 * math.cos(delta1-phi))) * math.sin(phi) / (m1+m2)) + v2 * math.sin(delta2-phi) * math.sin(phi+(math.pi)/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330556021 378 (2021-01-29 23:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here #if v1x == 0 and v1y > 0: # ang1 = math.pi/2 #elif v1x == 0 and v1y <0: # ang1 = (3*math.pi)/2 #else: ang1 = math.atan2(v1y, v1x) #if v2x == 0 and v2y > 0: # ang2 = math.pi/2 #elif v2x == 0 and v2y < 0: # ang2 = (3*math.pi)/2 #else: ang2 = math.atan2(v2y, v2x) #v1 = v1y/math.sin(ang1) #v2 = v2y/math.sin(ang2) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) #ang1 = math.acos(v1x/v1) #ang2 = math.acos(v2x/v2) phi = math.atan2((y1-y2), (x1-x2)) m1 = r1**2 m2 = r2**2 v1_x = ((((v1*math.cos(ang1-phi)*(m1-m2)) + (2*m2*v2*math.cos(ang2-phi)))/(m1+m2))*math.cos(phi)) + v1*math.sin(ang1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((((v1*math.cos(ang1-phi)*(m1-m2)) + (2*m2*v2*math.cos(ang2-phi)))/(m1+m2))*math.sin(phi)) + v1*math.sin(ang1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((((v2*math.cos(ang2-phi)*(m2-m1)) + (2*m1*v1*math.cos(ang1-phi)))/(m1+m2))*math.cos(phi)) + v2*math.sin(ang2-phi)*math.cos(phi+(math.pi/2)) v2_y = ((((v2*math.cos(ang2-phi)*(m2-m1)) + (2*m1*v1*math.cos(ang1-phi)))/(m1+m2))*math.sin(phi)) + v2*math.sin(ang2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330557721 379 (2021-02-01 13:12) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = ((r1)**2) m2 = ((r2)**2) A1 = math.atan2(v1y,v1x) A2 = math.atan2(v2y,v2x) FI = math.atan2((y1-y2),(x1-x2)) v1 = v1x/(math.cos(A1)) v2 = v2x/(math.cos(A2)) v3 = v1y/(math.sin(A1)) v4 = v2y/(math.sin(A2)) v1_x = ((((v1*math.cos(A1-FI)*(m1-m2))+(2*(m2)*(v2)*(math.cos(A2-FI))))/(m1+m2))*(math.cos(FI))+((v1*(math.sin(A1-FI))*(math.cos(FI+((math.pi)/2)))))) v1_y = ((((v3*math.cos(A1-FI)*(m1-m2))+(2*(m2)*(v4)*(math.cos(A2-FI))))/(m1+m2))*(math.sin(FI))+((v3*(math.sin(A1-FI))*(math.sin(FI+((math.pi)/2)))))) v2_x = ((((v2*math.cos(A2-FI)*(m2-m1))+(2*(m1)*(v1)*(math.cos(A1-FI))))/(m1+m2))*(math.cos(FI))+((v2*(math.sin(A2-FI))*(math.cos(FI+((math.pi)/2)))))) v2_y = ((((v4*math.cos(A2-FI)*(m2-m1))+(2*(m1)*(v3)*(math.cos(A1-FI))))/(m1+m2))*(math.sin(FI))+((v4*(math.sin(A2-FI))*(math.sin(FI+((math.pi)/2)))))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330558321 380 (2021-02-01 21:22) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y2-y1,x2-x1) v1_x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330559021 381 (2021-01-30 14:55) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) z = math.atan2((y2-y1),(x2-x1)) m1 = (r1)**2 m2 = (r2)**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt((v2x**2) + (v2y**2)) v1_x = (v1*math.cos(seta1-z)*(m1-m2)+2*m2*v2*math.cos(seta2-z))/(m1+m2)* math.cos(z)+v1*math.sin((seta1-z))*math.cos((math.pi)/2+(z)) v1_y = (v1*math.cos(seta1-z)*(m1-m2)+2*m2*v2*math.cos(seta2-z))/(m1+m2)* math.sin(z)+v1*math.sin((seta1-z))*math.sin((math.pi)/2+(z)) v2_x = (v2*math.cos(seta2-z)*(m2-m1)+2*m1*v1*math.cos(seta1-z))/(m1+m2)* math.cos(z)+v2*math.sin((seta2-z))*math.cos((math.pi)/2+(z)) v2_y = (v2*math.cos(seta2-z)*(m2-m1)+2*m1*v1*math.cos(seta1-z))/(m1+m2)* math.sin(z)+v2*math.sin((seta2-z))*math.sin((math.pi)/2+(z)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330560521 382 (2021-01-30 18:03) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here import math m1 = math.pow(r1,2) m2 = math.pow(r2,2) phi = math.atan2((y2-y1),(x2-x1)) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) v1 = math.sqrt(math.pow(v1x,2)+math.pow(v1y,2)) v2 = math.sqrt(math.pow(v2x,2)+math.pow(v2y,2)) #v1_x a = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*(math.cos(theta2-phi))))/(m1+m2))*(math.cos(phi))) b = v1*(math.sin(theta1-phi))*(math.cos(phi+(math.pi/2))) #v1_y c = ((((v1*(math.cos(theta1-phi))*(m1-m2))+(2*m2*v2*(math.cos(theta2-phi))))/(m1+m2))*(math.sin(phi))) d = v1*(math.sin(theta1-phi))*(math.sin(phi+(math.pi/2))) #v2_x e = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*(math.cos(theta1-phi))))/(m1+m2))*(math.cos(phi))) f = v2*(math.sin(theta2-phi))*(math.cos(phi+(math.pi/2))) #v2_y h = ((((v2*(math.cos(theta2-phi))*(m2-m1))+(2*m1*v1*(math.cos(theta1-phi))))/(m1+m2))*(math.sin(phi))) g = v2*(math.sin(theta2-phi))*(math.sin(phi+(math.pi/2))) v1_x = a+b v1_y = c+d v2_x = e+f v2_y = h+g return (v1_x, v1_y), (v2_x, v2_y) |
# 6330561121 383 (2021-01-30 18:08) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 ag1 = math.atan2(v1y,v1x) ag2 = math.atan2(v2y,v2x) v1 = v1x/math.cos(ag1) v2 = v2x/math.cos(ag2) cag = math.atan2((y2-y1),(x2-x1)) v1_x = ((v1*math.cos(ag1-cag)*(m1-m2)+2*m2*v2*math.cos(ag2-cag))/(m1+m2))*math.cos(cag)+v1*math.sin(ag1-cag)*math.cos(cag+(math.pi/2)) v1_y = ((v1*math.cos(ag1-cag)*(m1-m2)+2*m2*v2*math.cos(ag2-cag))/(m1+m2))*math.sin(cag)+v1*math.sin(ag1-cag)*math.sin(cag+(math.pi/2)) v2_x = ((v2*math.cos(ag2-cag)*(m2-m1)+2*m1*v1*math.cos(ag1-cag))/(m1+m2))*math.cos(cag)+v2*math.sin(ag2-cag)*math.cos(cag+(math.pi/2)) v2_y = ((v2*math.cos(ag2-cag)*(m2-m1)+2*m1*v1*math.cos(ag1-cag))/(m1+m2))*math.sin(cag)+v2*math.sin(ag2-cag)*math.sin(cag+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330562821 384 (2021-01-30 12:57) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2((y1-y2),(x1-x2)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2) + v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(theta1-phi)*(m1-m2) + 2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2) + v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m1+m2) + v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(theta2-phi)*(m2-m1) + 2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m1+m2) + v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330563421 385 (2021-01-30 15:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y1-y2,x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m2+m1)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m2+m1)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330564021 386 (2021-01-29 23:43) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan2(y1 - y2,x1 - x2) m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(theta1-phi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-phi))) * (math.cos(phi)/(m1+m2)))+(v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2))) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2)) + (2*m2*v2*math.cos(theta2-phi))) * (math.sin(phi)/(m1+m2)))+(v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2))) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1)) + (2*m1*v1*math.cos(theta1-phi))) * (math.cos(phi)/(m2+m1)))+(v2*math.sin(theta2-phi)*math.cos(phi+(math.pi/2))) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1)) + (2*m1*v1*math.cos(theta1-phi))) * (math.sin(phi)/(m2+m1)))+(v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330565721 387 (2021-01-30 22:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 +v1y**2) v2 = math.sqrt(v2x**2 +v2y**2) p = math.atan2((y1-y2),(x1-x2)) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) v1_x = ((v1*math.cos(a1-p)*(m1-m2)*math.cos(p)+2*m2*v2*math.cos(a2-p)*math.cos(p))/(m1+m2))+v1*math.sin(a1-p)*math.cos(p+(math.pi/2)) v1_y = ((v1*math.cos(a1-p)*(m1-m2)*math.sin(p)+2*m2*v2*math.cos(a2-p)*math.sin(p))/(m1+m2))+v1*math.sin(a1-p)*math.sin(p+(math.pi/2)) v2_x = ((v2*math.cos(a2-p)*(m2-m1)*math.cos(p)+2*m1*v1*math.cos(a1-p)*math.cos(p))/(m2+m1))+v2*math.sin(a2-p)*math.cos(p+(math.pi/2)) v2_y = ((v2*math.cos(a2-p)*(m2-m1)*math.sin(p)+2*m1*v1*math.cos(a1-p)*math.sin(p))/(m2+m1))+v2*math.sin(a2-p)*math.sin(p+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330566321 388 (2021-01-29 17:32) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here a1=math.atan2(v1y, v1x) a2=math.atan2(v2y, v2x) phi=math.atan2((y1-y2), (x1-x2)) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x = (v1*math.cos(a1-phi)*(m1-m2)+2*m2*v2*math.cos(a2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(a1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(a1-phi)*(m1-m2)+2*m2*v2*math.cos(a2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(a1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(a2-phi)*(m2-m1)+2*m1*v1*math.cos(a1-phi))*math.cos(phi)/(m1+m2)+v2*math.sin(a2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(a2-phi)*(m2-m1)+2*m1*v1*math.cos(a1-phi))*math.sin(phi)/(m1+m2)+v2*math.sin(a2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330567021 389 (2021-01-31 23:24) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): ################################################################################### # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) phi = math.atan2(y1-y2, x1-x2) m1 = r1**2 m2 = r2**2 v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2) )*math.cos(phi) + v1*math.sin(theta1-phi)*math.cos(phi + math.pi/2) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+(2*m2*v2*math.cos(theta2-phi)))/(m1+m2) )*math.sin(phi) + v1*math.sin(theta1-phi)*math.sin(phi + math.pi/2) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2) )*math.cos(phi) + v2*math.sin(theta2-phi)*math.cos(phi + math.pi/2) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+(2*m1*v1*math.cos(theta1-phi)))/(m1+m2) )*math.sin(phi) + v2*math.sin(theta2-phi)*math.sin(phi + math.pi/2) #################################################################################### return (v1_x, v1_y), (v2_x, v2_y) |
# 6330568621 390 (2021-01-31 19:40) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2y**2 + v2x**2) a1 = math.atan2(v1y,v1x) a2 = math.atan2(v2y,v2x) p = math.atan2((y1-y2),(x1-x2)) v1_x = (((v1*math.cos(a1-p)*(m1-m2)+(2*m2*v2*math.cos(a2-p)))/(m1+m2))*math.cos(p))+v1*math.sin(a1-p)*math.cos(p+(math.pi/2)) v1_y = (((v1*math.cos(a1-p)*(m1-m2)+(2*m2*v2*math.cos(a2-p)))/(m1+m2))*math.sin(p))+v1*math.sin(a1-p)*math.sin(p+(math.pi/2)) v2_x = (((v2*math.cos(a2-p)*(m2-m1)+(2*m1*v1*math.cos(a1-p)))/(m1+m2))*math.cos(p))+v2*math.sin(a2-p)*math.cos(p+(math.pi/2)) v2_y = (((v2*math.cos(a2-p)*(m2-m1)+(2*m1*v1*math.cos(a1-p)))/(m1+m2))*math.sin(p))+v2*math.sin(a2-p)*math.sin(p+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330569221 391 (2021-02-01 18:31) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1=r1**2 m2=r2**2 a1=math.atan2(v1y,v1x) a2=math.atan2(v2y,v2x) v1=math.sqrt(v1y**2 + v1x**2) v2=math.sqrt(v2y**2 + v2x**2) l=math.atan2(y2-y1,x2-x1) v1_x = (((v1*math.cos(a1-l)*(m1-m2))+(2*m2*v2*math.cos(a2-l)))/(m1+m2))*math.cos(l)+v1*math.sin(a1-l)*math.cos(l+math.pi) v1_y = (((v1*math.cos(a1-l)*(m1-m2))+(2*m2*v2*math.cos(a2-l)))/(m1+m2))*math.sin(l)+v1*math.sin(a1-l)*math.sin(l+math.pi) v2_x = (((v2*math.cos(a2-l)*(m2-m1))+(2*m1*v1*math.cos(a1-l)))/(m1+m2))*math.cos(l)+v2*math.sin(a2-l)*math.cos(l+math.pi) v2_y = (((v2*math.cos(a2-l)*(m2-m1))+(2*m1*v1*math.cos(a1-l)))/(m1+m2))*math.sin(l)+v2*math.sin(a2-l)*math.sin(l+math.pi) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330570821 392 (2021-01-30 08:53) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 phi = math.atan2((y2-y1),(x2-x1)) theta1 = math.atan2(v1y,(v1x)) theta2 = math.atan2(v2y,(v2x)) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.cos(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.cos(phi+(0.5*math.pi))) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2))+(2*m2*v2*math.cos(theta2-phi)))*math.sin(phi)/(m1+m2))+(v1*math.sin(theta1-phi)*math.sin(phi+(0.5*math.pi))) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.cos(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.cos(phi+(0.5*math.pi))) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1))+(2*m1*v1*math.cos(theta1-phi)))*math.sin(phi)/(m1+m2))+(v2*math.sin(theta2-phi)*math.sin(phi+(0.5*math.pi))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330571421 393 (2021-01-29 11:47) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1=math.sqrt((v1x**2)+(v1y**2)) v2=math.sqrt((v2x**2)+(v2y**2)) ang1=math.atan2(v1y,v1x) ang2=math.atan2(v2y,v2x) ang12=math.atan((y1-y2)/(x1-x2)) v1x = ((v1*math.cos(ang1-ang12)*(m1-m2)+2*m2*v2*math.cos(ang2-ang12))/(m1+m2))*math.cos(ang12)+v1*math.sin(ang1-ang12)*math.cos(ang12+(math.pi/2)) v1y = ((v1*math.cos(ang1-ang12)*(m1-m2)+2*m2*v2*math.cos(ang2-ang12))/(m1+m2))*math.sin(ang12)+v1*math.sin(ang1-ang12)*math.sin(ang12+(math.pi/2)) v2x = ((v2*math.cos(ang2-ang12)*(m2-m1)+2*m1*v1*math.cos(ang1-ang12))/(m1+m2))*math.cos(ang12)+v2*math.sin(ang2-ang12)*math.cos(ang12+(math.pi/2)) v2y = ((v2*math.cos(ang2-ang12)*(m2-m1)+2*m1*v1*math.cos(ang1-ang12))/(m1+m2))*math.sin(ang12)+v2*math.sin(ang2-ang12)*math.sin(ang12+(math.pi/2)) v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330572021 394 (2021-01-31 20:51) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here θ1 = math.atan2(v1y,v1x) θ2 = math.atan2(v2y,v2x) φ = math.atan2(y2-y1,x2-x1) m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = (((v1*math.cos(θ1-φ)*(m1-m2))+(2*m2*v2*math.cos(θ2-φ)))/(m1+m2))*math.cos(φ)+v1*math.sin(θ1-φ)*math.cos(φ+math.pi/2) v1_y = (((v1*math.cos(θ1-φ)*(m1-m2))+(2*m2*v2*math.cos(θ2-φ)))/(m1+m2))*math.sin(φ)+v1*math.sin(θ1-φ)*math.sin(φ+math.pi/2) v2_x = (((v2*math.cos(θ2-φ)*(m2-m1))+(2*m1*v1*math.cos(θ1-φ)))/(m2+m1))*math.cos(φ)+v2*math.sin(θ2-φ)*math.cos(φ+math.pi/2) v2_y = (((v2*math.cos(θ2-φ)*(m2-m1))+(2*m1*v1*math.cos(θ1-φ)))/(m2+m1))*math.sin(φ)+v2*math.sin(θ2-φ)*math.sin(φ+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330573721 395 (2021-01-30 01:28) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y, v1x) theta2 = math.atan2(v2y, v2x) v1 = v1x/math.cos(theta1) v2 = v2x/math.cos(theta2) phi = math.atan2(y1-y2, x1-x2) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi)+v1*math.sin(theta1-phi)*math.cos(phi+(math.pi/2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi)+v1*math.sin(theta1-phi)*math.sin(phi+(math.pi/2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi)+v2*math.sin(theta2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330574321 396 (2021-02-01 20:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = ((v1x**2)+(v1y**2))**0.5 v2 = ((v2x**2)+(v2y**2))**0.5 s1 = math.atan2(v1y, v1x) s2 = math.atan2(v2y, v2x) s3 = math.atan2((y2-y1), (x2-x1)) v1_x = ((((v1*math.cos(s1-s3)*(m1-m2))+(2*m2*v2*math.cos(s2-s3)))*math.cos(s3))/(m1+m2))+(v1*math.sin(s1-s3)*math.cos(s3+(math.pi/2))) v1_y = ((((v1*math.cos(s1-s3)*(m1-m2))+(2*m2*v2*math.cos(s2-s3)))*math.sin(s3))/(m1+m2))+(v1*math.sin(s1-s3)*math.sin(s3+(math.pi/2))) v2_x = ((((v2*math.cos(s2-s3)*(m2-m1))+(2*m1*v1*math.cos(s1-s3)))*math.cos(s3))/(m1+m2))+(v2*math.sin(s2-s3)*math.cos(s3+(math.pi/2))) v2_y = ((((v2*math.cos(s2-s3)*(m2-m1))+(2*m1*v1*math.cos(s1-s3)))*math.sin(s3))/(m1+m2))+(v2*math.sin(s2-s3)*math.sin(s3+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330575021 397 (2021-01-28 16:24) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) a = math.atan2((y1-y2),(x1-x2)) b1 = math.atan2(v1y,v1x) b2 = math.atan2(v2y,v2x) v1_x = ( ( v1*math.cos(b1-a)*(m1-m2)*math.cos(a)+2*m2*v2*math.cos(b2-a)*math.cos(a) )/(m1+m2) )+v1*math.sin(b1-a)*math.cos(a+(math.pi/2)) v1_y = ( ( v1*math.cos(b1-a)*(m1-m2)*math.sin(a)+2*m2*v2*math.cos(b2-a)*math.sin(a) )/(m1+m2) )+v1*math.sin(b1-a)*math.sin(a+(math.pi/2)) v2_x = ( ( v2*math.cos(b2-a)*(m2-m1)*math.cos(a)+2*m1*v1*math.cos(b1-a)*math.cos(a) )/(m2+m1) )+v2*math.sin(b2-a)*math.cos(a+(math.pi/2)) v2_y = ( ( v2*math.cos(b2-a)*(m2-m1)*math.sin(a)+2*m1*v1*math.cos(b1-a)*math.sin(a) )/(m2+m1) )+v2*math.sin(b2-a)*math.sin(a+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330576621 398 (2021-01-30 16:09) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here p = math.atan((y1-y2)/(x1-x2)) c1 = math.atan2(v1y, v1x) c2 = math.atan2(v2y, v2x) v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) v1_x = ((v1*math.cos(c1-p)*(r1**2-r2**2)+2*(r2**2)*v2*math.cos(c2-p))/(r1**2+r2**2))*math.cos(p)+v1*math.sin(c1-p)*math.cos(p+(math.pi/2)) v1_y = ((v1*math.cos(c1-p)*(r1**2-r2**2)+2*(r2**2)*v2*math.cos(c2-p))/(r1**2+r2**2))*math.sin(p)+v1*math.sin(c1-p)*math.sin(p+(math.pi/2)) v2_x = ((v2*math.cos(c2-p)*(r2**2-r1**2)+2*(r1**2)*v1*math.cos(c1-p))/(r1**2+r2**2))*math.cos(p)+v2*math.sin(c2-p)*math.cos(p+(math.pi/2)) v2_y = ((v2*math.cos(c2-p)*(r2**2-r1**2)+2*(r1**2)*v1*math.cos(c1-p))/(r1**2+r2**2))*math.sin(p)+v2*math.sin(c2-p)*math.sin(p+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330577221 399 (2021-01-29 20:32) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi=math.atan2((y2-y1),(x2-x1)) m1=(r1)**2 m2=(r2)**2 v1=(v1x**2+v1y**2)**0.5 v2=(v2x**2+v2y**2)**0.5 v1_x = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.cos(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))*math.sin(phi)/(m1+m2)+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.cos(phi)/(m2+m1)+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))*math.sin(phi)/(m2+m1)+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330578921 400 (2021-01-28 19:54) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = math.sqrt(v1x**2+v1y**2) v2 = math.sqrt(v2x**2+v2y**2) t1 = math.acos(v1x/v1) t2 = math.acos(v2x/v2) c = math.atan((y1-y2)/(x2-x1)) m1 = r1**2 m2 = r2**2 v1_x = (((v1*math.cos(t1-c)*(m1-m2)+2*m2*v2*math.cos(t2-c))/(m1+m2))*math.cos(c)+v1*math.sin(t1-c)*math.cos(c+math.pi/2)) v1_y = (((v1*math.cos(t1-c)*(m1-m2)+2*m2*v2*math.cos(t2-c))/(m1+m2))*math.sin(c)+v1*math.sin(t1-c)*math.sin(c+math.pi/2)) v2_x = (((v2*math.cos(t2-c)*(m1-m2)+2*m1*v1*math.cos(t1-c))/(m1+m2))*math.cos(c)+v2*math.sin(t2-c)*math.cos(c+math.pi/2)) v2_y = (((v2*math.cos(t2-c)*(m1-m2)+2*m1*v1*math.cos(t1-c))/(m1+m2))*math.sin(c)+v2*math.sin(t2-c)*math.sin(c+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330579521 401 (2021-01-31 18:49) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # # the 2d-collision equations can be found at # # https://en.wikipedia.org/wiki/Elastic_collision # # # # insert your code here import math as m s1=m.atan2(v1y,v1x) s2=m.atan2(v2y,v2x) phi=m.atan2(y2-y1,x2-x1) m1=r1**2 m2=r2**2 v1=m.sqrt((v1x**2)+(v1y**2)) v2=m.sqrt((v2x**2)+(v2y**2)) v1_x=((v1*(m.cos(s1-phi))*(m1-m2)+2*m2*v2*(m.cos(s2-phi)))*m.cos(phi))/(m1+m2)+(v1*(m.sin(s1-phi))*(m.cos(phi+(m.pi/2)))) v1_y=((v1*(m.cos(s1-phi))*(m1-m2)+2*m2*v2*(m.cos(s2-phi)))*m.sin(phi))/(m1+m2)+(v1*(m.sin(s1-phi))*(m.sin(phi+(m.pi/2)))) v2_x=((v2*(m.cos(s2-phi))*(m2-m1)+2*m1*v1*(m.cos(s1-phi)))*m.cos(phi))/(m1+m2)+(v2*(m.sin(s2-phi))*(m.cos(phi+(m.pi/2)))) v2_y=((v2*(m.cos(s2-phi))*(m2-m1)+2*m1*v1*(m.cos(s1-phi)))*m.sin(phi))/(m1+m2)+(v2*(m.sin(s2-phi))*(m.sin(phi+(m.pi/2)))) # v1_x = v1x # v1_y = v1y # v2_x = v2x # v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330580021 402 (2021-02-01 00:33) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1=math.sqrt((v1x)**2+(v1y)**2) v2=math.sqrt((v2x)**2+(v2y)**2) m1=(r1)**2 m2=(r2)**2 p=math.atan((y1-y2)/(x1-x2)) c1=math.atan2(v1y,v1x) c2=math.atan2(v2y,v2x) a=(v1*(math.cos(c1-p))*(m1-m2)+(2*(m2)*v2*(math.cos(c2-p))))/(m1+m2) b=(v2*(math.cos(c2-p))*(m2-m1)+(2*(m1)*v1*(math.cos(c1-p))))/(m1+m2) v1_x=a*math.cos(p)+v1*math.sin(c1-p)*math.cos(p+math.pi/2) v1_y=a*math.sin(p)+v1*math.sin(c1-p)*math.sin(p+math.pi/2) v2_x=b*math.cos(p)+v2*math.sin(c2-p)*math.cos(p+math.pi/2) v2_y=b*math.sin(p)+v2*math.sin(c2-p)*math.sin(p+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330583021 403 (2021-01-31 11:33) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here c = math.atan2((y1-y2),(x1-x2)) v1 = math.sqrt(((v1x)**2)+((v1y)**2)) v2 = math.sqrt(((v2x)**2)+((v2y)**2)) a1 = math.atan2((v1y),(v1x)) a2 = math.atan2((v2y),(v2x)) m1 = (r1)**2 m2 = (r2)**2 v1_x = ((((v1*math.cos(a1-c)*(m1-m2))+(2*m2*v2*math.cos(a2-c)))*math.cos(c))/(m1+m2))+(v1*math.sin(a1-c)*math.cos(c+math.pi/2)) v1_y = ((((v1*math.cos(a1-c)*(m1-m2))+(2*m2*v2*math.cos(a2-c)))*math.sin(c))/(m1+m2))+(v1*math.sin(a1-c)*math.sin(c+math.pi/2)) v2_x = ((((v2*math.cos(a2-c)*(m2-m1))+(2*m1*v1*math.cos(a1-c)))*math.cos(c))/(m1+m2))+(v2*math.sin(a2-c)*math.cos(c+math.pi/2)) v2_y = ((((v2*math.cos(a2-c)*(m2-m1))+(2*m1*v1*math.cos(a1-c)))*math.sin(c))/(m1+m2))+(v2*math.sin(a2-c)*math.sin(c+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330585221 404 (2021-01-29 23:13) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here m1 = r1**2 m2 = r2**2 theta_1 = math.atan2(v1y, v1x) theta_2 = math.atan2(v2y, v2x) phi = math.atan2((y1-y2), (-x2+x1)) v1 = math.sqrt((v1x**2)+(v1y**2)) v2 = math.sqrt((v2x**2)+(v2y**2)) v1_x = (((v1*math.cos(theta_1-phi)*(m1-m2)) + 2*m2*v2*math.cos(theta_2-phi))/(m1+m2))*((math.cos(phi))) + v1*math.sin(theta_1-phi)*math.cos(phi+(math.pi/2)) v1_y = (((v1*math.cos(theta_1-phi)*(m1-m2)) + 2*m2*v2*math.cos(theta_2-phi))/(m1+m2))*((math.sin(phi))) + v1*math.sin(theta_1-phi)*math.sin(phi+(math.pi/2)) v2_x = (((v2*math.cos(theta_2-phi)*(m2-m1)) + 2*m1*v1*math.cos(theta_1-phi))/(m1+m2))*((math.cos(phi))) + v2*math.sin(theta_2-phi)*math.cos(phi+(math.pi/2)) v2_y = (((v2*math.cos(theta_2-phi)*(m2-m1)) + 2*m1*v1*math.cos(theta_1-phi))/(m1+m2))*((math.sin(phi))) + v2*math.sin(theta_2-phi)*math.sin(phi+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330586921 405 (2021-01-31 21:15) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1_x = v1x v1_y = v1y v2_x = v2x v2_y = v2y m1 = (r1)**2 m2 = (r2)**2 seta1 = math.atan2(v1y,v1x) seta2 = math.atan2(v2y,v2x) phi = math.atan2(y1-y2,x1-x2) v1 = ((v1x**2+v1y**2)**0.5) v2 = ((v2x**2+v2y**2)**0.5) v1_x = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))*math.cos(phi)/(m1+m2)) + (v1*math.sin(seta1-phi)*math.cos(phi+(math.pi/2))) v1_y = ((v1*math.cos(seta1-phi)*(m1-m2)+2*m2*v2*math.cos(seta2-phi))*math.sin(phi)/(m1+m2)) + (v1*math.sin(seta1-phi)*math.sin(phi+(math.pi/2))) v2_x = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))*math.cos(phi)/(m1+m2)) + (v2*math.sin(seta2-phi)*math.cos(phi+(math.pi/2))) v2_y = ((v2*math.cos(seta2-phi)*(m2-m1)+2*m1*v1*math.cos(seta1-phi))*math.sin(phi)/(m1+m2)) + (v2*math.sin(seta2-phi)*math.sin(phi+(math.pi/2))) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330587521 406 (2021-01-30 15:17) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1=math.atan2(v1y, v1x) theta2=math.atan2(v2y, v2x) phi=math.atan((y2-y1)/(x2-x1)) m1=r1**2 m2=r2**2 v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) v1_x = (((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.cos(phi)))+v1*math.sin(theta1-phi)*math.cos(phi+math.pi/2) v1_y = (((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2)*math.sin(phi)))+v1*math.sin(theta1-phi)*math.sin(phi+math.pi/2) v2_x = (((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.cos(phi)))+v2*math.sin(theta2-phi)*math.cos(phi+math.pi/2) v2_y = (((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2)*math.sin(phi)))+v2*math.sin(theta2-phi)*math.sin(phi+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330588121 407 (2021-02-01 00:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): v1=math.sqrt(v1x**2+v1y**2) v2=math.sqrt(v2x**2+v2y**2) ax = ((v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y2-y1),(x2-x1)))*(r1**2-r2**2))+(2*r2**2*v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y2-y1),(x2-x1)))))*math.cos(math.atan2((y2-y1),(x2-x1)))/(r1**2+r2**2) bx = v1*math.sin(math.atan2(v1y,v1x)-math.atan2((y2-y1),(x2-x1)))*math.cos(math.atan2((y2-y1),(x2-x1))+(math.pi/2)) v1_x = ax+bx ay = ((v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y2-y1),(x2-x1)))*(r1**2-r2**2))+(2*r2**2*v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y2-y1),(x2-x1)))))*math.sin(math.atan2((y2-y1),(x2-x1)))/(r1**2+r2**2) by = v1*math.sin(math.atan2(v1y,v1x)-math.atan2((y2-y1),(x2-x1)))*math.sin(math.atan2((y2-y1),(x2-x1))+(math.pi/2)) v1_y = ay+by a2x=((v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y2-y1),(x2-x1)))*(r2**2-r1**2))+(2*r1**2*v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y2-y1),(x2-x1)))))*math.cos(math.atan2((y2-y1),(x2-x1)))/(r1**2+r2**2) b2x= v2*math.sin(math.atan2(v2y,v2x)-math.atan2((y2-y1),(x2-x1)))*math.cos(math.atan2((y2-y1),(x2-x1))+(math.pi/2)) v2_x = a2x+b2x a2y=((v2*math.cos(math.atan2(v2y,v2x)-math.atan2((y2-y1),(x2-x1)))*(r2**2-r1**2))+(2*r1**2*v1*math.cos(math.atan2(v1y,v1x)-math.atan2((y2-y1),(x2-x1)))))*math.sin(math.atan2((y2-y1),(x2-x1)))/(r1**2+r2**2) b2y= v2*math.sin(math.atan2(v2y,v2x)-math.atan2((y2-y1),(x2-x1)))*math.sin(math.atan2((y2-y1),(x2-x1))+(math.pi/2)) v2_y= a2y+b2y return (v1_x, v1_y), (v2_x, v2_y) |
# 6330589821 408 (2021-01-30 12:44) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) phi = math.atan((y2-y1)/(x2-x1)) v1_x = ((((v1x/math.cos(theta1)*(math.cos(theta1-phi))*((r1**2)-(r2**2)))+(2*(r2**2)*(v2x/math.cos(theta2))*(math.cos(theta2-phi))))/((r1**2)+(r2**2)))*math.cos(phi))+(v1x/math.cos(theta1))*(math.sin(theta1-phi))*(math.cos(phi+math.pi/2)) v1_y = ((((v1x/math.cos(theta1)*(math.cos(theta1-phi))*((r1**2)-(r2**2)))+(2*(r2**2)*(v2x/math.cos(theta2))*(math.cos(theta2-phi))))/((r1**2)+(r2**2)))*math.sin(phi))+(v1x/math.cos(theta1))*(math.sin(theta1-phi))*(math.sin(phi+math.pi/2)) v2_x = ((((v2x/math.cos(theta2)*(math.cos(theta2-phi))*((r2**2)-(r1**2)))+(2*(r1**2)*(v1x/math.cos(theta1))*(math.cos(theta1-phi))))/((r1**2)+(r2**2)))*math.cos(phi))+(v2x/math.cos(theta2))*(math.sin(theta2-phi))*(math.cos(phi+math.pi/2)) v2_y = ((((v2x/math.cos(theta2)*(math.cos(theta2-phi))*((r2**2)-(r1**2)))+(2*(r1**2)*(v1x/math.cos(theta1))*(math.cos(theta1-phi))))/((r1**2)+(r2**2)))*math.sin(phi))+(v2x/math.cos(theta2))*(math.sin(theta2-phi))*(math.sin(phi+math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330591021 409 (2021-01-28 22:22) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here v1 = (v1y**2+v1x**2)**0.5 v2 = (v2y**2+v2x**2)**0.5 theta1 = math.atan2(v1y,v1x) theta2 = math.atan2(v2y,v2x) fe = math.atan2((y2-y1),(x2-x1)) m1 = r1**2 m2 = r2**2 v1_x = ((v1*(math.cos(theta1-fe))*(m1-m2)+2*m2*v2*math.cos(theta2-fe))/(m1+m2))*math.cos(fe)+v1*math.sin(theta1-fe)*math.cos(fe+math.pi/2) v1_y = ((v1*(math.cos(theta1-fe))*(m1-m2)+2*m2*v2*math.cos(theta2-fe))/(m1+m2))*math.sin(fe)+v1*math.sin(theta1-fe)*math.sin(fe+math.pi/2) v2_x = ((v2*(math.cos(theta2-fe))*(m2-m1)+2*m1*v1*math.cos(theta1-fe))/(m1+m2))*math.cos(fe)+v2*math.sin(theta2-fe)*math.cos(fe+math.pi/2) v2_y = ((v2*(math.cos(theta2-fe))*(m2-m1)+2*m1*v1*math.cos(theta1-fe))/(m1+m2))*math.sin(fe)+v2*math.sin(theta2-fe)*math.sin(fe+math.pi/2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330592621 410 (2021-01-29 16:10) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here dy = y2 - y1 dx = x2 - x1 m1 = r1**2 m2 = r2**2 theta1 = math.atan2(v1y , v1x) theta2 = math.atan2(v2y , v2x) phi = math.atan2(dy , dx) v1 = v1y / math.sin(theta1) v2 = v2y / math.sin(theta2) v1_x = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.cos(phi) +v1*math.sin(theta1-phi) *math.cos(phi+ (math.pi / 2)) v1_y = ((v1*math.cos(theta1-phi)*(m1-m2)+2*m2*v2*math.cos(theta2-phi))/(m1+m2))*math.sin(phi) +v1*math.sin(theta1-phi) *math.sin(phi+ (math.pi / 2)) v2_x = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.cos(phi) +v2*math.sin(theta2-phi) *math.cos(phi+ (math.pi / 2)) v2_y = ((v2*math.cos(theta2-phi)*(m2-m1)+2*m1*v1*math.cos(theta1-phi))/(m1+m2))*math.sin(phi) +v2*math.sin(theta2-phi) *math.sin(phi+ (math.pi / 2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330593221 411 (2021-01-31 16:35) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision gramma = math.atan2(y2-y1, x2-x1) # phi v1 = math.sqrt((v1x ** 2) + (v1y ** 2)) #ขนาดv1 zeta1 = math.atan2(v1y , v1x) m1 = r1 ** 2 v2 = math.sqrt((v2x ** 2) + (v2y ** 2)) zeta2 = math.atan2(v2y , v2x) m2 = r2 ** 2 # insert your code here v1_x = (((v1*math.cos(zeta1-gramma)*(m1-m2))+(2*m2*v2*math.cos(zeta2-gramma)))/(m1+m2))*math.cos(gramma)+v1*math.sin(zeta1-gramma)*math.cos(gramma+(math.pi/2)) v1_y = (((v1*math.cos(zeta1-gramma)*(m1-m2))+(2*m2*v2*math.cos(zeta2-gramma)))/(m1+m2))*math.sin(gramma)+v1*math.sin(zeta1-gramma)*math.sin(gramma+(math.pi/2)) v2_x = (((v2*math.cos(zeta2-gramma)*(m2-m1))+(2*m1*v1*math.cos(zeta1-gramma)))/(m1+m2))*math.cos(gramma)+v2*math.sin(zeta2-gramma)*math.cos(gramma+(math.pi/2)) v2_y = (((v2*math.cos(zeta2-gramma)*(m2-m1))+(2*m1*v1*math.cos(zeta1-gramma)))/(m1+m2))*math.sin(gramma)+v2*math.sin(zeta2-gramma)*math.sin(gramma+(math.pi/2)) return (v1_x, v1_y), (v2_x, v2_y) |
# 6330594921 412 (2021-02-01 00:34) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here omg = math.atan2(y1-y2, x1-x2) deg1 = math.atan2(v1y, v1x) deg2 = math.atan2(v2y, v2x) v1 = math.sqrt(v1x**2 + v1y**2) v2 = math.sqrt(v2x**2 + v2y**2) m1 = r1**2 m2 = r2**2 v1_x = ((v1 * math.cos(deg1 - omg) * (m1 - m2) + 2 * m2 * v2 * math.cos(deg2 - omg)) * math.cos(omg) / (m1 + m2)) + v1 * math.sin(deg1 - omg) * math.cos(omg + math.pi / 2) v1_y = ((v1 * math.cos(deg1 - omg) * (m1 - m2) + 2 * m2 * v2 * math.cos(deg2 - omg)) * math.sin(omg) / (m1 + m2)) + v1 * math.sin(deg1 - omg) * math.sin(omg + math.pi / 2) v2_x = ((v2 * math.cos(deg2 - omg) * (m2 - m1) + 2 * m1 * v1 * math.cos(deg1 - omg)) * math.cos(omg) / (m1 + m2)) + v2 * math.sin(deg2 - omg) * math.cos(omg + math.pi / 2) v2_y = ((v2 * math.cos(deg2 - omg) * (m2 - m1) + 2 * m1 * v1 * math.cos(deg1 - omg)) * math.sin(omg) / (m1 + m2)) + v2 * math.sin(deg2 - omg) * math.sin(omg + math.pi / 2) return (v1_x, v1_y), (v2_x, v2_y) |
# 6331138621 413 (2021-02-01 23:30) def update_v(x1, y1, r1, v1x, v1y, x2, y2, r2, v2x, v2y): # the 2d-collision equations can be found at # https://en.wikipedia.org/wiki/Elastic_collision # insert your code here t1 = math.atan2(v1y,v1x) t2 = math.atan2(v2y,v2x) m1 = math.pow(r1,2) m2 = math.pow(r2,2) v1 = math.sqrt(math.pow(v1y,2)+math.pow(v1x,2)) v2 = math.sqrt(math.pow(v2y,2)+math.pow(v2x,2)) p = math.atan2(y1-y2,x1-x2) v1_x = (((v1*math.cos(t1-p)*(m1-m2))+(2*m2*v2*math.cos(t2-p)))/(m1+m2))*math.cos(p)+((v1*math.sin(t1-p))*(math.cos(p+(math.pi/2)))) v1_y = (((v1*math.cos(t1-p)*(m1-m2))+(2*m2*v2*math.cos(t2-p)))/(m1+m2))*math.sin(p)+((v1*math.sin(t1-p))*(math.sin(p+(math.pi/2)))) v2_x = (((v2*math.cos(t2-p)*(m2-m1))+(2*m1*v1*math.cos(t1-p)))/(m1+m2))*math.cos(p)+((v2*math.sin(t2-p))*(math.cos(p+(math.pi/2)))) v2_y = (((v2*math.cos(t2-p)*(m2-m1))+(2*m1*v1*math.cos(t1-p)))/(m1+m2))*math.sin(p)+((v2*math.sin(t2-p))*(math.sin(p+(math.pi/2)))) #v1_x = v1x #v1_y = v1y #v2_x = v2x #v2_y = v2y return (v1_x, v1_y), (v2_x, v2_y) |