about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
authoremile <hanemile@protonmail.com>2018-10-08 19:35:19 +0200
committeremile <hanemile@protonmail.com>2018-10-08 19:35:19 +0200
commit6e9ebcf82cad78b468834ce07882db3c5ac45a53 (patch)
treee7a44eded47de6799a9c61de087d0a802b479fbe /main.go
parent3217f42c1175ae0c984433d6b4f091c7990d620a (diff)
Trying out channels
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/main.go b/main.go
index 26b9a8a..e10aa2a 100644
--- a/main.go
+++ b/main.go
@@ -9,22 +9,38 @@ import (
 	"fmt"
 )
 
+func AddToChannel(starsChan chan structs.Star, slice []structs.Star) {
+
+	for index, _ := range slice {
+		starsChan <- slice[index]
+	}
+
+}
+
 func main() {
 	// the slice starsSlice stores the star structures
 	starsSlice := []structs.Star{
 		{structs.Coord{X: 100, Y: 100}, structs.Force{0, 0}, 1000},
 		{structs.Coord{X: 200, Y: 300}, structs.Force{0, 0}, 1000},
 		{structs.Coord{X: 100, Y: 500}, structs.Force{0, 0}, 1000},
+		{structs.Coord{X: -200000.0, Y: 8000.0}, structs.Force{X: 0, Y: 0}, 8000000000},
+		{structs.Coord{X: 200000.0, Y: 0.0}, structs.Force{X: 0, Y: 0}, 8000000000},
+		{structs.Coord{X: 0.0, Y: 200000}, structs.Force{X: 0, Y: 0}, 8000000000},
+		{structs.Coord{X: 20000.0, Y: 80000}, structs.Force{X: 0, Y: 0}, 4000000},
 	}
 
+	// Define a channel
+	starsChannel := make(chan structs.Star, len(starsSlice))
+
 	llog.Good("Opening the csv")
-	starsSlice = csv.Import("data/structure03.ita.uni-heidelberg.de_26635.csv", 0, 4000, starsSlice)
+	starsSlice = csv.Import("data/structure03.ita.uni-heidelberg.de_26635.csv", 0, 2000, starsSlice)
+	go AddToChannel(starsChannel, starsSlice)
 	fmt.Printf("Done\n")
 
-	llog.Good("Calculate the forces acting")
+	llog.Good("Calculate the acting forces")
 	forces.CalcAllForces(starsSlice)
 
 	llog.Good("Drawing the slice")
-	draw.Slice(starsSlice, "out.png")
+	draw.Slice(starsSlice, "out_50000.png")
 	fmt.Printf("Done\n")
 }