Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Conservation of Momentum

Author
Message
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 01:31
Hello. I'm wondering if any of you can help me with a little problem I have. I have no idea how to calculate the velocity of an object after a collision.

For example, two coins hit each other head on. as shown in my little diagram below. They both have a velocity of 2m/s. One has a mass of 40g and one has a mass of 20g.

O -> <- O

Could somebody explain the steps required to calculate the momentum of each coin after the collision? This is probably a little beyond my ability, but I'd still like to give it a try.

Thanks!

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 21st Jun 2011 01:56
I think the one with the least mass gains the highest velocity, don't the forces average out?

Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 02:03
I'm not really sure at all. I was hoping on of the maths gurus around here would know exactly how to work it out.

lazerus
17
Years of Service
User Offline
Joined: 30th Apr 2008
Location:
Posted: 21st Jun 2011 02:24
1m/s <(40) (20) > 3m/s

I think thats right but its late so get a double check on that aha XD

Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 02:28
How on earth did you work that one out?

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jun 2011 03:54
Is this an elastic or inelastic collision?


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 04:12
Elastic.

However, I don't fully understand the difference, could you explain that?

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jun 2011 04:16
The difference is that perfectly inelastic collisions result in the two objects "sticking" together and end up with a shared velocity (unless all kinetic energy was lost in the collision due to breaking/heat/etc). An elastic collision results in the two objects exchanging energy and going their separate ways, lol.


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jun 2011 04:25 Edited at: 21st Jun 2011 04:29
Okay here it is for elastic. Basically, before and after the collision, total momentum in the system remains the same. Momentum is calculated by Mass*Velocity. So, before collision we have 40*2 + 20*2 = 120. We will need to keep that the same. For the sake of giving proper direction, we will say that the 20g particle has a velocity of -2.

u1 = old velocity of 40g particle (2)
m1 = mass of 40g particle (40)
u2 = old velocity of 20g particle (-2)
m2 = mass of 20g particle (20)

To calculate the new velocity of the 40g particle we will use the following equation:

v = (u1(m1 - m2) + 2*m2*u2) / (m1 + m2)

Plug it all in, do the math and we get:
v = 1.33333 m/s (New velocity of 40g particle)

Do the same for the 20g particle, but swapping the values in the numerator.

v = (u2(m2 - m1) + 2*m1*u1) / (m1 + m2)
v = 3.33333 m/s (New velocity of 20g particle)


Now, we said we had to conserve momentum, so these new velocities have to hold true to that. Let's find out:
40*1.3333 + 20*3.3333 = 119.9999999 (Pretty much 120)

Yup, so that's your answer!

Btw, since they both came out with positive values here, they are both traveling in the positive direction (Since the 20g particle was originally traveling in the negative direction, straight at the 40g particle that was already moving in the positive direction)

(40)>1.33m/s (20)>3.33m/s


Hope that all made sense.


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 04:30
Ah that's brilliant! Thanks so much for taking the time to answer that. Sorry to seem ungrateful, but could you also explain where this equation comes from?

v = (u1(m1 - m2) + 2*m2*u2) / (m1 + m2)

or could you provide a link to where I could read up on it?

Thanks a lot.

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jun 2011 04:48 Edited at: 21st Jun 2011 04:50
I can't say for certain (Not like I have a degree in physics or anything lol) but here's my take on it:

The u1(m1-m2)+2*m2*u2 portion is grabbing the difference in momentum of the two particles and applying it with the velocity of the particle being used. Dividing by the combined mass of the two particles, we are left with the new velocity.

Taking a dimensional analysis approach to this (for the sake of understanding lol) let's look at the unit trail:

u1 and u2 have a unit of (m/s)
m1 and m2 have a unit of (g)

Adding or subtracting mass leaves the same unit (obviously), but when we multiply the velocity with the mass, we get a unit of (g*m/s).... no that unit doesn't make sense, but in physics that sort of unit can be converted into a general momentum unit. We won't do that because we're not looking for the momentum here. However that unit is derived from both u1(m1 - m2) and 2*m2*u2, thus adding them together we have the same unit. Dividing by a mass (g), we cancel out the mass in the unit (g*m/s) and come back to velocity (m/s).

