point in convex hull?

조회 수: 49 (최근 30일)
Noe alvarado
Noe alvarado 2012년 3월 23일
how compute if a point point is inside the convex hull ?

채택된 답변

Friedrich
Friedrich 2012년 3월 23일
Hi,
I would use convhull and inpolygon:
xx = -1:.05:1; yy = abs(sqrt(xx));
[x,y] = pol2cart(xx,yy);
k = convhull(x,y);
hold on
plot(x(k),y(k),'r-',x,y,'b+')
x_test = rand(10,1);
y_test = rand(10,1);
IN = inpolygon(x_test,y_test,x(k),y(k))
plot(x_test(IN),y_test(IN),'g*',x_test(~IN),y_test(~IN),'y*')
hold off
  댓글 수: 2
Noe alvarado
Noe alvarado 2012년 3월 23일
thanks for your answer, but it can work in high dimension?
I'm vorking with points in high dimension (4,5,6..)
Friedrich
Friedrich 2012년 3월 23일
This wont work in higher dimensions. You have to do some smart geometry stuff to get the information you like. you can use convhulln to get the facets of your convex hull and also the corners (x_i, i = 1..m). After that try to get coefficients a_i > 0 so that
sum_i x_i*a_i = v where sum_i a_i = 1 (basically that's the definition of the convex hull). (v is the vector you like to know if its inside or outside of the convex hull). Finding one solution for the system of equations is easy, but the condition that the sum over the coefficients gives 1 is pretty tricky. I don't know if there is an easy way to get solve this.
Seems more like a mathematical question rather than a MATLAB question for me.
If you know an algorithm come back and ask how to implement/use this in MATLAB. But first you need to know how to check this in theory before doing it in MATLAB.

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

추가 답변 (1개)

Matt Kindig
Matt Kindig 2012년 3월 23일
There is a file on the File Exchange called 'inhull'. I have used it for precisely this purpose.
  댓글 수: 2
Noe alvarado
Noe alvarado 2012년 4월 12일
thanks
Noe alvarado
Noe alvarado 2012년 4월 12일
thanks

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

카테고리

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