1 # -*- coding: utf-8 -*-
4 from geomsmesh import geompy
6 from triedreBase import triedreBase
7 O, OX, OY, OZ = triedreBase()
9 # -----------------------------------------------------------------------------
10 # --- operateur de rotation translation d'un objet centré à l'origine
12 def rotTrans(objet, orientation, point, normal, trace = False):
14 Déplacement par rotation translation d'un objet centré à l'origine, vers un point de la surface de la pièce saine
15 dans laquelle on insère le défaut.
16 @param objet : objet original centré à l'origine (geomObject)
17 @param orientation : rotation selon OX de l'objet original (degrés)
18 @param point : le point qui sera le centre de l'objet déplacé (geomObject), en général sur la surface de la pièce saine
19 @param normal : la normale à la surface de la pièce saine au point central (geomObject)
20 @return trans : objet transformé (geomObject)
23 planXY = geompy.MakePlaneLCS(None, 2000, 1)
24 projXY = geompy.MakeProjection(normal, planXY)
25 [v1,v2] = geompy.ExtractShapes(projXY, geompy.ShapeType["VERTEX"], False)
26 xyz1 = geompy.PointCoordinates(v1)
27 xyz2 = geompy.PointCoordinates(v2)
30 sinalpha = y / math.sqrt(x*x + y*y)
31 cosalpha = x / math.sqrt(x*x + y*y)
32 alpha = math.asin(sinalpha)
34 alpha = math.pi -alpha
36 beta = geompy.GetAngleRadians(OZ, normal)
37 [v1,v2] = geompy.ExtractShapes(normal, geompy.ShapeType["VERTEX"], False)
38 xyz1 = geompy.PointCoordinates(v1)
39 xyz2 = geompy.PointCoordinates(v2)
44 rot0 = geompy.MakeRotation(objet, OX, orientation*math.pi/180.0)
45 rot1 = geompy.MakeRotation(rot0, OZ, alpha)
46 axe2 = geompy.MakeRotation(OY, OZ, alpha)
47 rot2 = geompy.MakeRotation(rot1, axe2, beta -math.pi/2.)
48 logging.debug("alpha",alpha)
49 logging.debug("beta",beta)
51 geompy.addToStudy( rot1, 'rot1' )
52 geompy.addToStudy( axe2, 'axe2' )
53 geompy.addToStudy( rot2, 'rot2' )
55 xyz = geompy.PointCoordinates(point)
56 trans = geompy.MakeTranslation(rot2, xyz[0], xyz[1], xyz[2])