From 2ad649ad046ae9dde6707147492d0b0e6d0d2a20 Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 3 Aug 2012 11:19:10 +0000 Subject: [PATCH] IMP 0021537: [CEA 554] Add behaviour in GetAngle and GetAngleRadians. --- doc/salome/gui/GEOM/input/tui_angle.doc | 16 +++++++++- src/GEOM_SWIG/geompyDC.py | 41 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/doc/salome/gui/GEOM/input/tui_angle.doc b/doc/salome/gui/GEOM/input/tui_angle.doc index 120000a68..fa459d31e 100644 --- a/doc/salome/gui/GEOM/input/tui_angle.doc +++ b/doc/salome/gui/GEOM/input/tui_angle.doc @@ -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 diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 46a7d224d..3e5ab3dcf 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -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 -- 2.39.2