Code covered by the BSD License  

Highlights from
Cylinder

4.5

4.5 | 2 ratings Rate this file 23 Downloads (last 30 days) File Size: 2.21 KB File ID: #13995
image thumbnail

Cylinder

by Divahar Jayaraman

 

18 Feb 2007 (Updated 16 Mar 2007)

This function will construct a 3d cylinder connecting two points (centers)

| Watch this File

File Information
Description

This function constructs a cylinder connecting two center points

Usage :
[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
surface

Typical Inputs
X1=[10 10 10];
X2=[35 20 40];
r=1;
n=20;
cyl_color='b';
closed=1;

NOTE: There is a MATLAB function "cylinder" to revolve a curve about an
axis. This "Cylinder" provides more customization like direction and etc

Acknowledgements
This submission has inspired the following:
Cone
MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
22 Feb 2007 Charles Warren

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.

23 Mar 2007 Germain Aoun

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 ?
Thanks

04 Sep 2007 karl marx

Its very useful to me and all.

Please login to add a comment or rating.
Updates
16 Mar 2007

Thanks to Mr. Charles Warren.

The error that he has indicated has been corrected.

Tag Activity for this File
Tag Applied By Date/Time
specialized Divahar Jayaraman 22 Oct 2008 09:00:59
plotting Divahar Jayaraman 22 Oct 2008 09:00:59
graphics Divahar Jayaraman 22 Oct 2008 09:00:59
plot Divahar Jayaraman 22 Oct 2008 09:00:59
3d Divahar Jayaraman 22 Oct 2008 09:00:59
extrude Divahar Jayaraman 22 Oct 2008 09:00:59
revolve Divahar Jayaraman 22 Oct 2008 09:00:59
pipe Divahar Jayaraman 22 Oct 2008 09:00:59
rotate Divahar Jayaraman 22 Oct 2008 09:00:59
cylinder Peter 27 May 2009 15:09:42
rotate Beth Savoy 05 Jun 2009 09:21:03
3d amir 27 Feb 2011 16:07:41
cylinder kivinlo lou 21 Jun 2011 10:40:29
3d kivinlo lou 21 Jun 2011 10:40:32

Contact us at files@mathworks.com