anastruct.vertex

Classes

Vertex

Utility point in 2D.

Functions

vertex_range(→ list)

Create a list of n Vertex objects between two Vertex objects

det_coordinates(→ numpy.ndarray)

Convert a point to coordinates

Module Contents

class anastruct.vertex.Vertex(x: anastruct._types.VertexLike | anastruct._types.NumberLike, y: anastruct._types.NumberLike | None = None)[source]

Utility point in 2D.

property x: float[source]

X coordinate

Returns:

float: X coordinate

property y: float[source]

Y coordinate

Returns:

float: Y coordinate

property y_neg: float[source]

Y negative coordinate (equals negative of Y coordinate)

Returns:

float: Y_neg coordinate

modulus() float[source]

Magnitude of the vector from the origin to the Vertex

Returns:

float: Magnitude of the vector from the origin to the Vertex

unit() Vertex[source]

Unit vector from the origin to the Vertex

Returns:

Vertex: Unit vector from the origin to the Vertex

displace_polar(alpha: float, radius: float, inverse_y_axis: bool = False) None[source]

Displace the Vertex by a polar coordinate

Args:

alpha (float): Angle in radians radius (float): Radius inverse_y_axis (bool, optional): Return a negative Y coordinate. Defaults to False.

__add__(other: anastruct._types.VertexLike | anastruct._types.NumberLike) Vertex[source]

Add two Vertex objects

Args:

other (Union[VertexLike, NumberLike]): Vertex to add

Returns:

Vertex: Sum of the two Vertex objects

__radd__(other: anastruct._types.VertexLike | anastruct._types.NumberLike) Vertex[source]

Add two Vertex objects

Args:

other (Union[VertexLike, NumberLike]): Vertex to add

Returns:

Vertex: Sum of the two Vertex objects

__sub__(other: anastruct._types.VertexLike | anastruct._types.NumberLike) Vertex[source]

Subtract two Vertex objects

Args:

other (Union[VertexLike, NumberLike]): Vertex to subtract

Returns:

Vertex: Difference of the two Vertex objects

__rsub__(other: anastruct._types.VertexLike | anastruct._types.NumberLike) Vertex[source]

Subtract two Vertex objects

Args:

other (Union[VertexLike, NumberLike]): Vertex to subtract

Returns:

Vertex: Difference of the two Vertex objects

__mul__(other: anastruct._types.VertexLike | anastruct._types.NumberLike) Vertex[source]

Multiply two Vertex objects

Args:

other (Union[VertexLike, NumberLike]): Vertex to multiply

Returns:

Vertex: Product of the two Vertex objects

__rmul__(other: anastruct._types.VertexLike | anastruct._types.NumberLike) Vertex[source]

Multiply two Vertex objects

Args:

other (Union[VertexLike, NumberLike]): Vertex to multiply

Returns:

Vertex: Product of the two Vertex objects

__truediv__(other: anastruct._types.VertexLike | anastruct._types.NumberLike) Vertex[source]

Divide two Vertex objects

Args:

other (Union[VertexLike, NumberLike]): Vertex to divide

Returns:

Vertex: Quotient of the two Vertex objects

__eq__(other: object) bool[source]

Check if two Vertex objects are equal

Args:

other (object): Object to compare

Raises:

NotImplementedError: If the object is not a Vertex object or a tuple or list of length 2

Returns:

bool: True if the two Vertex objects are equal

__str__() str[source]

String representation of the Vertex object

Returns:

str: String representation of the Vertex object

__hash__() int[source]

Hash of the Vertex object

Returns:

int: Hash of the Vertex object

anastruct.vertex.vertex_range(v1: Vertex, v2: Vertex, n: int) list[source]

Create a list of n Vertex objects between two Vertex objects

Args:

v1 (Vertex): Starting Vertex v2 (Vertex): Ending Vertex n (int): Number of Vertex objects to create

Returns:

list: List of n Vertex objects between v1 and v2

anastruct.vertex.det_coordinates(point: anastruct._types.VertexLike | anastruct._types.NumberLike) numpy.ndarray[source]

Convert a point to coordinates

Args:

point (Union[VertexLike, NumberLike]): Point to convert

Raises:

TypeError: If the point is not convertable to a Vertex object

Returns:

np.ndarray: Coordinates of the point