Last active
March 26, 2023 04:27
-
-
Save smidm/b398312a13f60c24449a2c7533877dc0 to your computer and use it in GitHub Desktop.
Compute bounding box for an ellipse.
Thanks @drscotthawley! I fixed the notebook with slightly modified code.
@smidm what happens if angle_dim==0
? I get NaNs with a warning:
RuntimeWarning: invalid value encountered in double_scalars
t = np.arctan(-minor / 2 * np.tan(np.radians(angle_deg)) / (major / 2))
To avoid this, I just added a little fudge factor above that line:
if 0==angle_deg: angle_deg = 1e-8 # slight fudge to avoid division by zero
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This can return min values that are greater than their corresponding max values, e.g. when a negative angle is supplied. Recommend you wrap these lines in
sorted()
, e.g.