Following units like this can be very important in physics equations. However, don't rely on dimensional analysis to "make up" an equation as I did so often on physics exams when I had no clue what I was really doing Just because the unit comes out right, doesn't mean the answer is right


As fr how the equation was derived by mathmaticians... I couldn't honestly say as this equation has been around for quite some time.


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 04:52 Edited at: 2nd Jul 2014 04:06
That makes perfect sense, but I guess i'll still need some time to full get my head around it.

Cheers for taking the time to help me out, I owe you one.
Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jun 2011 05:07
No problem! Just know that if you're going to be doing 2-dimensional collisions instead of the 1-dimensional here, the equations change vastly and become much more complex (incorporating trigonometry).


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 05:16
I guessed they would become more difficult. If you know anything about that and you're willing to explain, then I'm all ears! But for now, I want to get 1-dimensional working.

Thanks!

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jun 2011 05:36
Hmmm, I think the simplest method I've come across uses trig.

Mind you, I've only ever worked with circles for this, so be aware that any other shape uses far more complex algorithms.

I have to go right now, but if no body else explains it before I come back, I'll do my best.


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 21st Jun 2011 06:51
Quote: "40*1.3333 + 20*3.3333 = 119.9999999 (Pretty much 120)"

Ah, but 199.9999 repeating is in fact exactly equivalent to 120, not just close, no?

*troll*

Anyway, from what I remember of physics, for a 2D collision, you would do the same things you did for the 1D collision, but you would do them for both the X and Y axes. So you would use simple trig to break each object's velocity into perpendicular X and Y components (for example, an object moving at 30 degrees at 1 m/s would have X: 2 m/s, Y: 1.41 m/s). Then you do that thing up there for the X axis and Y axis individually to get the components after the collision, and put them back together using geometry and trig.

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 21st Jun 2011 08:45 Edited at: 21st Jun 2011 09:48
Quote: "Hmmm, I think the simplest method I've come across uses trig."


LIES!!!!

[edit]

Well... I tried writing a tutorial but it's really too much to explain a whole other style of math in one post. Suffice it to say that some vector multiplications can solve the above problem, no trig involved (errm, although conceptually trig is involved). It'd look something like this:

where all variables starting with capital letters are vector quantities, and all starting with lowercase are scalars. I believe something like this would work:

I can write up a c++ example if it'd help.

[edit2]
also this post/project of mine is relevant. The code posted there doesn't use collision as I described, but I did try out that style collision.

http://forum.thegamecreators.com/?m=forum_view&t=167604&b=6


Why does blue text appear every time you are near?
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 21st Jun 2011 17:42
Quote: "Ah, but 199.9999 repeating is in fact exactly equivalent to 120, not just close, no?"


Indeed.

Ah Neuro I knew you'd have all the answers. :3 Your project was where I got inspiration from, but I couldn't remember where I'd seen it.


I guess it would be beneficial to take a look over your source code to help me understand.

Thanks a lot guys!

lazerus
17
Years of Service
User Offline
Joined: 30th Apr 2008
Location:
Posted: 21st Jun 2011 18:08 Edited at: 21st Jun 2011 18:09
Heh close enough for doing the math of it off the top of my head.

bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 21st Jun 2011 18:29
Saw the title of the OP and immediately thought of Portal!!

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 22nd Jun 2011 02:04
Instead of attempting to explain everything here, which would take forever... I've taken the liberty of looking up a document that is probably just what you're looking for.

