Created
October 27, 2016 03:27
-
-
Save thoolihan/7bd40d9be73ee532479df952028fec1b to your computer and use it in GitHub Desktop.
Calculating and graphing a partial circle and inner circle in python
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
import numpy as np | |
import matplotlib.pyplot as plt | |
from math import pi, cos, sin | |
arc_size = pi / 2 | |
points = 20 | |
inner_ratio = .4 | |
theta = np.arange(0, arc_size, arc_size / points) | |
x1 = np.array([cos(t) for t in theta]) | |
y1 = np.array([sin(t) for t in theta]) | |
x2 = inner_ratio * x1 | |
y2 = inner_ratio * y1 | |
plt.plot(x1, y1, 'b.', label="Radius 1") | |
plt.plot(x2, y2, 'r.', label="Radius %.1f" % inner_ratio) | |
plt.title("Partial Circle") | |
plt.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment