Created
March 22, 2019 10:40
-
-
Save kaskichandrakant/0a7f0a9e475da5adedf119b536f98924 to your computer and use it in GitHub Desktop.
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 | |
field = np.zeros((500,500)) | |
center = [25, 25] | |
radius = 20 | |
x = np.arange(0, radius, 0.0001) | |
abs_y = (radius**2 - x**2)**0.5 | |
y1 = np.floor((-1*abs_y + center[1])*10).astype(np.int_) | |
y2 = np.floor((abs_y + center[1])*10).astype(np.int_) | |
x1 = np.floor((-1*x + center[0])*10).astype(np.int_) | |
x2 = np.floor((x + center[0])*10).astype(np.int_) | |
field[x1, y1] = 1 | |
field[x2, y1] = 1 | |
field[x1, y2] = 1 | |
field[x2, y2] = 1 | |
plt.imshow(field) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment