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

18 views (last 30 days)
[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 Comment
KSSV
KSSV on 7 Apr 2021
Get the angle of line and then rotate cyclinder by this angle.

Sign in to comment.

Accepted Answer

DGM
DGM on 7 Apr 2021
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 Comment
Kevin Hanekom
Kevin Hanekom on 7 Apr 2021
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!

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!