Rotating a Cylinder to fit the line x=y=z
17 views (last 30 days)
Show older comments
[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
Accepted Answer
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.
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!