Expand description
§Never Tell Me The Odds
§Part One
We find the intersection for each pair of hailstones by solving a pair of linear simultaneous equations in 2 unknowns:
a
andg
are the x positions of the pair of hailstones.b
andh
are the y positions.d
andj
are the x velocities.e
andk
are the x velocities.- Let
t
andu
be the times that the first and second hailstone respectively are at the intersection point.
Then we can write:
a + dt = g + ju
=>dt - ju = g - a
b + et = h + ku
=>et - ku = h - b
In matrix form:
| d -j ||u| = | g - a |
| e -k ||t| | h - b |
Solve by finding the inverse of the 2x2 matrix and premultiplying both sides. The inverse is:
______1______ | -k j |
d(-k) - (-j)e | -e d |
Then we check that both times are non-negative and that the intersection point is inside the target area.
§Part Two
First we choose 3 arbitrary hailstones. Then we subtract the position and velocity of the the first to make the other two relative.
The two hailstones will intercept a line leaving the origin. We can determine this line by intersection the two planes that the hailstone’s velocity lie in. These planes are defined by a normal vector orthogonal to the plane.
This normal vector is the cross product of any two vector that lie in the plane, in this case the velocity and also the vector from the origin to the starting location of the hailstone.
The direction but not necessarily the magnitude of the velocity is then given by the cross product of the two normals.
Given the rock direction we can calculate the times that the two hailstones are intercepted then use this to determine the original position of the rock, as long as the two times are different.
Structs§
- Vector 🔒
Constants§
- RANGE 🔒