Syntax
SG=SGcylinder([r,h,n,ri,ry,al])
Input Parameter
r : | | Radius |
h : | | Height |
n : | | number of points |
ri : | | Inner Radius |
ry : | | Radius in y |
al : | | Angle of circle; default is 2*pi |
Output Parameter
Examples
SGcylinder(5,30)
SGcylinder(5,30,6)
SGcylinder(5,30,6,2)
SGcylinder(5,30,6,2,10)
SGcylinder(5,30,'',2,10,2*pi/1.5) % Elliptic with inner bore
Copyright 2018-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, SGcylinder, generates a 3D cylinder model using specified parameters. It is part of the SolidGeometry library.
Input Parameters
- r: Radius of the cylinder.
- h: Height of the cylinder. If a single value is provided, it is used as the height. If two values are provided, they define the start and end heights.
- n: Number of points used to define the circle. If not specified, a default is used.
- ri: Inner radius for a hollow cylinder. Default is 0, indicating a solid cylinder.
- ry: Radius in the y-direction, allowing for elliptical cross-sections. Default is the same as r.
- al: Angle of the circle in radians. Default is 2*pi, representing a full circle.
Output
- SG: The resulting solid geometry of the cylinder.
Algorithm Steps
- Check for the 'frames' parameter using
getfuncparamStr
.
- Retrieve and set default values for
r
, h
, n
, ri
, ry
, and al
using getfuncparams
.
- Set
d
to 1. The variable d
is intended for scaling but is not modified in this code.
- If
h
is a single value, convert it to a two-element array [0, h].
- If the first element of
h
is greater than the second, swap them to ensure correct height orientation.
- If
ri
is less than or equal to 0, create a solid cylinder using PLcircle
and SGofCPLz
.
- If
ri
is greater than 0, create a hollow cylinder by defining two circles and using SGofCPLz
.
- If
isframe
is true, apply SGTsetBFsimple
to the geometry.
- If no output is requested, plot the cylinder using
SGfigure
and SGTplotalpha
.
Algorithm explaination created using ChatGPT on 2025-08-19 08:06. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21