How can I draw a circle with centre lines and then rotate it?

조회 수: 5 (최근 30일)
quoroy
quoroy 2017년 7월 14일
편집: Prashant Arora 2017년 7월 28일
I am trying to draw mode shapes of planetary gears, where I have eigenvectors of the form Transpose of[x y u], where 'u' is a rotation coordinate u = radius*theta. The final result I'm looking for is something like the image, where the first state of the gears (represented by circles) can be exactly at it's equilibrium points at the center and with rotation at 0°, and then the red circles represent a translational mode, where the eigenvector only moves in the x and y direction (I can plot this) or rotational mode where the gear rotates by 'u' (I don't know how to plot this) and the center lines of each circle would also rotate or translate to make it more obvious.
First I tried to draw them like a normal circle with a centre and radius , I found lots of examples of how to do this, like:
function h = circle(x,y,r)
hold on
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
hold off
Then I found the function
viscircles(centers,radii)
But I don't know if there's a way to draw the center lines inside the circle (could just plot the lines individually and hold on the figure plot?). I basically have tons of data and eigenvectors so I want to find a way to automate the plotting by just putting in the x y u coordinates of the first and second states per gear, in the case of the example image, its a center sun, 4 planets and the carrier.
I'd really appreciate any suggestions, I'm quite new to matlab.

채택된 답변

Prashant Arora
Prashant Arora 2017년 7월 17일
편집: Prashant Arora 2017년 7월 17일
You can use the following method to draw lines inside a circle and rotate/translate them.
radius = 5;
center = [10 15];
rotation = pi/3;
translation = [-0.5 -0.6];
rotTForm = [cos(rotation) sin(rotation); -sin(rotation) cos(rotation)];
viscircles(center,radius,'Color','b');
hold on;
%Circle just needs to be translated, as rotation won't have any effect on
%visuals
viscircles(center+translation,radius,'Color','r');
centerLines = center + [0 radius; 0 0; radius 0];
rotatedLines = (centerLines - center)*rotTForm + center + translation;
plot(centerLines(:,1), centerLines(:,2),'-.');
hold on
plot(rotatedLines(:,1), rotatedLines(:,2),'-.');
  댓글 수: 3
quoroy
quoroy 2017년 7월 28일
@Prashant Arora how can I draw crosses instead of L type lines, I can't figure out how the [0 radius; 0 0; radius 0]; works, thanks!
Prashant Arora
Prashant Arora 2017년 7월 28일
편집: Prashant Arora 2017년 7월 28일
Hi quoroy, You can create two different lines for the cross. Or you can simply replace the code for centerLines defined as:
centerLines = center + radius*[-1 0;0 0;0 1;0 -1;0 0;1 0];

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by