Help with elastic collision algorithm (need unit vector and velocity)

In summary, the conversation discusses the implementation of an elastic collision algorithm and the need for knowledge of physics algebra to optimize it. The conversation also touches on the conservation of momentum and energy, the concept of impulse, and using normal and tangent unit vectors to determine the final velocity and angle of the objects involved in the collision.
  • #1
Omnirizon
6
0
hello there. this is as much a comp sci question as a physics question, however the comp sci board looked more like a 'computer technology' board, and didn't have much stuff relevant to physics. even though I'm trying to optimize an algorithm for a very specific need, it requires knowledge of the physics algebra (knowledge I don't have and am hoping someone here does...)

I have implemented an elastic collision algorithm, but with one problem. the rest of my code needs a velocity and angle (at the minimum, having the unit vector would be nice too). I can't seem to figure out how to get this out of the elastic collision algorithm without just deriving them from the final product. Isn't there a cheaper way than that? In the course of the algorithm many things are computed (normal vector, normal and tangent unit vector, some scalars...). I've linked the code:

http://paste.pocoo.org/show/144824/"

Even if it would be more expensive to get unit vector and velocity, and calculate new vector from those, it might be cheaper than doing final step (lines 18-21, in the paste) and then getting unit vector and velocity from it.

Any smart people in here that can tell me which parameters computed in the course of this algorithm can be used for that? (note: I can see that the vmark.. and v0t/v1t variables can be used to get velocity. now what about unit vector? is there a cheaper way than doing that last step?)
 
Last edited by a moderator:
Physics news on Phys.org
  • #2


Hello! As a physicist, I can definitely help you with this problem. First of all, I would recommend checking out some resources on elastic collisions and the equations involved. This will give you a better understanding of the physical concepts behind the algorithm and how to manipulate the variables to get the desired results.

In terms of your specific question, there are a few things to consider. The first is the conservation of momentum and energy in an elastic collision. This means that the total momentum and energy before and after the collision should be the same. Using this principle, you can derive equations for the final velocity and angle of the objects involved in the collision.

Another important factor is the concept of impulse, which is the change in momentum during a collision. This can be calculated using the normal vector and the scalar values you have computed in your algorithm. From this, you can then determine the final velocity and angle of the objects involved.

In terms of getting the unit vector, you can use the normal and tangent unit vectors that you have already computed in your algorithm. These can be used to determine the direction of the final velocity.

Overall, it is important to understand the physical principles behind elastic collisions in order to optimize your algorithm. I hope this helps and good luck with your project!
 
  • #3


I can understand your frustration with trying to optimize an algorithm without the necessary physics knowledge. In order to get the velocity and unit vector from the elastic collision algorithm, you will need to use the conservation of momentum and conservation of kinetic energy equations.

First, you will need to calculate the total momentum of the system before the collision, which can be done by multiplying the mass of each object by its initial velocity. Then, after the collision, you can use the conservation of momentum equation to calculate the final velocity of each object.

Next, you can use the conservation of kinetic energy equation to calculate the total kinetic energy before and after the collision. This will give you the final velocity of each object in terms of the initial velocity and the mass ratio of the objects.

To get the unit vector, you can use the normal and tangent unit vectors that are already computed in the algorithm. These unit vectors represent the direction of the collision and can be used to determine the direction of the final velocity vectors.

I hope this helps guide you in the right direction. Remember to always check your equations and units to ensure accuracy in your algorithm. Good luck!
 

What is an elastic collision?

An elastic collision is a type of collision in which the total kinetic energy of the system is conserved. This means that the total energy before the collision is equal to the total energy after the collision.

What is a unit vector?

A unit vector is a vector with a magnitude of 1 and does not have any specific direction. It is often used in physics and mathematics to simplify calculations and represent a direction in a coordinate system.

How do you calculate the unit vector in an elastic collision?

To calculate the unit vector in an elastic collision, you need to first calculate the total momentum of the system before and after the collision. Then, divide the total momentum by its magnitude to get the unit vector.

What is the importance of the velocity in an elastic collision?

The velocity plays a crucial role in an elastic collision as it determines the direction and speed of the objects involved in the collision. It is used to calculate the total momentum and energy of the system, which are conserved in an elastic collision.

What are some real-life examples of elastic collisions?

Some examples of elastic collisions in real life include a game of pool, where the balls collide and bounce off each other without losing any energy, and a rubber ball bouncing off a hard surface, where the kinetic energy is conserved. Another example is the collision of molecules in a gas, where the kinetic energy is transferred without any energy loss.

Similar threads

Replies
14
Views
1K
  • Mechanics
Replies
2
Views
926
Replies
10
Views
4K
  • General Math
Replies
11
Views
1K
Replies
4
Views
4K
Replies
4
Views
4K
Replies
1
Views
7K
  • Programming and Computer Science
Replies
30
Views
4K
  • Introductory Physics Homework Help
Replies
10
Views
4K
Back
Top