Salome HOME
IMP 0021537: [CEA 554] Add behaviour in GetAngle and GetAngleRadians.
authorjfa <jfa@opencascade.com>
Fri, 3 Aug 2012 11:19:10 +0000 (11:19 +0000)
committerjfa <jfa@opencascade.com>
Fri, 3 Aug 2012 11:19:10 +0000 (11:19 +0000)
doc/salome/gui/GEOM/input/tui_angle.doc
src/GEOM_SWIG/geompyDC.py

index 120000a68a306460a032ebc8744bc69b33ce8d5d..fa459d31eb5bed40c1d5024a8ee204d1c6a97202 100644 (file)
@@ -28,11 +28,25 @@ if math.fabs(Angle - math.pi/4) > 1e-05:
     print "  Error: returned angle is", Angle, "while must be pi/4"
     pass
 
+Angle = geompy.GetAngleVectors(OX, OXY, True)
+
+print "\nAngle between vectors OX and OXY = ", Angle
+if math.fabs(Angle - 45.0) > 1e-05:
+    print "  Error: returned angle is", Angle, "while must be 45.0"
+    pass
+
+Angle = geompy.GetAngleRadiansVectors(OX, OXY, False)
+
+print "\nBig angle between vectors OX and OXY in radians = ", Angle
+if math.fabs(Angle - math.pi*7./4.) > 1e-05:
+    print "  Error: returned angle is", Angle, "while must be 7*pi/4"
+    pass
+
 # not in one plane
 OXY_shift = geompy.MakeTranslation(OXY,10,-10,20)
 Angle = geompy.GetAngle(OX, OXY_shift)
 
-print "Angle between OX and OXY_shift = ", Angle
+print "\nAngle between OX and OXY_shift = ", Angle
 if math.fabs(Angle - 45.0) > 1e-05:
     print "  Error: returned angle is", Angle, "while must be 45.0"
     pass
index 46a7d224d2e60ba4f8dd028a9186fa0e71fa9c04..3e5ab3dcfe7f4d6bfee37956169e2b9597b8b39c 100644 (file)
@@ -6638,6 +6638,47 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("GetAngle", self.MeasuOp)
             return anAngle
 
+        ## Get angle between the given vectors in degrees.
+        #  @param theShape1,theShape2 Vectors to find angle between.
+        #  @param theFlag If True, the normal vector is defined by the two vectors cross,
+        #                 if False, the opposite vector to the normal vector is used.
+        #  @return Value of the angle between the given vectors in degrees.
+        #
+        #  @ref tui_measurement_tools_page "Example"
+        def GetAngleVectors(self, theShape1, theShape2, theFlag = True):
+            """
+            Get angle between the given vectors in degrees.
+
+            Parameters: 
+                theShape1,theShape2 Vectors to find angle between.
+                theFlag If True, the normal vector is defined by the two vectors cross,
+                        if False, the opposite vector to the normal vector is used.
+
+            Returns:  
+                Value of the angle between the given vectors in degrees.
+            """
+            anAngle = self.MeasuOp.GetAngleBtwVectors(theShape1, theShape2)
+            if not theFlag:
+                anAngle = 360. - anAngle
+            RaiseIfFailed("GetAngleVectors", self.MeasuOp)
+            return anAngle
+
+        ## The same as GetAngleVectors, but the result is in radians.
+        def GetAngleRadiansVectors(self, theShape1, theShape2, theFlag = True):
+            """
+            Get angle between the given vectors in radians.
+
+            Parameters: 
+                theShape1,theShape2 Vectors to find angle between.
+                theFlag If True, the normal vector is defined by the two vectors cross,
+                        if False, the opposite vector to the normal vector is used.
+
+            Returns:  
+                Value of the angle between the given vectors in radians.
+            """
+            anAngle = self.GetAngleVectors(theShape1, theShape2, theFlag)*math.pi/180.
+            return anAngle
+
         ## @name Curve Curvature Measurement
         #  Methods for receiving radius of curvature of curves
         #  in the given point