MATLAB Answers

How can we make a rhombus in the middle?

23 views (last 30 days)
Ju Hee Hwang
Ju Hee Hwang on 29 Aug 2019
Commented: Ju Hee Hwang on 29 Aug 2019
-my rectangle code-
fr=zeros(512,512);
row=512;
col=512;
pok1=70;
pok2=70;
for x=row/2-pok1:1:row/2+pok1
for y=col/2-pok2:1:col/2+pok2
fr(x,y)=1;
end
end
I want to make the square look like a rotated shape.
I want to resize the diamond as in the code above.
What should I do?

  0 Comments

Sign in to comment.

Accepted Answer

KSSV
KSSV on 29 Aug 2019
Edited: KSSV on 29 Aug 2019
Play with the points in R....you give the vertices of vertices..you will get it.
fr=zeros(512,512);
% Rhombus points
R = [350 250 ;
250 200 ;
150 250 ;
250 250] ;
[X,Y] = meshgrid(1:512,1:512) ;
idx = inpolygon(X,Y,R(:,1),R(:,2)) ;
fr(idx) = 1 ;
pcolor(fr)
shading interp

  1 Comment

Ju Hee Hwang
Ju Hee Hwang on 29 Aug 2019
Wow:)
It was very helpful!
I got a rhombus.

Sign in to comment.

More Answers (0)


Translated by