Advertisement

Got a line and a Direction, angle of rebound?

Started by February 05, 2002 10:47 AM
2 comments, last by ScrewWorkn 23 years ago
Ok, I''m sure I should be able to figure this out, but 3 hours later I''m still stuck. (this is all 2D) I have a line segment formed from PointA and PointB. I have an Objected heading in a direction Vector (I also have the angle). I can tell if the two collide but I''m having trouble determining the angle and therefore the vector the object takes after the collision. Thanks guys. ScrewWorkn
ok, I hope you know the intersection point, if you know that try this:
calculate the angle between your plane (p) and your velocity vector (v), (cos(angle)=p dot v / |v||p|), the rotate your velocity 2 times that angle (think of p as a mirror and v as light). I think that should work..
Advertisement
quote:
Original post by Anonymous Poster
ok, I hope you know the intersection point, if you know that try this:
calculate the angle between your plane (p) and your velocity vector (v), (cos(angle)=p dot v / |v||p|), the rotate your velocity 2 times that angle (think of p as a mirror and v as light). I think that should work..


Ok, I know I should know this but to clarify. How do I get the dot of p and v, and how do I multiply |v| and |p|. When you say velocity vector is v, is that the angle that the object is moving at. What format is p specified in? I can just use a line since I''m working in 2D right? Sorry I''m very new to this stuff.
if p = {px, py} and v = {vx, vy} then:

p dot v = (px*vx)+(py*vy)

and

|p|*|v| = sqrt(px² + py²) * sqrt(vx² + vy²)

the || simply mean that you should use the lenght/absolute value

My post up, your post down, my site here

This topic is closed to new replies.

Advertisement