aerosandbox.geometry.polygon ============================ .. py:module:: aerosandbox.geometry.polygon Attributes ---------- .. autoapisummary:: aerosandbox.geometry.polygon.theta Classes ------- .. autoapisummary:: aerosandbox.geometry.polygon.Polygon Module Contents --------------- .. py:class:: Polygon(coordinates) Bases: :py:obj:`aerosandbox.common.AeroSandboxObject` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: coordinates .. py:method:: __repr__() .. py:method:: x() Returns the x coordinates of the polygon. Equivalent to Polygon.coordinates[:,0]. :returns: X coordinates as a vector .. py:method:: y() Returns the y coordinates of the polygon. Equivalent to Polygon.coordinates[:,1]. :returns: Y coordinates as a vector .. py:method:: n_points() Returns the number of points/vertices/coordinates of the polygon. .. py:method:: scale(scale_x = 1.0, scale_y = 1.0) Scales a Polygon about the origin. :param scale_x: Amount to scale in the x-direction. :param scale_y: Amount to scale in the y-direction. Returns: The scaled Polygon. .. py:method:: translate(translate_x = 0.0, translate_y = 0.0) Translates a Polygon by a given amount. :param translate_x: Amount to translate in the x-direction :param translate_y: Amount to translate in the y-direction Returns: The translated Polygon. .. py:method:: rotate(angle, x_center = 0.0, y_center = 0.0) Rotates a Polygon clockwise by the specified amount, in radians. Rotates about the point (x_center, y_center), which is (0, 0) by default. :param angle: Angle to rotate, counterclockwise, in radians. :param x_center: The x-coordinate of the center of rotation. :param y_center: The y-coordinate of the center of rotation. Returns: The rotated Polygon. .. py:method:: area() Returns the area of the polygon. .. py:method:: perimeter() Returns the perimeter of the polygon. .. py:method:: centroid() Returns the centroid of the polygon as a 1D np.ndarray of length 2. .. py:method:: Ixx() Returns the nondimensionalized Ixx moment of inertia, taken about the centroid. .. py:method:: Iyy() Returns the nondimensionalized Iyy moment of inertia, taken about the centroid. .. py:method:: Ixy() Returns the nondimensionalized product of inertia, taken about the centroid. .. py:method:: J() Returns the nondimensionalized polar moment of inertia, taken about the centroid. .. py:method:: write_sldcrv(filepath = None) Writes a .sldcrv (SolidWorks curve) file corresponding to this Polygon to a filepath. :param filepath: A filepath (including the filename and .sldcrv extension) [string] if None, this function returns the .sldcrv file as a string. Returns: None .. py:method:: contains_points(x, y) Returns a boolean array of whether some (x, y) point(s) are contained within the Polygon. Note: This function is unfortunately not automatic-differentiable. :param x: x-coordinate(s) of the query points. :param y: y-coordinate(s) of the query points. :returns: A boolean array of the same size as x and y, with values corresponding to whether the points are inside the Polygon. .. py:method:: as_shapely_polygon() Returns a Shapely Polygon object representing this polygon. Shapely is a Python library for 2D geometry operations. While it is more powerful than this class (e.g., allows for union/intersection calculation between Polygons), it is not automatic-differentiable. .. py:method:: jaccard_similarity(other) Calculates the Jaccard similarity between this polygon and another polygon. Note: This function is unfortunately not automatic-differentiable. :param other: The other polygon to compare to. :returns: The Jaccard similarity between this polygon and the other polygon. * 0 if the polygons are completely disjoint * 1 if the polygons are identical .. py:method:: draw(set_equal=True, color=None, **kwargs) Draws the Polygon on the current matplotlib axis. :param set_equal: Whether to set the aspect ratio of the plot to be equal. :param \*\*kwargs: Keyword arguments to pass to the matplotlib.pyplot.fill function. See: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.fill.html Returns: None (draws on the current matplotlib axis) .. py:data:: theta