Rotating a Cylinder to fit the line x=y=z

조회 수: 18 (최근 30일)
Kevin Hanekom
Kevin Hanekom 2021년 4월 7일
댓글: Kevin Hanekom 2021년 4월 7일
[sig_1, sig_2, sig_3] = cylinder;
%sig_3 = sig_3 * 2;
g = surf(sig_1,sig_2,sig_3);
direction =[1 1 1];
rotate(g,direction, 45)
xlabel("x");
ylabel("y");
zlabel("z");
title('Von Mises Yield Surface')
hold on
Q = plot3([0 2], [0 2], [0 2]);
hold off
Hey everyone, I am new to matlab and am trying to figure out how I would be able to rotate a cylinder to fit the line y=x=z, like a von mises surface. Could i use the line as a refrence point for my cylinder? Or am i rotating my surface wrong?
Any help or refrence to a source that might help will be greatly appreciated
  댓글 수: 1
KSSV
KSSV 2021년 4월 7일
Get the angle of line and then rotate cyclinder by this angle.

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

채택된 답변

DGM
DGM 2021년 4월 7일
The vector you're using is the vector you're trying to align the cylinder to. The vector you need to be specifying is the axis of rotation, which should be orthogonal to [1 1 1]. It also seems that rotate() likes to move the origin around depending on the plot box, so you'll have to make it stop doing that by explicitly specifying a coordinate origin. Lastly, the rotation angle isn't 45 degrees.
clf
[sig_1, sig_2, sig_3] = cylinder;
g = surf(sig_1,sig_2,sig_3);
rotaxis = [135 0]; % i decided to do this polar instead of cart
rotate(g,rotaxis,90-atand(1/sqrt(2)),[0 0 0])
xlabel('x');
ylabel('y');
zlabel('z');
title('Von Mises Yield Surface')
hold on
axis equal
Q = plot3([0 2], [0 2], [0 2]);
Q = plot3([1 -1], [-1 1], [0 0]);
hold off
And like I said, the angle isn't 45. It's easy enough to derive, though.
  댓글 수: 1
Kevin Hanekom
Kevin Hanekom 2021년 4월 7일
You are my savior! Thank you for the help!! But yes i see now, theta is = 45 but that doesnt necessarily mean that phi also = 45.
Again, Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by