about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--quadtree.go24
-rw-r--r--quadtree_test.go54
2 files changed, 39 insertions, 39 deletions
diff --git a/quadtree.go b/quadtree.go
index 95d4780..f83f739 100644
--- a/quadtree.go
+++ b/quadtree.go
@@ -11,7 +11,7 @@ import (
 )
 
 type Node struct {
-	Boundry      BoundingBox // Spatial outreach of the quadtree
+	Boundary     BoundingBox // Spatial outreach of the quadtree
 	CenterOfMass Vec2        // Center of mass of the cell
 	TotalMass    float64     // Total mass of all the stars in the cell
 	Depth        int         // Depth of the cell in the tree
@@ -26,7 +26,7 @@ type Node struct {
 // resulting in a node that should (in theory) fit the whole galaxy if defined correctly.
 func NewRoot(BoundingBoxWidth float64) *Node {
 	return &Node{
-		Boundry: BoundingBox{
+		Boundary: BoundingBox{
 			Center: Vec2{0, 0},
 			Width:  BoundingBoxWidth,
 		},
@@ -40,18 +40,18 @@ func NewRoot(BoundingBoxWidth float64) *Node {
 
 // Create a new new node using the given bounding box
 func NewNode(bounadry BoundingBox) *Node {
-	return &Node{Boundry: bounadry}
+	return &Node{Boundary: bounadry}
 }
 
 // Subdivide the tree
 func (n *Node) Subdivide() {
 
 	// define new values defining the new BoundaryBoxes
-	newBoundaryWidth := n.Boundry.Width / 2
-	newBoundaryPosX := n.Boundry.Center.X + (newBoundaryWidth / 2)
-	newBoundaryPosY := n.Boundry.Center.Y + (newBoundaryWidth / 2)
-	newBoundaryNegX := n.Boundry.Center.X - (newBoundaryWidth / 2)
-	newBoundaryNegY := n.Boundry.Center.Y - (newBoundaryWidth / 2)
+	newBoundaryWidth := n.Boundary.Width / 2
+	newBoundaryPosX := n.Boundary.Center.X + (newBoundaryWidth / 2)
+	newBoundaryPosY := n.Boundary.Center.Y + (newBoundaryWidth / 2)
+	newBoundaryNegX := n.Boundary.Center.X - (newBoundaryWidth / 2)
+	newBoundaryNegY := n.Boundary.Center.Y - (newBoundaryWidth / 2)
 
 	// define the new Subtrees
 	n.Subtrees[0] = NewNode(BoundingBox{Vec2{newBoundaryNegX, newBoundaryPosY}, newBoundaryWidth})
@@ -69,7 +69,7 @@ func (n *Node) Insert(star Star2D) error {
 	if n.Star == (Star2D{}) {
 		// if a subtree is present, insert the star into that subtree
 		if n.Subtrees != [4]*Node{} {
-			QuadrantBlocking := star.getRelativePositionInt(n.Boundry)
+			QuadrantBlocking := star.getRelativePositionInt(n.Boundary)
 			err := n.Subtrees[QuadrantBlocking].Insert(star)
 			if err != nil {
 				fmt.Println(err)
@@ -90,7 +90,7 @@ func (n *Node) Insert(star Star2D) error {
 		}
 
 		// Insert the blocking star into it's subtree
-		QuadrantBlocking := n.Star.getRelativePositionInt(n.Boundry)
+		QuadrantBlocking := n.Star.getRelativePositionInt(n.Boundary)
 		err := n.Subtrees[QuadrantBlocking].Insert(n.Star)
 		if err != nil {
 			fmt.Println(err)
@@ -98,7 +98,7 @@ func (n *Node) Insert(star Star2D) error {
 		n.Star = Star2D{}
 
 		// Insert the blocking star into it's subtree
-		QuadrantBlockingNew := star.getRelativePositionInt(n.Boundry)
+		QuadrantBlockingNew := star.getRelativePositionInt(n.Boundary)
 		err = n.Subtrees[QuadrantBlockingNew].Insert(star)
 		if err != nil {
 			fmt.Println(err)
@@ -278,7 +278,7 @@ func (n Node) CalcAllForces(star Star2D, theta float64) Vec2 {
 	var tmpY float64 = math.Pow(star.C.Y-n.Star.C.Y, 2)
 	var distance float64 = math.Sqrt(tmpX + tmpY)
 
-	var localtheta float64 = n.Boundry.Width / distance
+	var localtheta float64 = n.Boundary.Width / distance
 
 	// if the subtree is not empty...
 	if n.Subtrees != ([4]*Node{}) {
diff --git a/quadtree_test.go b/quadtree_test.go
index 76ee7c4..bdab08e 100644
--- a/quadtree_test.go
+++ b/quadtree_test.go
@@ -29,7 +29,7 @@ func TestNewRoot(t *testing.T) {
 				BoundingBoxWidth: 100,
 			},
 			want: &Node{
-				Boundry: BoundingBox{
+				Boundary: BoundingBox{
 					Center: Vec2{
 						X: 0,
 						Y: 0,
@@ -100,7 +100,7 @@ func TestNewNode(t *testing.T) {
 				},
 			},
 			want: &Node{
-				Boundry: BoundingBox{
+				Boundary: BoundingBox{
 					Center: Vec2{
 						X: 3,
 						Y: 15,
@@ -196,7 +196,7 @@ func TestNode_Subdivide(t *testing.T) {
 				},
 				Subtrees: [4]*Node{
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: 25,
@@ -223,7 +223,7 @@ func TestNode_Subdivide(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: 25,
@@ -250,7 +250,7 @@ func TestNode_Subdivide(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: -25,
@@ -277,7 +277,7 @@ func TestNode_Subdivide(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: -25,
@@ -310,7 +310,7 @@ func TestNode_Subdivide(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := &Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,
@@ -609,7 +609,7 @@ func TestNode_Insert(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := &Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,
@@ -725,7 +725,7 @@ func TestNode_GenForestTree(t *testing.T) {
 			},
 			args: args{
 				node: &Node{
-					Boundry: BoundingBox{
+					Boundary: BoundingBox{
 						Center: Vec2{
 							X: 0,
 							Y: 0,
@@ -758,7 +758,7 @@ func TestNode_GenForestTree(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,
@@ -837,7 +837,7 @@ func TestNode_DrawTreeLaTeX(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,
@@ -938,7 +938,7 @@ func TestNode_GetAllStars(t *testing.T) {
 				},
 				Subtrees: [4]*Node{
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: 25,
@@ -965,7 +965,7 @@ func TestNode_GetAllStars(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: 25,
@@ -992,7 +992,7 @@ func TestNode_GetAllStars(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: -25,
@@ -1019,7 +1019,7 @@ func TestNode_GetAllStars(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: -25,
@@ -1098,7 +1098,7 @@ func TestNode_GetAllStars(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,
@@ -1177,7 +1177,7 @@ func TestNode_CalcCenterOfMass(t *testing.T) {
 				},
 				Subtrees: [4]*Node{
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: 25,
@@ -1204,7 +1204,7 @@ func TestNode_CalcCenterOfMass(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: 25,
@@ -1231,7 +1231,7 @@ func TestNode_CalcCenterOfMass(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: -25,
@@ -1258,7 +1258,7 @@ func TestNode_CalcCenterOfMass(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: -25,
@@ -1295,7 +1295,7 @@ func TestNode_CalcCenterOfMass(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := &Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,
@@ -1357,7 +1357,7 @@ func TestNode_CalcTotalMass(t *testing.T) {
 				},
 				Subtrees: [4]*Node{
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: 25,
@@ -1384,7 +1384,7 @@ func TestNode_CalcTotalMass(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: 25,
@@ -1411,7 +1411,7 @@ func TestNode_CalcTotalMass(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: -25,
 								Y: -25,
@@ -1438,7 +1438,7 @@ func TestNode_CalcTotalMass(t *testing.T) {
 						Subtrees: [4]*Node{},
 					},
 					{
-						Boundry: BoundingBox{
+						Boundary: BoundingBox{
 							Center: Vec2{
 								X: 25,
 								Y: -25,
@@ -1472,7 +1472,7 @@ func TestNode_CalcTotalMass(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := &Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,
@@ -1562,7 +1562,7 @@ func TestNode_CalcAllForces(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			n := Node{
-				Boundry:      tt.fields.Boundry,
+				Boundary:     tt.fields.Boundry,
 				CenterOfMass: tt.fields.CenterOfMass,
 				TotalMass:    tt.fields.TotalMass,
 				Depth:        tt.fields.Depth,