1

Im not good at math, I could find everything so far, but not this one. And I just cant figure it out. I think Im just not seeing it. Im calculating directions, two circles collide, one has an incoming direction, and needs to get an outgoing direction.

So far I know how to get the collision point and I can calculate the incoming/outgoing angle alfa. (Calculating the angle between two lines without having to calculate the slope? (Java))

Im stuck on constructing the outgoing line and retrieving the m or a ( y = ax + b ).

enter image description here

So, from the picture, I know y, i, alfa and the point where all lines intersect (not marked, sorry).

Could anyone help me out? Im programming in Java.

Community
  • 1
  • 1
T-W
  • 162
  • 1
  • 7
  • This is a pure maths question, so is probably off-topic for Stack Overflow. But I highly recommend that you spend some time reviewing geometry/algebra, as without it programming things like this (a game?) will not be productive. – Oliver Charlesworth Mar 18 '12 at 20:55
  • I believe this question would be more suited to http://math.stackexchange.com – jwodder Mar 18 '12 at 20:56
  • Two circles collide? Where is the second circle? To me this is more of an elementary physics (mechanics) question than anything else. Are the circles (balls) deformable? That introduces another dimension in the question. – Rook Mar 18 '12 at 20:58
  • Im sorry, you are absolutely right. Ill head over to math. I just got sucked into it. The circle currently has nothing to do with the situation. – T-W Mar 18 '12 at 21:09

1 Answers1

1

If momentum is conserved during a collision with a horizontal boundary, the collision will just flip the sign of m. That is the m value afterward is -1 times the m value before.

Suppose the equation of the original line is y=mx+c and the equation of the line after the collision is y=-mx+b. At the intersection point, the x and y values are the same.

To avoid confusion later, we'll call the x and y-values of the collision point (X,Y) not (x,y)

At the intersection the line equations for both lines hold (for x=X, y=Y). So,

Y = mX+c = -mX+b.
=> mX+c+mX = b (adding mX to both sides)
=> 2mX+c = b (collecting the terms in m)

So the intercept of the second line (which you referred to as "m or a" in your question) is 2mX+c, where X is the x-position at which the collision occurs. Hence the equation of the second line is:

y = -mx + (2mX + c)
James Youngman
  • 3,623
  • 2
  • 19
  • 21