about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhanemile <emile.hansmaennel@gmail.com>2017-12-05 12:03:44 +0100
committerhanemile <emile.hansmaennel@gmail.com>2017-12-05 12:03:44 +0100
commit19e8be5a5cca95474abf934fd13404dd5b73fe84 (patch)
tree439c1083eefa16ee5cb6c6788b1be5dd39755f2a
parent41322dea056ec583d86587fef0761af2f83dcc5d (diff)
implemented displaying the stars using an x-y-coordinate system
-rwxr-xr-xsrc/gen.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gen.py b/src/gen.py
index ca7616b..8f8b26f 100755
--- a/src/gen.py
+++ b/src/gen.py
@@ -6,6 +6,7 @@ import math
 import os
 import socket
 import time
+import matplotlib.pyplot as plt
 host = socket.gethostname()
 
 # variables
@@ -35,6 +36,9 @@ def phi(x):
     c = a * b
     return c
 
+listx = []
+listy = []
+
 def gen_stars(stars):
     stars = int(stars)
 
@@ -63,8 +67,6 @@ def gen_stars(stars):
         rand_val = np.random.uniform(rand_min, rand_max, size=1)
         rho_xy = rho(math.sqrt(x**2 + y**2))
 
-        print("{:<20}{:<20}{:<20}{:<20}".format(str(x), str(y), str(rho_xy), str(rand_val)))
-
         # if the random value is smaller than the rho value, generate a star
         if rand_val < rho_xy:
 
@@ -73,6 +75,8 @@ def gen_stars(stars):
 
                 # write the data to the file
                 data.write(str(x).strip("[]") + "," + str(y).strip("[]") + "\n")
+                listx.append(x)
+                listy.append(y)
                 print(str(x) + ", " + str(y))
 
     print("range_min: " + str(range_min))
@@ -82,4 +86,9 @@ def gen_stars(stars):
     print("rand_max: " + str(rand_max))
 
 # generate n stars
-gen_stars(1e5)
+gen_stars(1e6)
+
+# plot the stars coordinates in 2D space
+plt.scatter(listx, listy)
+# plt.plot(listx, listy)
+plt.show()