about summary refs log tree commit diff
path: root/force.go
diff options
context:
space:
mode:
authorhanemile <hanemile@chaosdorf.de>2018-09-28 18:11:30 +0200
committerhanemile <hanemile@chaosdorf.de>2018-09-28 18:11:30 +0200
commit69f15d0f4f08758ca2ac6f3dc17cfd922f419018 (patch)
tree8a6eaa3b0c39ee6d505d5c275c63ed96e2feadea /force.go
parent49c3bb3c595d477e345bad0c7d51b32ac72100a3 (diff)
forces calculates the forces acting in between a given star and all the stars in a given slice
Diffstat (limited to 'force.go')
-rw-r--r--force.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/force.go b/force.go
index a839459..ed45849 100644
--- a/force.go
+++ b/force.go
@@ -29,3 +29,20 @@ func forces_acting(s1 star, s2 star) force {
 
 	return F
 }
+
+// forces calculates the forces acting in between a given star and all the other stars in a given array.
+func forces(stars_arr []star, nr int) {
+
+	// Iterate over all the stars in the stars_arr
+	for index, _ := range stars_arr {
+
+		// If the current star is not the star itself
+		if index != nr {
+
+			// generate a new force and add it to the overall force of the star
+			fa := force_acting(stars_arr[nr], stars_arr[index])
+			stars_arr[nr].f.x += fa.x
+			stars_arr[nr].f.y += fa.y
+		}
+	}
+}