microstructpy.geometry.rectangle module¶
-
class
microstructpy.geometry.rectangle.
Rectangle
(**kwargs)[source]¶ Bases:
microstructpy.geometry.n_box.NBox
This class contains a generic, 2D rectangle. The position and dimensions of the box can be specified using any of the parameters below.
Parameters: - length (float, optional) – Length of the rectangle.
- width (float, optional) – Width of the rectangle.
- side_lengths (list, optional) – Side lengths. Defaults to (1, 1).
- center (list, optional) – Center of rectangle. Defaults to (0, 0).
- corner (list, optional) – bottom-left corner.
- bounds (list, optional) – Bounds of rectangle. Expected to be in the format [(xmin, xmax), (ymin, ymax)].
- limits – Alias for bounds.
- angle (float, optional) – The rotation angle, in degrees.
- angle_deg (float, optional) – The rotation angle, in degrees.
- angle_rad (float, optional) – The rotation angle, in radians.
- matrix (2x2 array, optional) – The rotation matrix.
-
best_fit
(points)[source]¶ Find rectangle of best fit for points
Parameters: points (list) – List of points to fit. Returns: - an instance of the class
- that best fits the points.
Return type: microstructpy.geometry.Rectangle
-
plot
(**kwargs)[source]¶ Plot the rectangle.
This function adds a matplotlib.patches.Rectangle patch to the current axes. The keyword arguments are passed through to the patch.
Parameters: **kwargs (dict) – Keyword arguments for the patch.
-
angle
¶
-
angle_deg
¶
-
angle_rad
¶
-
area
¶ area of rectangle
Type: float
-
length
¶
-
n_dim
¶ number of dimensions, 2
Type: int
-
width
¶
-
class
microstructpy.geometry.rectangle.
Square
(**kwargs)[source]¶ Bases:
microstructpy.geometry.rectangle.Rectangle
A square.
This class contains a generic, 2D square. It is derived from the
microstructpy.geometry.Rectangle
class and contains theside_length
property, rather than multiple side lengths.Parameters: - side_length (float, optional) – Side length. Defaults to 1.
- center (list, optional) – Center of rectangle. Defaults to (0, 0).
- corner (list, optional) – bottom-left corner.
-
side_length
¶ length of the side of the square.
Type: float