Cylinder¶
-
class
sknano.core.geometric_regions.Cylinder(p1=None, p2=None, r=1)[source] [edit on github][source]¶ Bases:
sknano.core.geometric_regions.Geometric3DRegionGeometric3DRegionfor a cylinder.New in version 0.3.10.
Represents a cylinder of radius r around the line from (x1,y1,z1) to (x2,y2,z2).
Parameters: Notes
Cylinderrepresents a cylinder region {p1+ρcos(θ)v1+ρsin(θ)v2+v3z|0≤θ≤2π∧0≤ρ≤1∧0≤z≤1} where v3=p2−p1 and the vectors {v1,v2,v3} are orthogonal with |v1|=|v2|=1, and p1=(x1,y1,z1) and p2=(x2,y2,z2).Calling
Cylinderwith no parameters is equivalent toCylinder(p1=[0, 0, -1], p2=[0, 0, 1], r=1).Attributes
axisCylinderaxisVector\boldsymbol{\ell}=p_2 - p_1.bounding_boxBounding Cuboid.centerAlias for centroid.centroidCylindercentroid, (c_x, c_y, c_z).fmtstrFormat string. measureAlias for volume, which is the measure of a 3D geometric region.ndimReturn the dimensions. p1Cylinderaxis point p_1=(x_1, y_1, z_1).p2Cylinderaxis point p_2=(x_2, y_2, z_2).pmaxPointat maximum extent.pminPointat minimum extent.rCylinderradius r.volumeCylindervolume, V=\pi r^2 \ell.Methods
center_centroid()Center centroidon origin.contains(point)Test region membership of pointinCylinder.get_points()Return list of points from GeometricRegion.pointsandGeometricRegion.vectorsrotate(**kwargs)Rotate GeometricRegionpointsandvectors.todict()Returns a dictof theCylinderconstructor parameters.translate(t[, fix_anchor_points])Translate GeometricRegionpointsandvectorsbyVectort.Attributes Summary
axisCylinderaxisVector\boldsymbol{\ell}=p_2 - p_1.centroidCylindercentroid, (c_x, c_y, c_z).p1Cylinderaxis point p_1=(x_1, y_1, z_1).p2Cylinderaxis point p_2=(x_2, y_2, z_2).rCylinderradius r.volumeCylindervolume, V=\pi r^2 \ell.Methods Summary
contains(point)Test region membership of pointinCylinder.todict()Returns a dictof theCylinderconstructor parameters.Attributes Documentation
-
axis¶ CylinderaxisVector\boldsymbol{\ell}=p_2 - p_1.Returns: 3D VectoralongCylinderaxis fromPointp_1=(x_1, y_1, z_1) toPointp_2=(x_2, y_2, z_2).Return type: Vector
-
centroid¶ Cylindercentroid, (c_x, c_y, c_z).Computed as:
c_x = \frac{x_1 + x_2}{2}c_y = \frac{y_1 + y_2}{2}c_z = \frac{z_1 + z_2}{2}
Methods Documentation
-
contains(point)[source] [edit on github][source]¶ Test region membership of
pointinCylinder.Parameters: point (array_like) – Returns: Trueifpointis withinCylinder,Falseotherwise.Return type: boolNotes
A
point(p_x, p_y, p_z) is within the bounded region of a cylinder with radius r around the line from p_1=(x_1, y_1, z_1) to p_2 = (x_2, y_2, z_2) if the following is true:0\le q\le 1\land (x_1 - p_x + (x_2 - x_1) q)^2 + (y_1 - p_y + (y_2 - y_1) q)^2 + (z_1 - p_z + (z_2 - z_1) q)^2 \le r^2where q is:
q = \frac{(p_x - x_1)(x_2 - x_1) + (p_y - y_1)(y_2 - y_1) + (p_z - z_1)(z_2 - z_1)}{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}
-