diff options
author | hanemile <hanemile@protonmail.com> | 2018-12-14 16:01:49 +0100 |
---|---|---|
committer | hanemile <hanemile@protonmail.com> | 2018-12-14 16:01:49 +0100 |
commit | 5b07e06dcd837431ffc4e9ad0c2798029cf40a48 (patch) | |
tree | 37f84f89de66565604af2f07c9545cecb415f2e8 /csv | |
parent | 35c8993423f9240aefa0b4bd839fba85b8a3c944 (diff) |
Updated some stuff, this is probably going to be the final commit in this monolithic application, because of the new microservices used in the rewrite.
Diffstat (limited to 'csv')
-rw-r--r-- | csv/csv.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/csv/csv.go b/csv/csv.go index 1b3c0bc..01c3743 100644 --- a/csv/csv.go +++ b/csv/csv.go @@ -40,3 +40,25 @@ func Import(path string, start int, end int, slice []structs.Star2D) []structs.S return slice } + +// Generate a homogeneous Grid +func GenerateHomogeneousGrid(slice []structs.Star2D, left int, right int, step int) []structs.Star2D { + + // Iterate over a grid + for i := left; i < right; i += step { + for j := left; j < right; j += step { + + // generate a new star with the coordinates + tempStar := structs.Star2D{ + C: structs.Vec2{X: float64(i) + float64(rand.Intn(step)), Y: float64(j) + float64(rand.Intn(step))}, + M: float64(rand.Intn(500000)), + } + + // add the star to the slice + slice = append(slice, tempStar) + } + } + + // return the new slice containing a homogeneous grid of stars + return slice +} |