I need to use Voronoi to segment triangles, and now I have implemented triangle regions, but I am unable to segment triangles. I hope you can help me, thank you.

2 Ansichten (letzte 30 Tage)
close all; clear all; clc
figure()
x1=0.5;x2=2;x3=3.7;
y1=0.6;y2=3.1;y3=1.2;
triangle_x=[x1,x2,x3,x1];
triangle_y=[y1,y2,y3,y1];
fill(triangle_x,triangle_y,'w');
axis([0,4,0,3]);axis equal;
voronoi((0.7:2),(0.8:1),(2:2.1),(1.7:0.8));

Antworten (1)

Sreeram
Sreeram am 12 Jun. 2025
The issue lies in how "voronoi" is being called - its syntax expects two equal-length vectors of x and y coordinates. In the shared code, multiple range expressions are passed, which leads to the following error:
voronoi((0.7:2),(0.8:1),(2:2.1),(1.7:0.8));
Error using voronoi (line 83)
X and Y must be the same size.
To segment a triangle using "voronoi", you need to provide a set of seed points located within or around the triangle. For more details on the correct syntax, refer to the official documentation:
Here is a minimal example for reference:
close all; clear; clc
figure()
x = [0.5, 2, 3.7];
y = [0.6, 3.1, 1.2];
fill([x x(1)], [y y(1)], 'w');
axis([0 4 0 3]); axis equal; hold on;
voronoi([1.5, 2.5, 2], [1.2, 2.2, 1.8]);

Kategorien

Mehr zu Voronoi Diagram finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by