topologicpy 0.8.10__py3-none-any.whl → 0.8.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
topologicpy/Face.py CHANGED
@@ -3411,6 +3411,61 @@ class Face():
3411
3411
  return None
3412
3412
  return Face.ByWire(wire, tolerance=tolerance)
3413
3413
 
3414
+
3415
+ @staticmethod
3416
+ def ThirdVertex(face, tolerance: float = 0.0001, silent: bool = False):
3417
+ """
3418
+ Returns a third vertex on the input face to enable rotation matrix creation.
3419
+
3420
+ Parameters
3421
+ ----------
3422
+ face : topologic_core.Face
3423
+ The input face.
3424
+ tolerance : float , optional
3425
+ The desired tolerance. The default is 0.0001.
3426
+ silent : bool , optional
3427
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
3428
+
3429
+ Returns
3430
+ -------
3431
+ topologic_core.Face
3432
+ The created face.
3433
+
3434
+ """
3435
+ from topologicpy.Vector import Vector
3436
+ from topologicpy.Vertex import Vertex
3437
+ from topologicpy.Topology import Topology
3438
+
3439
+ if not Topology.IsInstance(face, "Face"):
3440
+ if not silent:
3441
+ print("Face.ThirdVertex - Error: The input face parameter is not a valid face. Returning None.")
3442
+ return None
3443
+ # Retrieve all vertices of the face
3444
+ vertices = Face.Vertices(face)
3445
+ centroid = Topology.Centroid(face)
3446
+ normal = Face.Normal(face)
3447
+ for vertex in vertices:
3448
+ # Skip the centroid itself
3449
+ if Vertex.Distance(centroid, vertex) <= tolerance:
3450
+ continue
3451
+
3452
+ # Vector from the centroid to the current vertex
3453
+ vector_to_vertex = Vector.ByVertices(centroid, vertex)
3454
+ vector_to_vertex_normalized = Vector.Normalize(vector_to_vertex)
3455
+
3456
+
3457
+ # Check if the vector_to_vertex is collinear with the normal direction
3458
+ if Vector.IsCollinear(vector_to_vertex_normalized, normal, tolerance):
3459
+ continue
3460
+
3461
+ # If not collinear, return this vertex
3462
+ return vertex
3463
+
3464
+ # No valid third vertex found
3465
+ if not silent:
3466
+ print("Face.ThirdVertex - Warning: No valid third vertex could be found. Returning None.")
3467
+ return None
3468
+
3414
3469
  @staticmethod
3415
3470
  def Trapezoid(origin= None, widthA: float = 1.0, widthB: float = 0.75, offsetA: float = 0.0, offsetB: float = 0.0, length: float = 1.0, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
3416
3471
  """