![]() ![]() # print(f'xy xy translator called for xy=') def angle_ofdxdy(dxdy): # returns angle, zīelow is a prep function that uses the above before calling the equations: def calc_impulse_xy1xy2(xy1_xy2, ball_mass=1, wall_mass=10000000, gamma=0): Tuples are input and output to the functions. Vector 2d collision code#So I was using the equations from this:īelow is the code that computes vector angle from dx dy velocities:įurther below are the equations (that require the converted vector input).Ĭode is in python 3.8x. Since I'm doing a remake on blobby, the the bodies are not necessarily balls - hit angles are not related to distance between X1,X2. We combine this last expression with the conservation of momentum and we get the normal component of v'1 :įinally, we find the formula of the wikipedia article for v'1 : The conservation of kinetic energy can be factorized then simplified with the conservation of momentum : So we can rewrite the conservation laws with normal components and we have a 1D problem now : The tangential components of velocities are unchanged. The conservation of total kinetic energy is expressed by :Īs there is no force applied in the tangential direction, the tangential components of velocities are unchanged after collision : The conservation of the total momentum is expressed by : The unit vector t is tangent to the surfaces of balls at the point of contact. ![]() The unit vector n is normal to the surfaces of balls at the point of contact.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |