about summary refs log tree commit diff
path: root/forces/forces.go
diff options
context:
space:
mode:
Diffstat (limited to 'forces/forces.go')
-rw-r--r--forces/forces.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/forces/forces.go b/forces/forces.go
index 5d0c414..03c6c7a 100644
--- a/forces/forces.go
+++ b/forces/forces.go
@@ -2,6 +2,8 @@ package forces
 
 import (
 	"../structs"
+	"fmt"
+	"gopkg.in/cheggaaa/pb.v1"
 	"math"
 )
 
@@ -54,14 +56,25 @@ func forces(stars_arr []structs.Star, nr int) structs.Force {
 	return force
 }
 
+// CalcAllForces calculates all the forces acting inbetween all the stars in the given starSlice slice and
+// returns a "new" slice contaning the forces
 func CalcAllForces(starSlice []structs.Star) []structs.Star {
 
 	// Define a new slice in which the stars (and the forces acting on them) should be saved
 	var new_slice []structs.Star
 
+	fmt.Printf("\n")
+
+	// Define a progres-bar
+	bar := pb.StartNew(len(starSlice)).Prefix("Stars done: ")
+	bar.SetWidth(80)
+
 	// Iterate over all the stars in the original slice
 	for index := range starSlice {
 
+		// Increment the progress-bar
+		bar.Increment()
+
 		// Calculate the force acting inbetween the given star and all other stars
 		// This utilizes go-routines :D
 		var force = forces(starSlice, index)
@@ -78,5 +91,8 @@ func CalcAllForces(starSlice []structs.Star) []structs.Star {
 
 	}
 
+	// Print a newline after the progressbar
+	bar.FinishPrint("")
+
 	return new_slice
 }