aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PhysicsSimulationBox.tsx
diff options
context:
space:
mode:
authorbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-02-18 15:00:46 -0500
committerbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-02-18 15:00:46 -0500
commit1bffa19d7b2c085a2f647a0269acdc05630d5146 (patch)
tree45a6da4c112baf5dba130ba0c5549a246039abf1 /src/client/views/nodes/PhysicsSimulationBox.tsx
parenta9b9c26764cae849af16078796578db53a180be4 (diff)
debugging
Diffstat (limited to 'src/client/views/nodes/PhysicsSimulationBox.tsx')
-rw-r--r--src/client/views/nodes/PhysicsSimulationBox.tsx67
1 files changed, 34 insertions, 33 deletions
diff --git a/src/client/views/nodes/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsSimulationBox.tsx
index e7d5e48f0..0f2bc43a0 100644
--- a/src/client/views/nodes/PhysicsSimulationBox.tsx
+++ b/src/client/views/nodes/PhysicsSimulationBox.tsx
@@ -7,6 +7,7 @@ import "./PhysicsSimulationBox.scss";
import Weight from "./PhysicsSimulationWeight";
import Wall from "./PhysicsSimulationWall"
import Wedge from "./PhysicsSimulationWedge"
+import { isUndefined } from "lodash";
export interface IForce {
description: string;
@@ -55,32 +56,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
constructor(props: any) {
super(props);
- // this.dataDoc.coefficientOfKineticFriction = 0;
- // this.dataDoc.coefficientOfStaticFriction = 0;
- // this.dataDoc.currentForceSketch = [];
- // this.dataDoc.updateDisplay = false;
- // this.dataDoc.elasticCollisions = false;
- // this.dataDoc.forceSketches = [];
- // this.dataDoc.pendulumAngle = 0;
- // this.dataDoc.pendulumLength = 300;
- // this.dataDoc.positionXDisplay = 0;
- // this.dataDoc.positionYDisplay = 0;
- // this.dataDoc.showAcceleration = false;
- // this.dataDoc.showForceMagnitudes = false;
- // this.dataDoc.showForces = false;
- // this.dataDoc.showVelocity = false;
- // this.dataDoc.startForces = [this.forceOfGravity];
- // this.dataDoc.startPendulumAngle = 0;
- // this.dataDoc.startPosX = 0;
- // this.dataDoc.startPosY = 0;
- // this.dataDoc.stepNumber = 0;
- // this.dataDoc.updatedForces = [this.forceOfGravity];
- // this.dataDoc.velocityXDisplay = 0;
- // this.dataDoc.velocityYDisplay = 0;
- // this.dataDoc.wallPositions = [];
- // this.dataDoc.wedgeAngle = 26;
- // this.dataDoc.wedgeHeight = Math.tan((26 * Math.PI) / 180) * this.xMax*0.6;
- // this.dataDoc.wedgeWidth = this.xMax*0.6;
}
// Add one weight to the simulation
@@ -111,7 +86,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
setToWedgeDefault () {
this.changeWedgeBasedOnNewAngle(26);
this.updateForcesWithFriction(this.dataDoc.coefficientOfStaticFriction);
- this.dataDoc.startForces = [this.forceOfGravity];
}
// Add a simple pendulum to the simulation
@@ -280,6 +254,38 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
this.dataDoc.simulationType = "Free Weight"
this.addWeight()
}
+ this.dataDoc.accelerationXDisplay = this.dataDoc.accelerationXDisplay ?? 0;
+ this.dataDoc.accelerationYDisplay = this.dataDoc.accelerationYDisplay ?? 0;
+ this.dataDoc.coefficientOfKineticFriction = this.dataDoc.coefficientOfKineticFriction ?? 0;
+ this.dataDoc.coefficientOfStaticFriction = this.dataDoc.coefficientOfStaticFriction ?? 0;
+ this.dataDoc.currentForceSketch = this.dataDoc.currentForceSketch ?? [];
+ this.dataDoc.elasticCollisions = this.dataDoc.elasticCollisions ?? false;
+ this.dataDoc.forceSketches = this.dataDoc.forceSketches ?? [];
+ this.dataDoc.pendulumAngle = this.dataDoc.pendulumAngle ?? 26;
+ this.dataDoc.pendulumLength = this.dataDoc.pendulumLength ?? 300;
+ this.dataDoc.positionXDisplay = this.dataDoc.positionXDisplay ?? 0;
+ this.dataDoc.positionYDisplay = this.dataDoc.positionYDisplay ?? 0;
+ this.dataDoc.showAcceleration = this.dataDoc.showAcceleration ?? false;
+ this.dataDoc.showForceMagnitudes = this.dataDoc.showForceMagnitudes ?? false;
+ this.dataDoc.showForces = this.dataDoc.showForces ?? false;
+ this.dataDoc.showVelocity = this.dataDoc.showVelocity ?? false;
+ this.dataDoc.startForces = this.dataDoc.startForces ?? [this.forceOfGravity];
+ this.dataDoc.startPendulumAngle = this.dataDoc.startPendulumAngle ?? 0;
+ this.dataDoc.startPosX = this.dataDoc.startPosX ?? 0;
+ this.dataDoc.startPosY = this.dataDoc.startPosY ?? 0;
+ this.dataDoc.stepNumber = this.dataDoc.stepNumber ?? 0;
+ this.dataDoc.updateDisplay = this.dataDoc.updateDisplay ?? false;
+ this.dataDoc.updatedForces = this.dataDoc.updatedForces ?? [this.forceOfGravity];
+ this.dataDoc.velocityXDisplay = this.dataDoc.velocityXDisplay ?? 0;
+ this.dataDoc.velocityYDisplay = this.dataDoc.velocityYDisplay ?? 0;
+ this.dataDoc.wallPositions = this.dataDoc.wallPositions ?? [];
+ this.dataDoc.wedgeAngle = this.dataDoc.wedgeAngle ?? 26;
+ this.dataDoc.wedgeHeight = this.dataDoc.wedgeHeight ?? Math.tan((26 * Math.PI) / 180) * this.xMax*0.6;
+ this.dataDoc.wedgeWidth = this.dataDoc.wedgeWidth ?? this.xMax*0.6;
+
+ this.dataDoc.adjustPendulumAngle = true;
+ this.dataDoc.simulationPaused = true;
+ this.dataDoc.simulationReset = false;
// Add listener for SHIFT key, which determines if sketch force arrow will be edited or deleted on click
document.addEventListener("keydown", (e) => {
@@ -292,12 +298,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
this.dataDoc.deleteMode = false;
}
});
-
- this.dataDoc.simulationPaused = true;
- this.dataDoc.simulationReset = false;
- this.dataDoc.accelerationXDisplay = 0;
- this.dataDoc.accelerationYDisplay = 0;
- this.dataDoc.adjustPendulumAngle = true;
}
componentDidUpdate() {
@@ -393,6 +393,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
this.addWeight()
this.dataDoc.simulationType = "Free Weight"
}
+ this.dataDoc.simulationReset = !this.dataDoc.simulationReset
}} >TYPE</button>)}
</div>
</div>