How to Plot the Trajectory of points on a bendRightAngle when Rotated 90 degrees
5 ビュー (過去 30 日間)
古いコメントを表示
I am working on the moving sofa problem in mathematics and am trying to plot the trajectory of several points on an L shape when rotated 90 degrees. I have made a right angle L of unit width (see code below). What I would like to do is define sseveral reference points along the inside of my L. I would like to draw a trajectory of these points as the L is rotated 90 degrees. I would also like the coordinates of the trajectory of the reference points along the rotation. I am not sure if this is asking too much.
RightAngle = bendRightAngle(Name='RightAngle',ReferencePoint=[0,0],Length=[3,3],Width=[1,1])
I greatly appreciate any help.
Steven
1 件のコメント
回答 (2 件)
William Rose
2022 年 11 月 12 日
Matlab can define a polygon. It could be convenient for your work. The only possible disadvantage is that a polyshape includes the corners only. A polyshape does not include additional points along a straight edge. If you want to track those with polyshape(), you might have to define sub-polygons.
Let's try Matlab's polygon functions:
sofa=polyshape([0,3,3,2,2,0],[0,0,2,2,1,1]); %vertices of sofa
plot(sofa);
Now rotate the sofa with Matlab's rotate function.
theta=[15,30,45,60,75]; %rotation angles
refpoint=[0.5,0.5]; %point to rotate about
hold on; axis equal %hold the current plot
for i=1:length(theta)
plot(rotate(sofa,theta(i),refpoint));
end
3 件のコメント
William Rose
2022 年 11 月 11 日
編集済み: William Rose
2022 年 11 月 11 日
You can define a nx2 array of points on the sofa
S=[0,0;1,0;2,0;3,0;3,2;2,2;2,1;1,1;0,1;0,0];
And plot it
plot(S(:,1),S(:,2),’-b.’);
Then multiply S by 2x2 rotation matrix R to get a new array with the rotated points. You can also combine with translation of the array of points.
Sorry can’t format this correctly, answering on phone.
R=[cos(t),sin(t);-sin(t),cos(t)];
t=angle to rotate by in radians
S1=S*R; %rotated array of points
Plot S1 like S but with a new color.
1 件のコメント
William Rose
2022 年 11 月 11 日
Oh by that was formatted even worse than I expected. All my carriage returns disappeared!
参考
カテゴリ
Help Center および File Exchange で Acoustics, Noise and Vibration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!