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.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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));

0 commentaires
Réponses (1)
Sreeram
le 12 Juin 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));
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]);
0 commentaires
Voir également
Catégories
En savoir plus sur Voronoi Diagram dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!