Generate distinct geometric shapes by using radius ?

조회 수: 1 (최근 30일)
Haytham Ali
Haytham Ali 2021년 6월 7일
답변: darova 2021년 6월 8일
I need a code where I can generate different geometric shapes in a form of a binary image (by using general equation or something like this).

답변 (1개)

darova
darova 2021년 6월 8일
Here is ax example
t = linspace(0,2*pi,4); % triangle
[x,y] = pol2cart(t,30); % cartesian coordinates
% move triangle to (50,50)
x = x + 50;
y = y + 50;
[x1,y1] = meshgrid(1:100);
A = zeros(100); % preallocation memory
ind = inpolygon(x1,y1,x,y); % indices inside the triangle
A(ind) = 1;
imshow(A)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by