This function constructs a cylinder connecting two center points
[Cylinder EndPlate1 EndPlate2] = Cylinder(X1+20,X2,r,n,'r',closed,lines)
Cylinder-------Handle of the cylinder
EndPlate1------Handle of the Starting End plate
EndPlate2------Handle of the Ending End plate
X1 and X2 are the 3x1 vectors of the two points
r is the radius of the cylinder
n is the no. of elements on the cylinder circumference (more--> refined)
cyl_color is the color definition like 'r','b',[0.52 0.52 0.52]
closed=1 for closed cylinder or 0 for hollow open cylinder
lines=1 for displaying the line segments on the cylinder 0 for only
X1=[10 10 10];
X2=[35 20 40];
NOTE: There is a MATLAB function "cylinder" to revolve a curve about an
axis. This "Cylinder" provides more customization like direction and etc
J. Divahar (2021). Cylinder (https://www.mathworks.com/matlabcentral/fileexchange/13995-cylinder), MATLAB Central File Exchange. Retrieved .
Thank you for the proposition Divahar. Very interesting!!!
I try to implement it to generate a cylindrical surface around a plotted line.
The idea that I have in mind was to generate a 3d surface of the trajectory of a Chaotic Lorenz system.
Later, the plotted cylindrical trajectory was going to be exported to a STL file to be printed in a 3d Printer.
Nevertheless, I didn't understand how to use the data of the Cylinder surface file in the workspace of Matlab after running your program
The code that Im using is in this link:
Much more intuitive than other cylinder functions
Still useful 10 years later. Thanks for the upload!
Its very useful to me and all.
Nice work ! Error corrected and no glitches here !
Is there a way to detect whether a point (X;Y;Z) belongs (is inside) to the volume delimited by a cylinder generated by your function ?
I get inconsistent results depending on whether I set closed. I think the translation code for the endcaps (lines 82-90) away from the origin, the offsets are wrong (cut and paste typos probably). Line 83 should end with +X1(1); line 85 should end with +X1(3); line 87 should end with +X1(1); line 89 should end with +X1(3). When I make those changes, I get consistent plots for closed=0,1.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!