Collision and Deflection in N-Body Simulations: Finding the Vector Solution

In summary: So, how do I go from x-y' to x-x'? Thanks for your help!You can use the Pythagorean Theorem to solve for x-x': (y-y')/(x-x')=Pythagoras(x-x')
  • #1
RossH
75
0
@Admin: question doesn't really lend itself to the template, so I'm not going to use it.

Hello. I am writing an N-body simulation program and am currently trying to add deflection/collision functionality and am having trouble figuring out how to do this.

So, I have two bodies coming towards each other at arbitrary vectors. Say, I have one at (0,0) moving along the vector (1,3) and one at (5,5) moving along the vector (-4,-2). These will obviously collide at the point (1,3) and then I have to figure out how they are going to deflect. (this is only in the x-y plane)

As I see it, there should be some sort of plane between the two bodies that I can pretend they reflect off of, and then use the angle incidence=angle deflection with that plane. I know the velocity of my bodies in the x and y directions, so it would be that hard to find the new velocity of the two bodies if I knew the plane, using trigonometry, but I am unsure how I would go about finding that plane. The problem is, of course, that both bodies are moving.

Thanks for any help you can provide.
 
Physics news on Phys.org
  • #2
Consider the line from the center of one mass to the center of the other, at the instant of contact. The plane you want is perpendicular to this line and passes through the point of contact. The force on each mass will be along the line. But it isn't like each reflecting off a wall. Consider, for example, a moving pool ball hitting a stationary one; the first will stop while the other carries off all the kinetic energy. I suppose that would be like a reflection in the frame of reference of the center of mass.
 
  • #3
Delphi51 said:
Consider the line from the center of one mass to the center of the other, at the instant of contact. The plane you want is perpendicular to this line and passes through the point of contact. The force on each mass will be along the line. But it isn't like each reflecting off a wall. Consider, for example, a moving pool ball hitting a stationary one; the first will stop while the other carries off all the kinetic energy. I suppose that would be like a reflection in the frame of reference of the center of mass.

Thanks!

For the purposes of this project I am assuming that both bodies will continue moving with a reduced momentum relative to their original momentum, just because I don't know enough physics to know what will happen and monitoring all of the conservation of energy, momentum, etc would be unnecessary programming.

Anyway, how do I find this plane? Suppose I have two bodies colliding with centers at (1,2) and (2,3), so I suppose they have radius of (1/2)sqrt(2). The point of contact is (1,2)+(sqrt(2)/2)*(1,1)=(1+sqrt(2)/2, 2+sqrt(2)/2). I'll call this (x', y'). I need to find a plane (or I guess a line would work just as well) that passes through this point as is perpendicular to the vector (1,1).

This seems like a dot product type thing. I know that (-y', x') is orthogonal to my original vector, but that wouldn't always pass through my point. Is it legal to take (-y'/x') and then translate it by adding (x', y') so that what was the origin will now pass through my point? Would this work?

Thanks!
 
  • #4
You have a point and a slope (The perpendicular slope is the negative reciprocal of the slope of the original line, so -1 in the example). The equation of the perpendicular line is (y-y')/(x-x') = -1.
 
  • #5
Delphi51 said:
You have a point and a slope (The perpendicular slope is the negative reciprocal of the slope of the original line, so -1 in the example). The equation of the perpendicular line is (y-y')/(x-x') = -1.

Wow, I'm stupid. Thanks. So, more generally, if my two bodies are at (x1, y1) and (x2, y2) when they collide, and the point of contact is (x', y') then the equation of the line will be
(y-y')/(x-x')=-(x1-x2)/(y1-y2)

Is this correct? Thanks for the help! If so, I think I can figure out the rest of it on my own.
 
  • #6
Looks good! And good luck with your program.
I once tried to make a curling rock program but ran out of energy when I tried to include spin.
 
  • #7
Hi again!

Alright, I've realized that this is actually a lot harder than I thought. So, now I have the line so I can treat the problem as just a single body deflecting off a line. The problem is that all of my information is in x-y coordinates, and I can assume that the line will be slanted, so the vector that describes the motion of this body as it approaches my line is in the wrong coordinate system. I can't break it up into x and y components in the coordinate plane of the line that I am using, or at least I'm not sure how.

