about summary refs log tree commit diff
diff options
context:
space:
mode:
-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
+		}
+	}
+}