How can we make a rhombus in the middle?

조회 수: 13 (최근 30일)
Ju Hee Hwang
Ju Hee Hwang 2019년 8월 29일
댓글: Ju Hee Hwang 2019년 8월 29일
-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?

채택된 답변

KSSV
KSSV 2019년 8월 29일
편집: KSSV 2019년 8월 29일
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
Ju Hee Hwang
Ju Hee Hwang 2019년 8월 29일
Wow:)
It was very helpful!
I got a rhombus.

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

추가 답변 (0개)

카테고리

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