MATLAB Answers

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

4 views (last 30 days)
Catalytic Kys
Catalytic Kys on 3 Dec 2019
Answered: Walter Roberson on 3 Dec 2019
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..

Answers (2)

Fabio Freschi
Fabio Freschi on 3 Dec 2019
% 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,:);

  0 Comments

Sign in to comment.


Sign in to answer this question.