vector - Ball-Line Collision Bounce Angles Python -
i'm writing program wherein user creates lines (represented (x1,y1,x2,y2)) balls subject gravity bounce off . these lines therefor not horizontal. i've been having trouble getting correct bounce angles. found sources provided method in order use need find line's bounce angle.
obviously there 2 possible normal vectors need 1 faces towards side of ball collision. problem need use tkinter in program , because of timestep collision detection works in way lets ball dip past line before collision detected. can't use center of ball (cx, cy) determine correct normal vector. i'm overcomplicating in head, i'm having trouble coming solution. think needs involve incident velocity vector (vx, vy) of ball on collision, i'm not sure how.
any ideas appreciated!!
the correct normal vector use 1 such n scalar v = n.x v.x + n.y v.y
negative. indeed, scalar product positive when 2 vectors globally in same direction. wanting negative means have 2 opposite-pointing vectors, want.
however, cannot define such normal vector on angles, not know how programmed algorithm careful edge case.
Comments
Post a Comment