Created
February 25, 2013 20:23
-
-
Save gourneau/5032953 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
| import random | |
| class shorter_float(float): | |
| """A float which returns only 3 digits after the decimal""" | |
| def __repr__(self): | |
| return "%0.3f" % self | |
| ires = 100.0 # Inverse resolution | |
| left = -100 | |
| right = 101 | |
| def ctrans(e): | |
| return e/ires | |
| def r2(x,y): | |
| return ctrans(x)**2 + ctrans(y)**2 | |
| def printM(mat): | |
| for row in mat: | |
| r = map(shorter_float, row) | |
| for i in r: | |
| t = i * 50 | |
| #t = t - random.randint(0, int(t/3)) | |
| print t, | |
| print "" | |
| hsph = [ [1 - r2(x, y) if r2(x, y) <= 1 else 0 for x in range(left,right)] for y in range(left,right)] | |
| printM(hsph) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment