Rectangle¶
-
class
sknano.core.geometric_regions.Rectangle(pmin=None, pmax=None, xmin=0, ymin=0, xmax=1, ymax=1)[source] [edit on github][source]¶ Bases:
sknano.core.geometric_regions.Geometric2DRegionGeometric2DRegionfor a rectangle.New in version 0.3.0.
Represents an axis-aligned bounded region from \(p_{\mathrm{min}}=(x_{\mathrm{min}},y_{\mathrm{min}})\) to \(p_{\mathrm{max}}=(x_{\mathrm{max}},y_{\mathrm{max}})\).
Parameters: - pmax (pmin,) – The minimum and maximum 2D point coordinates of the axis-aligned
rectangle from
pmin=[xmin, ymin]topmax=[xmax, ymax]. - ymin (xmin,) – The minimum \((x, y)\) point of the axis-aligned rectangle.
- ymax (xmax,) – The maximum \((x, y)\) point of the axis-aligned rectangle.
Notes
Rectanglerepresents the region \(\left\{\{x, y\}|x_{\mathrm{min}}\le x\le x_{\mathrm{max}} \land y_{\mathrm{min}}\le y\le y_{\mathrm{max}}\right\}\)Calling
Rectanglewith no parameters is equivalent toRectangle(pmin=[0, 0], pmax=[1, 1]).Attributes
aAlias for Rectangle.lx.areaRectanglearea, \(A=\ell_x\ell_y\)bAlias for Rectangle.ly.bounding_boxBounding Cuboid.centerAlias for centroid.centroidRectanglecentroid, \((c_x, c_y)\).fmtstrFormat string. lengthstupleof side lengthslxDistance between \(x_{\mathrm{max}}-x_{\mathrm{min}}\). lyDistance between \(y_{\mathrm{max}}-y_{\mathrm{min}}\). measureAlias for area, which is the measure of a 2D geometric region.ndimReturn the dimensions. pmax2D Pointat (xmax,ymax).pmin2D Pointat (xmin,ymin).xmax\(x_{\mathrm{max}}\) coordinate. xmin\(x_{\mathrm{min}}\) coordinate. ymax\(y_{\mathrm{max}}\) coordinate. ymin\(y_{\mathrm{min}}\) coordinate. Methods
center_centroid()Center centroidon origin.contains(point)Test region membership of pointinRectangle.get_points()Return list of points from GeometricRegion.pointsandGeometricRegion.vectorsrotate(**kwargs)Rotate GeometricRegionpointsandvectors.todict()Returns a dictof theRectangleconstructor parameters.translate(t[, fix_anchor_points])Translate GeometricRegionpointsandvectorsbyVectort.Attributes Summary
aAlias for Rectangle.lx.areaRectanglearea, \(A=\ell_x\ell_y\)bAlias for Rectangle.ly.centroidRectanglecentroid, \((c_x, c_y)\).lengthstupleof side lengthslxDistance between \(x_{\mathrm{max}}-x_{\mathrm{min}}\). lyDistance between \(y_{\mathrm{max}}-y_{\mathrm{min}}\). pmax2D Pointat (xmax,ymax).pmin2D Pointat (xmin,ymin).xmax\(x_{\mathrm{max}}\) coordinate. xmin\(x_{\mathrm{min}}\) coordinate. ymax\(y_{\mathrm{max}}\) coordinate. ymin\(y_{\mathrm{min}}\) coordinate. Methods Summary
contains(point)Test region membership of pointinRectangle.todict()Returns a dictof theRectangleconstructor parameters.Attributes Documentation
-
a¶ Alias for
Rectangle.lx.
-
b¶ Alias for
Rectangle.ly.
-
centroid¶ Rectanglecentroid, \((c_x, c_y)\).Computed as the 2D
Point\((c_x, c_y)\) with coordinates:\[c_x = \frac{x_{\mathrm{min}}+x_{\mathrm{max}}}{2}\]\[c_y = \frac{y_{\mathrm{min}}+y_{\mathrm{max}}}{2}\]Returns: 2D Pointof centroid.Return type: Point
-
lx¶ Distance between \(x_{\mathrm{max}}-x_{\mathrm{min}}\).
-
ly¶ Distance between \(y_{\mathrm{max}}-y_{\mathrm{min}}\).
-
xmax¶ \(x_{\mathrm{max}}\) coordinate.
-
xmin¶ \(x_{\mathrm{min}}\) coordinate.
-
ymax¶ \(y_{\mathrm{max}}\) coordinate.
-
ymin¶ \(y_{\mathrm{min}}\) coordinate.
Methods Documentation
-
contains(point)[source] [edit on github][source]¶ Test region membership of
pointinRectangle.Parameters: point (array_like) – Returns: Trueifpointis withinRectangle,False, otherwise.Return type: boolNotes
A point \((p_x, p_y)\) is within the bounded region of a rectangle with lower corner at \(p_{\mathrm{min}}= (x_{\mathrm{min}}, y_{\mathrm{min}})\) and upper corner at \(p_{\mathrm{max}}= (x_{\mathrm{max}}, y_{\mathrm{max}})\) if the following is true:
\[x_{\mathrm{min}}\le x\le x_{\mathrm{max}}\land\]\[y_{\mathrm{min}}\le y\le y_{\mathrm{max}}\]
- pmax (pmin,) – The minimum and maximum 2D point coordinates of the axis-aligned
rectangle from