How do I rotate a square /rectangle using line as the reference point? Thank you
조회 수: 2 (최근 30일)
이전 댓글 표시
clc
clear all
close all
polyin = polyshape([0 1 1 0],[0 0 10 10]); %original shape
c1=rotate(polyin,-1.64329,[1 0]);
[x,y]=centroid(polyin);
[x1,y1] = centroid(c1);
plot([polyin c1])
axis equal
hold on
plot(x,y,'r*',x1,y1,'r*')
hold off
답변 (1개)
Adam Danz
2023년 1월 15일
편집: Adam Danz
2023년 1월 23일
I believe you're asking how to rotate the polyshape about its centerpoint. If so, specify the reference point of rotation using the thrid argument in polyout = rotate(polyin,theta,refpoint). The center point is returned by centroid().
polyin = polyshape([0 1 1 0],[0 0 10 10]); %original shape
[x,y]=centroid(polyin); % center point
c1=rotate(polyin,-1.64329,[x,y]); % rotate about center point
[x1,y1] = centroid(c1);
plot([polyin c1])
axis equal
hold on
plot(x,y,'r*',x1,y1,'r*')
hold off
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Elementary Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!