about summary refs log tree commit diff
path: root/update.go
diff options
context:
space:
mode:
Diffstat (limited to 'update.go')
-rw-r--r--update.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/update.go b/update.go
new file mode 100644
index 0000000..402a64c
--- /dev/null
+++ b/update.go
@@ -0,0 +1,27 @@
+package main
+
+import (
+	"log"
+	"net/http"
+	"strconv"
+
+	"github.com/gorilla/mux"
+)
+
+// updateCenterOfMassHandler updates the center of mass in each node in tree with the given index
+func updateCenterOfMassHandler(w http.ResponseWriter, r *http.Request) {
+	log.Println("Updating the center of mass")
+	vars := mux.Vars(r)
+	treeindex, _ := strconv.ParseInt(vars["treeindex"], 10, 0)
+
+	treeArray[treeindex].CalcCenterOfMass()
+}
+
+// updateTotalMassHandler updates the total mass in each node in the tree with the given index
+func updateTotalMassHandler(w http.ResponseWriter, r *http.Request) {
+	log.Println("Updating the total mass")
+	vars := mux.Vars(r)
+	treeindex, _ := strconv.ParseInt(vars["treeindex"], 10, 0)
+
+	treeArray[treeindex].CalcTotalMass()
+}