vector<Hex> hex_linedraw(Hex a, Hex b) { int N = hex_distance(a, b); vector<Hex> results = {}; double step = 1.0 / max(N, 1); for (int i = 0; i <= N; i++) { results.push_back(hex_round(hex_lerp(a, b, step * i))); } return results; }
std::vector<point> line(const point& p1, const point& p2) { std::vector<point> res; int n = distance(p1, p2); int x1, y1, z1; std::tie(x1,y1,z1) = oddq_to_cube_coords(p1); int x2, y2, z2; std::tie(x2,y2,z2) = oddq_to_cube_coords(p2); for(int i = 0; i <= n; ++i) { const float i_over_n = static_cast<float>(i)/n; const float xt = x1 * (1.0f - i_over_n) + x2 * i_over_n + 1e-6f; const float yt = y1 * (1.0f - i_over_n) + y2 * i_over_n + 1e-6f; const float zt = z1 * (1.0f - i_over_n) + z2 * i_over_n - 2e-6f; res.emplace_back(cube_to_oddq_coords(hex_round(xt, yt, zt))); } return res; }