diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index 886a886df1..280c317ae4 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -316,6 +316,7 @@ RotatedRect RotatedRect(); RotatedRect(const Point2f& center, const Size2f& size, float angle); RotatedRect(const CvBox2D& box); + RotatedRect(const Point2f& point1, const Point2f& point2, const Point2f& point3); //! returns 4 vertices of the rectangle void points(Point2f pts[]) const; @@ -338,7 +339,11 @@ The class represents rotated (i.e. not up-right) rectangles on a plane. Each rec :param size: Width and height of the rectangle. :param angle: The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. :param box: The rotated rectangle parameters as the obsolete CvBox2D structure. + .. ocv:function:: RotatedRect::RotatedRect(const Point2f& point1, const Point2f& point2, const Point2f& point3) + :param point1: + :param point2: + :param point3: Any 3 end points of the RotatedRect. They must be given in order (either clockwise or anticlockwise). .. ocv:function:: void RotatedRect::points( Point2f pts[] ) const .. ocv:function:: Rect RotatedRect::boundingRect() const diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 02ca1c9698..7f1dfe690b 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -5216,7 +5216,7 @@ RotatedRect::RotatedRect(const Point2f& _point1, const Point2f& _point2, const P // wd_i stores which vector (0,1) or (1,2) will make the width // One of them will definitely have slope within -1 to 1 int wd_i = 0; - if( vecs[1][0] != 0 && abs(vecs[1][1] / vecs[1][0]) <= 1.0f ) wd_i = 1; + if( abs(vecs[1][1]) < abs(vecs[1][0]) ) wd_i = 1; int ht_i = (wd_i + 1) % 2; float _angle = atan(vecs[wd_i][1] / vecs[wd_i][0]) * 180.0f / (float) CV_PI; diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 23c0aad620..71c7391542 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -403,6 +403,7 @@ protected: Size s1(6, 7), os1; Complex c1(9, 10), oc1; Rect r1(11, 12, 13, 14), or1; + RotatedRect rr1(Point2f(0,0), Point2f(100,100), Point2f(50, 150)); Vec v1(15, 16, 17, 18, 19), ov1; Scalar sc1(20.0, 21.1, 22.2, 23.3), osc1; Range g1(7, 8), og1;