about summary refs log tree commit diff
path: root/star.go
diff options
context:
space:
mode:
authorhanemile <hanemile@protonmail.com>2019-01-24 20:36:42 +0100
committerhanemile <hanemile@protonmail.com>2019-01-24 20:36:42 +0100
commit6102ad0b000d4b213cff5928239807f993771a40 (patch)
treee3e818b9e3e1c16027003d47cec5e42bcd127e08 /star.go
parent9f82827465369fd676e221e98b4ca9bf39c78504 (diff)
update
Diffstat (limited to 'star.go')
-rw-r--r--star.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/star.go b/star.go
index 7450da5..feea20d 100644
--- a/star.go
+++ b/star.go
@@ -36,6 +36,12 @@ func (s Star2D) InsideOf(boundary BoundingBox) bool {
 	}
 }
 
+// calcNewPos calculates the new position of a star using the force acting on it
+func (s *Star2D) CalcNewPos(force Vec2, timestep float64) {
+	acceleration := NewVec2(force.X/s.M, force.Y/s.M)
+	s.Accelerate(acceleration, timestep)
+}
+
 // Return a copy of the star by returning a star struct with the same values.
 func (s *Star2D) Copy() Star2D {
 	return Star2D{s.C.Copy(), s.V.Copy(), s.M}