Modify code of straight circular cone to get a slate one

8 views (last 30 days)
R = 1; %// radius
H = 3; %// height
N = 100; %// number of points to define the circumference
[x, y, z] = cylinder([R 0], N);
mesh(x, y, H*z)
does a straight circular cone. How to modify to get a slate one like
Comments are welcome.
Thanks

Answers (1)

John D'Errico
John D'Errico on 14 Apr 2023
Assuming you mean a skewed cone, this is simple to do. You already know how to use the cylinder function.
help cylinder
CYLINDER Generate cylinder. [X,Y,Z] = CYLINDER(R,N) forms the unit cylinder based on the generator curve in the vector R. Vector R contains the radius at equally spaced points along the unit height of the cylinder. The cylinder has N points around the circumference. SURF(X,Y,Z) displays the cylinder. [X,Y,Z] = CYLINDER(R), and [X,Y,Z] = CYLINDER default to N = 20 and R = [1 1]. Omitting output arguments causes the cylinder to be displayed with a SURF command and no outputs to be returned. CYLINDER(AX,...) plots into AX instead of GCA. See also SPHERE, ELLIPSOID. Documentation for cylinder doc cylinder
A cone is simple.
First, what is a cylinder? It is a circle, translated along the z axis, so the same circle at any value of z. Now, we can create a cone, by scaling the x and y values that come out, by multiplying by z. Nicely, cylinder actually does that for you.
R = 1; %// radius
H = 3; %// height
N = 100; %// number of points to define the circumference
[x, y, z] = cylinder([R 0], N);
mesh(x,y,z)
But a skewed cone, is now one that also has x and y translated over, also as a function of z.
x = x + z/2;
mesh(x,y,z)
  1 Comment
nodek
nodek on 14 Apr 2023
Great, thank you.
I got it.
"slate" was a translation by google. I'm speaking swiss german :)

Sign in to comment.

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!