unified the coordinate interpretation in RotatedRect (ticket #425)

This commit is contained in:
Vadim Pisarevsky
2010-11-29 18:14:08 +00:00
parent 4a973d4633
commit a937d9d43c
8 changed files with 51 additions and 39 deletions

View File

@@ -1765,34 +1765,6 @@ inline RotatedRect::operator CvBox2D() const
CvBox2D box; box.center = center; box.size = size; box.angle = angle;
return box;
}
inline void RotatedRect::points(Point2f pt[]) const
{
double _angle = angle*CV_PI/180.;
float a = (float)cos(_angle)*0.5f;
float b = (float)sin(_angle)*0.5f;
pt[0].x = center.x - a*size.height - b*size.width;
pt[0].y = center.y + b*size.height - a*size.width;
pt[1].x = center.x + a*size.height - b*size.width;
pt[1].y = center.y - b*size.height - a*size.width;
pt[2].x = 2*center.x - pt[0].x;
pt[2].y = 2*center.y - pt[0].y;
pt[3].x = 2*center.x - pt[1].x;
pt[3].y = 2*center.y - pt[1].y;
}
inline Rect RotatedRect::boundingRect() const
{
Point2f pt[4];
points(pt);
Rect r(cvFloor(min(min(min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
cvFloor(min(min(min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
cvCeil(max(max(max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
cvCeil(max(max(max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
r.width -= r.x - 1;
r.height -= r.y - 1;
return r;
}
//////////////////////////////// Scalar_ ///////////////////////////////