1. Not finding help here? Sign up for a free 30min 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!

Finding vector of deflection

  1. Dec 6, 2011 #1
    @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.
  2. jcsd
  3. Dec 6, 2011 #2


    User Avatar
    Homework Helper

    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.
  4. Dec 6, 2011 #3

    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?

  5. Dec 6, 2011 #4


    User Avatar
    Homework Helper

    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.
  6. Dec 6, 2011 #5
    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

    Is this correct? Thanks for the help! If so, I think I can figure out the rest of it on my own.
  7. Dec 6, 2011 #6


    User Avatar
    Homework Helper

    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.
  8. Dec 7, 2011 #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.

    Attached Files:

  9. Dec 7, 2011 #8


    User Avatar
    Homework Helper

    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.
  10. Dec 7, 2011 #9
    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.
  11. Dec 7, 2011 #10


    User Avatar
    Homework Helper

    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Finding vector of deflection
  1. Finding vector (Replies: 1)