Measuring & counting lines inside voronoi polygons

1 次查看(过去 30 天)
Hello, I have a plot of a set of points after voronoi tesselation and I have to do things as follows: 1. add a set of a known number of vertical lines (the distance between them should be equal) 2. count the number of lines inside each voronoi polygon and measure the length of lines inside each polygon (separately + averagely) 3. count the number of polygons each line crosses.
Does anyone have an idea how to do this? Please take into account that I am completely unexperienced in MatLab, so I even don't know how to add this set of lines to my plot.
I will appreciate ANY help, even basic information.

回答(1 个)

Ronit
Ronit 2025-6-4
Hello @Joanna,
1. Add vertical lines to the Voronoi plot.
  • Use the line() function to create primitive lines.
  • Use a for loop to plot vertical lines from "y_min" to "y_max" at fixed "x" positions.
% d is the distance between vertical lines
for x = x_min:d:x_max
line([x x], [y_min y_max], 'Color', 'r');
end
2. Count the number of vertical lines inside each Voronoi polygon & their total/average lengths.
  • Loop through each polygon (Voronoi region). Turn each Voronoi region into a polyshape using the polyshape() function.
  • For each polygon, check which vertical lines intersect it.
  • Use intersect() function to find the overlapping segment.
  • Then measure the intersection length.
  • Use norm() to compute length from intersection vertices.
3.Count the number of polygons each vertical line crosses.
  • Loop through all the polygons.
  • Use overlaps() to check if a line touches it.
  • Count how many polygons each line intersects.
To help you with the implementation, please refer to the following documentation pages for the above mentioned functions:
I hope this helps with your query.
Thanks!

类别

Help CenterFile Exchange 中查找有关 Voronoi Diagram 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by