Skip to content
Gaspar edited this page Jan 17, 2024 · 8 revisions

Class Face

Represents a face defined by a plane and a texture.

Attributes

Attribute Type Description Note
id int The unique identifier for the face
plane Plane The Plane that composes the face
texture Texture The texture definition
_vertices list[Point] List of vertices ordered in clockwise To get value use vertices property instead
_edges list[Edge] List of edges To get value use edges property instead

Methods

__init__(self, plane: Plane, texture: Texture)

Constructor method for the Face class.

f = Face()

normal

Returns the normal vector of the face's plane.

normal_vec = f.normal

texture_normal

Returns the normal vector of the face's texture.

t_normal = f.texture_normal

vertices

Get a list of vertices of the face.

# Before you must call Brush vertices property `b.vertices`
list_face_verts = f.vertices 

edges

Get a list of Edge object of the face.

# Before you must call Face vertices property `f.vertices`
list_face_edges = f.edges

centroid(self)

Calculates the centroid of the face.

# Before you must use Brush vertices `b.vertices`
face_centroid = f.centroid() 

copy(self)

Creates a deep copy of the face.

f_copy = f.copy()

has_texture(self, text_name: str, exact: bool = True)

Checks if the face has a specific texture.

if f.has_texture('aaatrigger', exact=True):
  # ...

is_valid(self, threshold: float = 1e-3)

Checks if the face is valid based on its geometry or the texture axis alignment.

if f.is_valid():
   # ...

move_by(self, x: float, y: float, z: float)

Moves the face by specified offsets.

f.move_by(10,20,30)

rotate_x(self, angle: float, center: Point)

Rotates the face around the X-axis.

f.rotate_x(45)

rotate_y(self, angle: float, center: Point)

Rotates the face around the Y-axis.

f.rotate_y(45)

rotate_z(self, angle: float, center: Point)

Rotates the face around the Z-axis.

f.rotate_z(45)

rotate_xyz(self, phi, theta, psi)

Rotates the face around the XYZ axes.

f.rotate_xyz(45,45,45)

rotate_around_axis(self, angle: float, axis: Vector3)

Rotates the face around a given axis.

f.rotate_around_axis(45, Vector3(1,1,1))

set_texture(self, text_name: str)

Sets the texture name of the face.

f.set_texture('null')

_add_vertex(self, vertex: Point)

Adds a vertex to the face.


_get_edges(self)

Computes the edges of the face based on its vertices.


__repr__(self)

Returns a string representation of the face.


__iter__(self)

Return an iterator over the face plane points.

for point in f:
  # ...

__contains__(self, other: Union[str, Point])

Checks if a texture or a point is present in the face plane.

if Point(32,32,32) in f:
 # ...
if 'aaatrigger' in f:
 # ...

Next: Class Texture