Hi, I want to loop through the voronoi triangles, get their (x,y) cordinates and then check for the density values which i have in a form of 2d array. How can i do that?
This is my code:
using Distributions
mean_signal = [1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2, 0, 3, 0]
std_dev = [0.9, 0.2, 0.1, 0.3, 0.2, 0.3, 0.9, 0.3]
density_values = [pdf(Distributions.Normal(mean, std), x) for (mean, std) in zip(mean_signal, std_dev), x in range(0, 10, length=10)]
@show (density_values)
fig = Figure()
ax = Axis(fig[1, 1])
heatmap!(ax, density_values, colormap=:viridis)
tri = triangulate(points)
vorn = voronoi(tri)
ax2 = PlotConfig.configure_plot(fig, 1, 2, "Voronoi", "x", "y")
ax3 = PlotConfig.configure_plot(fig, 2, 1, "Centroids", "x", "y")
voronoiplot!(ax2, vorn, show_generators=false)
centroids = zeros(2, num_polygons(vorn))
for (j, i) in enumerate(each_polygon_index(vorn))
centroids[:, j] .= DelaunayTriangulation.get_centroid(vorn, i)
end
GLMakie.scatter!(ax3, centroids)
resize_to_layout!(fig)
display(fig)