Created
November 22, 2015 20:05
-
-
Save robintw/0abb2426b0886c303078 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_ellipse(x, x0, y, y0, theta, a, b): | |
"""Creates an ellipse in an array. | |
Parameters: | |
x: Array resulting from meshgrid function | |
x0: Unused | |
y: Array resulting from meshgrid function | |
y0: Unused | |
theta: Angle of rotation of the ellipse, in radians | |
a: Length of major axis | |
b: Length of the minor axis | |
Returns: | |
Array with the ellipse in it. | |
""" | |
c = np.cos(theta) | |
s = np.sin(theta) | |
a2 = a**2 | |
b2 = b**2 | |
#xnew = x - x0 | |
#ynew = y - y0 | |
xnew = x | |
ynew = y | |
ellipse = (xnew * c + ynew * s)**2 / a2 + (xnew * s - ynew * c)**2 / b2 | |
return ellipse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment