diff options
author | hanemile <emile.hansmaennel@gmail.com> | 2018-01-16 15:59:01 +0100 |
---|---|---|
committer | hanemile <emile.hansmaennel@gmail.com> | 2018-01-16 15:59:01 +0100 |
commit | 50012de6c2fd3eae0aa04b7a2b4e497dc0bae27a (patch) | |
tree | 51c6ba3aa9cb2771c2d7aa0c9bbe54fa5b4d2ef7 /src/python/cells.py | |
parent | e5d00b1b2e2e7c0684dae7324feb86c36188047b (diff) |
updated the source files
Diffstat (limited to 'src/python/cells.py')
-rwxr-xr-x | src/python/cells.py | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/src/python/cells.py b/src/python/cells.py index abafcf0..3304296 100755 --- a/src/python/cells.py +++ b/src/python/cells.py @@ -1,14 +1,62 @@ #!/usr/bin/env python import numpy as np +from numpy import genfromtxt +import json +import bpy +import time +import sys -num = 1e6 +num = 100 # number of stars that should be generated +range_max = 10 # define the range in which the coordinates should be generated +axes = 3 # define the number of axes +data = "galaxy" # define the name of the galaxy +path = "cell_stars/1.csv" # define the path where the galaxy should be saved # generate random coordinates -rand_a = (np.random.rand(num, 3) * 2000) - 1000 -print(rand_a) +# rand_a = (np.random.rand(num, axes) * 2 * rand_range) - rand_range -# Out goal is to define a 6D array in wich the first three dimension describe -# the a point, in out case, the corner of a cell containing some stars. -# The other three dimensions are used to store a vector descibing the overall -# forces in the cell. + +for i in range(0, num, 1): + + # generate the random star-coordinates + x = np.random.uniform(-range_max, range_max, size=1) + y = np.random.uniform(-range_max, range_max, size=1) + z = np.random.uniform(-range_max, range_max, size=1) + + with open(path, "a") as star_data: + x_a = str(float(x)) + ", " + y_a = str(float(y)) + ", " + z_a = str(float(z)) + + star_data.write(x_a + y_a + z_a + "\n") + +for data in path: + verts = genfromtxt(path, delimiter=', ', skip_header=0, usecols = (0, 1, 2)) + + # create mesh and object + mesh = bpy.data.meshes.new(data) + object = bpy.data.objects.new(data,mesh) + + # set mesh location + object.location = bpy.context.scene.cursor_location + bpy.context.scene.objects.link(object) + + # create mesh from python data + mesh.from_pydata(verts,[],[]) + mesh.update(calc_edges=True) + + bpy.ops.object.select_all(action='SELECT') + +# parsed_json = json.loads(stars) +# print(parsed_json["s1"]) +# +# +# # The Vector array contains vectors describing forces acting inside the cells. +# cell_num = 3 # number of cells +# +# vector_arr = np.zeros((cell_num, cell_num, cell_num)) +# +# vector_arr[0][1][2] = Vector(1, 2, 3) +# +# print(vector_arr[0]) |