getRotatedRectPoints function
Calculates the 4 corner points of a rotated rectangle.
Matches OpenCV's cv.boxPoints() behavior for drawing rotated bounding boxes. Parameters:
cx,cy: Center coordinates of the rectanglewidth,height: Dimensions of the rectanglerotation: Rotation angle in radians
Returns a list of 4 Offset points representing the corners of the rotated rectangle.
Implementation
List<Offset> getRotatedRectPoints(
double cx,
double cy,
double width,
double height,
double rotation,
) {
final b = cos(rotation) * 0.5;
final a = sin(rotation) * 0.5;
return [
Offset(cx - a * height - b * width, cy + b * height - a * width),
Offset(cx + a * height - b * width, cy - b * height - a * width),
Offset(cx + a * height + b * width, cy - b * height + a * width),
Offset(cx - a * height + b * width, cy + b * height + a * width),
];
}