1 # -*- coding: utf-8 -*-
4 from geomsmesh import geompy
5 from geomsmesh import geomPublish
6 from geomsmesh import geomPublishInFather
9 from triedreBase import triedreBase
10 O, OX, OY, OZ = triedreBase()
12 # -----------------------------------------------------------------------------
13 # --- operateur de rotation translation d'un objet centré à l'origine
15 def rotTrans(objet, orientation, point, normal, trace = False):
17 Déplacement par rotation translation d'un objet centré à l'origine, vers un point de la surface de la pièce saine
18 dans laquelle on insère le défaut.
19 @param objet : objet original centré à l'origine (geomObject)
20 @param orientation : rotation selon OX de l'objet original (degrés)
21 @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
22 @param normal : la normale à la surface de la pièce saine au point central (geomObject)
23 @return trans : objet transformé (geomObject)
26 planXY = geompy.MakePlaneLCS(None, 2000, 1)
27 projXY = geompy.MakeProjection(normal, planXY)
28 [v1,v2] = geompy.ExtractShapes(projXY, geompy.ShapeType["VERTEX"], False)
29 xyz1 = geompy.PointCoordinates(v1)
30 xyz2 = geompy.PointCoordinates(v2)
33 sinalpha = y / math.sqrt(x*x + y*y)
34 cosalpha = x / math.sqrt(x*x + y*y)
35 alpha = math.asin(sinalpha)
37 alpha = math.pi -alpha
39 beta = geompy.GetAngleRadians(OZ, normal)
40 [v1,v2] = geompy.ExtractShapes(normal, geompy.ShapeType["VERTEX"], False)
41 xyz1 = geompy.PointCoordinates(v1)
42 xyz2 = geompy.PointCoordinates(v2)
47 rot0 = geompy.MakeRotation(objet, OX, orientation*math.pi/180.0)
48 rot1 = geompy.MakeRotation(rot0, OZ, alpha)
49 axe2 = geompy.MakeRotation(OY, OZ, alpha)
50 rot2 = geompy.MakeRotation(rot1, axe2, beta -math.pi/2.)
51 logging.debug("alpha",alpha)
52 logging.debug("beta",beta)
54 geomPublish(initLog.debug, rot1, 'rot1' )
55 geomPublish(initLog.debug, axe2, 'axe2' )
56 geomPublish(initLog.debug, rot2, 'rot2' )
58 xyz = geompy.PointCoordinates(point)
59 trans = geompy.MakeTranslation(rot2, xyz[0], xyz[1], xyz[2])