Generate distinct geometric shapes by using radius ?

1 visualización (últimos 30 días)
Haytham Ali
Haytham Ali el 7 de Jun. de 2021
Respondida: darova el 8 de Jun. de 2021
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).

Respuestas (1)

darova
darova el 8 de Jun. de 2021
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)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by