【发布时间】:2015-05-10 19:19:42
【问题描述】:
我有一个类似的问题,但虽然我得到了社区的帮助,但我无法解决。
我有以下问题: 球向移动线移动。 我想知道球何时撞到线。
我最好的解决方法:
所有变量:
f(x) ... The line of the ball movement
g(x) ... The line before it moved
g1(x) ... The line after it moved
g2(x) ... The line after it moved + the radius (when the ball center hits this line, the ball border hits g1(x)
A (Ax, Ay) ... First point of the line before it moved
A1 (A1x, A1y) ... First point of the line after it moved
B (Bx, By) ... Second point of the line before it moved
B1 (B1x, B1y) ... Second point of the line after it moved
Vc (Vcx, Vxy) ... Speed of ball
Va (Vax, Vay) ... Speed for point A
Vb (Vbx, Vby) ... Speed for point B
r ... Radius of the ball
t ... Time of collision
- 我计算 A1 和 B1
A1 = (Ax + Vax * t, Ay + Vay * t)
B1 = (Bx + Vbx * t, By + Vby * t)
- 我为 g1(x) 建立方程
g1: y1 = k1 * x + d1 (y = kx + d)
k1 = (B1y-A1y)/(B1x-A1x) (k = (dif between y)/(dif between x))
d1 = A1y - k1 * A1x (d = y - kx)
- 我为 g2(x) 建立方程
g2: y2 = k1 * x + d2
- 我使用两条平行线之间的距离方程计算 d2 (see wikipedia)。我知道 g1(x) 和 g2(x) 之间的距离是球的半径
r = abs(d2 - d1)/sqrt(k1^2 + 1)
我为 d2 解决它
我为 f(x) 建立方程
f: y = k * x + d
k = Vcy/Vcx
d = Cy - k * Cx
- 我计算交点
f(x) = g2(x)
- 我解决了这个问题
Microsoft 数学和我的 TI Nspire CX CAS 能够计算除第 8 步之外的每一步
有没有更简单的方法?
或者你知道任何应该能够解决它的程序吗?
(我的老问题:click me)
【问题讨论】:
-
哦。所以
(y = kx + d)有点像评论,因为(现在很清楚)是(k = (dif between y)/(dif between x))。我明白。最初没有努力做到这一点。 -
我有一个名为 Derive 的 Windows CAS,我想给出
f(x) = g2(x)等式。并不是说它可以或将解决t,但它会比 Nspire 更快。 -
P.S. Nspire 由 Derive 驱动,在 TI 收购它并将其从市场上撤下以销售更多几乎功能不那么强大的计算器之前,它是一个开发出色、功能强大的 CAS .
-
刚刚有人建议我转移到聊天室,但我怀疑我还有很多要补充的,所以我们不要。
-
在
_上导出扼流圈,所以我删除了所有内容并提出了一个关于多字母变量的方程——并列不是乘法; SPACE 是乘法(例如,vax是一个变量,t vax是“t乘以该变量”):-(t vax+Ax )) (t vby-t vay+By-Ay )+r √((t vby-t vay+By-Ay )^2+1)+x (t vby-t vay+By-Ay )+t vay+Ay=(x vy-Cx vy)/vx +Cy。如果这抓住了这个想法,它就能够解决t,这是一个可怕的混乱,我将作为答案发布IF那个方程是正确的。而混乱表明不是。
标签: java math collision-detection collision