@@ -463,6 +463,54 @@ def rotate(self, deg_angle=None, rad_angle=None, axis='x'):
463463 elif id == 3 :
464464 self .root_face = face
465465
466+ def mirror (self , point1 , point2 , point3 ):
467+ """
468+ 3D mirroring of the blade with respect to a plane defined by three points
469+
470+ :param list point1: coordinates of point1
471+ :param list point2: coordinates of point2
472+ :param list point3: coordinates of point3
473+
474+ """
475+ if len (self .blade_coordinates_up ) == 0 :
476+ raise ValueError ('You must apply transformations before rotation.' )
477+
478+ from OCC .Core .BRepBuilderAPI import BRepBuilderAPI_Transform
479+ from OCC .Core .gp import gp_Pnt
480+ from OCC .Core .gp import gp_Vec
481+ from OCC .Core .gp import gp_Dir
482+ from OCC .Core .gp import gp_Ax2
483+ from OCC .Core .gp import gp_Trsf
484+
485+ point1 = gp_Pnt (* point1 )
486+ point2 = gp_Pnt (* point2 )
487+ point3 = gp_Pnt (* point3 )
488+
489+ # Two vectors defining the directions of the plane
490+ vector1 = gp_Vec (point1 , point2 )
491+ vector2 = gp_Vec (point2 , point3 )
492+ # Normal versor to the plane passing through the three points
493+ normal = gp_Dir (vector1 .Crossed (vector2 ))
494+ # Ax2 object identifying the plane
495+ ax2 = gp_Ax2 (point1 , normal )
496+
497+ # Mirroring wrt plane transformation
498+ trsf = gp_Trsf ()
499+ trsf .SetMirror (ax2 )
500+
501+ for id , face in enumerate ([self .upper_face , self .lower_face ,
502+ self .tip_face , self .root_face ]):
503+ brep_tr = BRepBuilderAPI_Transform (face , trsf , True , True )
504+ face = brep_tr .Shape ()
505+ if id == 0 :
506+ self .upper_face = face
507+ elif id == 1 :
508+ self .lower_face = face
509+ elif id == 2 :
510+ self .tip_face = face
511+ elif id == 3 :
512+ self .root_face = face
513+
466514 def scale (self , factor ):
467515 """
468516 Scale the blade coordinates by a specified factor.
0 commit comments