General > Announcements
Version 2.42.5 Released
Numsgil:
Got matlab today, here's the answer I get:
Collision occurs if c * t^2 + 2*b*t+(a-rad^2) <= 0
The actual collision (both the entrance and exit "wouds") occur at c * t^2 + 2*b*t+(a-rad^2) = 0
where:
a = deltapos dot deltapos
b = deltapos dot deltavel
c = deltavel dot deltavel
roots are at:
t = -(b +/- sqrt(b^2 - a*c + c*rad^2)) / c
EricL:
Yup, that's what I came up with.
Here's the heart of the current code...
B0 = rob(robnum).pos
d = VectorSub(vs, vb) ' Vector of velocity change from both both and shot over time t
p = VectorSub(S0, B0)
P2 = VectorMagnitudeSquare(p) ' |P|^2
D2 = VectorMagnitudeSquare(d) ' |D|^2
If D2 = 0 Then GoTo CheckRestOfBots
DdotP = Dot(d, p)
x = -DdotP
y = DdotP ^ 2 - D2 * (P2 - r ^ 2)
If y < 0 Then GoTo CheckRestOfBots ' No collision
y=Sqr(y)
time0 = (x - y) / D2
time1 = (x + y) / D2
Numsgil:
I like this double checking of answers
Navigation
[0] Message Index
[*] Previous page
Go to full version