mahautils.shapes.OpenShape2D#

class mahautils.shapes.OpenShape2D(default_num_coordinates: int | None = None, construction: bool = False, units: str | None = None)#

Bases: Shape2D

A class that represents an open, two-dimensional shape

This class is intended to represent open shapes (i.e., shapes for which the boundary does not form a single closed path, so there is no clear definition as to whether a point in space is inside or outside the shape).

Methods

__init__([default_num_coordinates, ...])

Creates an object representing an open, 2D geometric shape

xy_coordinates(*args, **kwargs)

Generates Cartesian coordinates of the shape

Inherited Attributes

construction

Whether the shape is a "construction shape" meant for visual display but not functional geometry

default_num_coordinates

The number of coordinates to use when representing a discretized form of the shape

is_closed

Whether the shape is bounded by a closed perimeter

units

The units in which the geometry is defined

Inherited Methods

points()

Returns a list containing discretized points around the perimeter of the shape

reflect(pntA, pntB)

Reflects the shape across a line defined by two points

reflect_x()

Reflects the shape over the \(x\)-axis

reflect_y()

Reflects the shape over the \(y\)-axis

rotate(center, angle[, angle_units])

Rotates the shape in the \(xy\)-plane

translate([x, y])

Translates the shape in the \(xy\)-plane

__init__(default_num_coordinates: int | None = None, construction: bool = False, units: str | None = None) None#

Creates an object representing an open, 2D geometric shape

Defines an object which represents an open shape in the 2D Cartesian coordinate system.

Parameters:
  • default_num_coordinates (int, optional) – The default number of coordinates to use when representing the shape (default is None)

  • construction (bool, optional) – Whether the shape is a “construction shape” meant for visual display but not functional geometry (default is False)

property construction#

Whether the shape is a “construction shape” meant for visual display but not functional geometry

property default_num_coordinates#

The number of coordinates to use when representing a discretized form of the shape

property is_closed#

Whether the shape is bounded by a closed perimeter

points() Tuple[ndarray, ...]#

Returns a list containing discretized points around the perimeter of the shape

This method returns a tuple, of which each element is a point along the perimeter of the shape.

See also

xy_coordinates

Returns the same coordinates as xy_coordinates() except that points are returned as a list, where each entry is a point on the perimeter of the shape (essentially the transpose of xy_coordinates())

reflect(pntA: List[float] | Tuple[float, float] | ndarray | CartesianPoint2D, pntB: List[float] | Tuple[float, float] | ndarray | CartesianPoint2D) None#

Reflects the shape across a line defined by two points

Parameters:
  • pntA (list or tuple or CartesianPoint2D) – One point on the line across which the shape is to be reflected

  • pntB (list or tuple or CartesianPoint2D) – Another point on the line across which the shape is to be reflected

reflect_x()#

Reflects the shape over the \(x\)-axis

reflect_y()#

Reflects the shape over the \(y\)-axis

rotate(center: List[float] | Tuple[float, float] | ndarray | CartesianPoint2D, angle: float, angle_units: str = 'rad') None#

Rotates the shape in the \(xy\)-plane

Rotates the shape the shape a given angle in the \(xy\)-plane about a user-specified point.

Parameters:
  • center (list or tuple or CartesianPoint2D) – The center of rotation about which to rotate the shape

  • angle (float) – The angle by which to rotate the shape about center

  • angle_units (str, optional) – The units (radians or degrees) of the angle argument. Must be either 'rad' or 'deg' (default is 'rad')

translate(x: float = 0, y: float = 0) None#

Translates the shape in the \(xy\)-plane

Translates the shape a user-specified distance in the \(x\)- and/or \(y\)-directions.

Parameters:
  • x (float, optional) – The distance to translate the shape in the \(x\)-direction (default is 0)

  • y (float, optional) – The distance to translate the shape in the \(y\)-direction (default is 0)

property units: str | None#

The units in which the geometry is defined

xy_coordinates(*args, **kwargs) Tuple[ndarray, ndarray]#

Generates Cartesian coordinates of the shape

This method generates a set of discretized points around the perimeter of the shape. Points are returned as a tuple of two NumPy arrays: the first NumPy array contains the x-coordinates of the points, and the second NumPy array contains the y-coordinates. This format makes it relatively easy to plot the shape using packages like Matplotlib.

See also

points

Returns the same coordinates as xy_coordinates() except that points are returned with the x- and y-coordinates grouped for each point (essentially the transpose of xy_coordinates())