Does anybody know how to write a function which returns the coordinates of a convex hull of a list of certain points?

조회 수: 1 (최근 30일)
Does anybody know how to write a function which returns the coordinates of a convex hull of a list of certain points?
I can't figure out how to use the convhull function, is it easy to write my own function to calculate the points of a convex hull?
What I'm looking to get:
input
List = [x1 y1; x2 y2; x3 y3; etc];
function that computes the x and y coordinates of the convex hull of List
output
convexHull = [xConv1 yConv1; xConv2 yConv2; etc];
Mathworks.png
Can someone please help me understand how to do this in code? I'm clueless..
  댓글 수: 2
Stephen23
Stephen23 2019년 12월 3일
편집: Stephen23 2019년 12월 3일
"I can't figure out how to use the convhull function..."
Try some of the convhull examples to get you started.
"...is it easy to write my own function to calculate the points of a convex hull?"
Not really, but you are welcome to try:

댓글을 달려면 로그인하십시오.

답변 (2개)

Fabio Freschi
Fabio Freschi 2019년 12월 3일
% your data
N = 20;
List = rand(N,2);
% convex hull (k is the pointer to the rows in List with the convex hull
k = convhull(List);
% convex hull points (counterclockwise)
convexHull = List(k,:);

Walter Roberson
Walter Roberson 2019년 12월 3일
convexHull = boundary(x, y, 0);

카테고리

Help CenterFile Exchange에서 Bounding Regions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by