1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Oct 13, 2009 #1
    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: May 4, 2017
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted