From 69f15d0f4f08758ca2ac6f3dc17cfd922f419018 Mon Sep 17 00:00:00 2001 From: hanemile Date: Fri, 28 Sep 2018 18:11:30 +0200 Subject: forces calculates the forces acting in between a given star and all the stars in a given slice --- force.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 + } + } +} -- cgit 1.4.1