about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--quadtree.go12
-rw-r--r--star.go6
-rw-r--r--vector2D.go3
3 files changed, 8 insertions, 13 deletions
diff --git a/quadtree.go b/quadtree.go
index eaca299..a9e60e6 100644
--- a/quadtree.go
+++ b/quadtree.go
@@ -1,7 +1,6 @@
 package structs
 
 import (
-	"encoding/json"
 	"fmt"
 	"io/ioutil"
 	"os/exec"
@@ -170,19 +169,14 @@ for tree={,draw, s sep+=0.25em}
 }
 
 // GetAllStars returns all the stars in the tree it is called on in an array
-func (n Node) GetAllStars() []string {
+func (n Node) GetAllStars() []Star2D {
 
 	// define a list to store the stars
-	listOfNodes := []string{}
+	listOfNodes := []Star2D{}
 
 	// if there is a star in the node, append the star to the list
 	if n.Star != (Star2D{}) {
-		starJson, err := json.Marshal(n.Star)
-		if err != nil {
-			panic(err)
-		}
-
-		listOfNodes = append(listOfNodes, string(starJson))
+		listOfNodes = append(listOfNodes, n.Star)
 	}
 
 	// iterate over all the subtrees
diff --git a/star.go b/star.go
index 1486d5f..7450da5 100644
--- a/star.go
+++ b/star.go
@@ -2,9 +2,9 @@ package structs
 
 // Define a struct storing essential star information such as it's coordinate, velocity and mass
 type Star2D struct {
-	C Vec2    // coordinates of the star
-	V Vec2    // velocity    of the star
-	M float64 // mass        of the star
+	C Vec2    `json:C` // coordinates of the star
+	V Vec2    `json:V` // velocity    of the star
+	M float64 `json:M` // mass        of the star
 }
 
 func NewStar2D(c Vec2, v Vec2, m float64) Star2D {
diff --git a/vector2D.go b/vector2D.go
index 2b95a72..551391d 100644
--- a/vector2D.go
+++ b/vector2D.go
@@ -5,7 +5,8 @@ import (
 )
 
 type Vec2 struct {
-	X, Y float64
+	X float64 `json:X`
+	Y float64 `json:Y`
 }
 
 // newVec2 returns a new Vec2 using the given coordinates