Cylinder

class sknano.core.geometric_regions.Cylinder(p1=None, p2=None, r=1)[source] [edit on github][source]

Bases: sknano.core.geometric_regions.Geometric3DRegion

Geometric3DRegion for a cylinder.

New in version 0.3.10.

Represents a cylinder of radius \(r\) around the line from \((x_1, y_1, z_1)\) to \((x_2, y_2, z_2)\).

Parameters:
  • p2 (p1,) – 3-tuples or Point class instances specifying the Cylinder axis from point \(p_1=(x_1,y_1,z_1)\) to \(p_2=(x_2,y_2,z_2)\).
  • r (float, optional) – Cylinder radius \(r\)

Notes

Cylinder represents a cylinder region \(\left\{p_1+\rho\cos(\theta)\mathbf{v}_1 + \rho\sin(\theta)\mathbf{v}_2 + \mathbf{v}_3 z| 0\le\theta\le 2\pi\land 0\le\rho\le 1\land 0\le z\le 1\right\}\) where \(\mathbf{v}_3=p_2 - p_1\) and the vectors \(\{\mathbf{v}_1,\mathbf{v}_2,\mathbf{v}_3\}\) are orthogonal with \(|\mathbf{v}_1|=|\mathbf{v}_2|=1\), and \(p_1=(x_1, y_1, z_1)\) and \(p_2=(x_2,y_2,z_2)\).

Calling Cylinder with no parameters is equivalent to Cylinder(p1=[0, 0, -1], p2=[0, 0, 1], r=1).

Attributes

axis Cylinder axis Vector \(\boldsymbol{\ell}=p_2 - p_1\).
bounding_box Bounding Cuboid.
center Alias for centroid.
centroid Cylinder centroid, \((c_x, c_y, c_z)\).
fmtstr Format string.
measure Alias for volume, which is the measure of a 3D geometric region.
ndim Return the dimensions.
p1 Cylinder axis point \(p_1=(x_1, y_1, z_1)\).
p2 Cylinder axis point \(p_2=(x_2, y_2, z_2)\).
pmax Point at maximum extent.
pmin Point at minimum extent.
r Cylinder radius \(r\).
volume Cylinder volume, \(V=\pi r^2 \ell\).

Methods

center_centroid() Center centroid on origin.
contains(point) Test region membership of point in Cylinder.
get_points() Return list of points from GeometricRegion.points and GeometricRegion.vectors
rotate(**kwargs) Rotate GeometricRegion points and vectors.
todict() Returns a dict of the Cylinder constructor parameters.
translate(t[, fix_anchor_points]) Translate GeometricRegion points and vectors by Vector t.

Attributes Summary

axis Cylinder axis Vector \(\boldsymbol{\ell}=p_2 - p_1\).
centroid Cylinder centroid, \((c_x, c_y, c_z)\).
p1 Cylinder axis point \(p_1=(x_1, y_1, z_1)\).
p2 Cylinder axis point \(p_2=(x_2, y_2, z_2)\).
r Cylinder radius \(r\).
volume Cylinder volume, \(V=\pi r^2 \ell\).

Methods Summary

contains(point) Test region membership of point in Cylinder.
todict() Returns a dict of the Cylinder constructor parameters.

Attributes Documentation

axis

Cylinder axis Vector \(\boldsymbol{\ell}=p_2 - p_1\).

Returns:3D Vector along Cylinder axis from Point \(p_1=(x_1, y_1, z_1)\) to Point \(p_2=(x_2, y_2, z_2)\).
Return type:Vector
centroid

Cylinder centroid, \((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}\]
p1

Cylinder axis point \(p_1=(x_1, y_1, z_1)\).

p2

Cylinder axis point \(p_2=(x_2, y_2, z_2)\).

r

Cylinder radius \(r\).

volume

Cylinder volume, \(V=\pi r^2 \ell\).

Methods Documentation

contains(point)[source] [edit on github][source]

Test region membership of point in Cylinder.

Parameters:point (array_like) –
Returns:True if point is within Cylinder, False otherwise.
Return type:bool

Notes

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^2\]

where \(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}\]
todict()[source] [edit on github][source]

Returns a dict of the Cylinder constructor parameters.