Square¶
-
class
sknano.core.geometric_regions.Square(center=None, a=1)[source] [edit on github][source]¶ Bases:
sknano.core.geometric_regions.Geometric2DRegionGeometric2DRegionfor a square.New in version 0.3.0.
Represents the axis-aligned bounded region with center \((c_x, c_y)\) and side length \(a\).
Parameters: - center (array_like, optional) – The center point coordinate \((c_x, c_y)\) of the axis-aligned square.
- a (float, optional) – The side length \(a\) of the axis-aligned square.
Notes
Squarerepresents the region \(\left\{\{c_i\pm\frac{a}{2}\}|a>0\forall i\in\{x,y\}\right\}\).Calling
Squarewith no parameters is equivalent toSquare(center=[0, 0], a=1).Attributes
aSide length \(a\) of the axis-aligned square. areaSquarearea, \(A=a^2\).bounding_boxBounding Cuboid.centerCenter point \((c_x, c_y)\) of axis-aligned square. centroidAlias for center.fmtstrFormat string. measureAlias for area, which is the measure of a 2D geometric region.ndimReturn the dimensions. pmaxPointat maximum extent.pminPointat minimum extent.Methods
center_centroid()Center centroidon origin.contains(point)Test region membership of pointinSquare.get_points()Return list of points from GeometricRegion.pointsandGeometricRegion.vectorsrotate(**kwargs)Rotate GeometricRegionpointsandvectors.todict()Returns a dictof theSquareconstructor parameters.translate(t[, fix_anchor_points])Translate GeometricRegionpointsandvectorsbyVectort.Attributes Summary
aSide length \(a\) of the axis-aligned square. areaSquarearea, \(A=a^2\).centerCenter point \((c_x, c_y)\) of axis-aligned square. centroidAlias for center.Methods Summary
contains(point)Test region membership of pointinSquare.todict()Returns a dictof theSquareconstructor parameters.Attributes Documentation
-
a¶ Side length \(a\) of the axis-aligned square.
-
center¶ Center point \((c_x, c_y)\) of axis-aligned square.
Methods Documentation
-
contains(point)[source] [edit on github][source]¶ Test region membership of
pointinSquare.Parameters: point (array_like) – Returns: Trueifpointis withinSquare,Falseotherwise.Return type: boolNotes
A
point\((p_x, p_y)\) is within the bounded region of a square with center \((c_x, c_y)\) and side length \(a\) if the following is true:\[c_i - \frac{a}{2}\le p_i\le c_i + \frac{a}{2}\forall i\in \{x, y\}\]