Last active
May 10, 2019 22:04
-
-
Save rileypeterson/6afe504250684c5ddf7aec26ddb89378 to your computer and use it in GitHub Desktop.
Plot rotated ellipse
This file contains 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
""" From: https://math.stackexchange.com/a/2647450/635480 """ | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def plot_rotated_ellipse(cx=1, cy=2, rx=3, ry=0.5, theta=np.pi/4): | |
alpha = np.linspace(0, 2*np.pi, 100) | |
x = rx*np.cos(alpha)*np.cos(theta) - ry*np.sin(alpha)*np.sin(theta) + cx | |
y = rx*np.cos(alpha)*np.sin(theta) + ry*np.sin(alpha)*np.cos(theta) + cy | |
plt.plot(x, y) | |
plot_rotated_ellipse() |
Author
rileypeterson
commented
May 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment