···
# File.read!("day19.txt")
-
File.read!("day19.txt")
|> Enum.map(fn scanner ->
···
-
b_{x_1} r_x + b_{x_0} = a_{x_1} \\
-
b_{x_2} r_x + b_{x_0} = a_{x_2}
-
b_{y_1} r_y + b_{y_0} = a_{y_1} \\
-
b_{y_2} r_y + b_{y_0} = a_{y_2} \\
-
b_{z_1} r_z + b_{z_0} = a_{z_1} \\
-
b_{z_2} r_z + b_{z_0} = a_{z_2} \\
···
This mean that we need to solve:
···
···
By applying [Cramer's Rule](https://en.wikipedia.org/wiki/Cramer%27s_rule) we can solve these
-
} = \frac{{b_1}_d - {b_2}_d}{{a_1}_d - {a_2}_d} \\
-
} = \frac{{a_1}_d {b_2}_d - {b_1}_d {a_2}_d}{{a_1}_d - {a_2}_d}
···
b_2 = reaxe(select_common(p0, p2), axes)
-
for i <- ~w[x y z]a, into: %{} do
r = div(a_1 - a_2, det_b)
b_0 = div(b_1 * a_2 - a_1 * b_2, det_b)
···
<!-- livebook:{"output":true} -->
-
{:module, Day19, <<70, 79, 82, 49, 0, 0, 26, ...>>, {:pairs, 1}}
···
<!-- livebook:{"output":true} -->
<!-- livebook:{"output":true} -->
···
# File.read!("day19.txt")
+
File.read!("2021/day19.txt")
|> Enum.map(fn scanner ->
···
+
To find rotation of point $b_1$ and $b_2$ around shift point $b_0$
+
{b_1}_x r_x + {b_0}_x = {a_1}_x \\
+
{b_2}_x r_x + {b_0}_x = {a_2}_x
+
{b_1}_y r_y + {b_0}_y = {a_1}_y \\
+
{b_2}_y r_y + {b_0}_y = {a_2}_y \\
+
{b_1}_z r_z + {b_0}_z = {a_1}_z \\
+
{b_2}_z r_z + {b_0}_z = {a_2}_z \\
···
This mean that we need to solve:
···
···
By applying [Cramer's Rule](https://en.wikipedia.org/wiki/Cramer%27s_rule) we can solve these
+
linear equations with (we are looking for $b_0$ and $r$):
+
} = \frac{{a_1}_d - {a_2}_d}{{b_1}_d - {b_2}_d} \\
+
} = \frac{{b_1}_d {a_2}_d - {a_1}_d {b_2}_d}{{b_1}_d - {b_2}_d}
···
b_2 = reaxe(select_common(p0, p2), axes)
+
for d <- ~w[x y z]a, into: %{} do
r = div(a_1 - a_2, det_b)
b_0 = div(b_1 * a_2 - a_1 * b_2, det_b)
···
<!-- livebook:{"output":true} -->
+
{:module, Day19, <<70, 79, 82, 49, 0, 0, 29, ...>>, {:pairs, 1}}
···
<!-- livebook:{"output":true} -->
<!-- livebook:{"output":true} -->