pyoptools.raytrace.surface.cylinder module¶
- class pyoptools.raytrace.surface.cylinder.Cylinder¶
Bases:
SurfaceClass to define cylindrical surfaces.
The Cylinder class represents a tube or hollow cylindrical surface in an optical system. The cylinder is defined by its radius and length, with the center located at the origin of the coordinate system (0, 0, 0) and its length aligned along the Z-axis.
- Parameters:
radius (double, optional) – The radius of the cylinder. The default value is 10.0.
length (double, optional) – The length of the cylinder. The default value is 10.0.
*args (tuple, optional) – Additional positional arguments passed to the Surface superclass.
**kwargs (dict, optional) – Additional keyword arguments passed to the Surface superclass.
- radius¶
The radius of the cylinder.
- Type:
double
- length¶
The length of the cylinder.
- Type:
double
Examples
Creating a cylinder surface with a specific radius and length:
>>> cs = Cylinder(radius=5.0, length=10.0)
Notes
The cylinder is centered at the origin of the coordinate system, with its length extending along the Z-axis.
This class inherits additional functionality and attributes from the Surface class, which can be used to further define the optical properties of the cylinder.
Refer to the Surface class documentation for more details on other options and attributes that can be used in conjunction with this class.
- length¶
- polylist()¶
Generate a list of points and polygons representing the cylindrical surface.
This method generates a list of points and polygons that can be used to visualize the cylindrical surface. It is specifically designed for closed surfaces, which is why it is overloaded in this class.
- Returns:
points: A list of tuples, where each tuple represents a point
(X, Y, Z) in 3D space that forms part of the cylindrical surface. - polys: A list of tuples, where each tuple contains three indices corresponding to points in the points list. These indices define the triangular polygons that make up the surface of the cylinder.
- Return type:
tuple of lists
Notes
The method discretizes the cylindrical surface by sampling it at 40
evenly spaced angles around the Z-axis. For each angle, two points are generated: one at the lower end of the cylinder (Z1) and one at the upper end (Z2). - The polygons are then created by connecting adjacent points to form triangular surfaces, ensuring that the entire cylindrical surface is covered. - The method is designed to handle the closed nature of the cylindrical surface, which is why it is overloaded in this specific class.
Examples
Generating the points and polygons for a cylinder surface:
points, polys = cylinder.polylist()
- radius¶