[英]How to bounce a point to hit a line with a certain angle
我有一条直线和一个点,直线具有一个角度{ angle }
point具有一个速度{ x, y }
,一点移动到直线上并命中它。 在这一点上,我想更改点的速度,就好像该点相对于线角度从线中反弹一样。 如何根据线角计算点的新速度?
没有“重力”? 完美的弹性?
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}
(注意:我不知道相对于a
是什么-垂直或水平,也不知道哪个方向。并且可能还有其他问题。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.