[英]How to bounce a point to hit a line with a certain angle
I have a line and a point, line has an angle { angle }
point has a velocity { x, y }
, point moves to the line and hits it. 我有一条直线和一个点,直线具有一个角度{ angle }
point具有一个速度{ x, y }
,一点移动到直线上并命中它。 At this point I want to change the velocity of the point, as if the point bounces from the line with regard to the line angle. 在这一点上,我想更改点的速度,就好像该点相对于线角度从线中反弹一样。 How do I calculate the new velocity of the point based on line angle? 如何根据线角计算点的新速度?
No 'gravity'? 没有“重力”? Perfect elasticity? 完美的弹性?
a = angle
b = atan(y/x) -- angle of 'velocity'
c = 2a-b -- angle of new velocity
r = sqrt(x*x + y*y) -- scaling of x,y
v = r * cos(c)
w = r * sin(c)
new velocity = {v, w}
(Caveat: I don't know what a
is relative to - vertical or horizontal, nor which direction. And there may be other issues.) (注意:我不知道相对于a
是什么-垂直或水平,也不知道哪个方向。并且可能还有其他问题。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.