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

  • Thread starter Omnirizon
  • Start date
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/" [Broken]

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:

Want to reply to this thread?

"Help with elastic collision algorithm (need unit vector and velocity)" You must log in or register to reply here.

Related Threads for: Help with elastic collision algorithm (need unit vector and velocity)

  • Posted
Replies
0
Views
1K
Replies
0
Views
2K
Replies
0
Views
825
Replies
0
Views
2K
Replies
0
Views
1K
Replies
0
Views
2K
  • Posted
Replies
0
Views
903
  • Posted
Replies
0
Views
3K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top