117 lines
4.2 KiB
Org Mode
117 lines
4.2 KiB
Org Mode
#+title: Notes
|
|
* i want help from math
|
|
https://math.stackexchange.com/questions/28503/how-to-find-intersection-of-two-lines-in-3d
|
|
|
|
'vector parametric form' is exactly what we're getting in the input?
|
|
* huh and only 'looking forward in time' so solutions with negative t are not important.
|
|
cooool
|
|
** i see that speeds are integers, so updated points are integers.
|
|
maybe i do calculation of every line on every time point?
|
|
|
|
and if i do that is there a way to get intersections efficietly?
|
|
** i'll also need the ends for lines? ends to the line segments.
|
|
with limits on the x & y by the task
|
|
|
|
for example both 7 <= <= 27
|
|
for input 200000000000000 <= <= 400000000000000
|
|
|
|
also. can't we move the coords? maybe not? maybe only for one
|
|
so, what do i do? to get the ends of the lines?
|
|
i try to calcluate with both x & y in 2 min\max. then if the other is ok, than that's the ends?
|
|
wait, what happens when i do x = 7, and x = 27 and y is outside? it means no intesections, i guess
|
|
or it could be outside from different sides, so not all x are ok, but there's still line there
|
|
** Using homogeneous coordinates
|
|
https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
|
|
no, i don't understant that
|
|
** https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Given_two_points_on_each_line
|
|
with 2 points. i guess
|
|
but also - check if the point in future of the hail, by comparing with speeds?
|
|
should be easy
|
|
** and i got wrong result
|
|
day24 result: 8406
|
|
** another formula gives
|
|
day24 result: 8406
|
|
** another formula
|
|
12938
|
|
*
|
|
* ok, part 2.
|
|
what if.
|
|
i start checking t = 0, 1, etc.
|
|
for each t, i need two points of the two hail lines.
|
|
|
|
it would constitute the trajectory.
|
|
then condition for the solution that all other hail lines will intersect it at some t.
|
|
so check for intersection (maybe not necessarily in the field?)
|
|
|
|
go though lines, if any fail to intersect - continue with t
|
|
|
|
if all intersect, find where the rock has to be in time 0
|
|
|
|
oh. no.
|
|
it's not just intersect. it's that the movement of the rock with t would be there at correct time? yuck?
|
|
|
|
would there really be more than i line that intersects all of the hail lines?
|
|
|
|
i'll just need to also figure out t=0 from other coords.
|
|
|
|
i don't like this at all.
|
|
|
|
And intersections have to be over (X, Y, Z)
|
|
** so 'hail mary' approach would be
|
|
scan first 1k nanoseconds. so already 1M calculations
|
|
( this is first part of desperation, that at least 2 hails will intercept in first 1k ticks )
|
|
|
|
for collision 1, assume HailA is on path.
|
|
then iterate for all other assumint they are intercepted on t 2 etc ?
|
|
|
|
no. the intersections could be on non-integer times?
|
|
( this would be second part of the 'hail mary' )
|
|
|
|
from that i should be able to construct the 'trajectory' line.
|
|
and then check with all other points - do the intersect?
|
|
( and check of intersection in future would be nice )
|
|
|
|
then if line confirmed, will need to calc for t = 0, t = 1, and get speeds
|
|
*** not hoping for all integer intersections
|
|
or what if i will hope for that?
|
|
let's try?
|
|
* ok, what if i could do system of equasions?
|
|
#+begin_src
|
|
yuck_test.go:12:
|
|
x + Dx * t0 == 19 + -2 * t0
|
|
y + Dy * t0 == 13 + 1 * t0
|
|
z + Dz * t0 == 19 + -2 * t0
|
|
x + Dx * t1 == 18 + -1 * t1
|
|
y + Dy * t1 == 19 + -1 * t1
|
|
z + Dz * t1 == 18 + -2 * t1
|
|
x + Dx * t2 == 20 + -2 * t2
|
|
y + Dy * t2 == 25 + -2 * t2
|
|
z + Dz * t2 == 20 + -4 * t2
|
|
solve for x, y, z, Dx, Dy, Dz, t1, t2, t3. ti > 0
|
|
#+end_src
|
|
|
|
#+begin_src
|
|
yuck_test.go:18:
|
|
x + Dx * t0 == 147847636573416 + 185 * t0
|
|
y + Dy * t0 == 190826994408605 + 49 * t0
|
|
z + Dz * t0 == 147847636573416 + 219 * t0
|
|
x + Dx * t1 == 287509258905812 + -26 * t1
|
|
y + Dy * t1 == 207449079739538 + 31 * t1
|
|
z + Dz * t1 == 287509258905812 + 8 * t1
|
|
x + Dx * t2 == 390970075767404 + -147 * t2
|
|
y + Dy * t2 == 535711685410735 + -453 * t2
|
|
z + Dz * t2 == 390970075767404 + -149 * t2
|
|
solve for x, y, z, Dx, Dy, Dz, t1, t2, t3. ti > 0
|
|
#+end_src
|
|
* got some solution
|
|
enefedov@LLF33A87M:~/Documents/personal/advent-of-code-2023$ python day24/pythonZ3/forInput.py
|
|
Solution: [t0 = 666003776903,
|
|
t2 = 779453185471,
|
|
t1 = 654152070134,
|
|
Dz = 18,
|
|
Dx = 47,
|
|
Dy = -360,
|
|
z = 273997500449219,
|
|
y = 463222539161932,
|
|
x = 239756157786030]
|