From 5b07e06dcd837431ffc4e9ad0c2798029cf40a48 Mon Sep 17 00:00:00 2001 From: hanemile Date: Fri, 14 Dec 2018 16:01:49 +0100 Subject: 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. --- csv/csv.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'csv') 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 +} -- cgit 1.4.1