Fit rectangle around Ellipse
- tomni.shape_fitting.fit_rect_around_ellipse(x: int, y: int, r1: float, r2: float, alpha: float) Tuple[int, int, int, int] [source]
Compute the bounding box coordinates of an ellipse given its parameters.
- Parameters
x (int) – The x-coordinate of the center of the ellipse.
y (int) – The y-coordinate of the center of the ellipse.
r1 (float) – The longest radius of the ellipse.
r2 (float) – The shortest radius of the ellipse, which is 90 degrees away from r1.
alpha (float) – The degrees between r1 and x-axis.
- Returns
A tuple containing the coordinates of the bounding box in the format (x1, y1, x2, y2).
- Return type
Tuple[int, int, int, int]
Special thanks to: https://math.stackexchange.com/questions/91132/how-to-get-the-limits-of-rotated-ellipse