1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026750: Method IsNormal(...) for gp_Vec2d returns FALSE if the angle between two vectors is equal to -90 degree (-M_PI/2 radian)

The bug has been fixed.
Test case for this issue has been created.

Correct alignment.
This commit is contained in:
nbv
2015-10-08 10:14:30 +03:00
committed by bugmaster
parent b400611710
commit d0fcf95a09
4 changed files with 101 additions and 56 deletions

View File

@@ -114,7 +114,7 @@ public:
//! Returns True if PI - Abs(<me>.Angle(Other)) <= AngularTolerance
//! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
//! Other.Magnitude() <= Resolution from gp.
Standard_Boolean IsOpposite (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
Standard_Boolean IsOpposite (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
//! Returns true if Abs(Angle(<me>, Other)) <= AngularTolerance or
@@ -122,7 +122,7 @@ public:
//! Two vectors with opposite directions are considered as parallel.
//! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
//! Other.Magnitude() <= Resolution from gp
Standard_Boolean IsParallel (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
Standard_Boolean IsParallel (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
//! Computes the angular value between <me> and <Other>
@@ -141,24 +141,24 @@ public:
Standard_Real SquareMagnitude() const;
void Add (const gp_Vec2d& Other);
void operator += (const gp_Vec2d& Other)
{
Add(Other);
}
void operator += (const gp_Vec2d& Other)
{
Add(Other);
}
//! Adds two vectors
gp_Vec2d Added (const gp_Vec2d& Other) const;
gp_Vec2d operator + (const gp_Vec2d& Other) const
{
return Added(Other);
}
gp_Vec2d operator + (const gp_Vec2d& Other) const
{
return Added(Other);
}
//! Computes the crossing product between two vectors
Standard_Real Crossed (const gp_Vec2d& Right) const;
Standard_Real operator ^ (const gp_Vec2d& Right) const
{
return Crossed(Right);
}
Standard_Real operator ^ (const gp_Vec2d& Right) const
{
return Crossed(Right);
}
//! Computes the magnitude of the cross product between <me> and
@@ -171,41 +171,41 @@ public:
Standard_Real CrossSquareMagnitude (const gp_Vec2d& Right) const;
void Divide (const Standard_Real Scalar);
void operator /= (const Standard_Real Scalar)
{
Divide(Scalar);
}
void operator /= (const Standard_Real Scalar)
{
Divide(Scalar);
}
//! divides a vector by a scalar
gp_Vec2d Divided (const Standard_Real Scalar) const;
gp_Vec2d operator / (const Standard_Real Scalar) const
{
return Divided(Scalar);
}
gp_Vec2d operator / (const Standard_Real Scalar) const
{
return Divided(Scalar);
}
//! Computes the scalar product
Standard_Real Dot (const gp_Vec2d& Other) const;
Standard_Real operator * (const gp_Vec2d& Other) const
{
return Dot(Other);
}
Standard_Real operator * (const gp_Vec2d& Other) const
{
return Dot(Other);
}
gp_Vec2d GetNormal() const;
void Multiply (const Standard_Real Scalar);
void operator *= (const Standard_Real Scalar)
{
Multiply(Scalar);
}
void operator *= (const Standard_Real Scalar)
{
Multiply(Scalar);
}
//! Normalizes a vector
//! Raises an exception if the magnitude of the vector is
//! lower or equal to Resolution from package gp.
gp_Vec2d Multiplied (const Standard_Real Scalar) const;
gp_Vec2d operator * (const Standard_Real Scalar) const
{
return Multiplied(Scalar);
}
gp_Vec2d operator * (const Standard_Real Scalar) const
{
return Multiplied(Scalar);
}
void Normalize();
@@ -219,24 +219,24 @@ public:
//! Reverses the direction of a vector
gp_Vec2d Reversed() const;
gp_Vec2d operator -() const
{
return Reversed();
}
gp_Vec2d operator -() const
{
return Reversed();
}
//! Subtracts two vectors
void Subtract (const gp_Vec2d& Right);
void operator -= (const gp_Vec2d& Right)
{
Subtract(Right);
}
void operator -= (const gp_Vec2d& Right)
{
Subtract(Right);
}
//! Subtracts two vectors
gp_Vec2d Subtracted (const gp_Vec2d& Right) const;
gp_Vec2d operator - (const gp_Vec2d& Right) const
{
return Subtracted(Right);
}
gp_Vec2d operator - (const gp_Vec2d& Right) const
{
return Subtracted(Right);
}
//! <me> is set to the following linear form :

View File

@@ -70,14 +70,11 @@ inline const gp_XY& gp_Vec2d::XY () const
{ return coord; }
inline Standard_Boolean gp_Vec2d::IsNormal
(const gp_Vec2d& Other,
const Standard_Real AngularTolerance) const
(const gp_Vec2d& theOther,
const Standard_Real theAngularTolerance) const
{
Standard_Real Ang = Angle(Other);
if (Ang < 0) Ang = - Ang;
Ang = M_PI / 2.0 - Angle(Other);
if (Ang < 0) Ang = - Ang;
return Ang <= AngularTolerance;
const Standard_Real anAng = Abs(M_PI_2 - Abs(Angle(theOther)));
return !(anAng > theAngularTolerance);
}
inline Standard_Boolean gp_Vec2d::IsOpposite
@@ -241,7 +238,7 @@ inline gp_Vec2d operator* (const Standard_Real Scalar,
{ return V.Multiplied(Scalar); }
inline gp_Vec2d gp_Vec2d::GetNormal() const
{
{
return gp_Vec2d(this->Y(), (-1)*this->X());
}
}