API Reference geometry

geometry

PHX Geometry Classes

Source: PHX/geometry.py


PolygonEdgeError

Raised when a PhxPolygonRectangular edge cannot be constructed due to missing vertices.

Inherits from: Exception

Attributes

AttributeTypeDescription
msg

PhxVertix2D

A 2D vertex point used for planar geometry operations.

Properties

PropertyTypeDescription
unique_keyReturn a unique key (str) for the Vertex. Used for dicts, welding, etc

Methods

is_equivalent(other)

Check coordinate equivalence with another vertex, ignoring ID.

ArgTypeDescription
otherThe vertex to compare against.

PhxVertix

A 3D vertex point used as the fundamental geometric primitive in PHX.

Properties

PropertyTypeDescription
unique_keyReturn a unique key (str) for the Vertex. Used for dicts, welding, etc

Methods

is_equivalent(other)

Check coordinate equivalence with another vertex, ignoring ID.

ArgTypeDescription
otherThe vertex to compare against.

distance_to(other)

Return the distance between this vertex and another.

ArgTypeDescription
other

PhxVector

A 3D vector used for normals, directions, and geometric operations.

Methods

classmethod from_2_points(_start_pt, _end_pt)

Return a new PhxVector based on a start and end point.

ArgTypeDescription
_start_pt
_end_pt

scale(_factor)

Scale this vector in-place by a scalar factor.

ArgTypeDescription
_factorThe scalar multiplier.

dot(other)

Get the dot product of this vector with another.

ArgTypeDescription
other

rotate_around(_axis, _angle_deg)

Rotate this vector around an axis by an angle in degrees using Rodrigues’ rotation formula.

ArgTypeDescription
_axisThe unit axis of rotation.
_angle_degThe rotation angle in degrees.

unitize()

Convert this vector to a unit vector.


PhxPlane

A 3D plane defined by an origin point, a normal vector, and local X/Y axes.

Properties

PropertyTypeDescription
normalThe plane’s surface normal vector.

Methods

xyz_to_xy(point)

Get a Point2D in the coordinate system of this plane from a Point3D.

ArgTypeDescription
point

xy_to_xyz(point)

Get a Point3D from a Point2D in the coordinate system of this plane.

ArgTypeDescription
point

PhxLineSegment

A 3D line segment defined by two endpoint vertices.

Properties

PropertyTypeDescription
lengthThe Euclidean length of the segment.

Methods

classmethod from_length(_length)

Create a PhxLineSegment from a length value along the X-axis.

ArgTypeDescription
_length

PhxPolygon

A 3D polygon surface defined by 3 or more coplanar vertices.

Properties

PropertyTypeDescription
areaThe polygon area, lazily computed from vertices using the shoelace formula.
centerThe polygon centroid, lazily computed as the average of all vertex positions.
display_nameThe polygon’s display name, falling back to its numeric ID if unset.
verticesThe ordered list of vertices defining this polygon’s boundary.
vertices_id_numbersThe ID numbers of all vertices in order.
angle_from_horizontalReturn the surface normal’s angle (degrees) off horizontal.
is_horizontalTrue if the polygon faces up or down (normal within tolerance of vertical).
is_verticalTrue if the polygon’s normal is perpendicular to the vertical axis.
cardinal_orientation_angleCalculate polygon normal’s horizontal angle off a reference. By default, the

Methods

add_vertix(_phx_vertix)

Append a vertex to this polygon’s boundary.

ArgTypeDescription
_phx_vertixThe vertex to add.

add_child_poly_id(_child_ids)

Register one or more child polygon IDs (e.g., window openings within a wall polygon).

ArgTypeDescription
_child_idsA single ID or collection of child polygon IDs.

set_vertex(_phx_vertix, index)

Set a vertex at a specific index.

ArgTypeDescription
_phx_vertix
index

calculate_area()

Calculate the area of the polygon.

calculate_center()

Find the center of the polygon.

scale(_scale_factor)

Scale the polygon in-place about its centroid by the given factor.

ArgTypeDescription
_scale_factorThe scale multiplier. Default: 1.0.

perimeter_length()

Calculate the total perimeter length of the polygon.


PhxPolygonRectangular

A rectangular polygon with named corner vertices and edge accessors.

Inherits from: PhxPolygon

Properties

PropertyTypeDescription
edge_topReturns the PhxLineSegment representing the ‘Top’ side of the Polygon (viewed from outside).
edge_leftReturns the PhxLineSegment representing the ‘Left’ side of the Polygon (viewed from outside).
edge_bottomReturns the PhxLineSegment representing the ‘Bottom’ side of the Polygon (viewed from outside).
edge_rightReturns the PhxLineSegment representing the ‘Right’ side of the Polygon (viewed from outside).
widthThe width of the rectangular polygon (top edge length).
heightThe height of the rectangular polygon (left edge length).
verticesReturn a List of the PhxPolygonRectangle Vertices (counter-clockwise from upper-left).
areaReturns the area of the rectangular surface.

Methods

add_vertix(_phx_vertix)

ArgTypeDescription
_phx_vertix

set_vertex(_phx_vertix, index)

Set a vertex at a specific index.

ArgTypeDescription
_phx_vertix
index

perimeter_length()

Calculate the total perimeter length of the polygon.


PhxGraphics3D

A collection of 3D polygons representing the geometry of a building component.

Properties

PropertyTypeDescription
verticesReturns a sorted list with all of the unique vertix objects of all the polygons in the collection.

Methods

add_polygons(_polygons)

Adds a new Polygon object to the collection

ArgTypeDescription
_polygons

get_polygons_by_id(_ids)

Returns a sorted list of polygons in the collection matching the IDs supplied.

ArgTypeDescription
_ids(Collection[int]): A collection of one or more id_nums to look for.