Salome HOME
7abbb78738bae1bc4694dec445e9f89e96e66dc0
[modules/geom.git] / doc / salome / examples / transformation_operations_ex02.py
1 # Rotation
2
3 import geompy
4 import salome
5 import math
6 gg = salome.ImportComponentGUI("GEOM")
7
8 # create a vertex and a vector
9 p1 = geompy.MakeVertex(10, 40,  0)
10 p2 = geompy.MakeVertex( 0,  0, 50)
11 p3 = geompy.MakeVertex(10, 50,-20)
12 p4 = geompy.MakeVertex(10, 50, 60)
13 v = geompy.MakeVector(p1, p2)
14 vr = geompy.MakeVector(p3, p4)
15
16 # create a cylinder
17 height = 35
18 radius1 = 20
19 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
20
21 # rotate the given object around the given axis by the given angle
22 rotation1 = geompy.MakeRotation(cylinder, vr, math.pi)
23 rotation2 = geompy.MakeRotationThreePoints(cylinder, p4, p1, p2)
24
25 # add objects in the study
26 id_vr = geompy.addToStudy(vr, "Rotation 1 axis")
27 id_p4 = geompy.addToStudy(p4, "Rotation 2 center")
28 id_p1 = geompy.addToStudy(p1, "Rotation 2 point 1")
29 id_p2 = geompy.addToStudy(p2, "Rotation 2 point 2")
30 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
31 id_rotation1 = geompy.addToStudy(rotation1, "Rotation 1")
32 id_rotation2 = geompy.addToStudy(rotation2, "Rotation 2")
33
34 # display the results
35 gg.createAndDisplayGO(id_vr)
36 gg.createAndDisplayGO(id_p4)
37 gg.createAndDisplayGO(id_p1)
38 gg.createAndDisplayGO(id_p2)
39 gg.createAndDisplayGO(id_cylinder)
40 gg.setDisplayMode(id_cylinder,1)
41 gg.createAndDisplayGO(id_rotation1)
42 gg.createAndDisplayGO(id_rotation2)
43 gg.setDisplayMode(id_rotation1,1)
44 gg.setDisplayMode(id_rotation2,1)