I uploaded a picture to describe what I mean. (Sorry about the quality- I don't have a scanner) The information that I have is X and Y, but the information that I need is X' and Y' if the line through point p is the line I am deflecting off of. I'm sure that there is a simple trigonometry trick to find this information, but I don't know where to start.

Anyway, thanks for your help.
 

Attachments

  • paint.jpg
    paint.jpg
    8.7 KB · Views: 441
  • #8
You need to calculate how far apart the circles are (distance from (x1,y1) to (x2,y2)). When that distance is equal to 2R, you have a collision and must figure out how the velocities change. The contact point (x',y') is just the midpoint of the line segment from center to center (average of x coords, average of y coords).

I think that "deflecting" off the common tangent line is a poor idea. In reality, much depends on the relative velocities of the objects. A better approach would be to figure out the momentum of each along the direction joining the centers and do a conservation of momentum and conservation of energy calc (or lose a few % if you wish) to determine the change in momentum in that direction. No change in the perpendicular direction. I don't think the computer time consumed in that calc will be significant.
 
  • #9
Delphi51 said:
You need to calculate how far apart the circles are (distance from (x1,y1) to (x2,y2)). When that distance is equal to 2R, you have a collision and must figure out how the velocities change. The contact point (x',y') is just the midpoint of the line segment from center to center (average of x coords, average of y coords).

I think that "deflecting" off the common tangent line is a poor idea. In reality, much depends on the relative velocities of the objects. A better approach would be to figure out the momentum of each along the direction joining the centers and do a conservation of momentum and conservation of energy calc (or lose a few % if you wish) to determine the change in momentum in that direction. No change in the perpendicular direction. I don't think the computer time consumed in that calc will be significant.

Yeah, I figured out how to check for when a collision is happening (actually, the bodies have variable radius, so it's when r1+r2>distance) and I figured out how to find the contact point (I'm using similar triangles).

Anyway, I'm not sure I understand what you are suggesting. So, at the point of collision both bodies deflect so that the portion of their momentum along the line connecting the centers is reversed, and both momentum and energy are conserved?

Would you mind terribly working an example problem with me?

So, I have two bodies, Body A is at (2,4) with r=2 inches and Body B is at (3,7) with r=1.16 inches.

Body A has a velocity of (1,2) and Body B has a velocity of (-2, 4) inches/second.

Body A has a density of 2g/in^2 and Body B has a density of 1g/in^2.

Therefore, Body A has mass of pi*r^2*p=25.13g and Body B has mass of 4.23g.

Body A has momentum 56.19 units (mass*velocity) and Body B has momentum 18.9 units
Body A has KE (1/2*m*v^2)=62.83 and Body B has KE=42.3

So now I need to figure out their new directions. The line connecting their centers is y-4=3(x-2).

Now I'm not sure what to do.
 
  • #10
A's v is at angle invTan(2/1) = 63.4 degrees counterclockwise from x direction
B's v is at 116.6 degrees counterclockwise
Unfortunately these angles don't always work out directly with inverse tan. For the B one , I had to add 180 degrees. You'll have to test a variety of directions and come up with a set of rules to adjust them.
A's momentum in the direction of slope= 3 (angle 71.6) is 56.19*cos(71.6-63.4) = 55.6.
B's momentum in that direction = 18.9*cos(116.6-71.6) = 13.4
Now using 1 instead of A, 2 instead of B
Conservation of momentum for the collision says m*v + m*v = m1*v1 + m2*v2
55.6 + 13.4 = 25.13*v1 + 4.23*v2 [1]
Conservation of energy says mv² + mv² = m*v1² + m2*v2²
125.6 + 84.4 = 25.13*v1² + 4.23*v2² [2]
Solve [1] for v2: v2 = 16.3 - 5.94v1
and sub in [2]: 210 = 25.13*v1² = 4.23(16.3 - 5.94v1)²
Quadratic solution: v1 = 27.6 or 0.328
sub in [1] to get: v2 = -148 or 14.4
B was originally going forward on the collision line, and was hit from behind, so it must continue going forward and the first solution is unreasonable. Conclude
A's speed after the collision is .328, B's is 14.4 along the collision line.
A's velocity perpendicular to the collision line was and is 2.24*sin(90-63.4) = 1
B's velocity perpendicular to the collision line was and is 4.47*sin(90-45) = -3.16
(I had to use my diagram to get the sign on B so some rule will be needed in the program for these two calcs)
A is (.328, 1), B = (14.4, -3.16) in the collision direction coordinates
A is (1.05, 71.8 degrees), B is (14.7 at -12.4 degrees)
Now we have to translate these back to the x,y coordinates.
A = 1.05 at 71.8-71.6 = 1.05 at 0.2 degrees, B = 14.7 at 71.6+12.4 = 14.7 at 84 degees.
Oh, dear, I have to for supper. And I realize this is way too complicated to be done correctly. Better to program it with some functions for rotating coordinates.
 

What is meant by "vector of deflection"?

The vector of deflection refers to the direction and magnitude of an object's displacement or deviation from its original position or trajectory. It is a measure of how far and in what direction an object has been moved or bent due to an external force.

How is the vector of deflection calculated?

The vector of deflection is calculated by measuring the initial position of an object and then measuring its final position after it has been subjected to a force. The displacement or deviation between these two positions is then represented as a vector, with the direction and magnitude determined by the change in position.

What factors can affect the vector of deflection?

The vector of deflection can be affected by various factors, including the magnitude and direction of the applied force, the properties of the object (such as its mass and stiffness), and any external constraints or supports that may be present.

Why is finding the vector of deflection important?

Knowing the vector of deflection can provide valuable information about the behavior of a system or structure under different types of forces. It can also help in designing and analyzing structures to ensure their stability and safety.

What are some common methods for finding the vector of deflection?

Some common methods for finding the vector of deflection include using mathematical equations, physical experiments, and computer simulations. Each method has its own advantages and limitations, and the choice of method depends on the specific situation and the accuracy required.

Similar threads

  • Introductory Physics Homework Help
Replies
1
Views
79
  • Introductory Physics Homework Help
10
Replies
335
Views
8K
  • Introductory Physics Homework Help
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
20
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
11
Views
1K
  • Introductory Physics Homework Help
Replies
25
Views
1K
  • Introductory Physics Homework Help
Replies
20
Views
968
  • Introductory Physics Homework Help
Replies
14
Views
1K
  • Introductory Physics Homework Help
Replies
11
Views
1K
Back
Top