This deals with vector math and not trigonometry, so the math should be fairly easy on the processor (assuming you're not simulating a galaxy )

http://www.vobarian.com/collisions/


Good luck!


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 22nd Jun 2011 02:09
Ah wow, you hit gold with that one. I hope you didn't spend too long looking for it. :3 Thanks a lot! I'll let you know how it goes.

Thanks

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 22nd Jun 2011 02:12
Didn't look for too long. It was a bottom link on the elastic collision wikipedia page


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 22nd Jun 2011 19:04
Woo, I got 1D Collisions working.

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 22nd Jun 2011 23:49
Sweet, triple dat multi-dimensional vector calculation!

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 23rd Jun 2011 00:02
Also... Most vector equations work for any number of dimensions. So say you have a vector class "NVector", with all the standard operations (like dot product, scalar multiplication, addition, subtraction, etc). If you work out a vector equation, then it's applicable in all dimensions! (most of the time)

So just by increasing the number of values stored per vector, and change the definitions of the dot product/what not methods, then you have collision in n-D!

I kinda wanted to adjust my n-body thing to 3d, then 4d, but... the rendering would just be too hard.


Why does blue text appear every time you are near?
Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Jun 2011 00:47
And unfortunately a 4d representation is too complex for our feeble minds to comprehend, let alone determine if there was a collision between somethings or not.


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 23rd Jun 2011 01:24
Oh no, don't talk about 4D. D: I can't do 2D yet. Dumb question probably, but what are dot product and scalar multiplication?

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Jun 2011 01:33 Edited at: 23rd Jun 2011 01:34
They are used extensively for manipulating vectors.

Dot product pretty much takes vector A, projects it onto vector B, and returns the resulting vector. To picture this, envision an imaginary line forming a right triangle between vector A and vector B (Does not necessarily line up with the end of vector B), where that imaginary line comes into contact with vector B, chop the rest off and what you're left with is the new vector.
Or, you can look up dot product on wikipedia, which has a few good pictures to show what it's doing.

The dot product plays a huge part in depricating the need for trigonometry here.

Scalar multiplication is a fancy way of saying that you're making the vector bigger or smaller by multiplying it with a single number (the scalar).


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 23rd Jun 2011 01:58
Scalar Multiplication should have been fairly obvious to me.

But I can't get my head around dot product. I'm sure I will in time, thanks.

BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 23rd Jun 2011 03:21
I still don't exactly understand what the dot product represents, and I just took a university-level linear algebra class. I just use it and move on with my life .

Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 23rd Jun 2011 03:26
Well if you did it at that level and don't understand it, I certainly don't have a chance at it.

BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 23rd Jun 2011 03:31 Edited at: 23rd Jun 2011 03:32
Actually, Plystire's explanation is about five times better than anything the prof taught us about dot products, so don't give up hope .

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 23rd Jun 2011 04:28 Edited at: 23rd Jun 2011 04:31
Well... I find I can't really understand something without first proving it, so without further adieu... you have two vectors:

A=<ax,ay> and B=<bx,by>

A.B=ax*bx+ay*by (by definition)

Now... Take this image:



The two lines from the origin represent the two vectors, A and B, and are labeled as such. s, k, and θ are all angles.

We can see that θ is the angle inbetween x and k. That means:

θ=s-k OR θ=k-s.

If you take the cosine of both sides of that equation, and note the property cos(x)=cos(-x), then we can say:
cos(θ[/b])=cos(s-k)=cos(k-s).

There's another very popular trig identity, which I can't quite remember, but you can derive it from euler's formula:
e^(iθ[b]
)=cos(θ[/b])+i*sin(θ[b])

So... [finding a different identity]
e^(iθ[/b])*e^(-ik)=e^(i*(θ-k))=cos(θ-k)+i*sin(θ-k)=...
...=(cos(θ[b]
)+i*sin(θ[/b]))(cos(-k)+i*sin(-k))
using the distributive property on that gives us an equarion in the form:
cos(θ-k)+i*sin(θ-k)=blah1+i*blah2
so
cos(θ-k)=blah1,
aaand multiplying out, and including the identity sin(-k)=-sin(k), you get:
[b][done finding identity]

cos(θ-k)=cos(θ[/b])*cos(k)+sin(θ[b])*sin(k)

So applying that to one of our equations:
cos(θ[/b])=cos(s-k)
=cos(s)*cos(k)+sin(s)*sin(k)

So there, we said it:
cos(θ[b]
)=cos(s)*cos(k)+sin(s)*sin(k)


Now lets take a moment to look at the picture again, and try to find the four values cos(s), cos(k), sin(s), and sin(k), but only given vectors A and B.

sin=opposite/hypotenuse, and the length of the hypotenuse is sqrt(a.x*a.x+a.y*a.y), which in vector shorthand is ||A||.
sin(s)=a.y/||A||
sin(k)=b.y/||B||

cos=adjacent/hypotenuse, so as before:
cos(s)=a.x/||A||
cos(k)=b.x/||B||

plugging those into our above equation:

cos(θ[/b])=cos(s)*cos(k)+sin(s)*sin(k)=a.x*b.x/([b]||A||*||B||)+a.y*b.y/([/b]||A||*||B||)

and if we multiply both sides by the length of A times the length of B:

||A||*||B||*cos(θ[b]
)=a.x*b.x+a.y*b.y

So... that's where that identity comes from. I'll try to write up an example with the geometric interpretation of it. The first obvious one is that if the angle between A and B is 90 degrees, the cos(90)=0, so A.B=0

[edit]
also, keep in mind, plaintext makes math look horrific. It's much nicer if you write it out xD


Why does blue text appear every time you are near?
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 23rd Jun 2011 05:07
Err, this demonstration is just as useful:
http://www.falstad.com/dotproduct/

The yellow line would be the dot product of A and B IF B (the blue line) had a length of one.


Why does blue text appear every time you are near?
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 23rd Jun 2011 12:12
Whoa.. thanks a lot Neuro, I'm sure that'll be very helpful when I get my head around it. I gave it a read last night but I was too tired to take any of it in.

I'll let you know how it goes, thanks so much for taking the time to explain it.

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Jun 2011 23:13 Edited at: 23rd Jun 2011 23:16
An easier way to imagine this working is to think of shining a light onto vector B such that the light is perpendicular to the vector.

So, if the light is shining straight down onto vector B, then the dot product of vector A and vector B would technically be the shadow that A casts onto B.


You know, I understand the mechanics of it all, but I've never actually come up with a real-world use for the dot product, regardless of using it many many times in predfined equations. I just must not be very creative when it comes to vector algorithms.

Don't worry about not being able to wrap your head around it all... It takes me FOREVER to understand a concept unless I can utilize it myself in my own way. Since I never was able to do that (relying instead on its use in "prebaked" equations), I took forever to understand the dot product.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 26th Jun 2011 02:55 Edited at: 26th Jun 2011 18:39
I think I finally understand how to do this! Thanks so much guys, again. I'll let you know if/when I get this working, hell, I'll even post the source somewhere in case anybody else needs help with this.

EDIT: Or maybe not, just an epic fail on my part. Below is the source I currently have, if anybody has the time to take a quick look through at and point out any flaw I've made I'd bake them a cake. The balls just bounce then travel in the same direction. I'm very confused.



Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 27th Jun 2011 12:47
Not really helpful for your problem, but you can speed up your distance check by removing the square root, and instead squaring the col_distance (a^2 + b^2 = c^2)

I'll take a look tomorrow, if no one else replies. Sorry, just too tired to think with arrows right now.


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Jun 2011 12:52
Ah, you're right, thanks. :3

No rush, don't apologize either, I don't expect you to look through, just if you have time and you're bored. Normally when I hit a block I leave it for a couple of days and come back to it, and it usually works.

Thanks.

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 28th Jun 2011 00:37
Not entirely sure, but I believe there's an order of operation problem on this line:

Quote: "v1n = v1n*( m1# - m2# ) + 2*m2#*v2n/(m1#+m2#)"


should look like:

Quote: "v1n = (v1n*( m1# - m2# ) + 2*m2#*v2n)/(m1#+m2#)"


Otherwise the division takes place BEFORE the addition. See if that helps out any.


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 28th Jun 2011 00:42
That didn't help. Thanks for taking the time though. I guess I'll just have to rewrite it, as I haven't got a clue xD

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 28th Jun 2011 00:45
Hmmmm... what is it doing right now then?


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 28th Jun 2011 00:51 Edited at: 28th Jun 2011 00:52
The same as before, both circles head in the same direction after collision. At the same speed, joined at the point of collision.

EDIT: If they don't hit head on, the don't move at all. I've done something very wrong.

Plystire
22
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 28th Jun 2011 01:01
Sounds like you need to debug it a bit. Looked over your collision math and don't see anything wrong (but might have missed something). In these situations I find that manually following the code and cross-checking the math myself with variables helps to weed out where problems are occuring. Maybe you can have the program print out what values everything is being set to upon collision, then go back with that information and see if it's right or wrong. If it's right, then find out why the circles aren't being given the velocities they should be, and it it's wrong, you may be able to find out where it's wrong based on the debug info.


Good luck!


~Plystire

Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 28th Jun 2011 14:59
Thanks. Looks like I'm in for a long night. :3

Login to post a reply

Server time is: 2025-05-21 05:29:21
Your offset time is: 2025-05-21 05:29:21