Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Angle
1 # Angle
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 import math
9 
10 OX = geompy.MakeVectorDXDYDZ(10, 0,0)
11 OXY = geompy.MakeVectorDXDYDZ(10,10,0)
12 
13 # in one plane
14 Angle = geompy.GetAngle(OX, OXY)
15 
16 print "\nAngle between OX and OXY = ", Angle
17 if math.fabs(Angle - 45.0) > 1e-05:
18  print " Error: returned angle is", Angle, "while must be 45.0"
19  pass
20 
21 Angle = geompy.GetAngleRadians(OX, OXY)
22 
23 print "\nAngle between OX and OXY in radians = ", Angle
24 if math.fabs(Angle - math.pi/4) > 1e-05:
25  print " Error: returned angle is", Angle, "while must be pi/4"
26  pass
27 
28 Angle = geompy.GetAngleVectors(OX, OXY, True)
29 
30 print "\nAngle between vectors OX and OXY = ", Angle
31 if math.fabs(Angle - 45.0) > 1e-05:
32  print " Error: returned angle is", Angle, "while must be 45.0"
33  pass
34 
35 Angle = geompy.GetAngleRadiansVectors(OX, OXY, False)
36 
37 print "\nBig angle between vectors OX and OXY in radians = ", Angle
38 if math.fabs(Angle - math.pi*7./4.) > 1e-05:
39  print " Error: returned angle is", Angle, "while must be 7*pi/4"
40  pass
41 
42 # not in one plane
43 OXY_shift = geompy.MakeTranslation(OXY,10,-10,20)
44 Angle = geompy.GetAngle(OX, OXY_shift)
45 
46 print "\nAngle between OX and OXY_shift = ", Angle
47 if math.fabs(Angle - 45.0) > 1e-05:
48  print " Error: returned angle is", Angle, "while must be 45.0"
49  pass
50 
51 # not linear
52 pnt1 = geompy.MakeVertex(0, 0, 0)
53 pnt2 = geompy.MakeVertex(10, 0, 0)
54 pnt3 = geompy.MakeVertex(20, 10, 0)
55 arc = geompy.MakeArc(pnt1, pnt2, pnt3)
56 try:
57  Angle = geompy.GetAngle(OX, arc)
58  pass
59 except:
60  # It is a correct case, because GetAngle() must not be computed on curvilinear edges.
61  pass
62 
63 assert (not geompy.MeasuOp.IsDone() ), 'Angle must not be computed on curvilinear edges.'

Download this script