Physics Equation

Robotoer

Member
Nov 9, 2004
39
0
0
I'm currently trying to program a physics engine of some sort. I would like it to be able to calculate changes in velocity, spin, direction, and shape of objects during a collosion. I've gotten to being able to calculate the changes in velocity of 1 dimensional point masses. I used Conservation of Momentum and Conservation of energy to come up with the most evil quadratic i've ever seen. I am having trouble with 1 dimensional collisions with compression taken into account. For example, lets say two 1 dimensional objects(line segments) collide. you are given their masses, velocities, and their compressability(i don't know what to use for this). once they collide, how do you find the new volume(length) of the 1 dimensional objects and their new velocities? Also, how do you calculate spin and how do you get the new direction of an object if it doesn't hit a surface head-on?

I would appreciate any help. Thankz in advance.





The Math:
M = momentum, m = mass, v = velocity, E = energy

Momentum of an object given it's mass and velocity(includes direction)
M = mv

Energy of an object given it's mass and velocity
E = (1/2)mv^2

Conservation of Momentum - momentum in a collision is neither created or lost
Momentum of object 1 + momentum of object 2 = new momentum of object 1 + new momentum of object 2

Written with variables:
(m1 = mass of object 1, m2 = mass of object 2, v1 = original velocity of object 1, v2 = original velocity of object 2, v3 = new velocity of object 1, v4 = new velocity of object 2)
m1*v1 + m2*v2 = m1*v3 + m2*v4

Conservation of Energy - energy in a collision is neither created or lost
Energy of object 1 + energy of object 2 = new energy of object 1 + new energy of object 2

Written with Variables:
(m1 = mass of object 1, m2 = mass of object 2, v1 = original velocity of object 1, v2 = original velocity of object 2, v3 = new velocity of object 1, v4 = new velocity of object 2)
(1/2)m1*v1^2 + (1/2)m2*v2^2 = (1/2)m1*v3^2 + (1/2)m2*v4^2


Okay... ready for the quadratic of doom? First, if your wondering why i'm getting another equation, here's why: I solved for v3(new velocity of object 1) so i could use that to solve for v4. Remember, this is going into a program, so i need to find an equation that can work for all situations. First what i did was solve one of the equations for v4. I then substituted the value into the other equation and solved for v3. By doing that i came up with this evil quadratic:

v3 = ( - (( 2 * pow (m1, 2) * v1) + (2 * m1 * m2 * v2)) + sqrt ( pow (((2 * pow (m1, 2) * v1) + (2 * m1 * m2 * v2)), 2) - 4 * (( -m1 * m2)- pow (m1, 2)) * ((-pow (m1, 2)*pow (v1, 2)) - (2 * m1 * m2 * v1 * v2) + (m1 * m2 * pow (v1, 2))))) / (2 * ((-m1 * m2) - (pow (m1, 2))))

Yeah... Trust me, it works. I basically ended up using the quadratic forumula, except a, b and c all were made up of other variables. This works, because everything except for v3 and v4 are given.
 

Robotoer

Member
Nov 9, 2004
39
0
0
I've looked at that before. The only problem was that that engine is a rigid body engine. I want to see if i can make a physics engine that can calculate changes in objects.
 

Woodchuck2000

Golden Member
Jan 20, 2002
1,632
1
0
Originally posted by: Robotoer
I've looked at that before. The only problem was that that engine is a rigid body engine. I want to see if i can make a physics engine that can calculate changes in objects.
Seriously, no. Other than the most basic hooke's law calculations there's no such thing as "Compressibility". When two bodies collide you get into incredibly complex maths very very quickly. Look up Finite Element Analysis.

It currenlty takes a fast 8 cpu server about a day to estimate what happens if two cars collide head-on. You're never going to come close in real time.
 

Woodchuck2000

Golden Member
Jan 20, 2002
1,632
1
0
Oh, and you're assuming a perfectly elastic collision and zero spin. Chuck that equation away, it won't help you.
 

PlasmaBomb

Lifer
Nov 19, 2004
11,636
2
81
Originally posted by: Robotoer

Conservation of Energy - energy in a collision is neither created or lost
Energy of object 1 + energy of object 2 = new energy of object 1 + new energy of object 2

Conservation of Energy is great but it would really be -
Energy of object 1 + energy of object 2 = new energy of object 1 + new energy of object 2 + heat + sound + light (depending on what hits what, for example sparks from metal to metal contact)

The heat component will in itself have several parts - heat stored by the bodies due to their compression not being efficient, heat loss to the environment as heating up air and general surroundings.
 

Woodchuck2000

Golden Member
Jan 20, 2002
1,632
1
0
Originally posted by: PlasmaBomb
Originally posted by: Robotoer

Conservation of Energy - energy in a collision is neither created or lost
Energy of object 1 + energy of object 2 = new energy of object 1 + new energy of object 2

Conservation of Energy is great but it would really be -
Energy of object 1 + energy of object 2 = new energy of object 1 + new energy of object 2 + heat + sound + light (depending on what hits what, for example sparks from metal to metal contact)

The heat component will in itself have several parts - heat stored by the bodies due to their compression not being efficient, heat loss to the environment as heating up air and general surroundings.
Plus energy lost through deformation, don't forget. Also remember that for pretty much anything except two solid spheres, the impact won't be at a single point.

 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
