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.
    조회 수: 6 (최근 30일)
  
       이전 댓글 표시
    
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
답변 (1개)
  Sreeram
 2025년 6월 12일
        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
참고 항목
카테고리
				Help Center 및 File Exchange에서 Voronoi Diagram에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

