i want to crop a polar with such parameter:
cv::Point2f center{7000, 3000};
float inner_radius = 1000;
float outter_radius = 2000;
float start_angle = 0;
float extend_angle = 270;
i get bounding rect through code blow:
std::vector<cv::Point2f> points;
float step = 1.0f;
for (size_t i = start_angle; i <= (start_angle + extend_angle); i += step)
{
float rad = DegreeToRadian(i);
points.emplace_back(center + inner_radius * cv::Point2f(std::cos(rad), std::sin(rad)));
points.emplace_back(center + outer_radius * cv::Point2f(std::cos(rad), std::sin(rad)));
}
for (size_t i = 0; i < 5; ++i)
{
float angle = 0.f + i * 90.0f;
if (InRange(angle, start_angle, start_angle + extend_angle))
{
float rad = DegreeToRadian(angle);
points.emplace_back(center + inner_radius * cv::Point2f(std::cos(rad), std::sin(rad)));
points.emplace_back(center + outer_radius * cv::Point2f(std::cos(rad), std::sin(rad)));
}
}
float end_rad = DegreeToRadian(start_angle + extend_angle);
points.emplace_back(center + inner_radius * cv::Point2f(std::cos(end_rad), std::sin(end_rad)));
points.emplace_back(center + outer_radius * cv::Point2f(std::cos(end_rad), std::sin(end_rad)));
auto mini_rect = cv::boundingRect(points);
the output is :
why the width and height is 4001 and 4001, the expected value is 4000 and 4000, how can i get the expected value?