You can't have 'compression' in 1-D, as a 1-D object doesn't have volume. You could do this in 2-D by reducing the dimensions of a 3-D system by assuming axisymmetry or similar. The volume reduction is related to the Poisson Ratio, which is the negative ratio of transverse strains. Unless you have a background in solid mechanics, I wouldn't even consider this - just stick with incompressibility.
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,601
166
111
www.slatebrookfarm.com
I only glanced at your equations above...
But, given your difficulties with 2 dimensional motion, I'd probably deal with it using parametric equations -
the x-coordinates as a function of time and the y-coordinates as a function of time.

Also, I understand what cyclo-wizard is saying about compression in 1-D.
But, I'm looking at your problem in a different manner. I'm thinking of it as motion in one dimension with 3 dimensional objects. i.e. drop a ball verticallly and have it bounce off the floor.

I'd slowly add features to any engine you're building, working with one physics concept at a time until you're satisfied that your engine is working fairly well.

Also, if you look for java applets, there are TONS on physics education sites that do work with some of the things you're talking about. Perhaps if you look at some of these, you'll find some of your solutions. There are a lot of momentum demos that I've used in class. And, many of these demos allow you to adjust between a perfectly inelastic collision and a perfectly elastic collision. Unless I'm mistaken, you'll know how elastic or inelastic the collision is going to be just from the materials that are colliding. No, I take that back... I'm not 100% certain, I'm thinking of spheres colliding. Regardless, drop the conservation of energy. Yes, it's a valid law, but you're *probably* not going to need it to do your problems.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Originally posted by: DrPizza
I only glanced at your equations above...
But, given your difficulties with 2 dimensional motion, I'd probably deal with it using parametric equations -
the x-coordinates as a function of time and the y-coordinates as a function of time.

Also, I understand what cyclo-wizard is saying about compression in 1-D.
But, I'm looking at your problem in a different manner. I'm thinking of it as motion in one dimension with 3 dimensional objects. i.e. drop a ball verticallly and have it bounce off the floor.

I'd slowly add features to any engine you're building, working with one physics concept at a time until you're satisfied that your engine is working fairly well.

Also, if you look for java applets, there are TONS on physics education sites that do work with some of the things you're talking about. Perhaps if you look at some of these, you'll find some of your solutions. There are a lot of momentum demos that I've used in class. And, many of these demos allow you to adjust between a perfectly inelastic collision and a perfectly elastic collision. Unless I'm mistaken, you'll know how elastic or inelastic the collision is going to be just from the materials that are colliding. No, I take that back... I'm not 100% certain, I'm thinking of spheres colliding. Regardless, drop the conservation of energy. Yes, it's a valid law, but you're *probably* not going to need it to do your problems.
:thumbsup:

Chasing the exact solution is way beyond the scope of what you should be looking to do. Indeed, most (if not all) realistic problems involving collisions don't have an exact solution. They may, however, be approximated to an arbitrary degree of accuracy by selecting a suitable model. This is the premise of finite element modeling, which is what you'd need to do if you really wanted to get into the nitty-gritty of these collisions. However, as someone else mentioned, there's no way you could hope to do this in real-time. Thus, your best bet is to come up with a 'good enough' approximation that achieves what you're looking for.
 

Robotoer

Member
Nov 9, 2004
39
0
0
Originally posted by: CycloWizard
:thumbsup:

Chasing the exact solution is way beyond the scope of what you should be looking to do. Indeed, most (if not all) realistic problems involving collisions don't have an exact solution. They may, however, be approximated to an arbitrary degree of accuracy by selecting a suitable model. This is the premise of finite element modeling, which is what you'd need to do if you really wanted to get into the nitty-gritty of these collisions. However, as someone else mentioned, there's no way you could hope to do this in real-time. Thus, your best bet is to come up with a 'good enough' approximation that achieves what you're looking for.

Yeah, That was what i was getting to, but i would like to create a physics engine as real as possible. To do deformations, i'm satisfied with a close approximation, but the part dealing with motion shouldn't be too hard.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Originally posted by: Robotoer
Does anyone know of how i could approximate deformations?
Well, to get any sort of realistic approximation, you need finite element analysis. You simply can't solve higher-dimension deformation problems with any sort of geometric complexities without it. If you want to treat everything as a 1-D body for collision purposes, then you could use simpler techniques, but nothing would be very 'real'.
 

M1CH43L

Junior Member
Oct 22, 2005
9
0
0
Concerning velocity and vertical displacement i have some equations that could help you that i just took a test on in my physics class .
*=Delta in this equation (change)
y=vertical displacement
Vi=Initial velocity
Vf=Final velocity
Vyi=Vertical initial velocity
Vyf=vertical final velocity
x=displacement
t=time
a=gravatational accelertaion (-9.81)
Vx= constant horizontal acceleration
also this is all for calculations for no air resistance
*y = Vyi(t)+1/2(a)t^2
VyF^2=Vyi^2+2(a)^y
Vyf=Vyi+a(t)
*x=(Vx)(t)
*x=1/2(Vi+Vf)t

probably doesn't help because you're way ahead of me but if that helped there ya go
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |