Random point inside a polygone

버전 1.0.1 (65.8 KB) 작성자: Stephane Dauvillier
Create random point inside a polygone
다운로드 수: 85
업데이트 날짜: 2019/5/15

라이선스 보기

If you have a 2D CONVEX polygone and you want to create uniform point indise it, you can use randPolygone. The function is based on another (provided) function randTriangle that work on triangle.

Uniform means each area of your polygone has the same chance to be taken.

Here are some examples:

triangle = [0,0;10,0;2,3];
losange = [0,0;2 ,1;0,2;-2,1];
carre = [0,0;2 ,0;2,2; 0,2];
hexagone = [0,0;1,0;10,1;30,8;20,8;0,5];
dodecagone = [cos(linspace(0,2*pi,13))',...
sin(linspace(0,2*pi,13))'];
dodecagone(end,:) = [] ;

rTriangle=randPolygone(triangle,1e4);
rLosange=randPolygone(losange,1e4);
rHexagone=randPolygone(hexagone,1e4);
rCarre=randPolygone(carre,1e4);
rDodecagone=randPolygone(dodecagone ,1e4);

figure
scatter(rTriangle(:,1),rTriangle(:,2),'.')

인용 양식

Stephane Dauvillier (2024). Random point inside a polygone (https://www.mathworks.com/matlabcentral/fileexchange/71398-random-point-inside-a-polygone), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016b
R2016a 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Elementary Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.1

include the live function randTriangle

1.0.0