Archived

This topic is now archived and is closed to further replies.

ScrewWorkn

Got a line and a Direction, angle of rebound?

Recommended Posts

ScrewWorkn    122
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest 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..

Share this post


Link to post
Share on other sites
ScrewWorkn    122
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.

Share this post


Link to post
Share on other sites
Jesper T    322
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

Share this post


Link to post
Share on other sites