From 6b7c2b5e3069710bd91406475dc480fe514c50c8 Mon Sep 17 00:00:00 2001
From: brynnchernosky <56202540+brynnchernosky@users.noreply.github.com>
Date: Tue, 2 May 2023 17:39:24 -0400
Subject: debugging

---
 .../nodes/PhysicsBox/PhysicsSimulationBox.tsx      | 39 +++++++++++-----------
 1 file changed, 19 insertions(+), 20 deletions(-)

(limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx')

diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
index 143ff9896..5335fc1ec 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
@@ -141,8 +141,10 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
     this.dataDoc.simulationSpeed = this.dataDoc.simulationSpeed ?? 2;
     this.dataDoc.simulationType = this.dataDoc.simulationType ?? "Inclined Plane";
     this.dataDoc.startForces = this.dataDoc.startForces ?? [];
-    this.dataDoc.startPosX = this.dataDoc.startPosX ?? 0;
-    this.dataDoc.startPosY = this.dataDoc.startPosY ?? 0;
+    this.dataDoc.startPosX = this.dataDoc.startPosX ?? Math.round((this.xMax * 0.5 - 200) * 10) / 10;
+    this.dataDoc.startPosY = this.dataDoc.startPosY ?? this.getDisplayYPos(
+      (400 - this.radius) * Math.tan((26 * Math.PI) / 180) + Math.sqrt(26)
+    );
     this.dataDoc.startVelX = this.dataDoc.startVelX ?? 0;
     this.dataDoc.startVelY = this.dataDoc.startVelY ?? 0;
     this.dataDoc.stepNumber = this.dataDoc.stepNumber ?? 0;
@@ -209,6 +211,16 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
     this.dataDoc.mass2 = this.dataDoc.mass2 ?? 1;
 
     // Setup simulation
+    this.setupSimulation()
+  }
+
+  componentDidUpdate() {
+    this.xMax = this.layoutDoc._width*0.7 ?? 700;
+    this.yMax = this.layoutDoc._height*0.7 ?? 700;
+    this.radius = 0.05*this.layoutDoc._height ?? 50;
+  }
+
+  setupSimulation = () => {
     if (this.dataDoc.simulationType != "Circular Motion") {
       this.dataDoc.startVelX = 0;
       this.dataDoc.setStartVelY = 0;
@@ -365,18 +377,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
       // }
       this.dataDoc.simulationReset = (!this.dataDoc.simulationReset);
     }
-
-
-    console.log("width: ", this.xMax)
-    console.log("height: ", this.yMax)
-  }
-
-  componentDidUpdate() {
-    this.xMax = this.layoutDoc._width*0.7 ?? 700;
-    this.yMax = this.layoutDoc._height*0.7 ?? 700;
-    this.radius = 0.05*this.layoutDoc._height ?? 50;
-    console.log("width: ", this.xMax)
-    console.log("height: ", this.yMax)
   }
 
   // Helper function to go between display and real values
@@ -1270,9 +1270,9 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
               <div
                 style={{
                   position: "fixed",
-                  left: "10vw",
-                  top: "95vh",
-                  width: "50vw",
+                  left: 0.10*this.layoutDoc._width + "px",
+                  top: 0.95*this.layoutDoc._height + "px",
+                  width: 0.50*this.layoutDoc._width + "px",
                 }}
               >
                 <LinearProgress />
@@ -1290,7 +1290,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
                   value={this.dataDoc.simulationType}
                   onChange={(event) => {
                     this.dataDoc.simulationType = (event.target.value);
-                    // TODO change simulation type based on mode/type
+                    this.setupSimulation()
                   }}
                   style={{ height: "2em", width: "100%", fontSize: "16px" }}
                 >
@@ -1458,8 +1458,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
               value={this.dataDoc.mode}
               onChange={(event) => {
                 this.dataDoc.mode = (event.target.value);
-
-                // TODO setup simulation based on type and mode
+                this.setupSimulation()
               }}
               style={{ height: "2em", width: "100%", fontSize: "16px" }}
             >
-- 
cgit v1.2.3-70-g09d2

