aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/PhysicsSimulationBox.tsx12
-rw-r--r--src/client/views/nodes/PhysicsSimulationWedge.tsx4
-rw-r--r--src/client/views/nodes/PhysicsSimulationWeight.tsx160
3 files changed, 88 insertions, 88 deletions
diff --git a/src/client/views/nodes/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsSimulationBox.tsx
index 2db49de3c..d0e854263 100644
--- a/src/client/views/nodes/PhysicsSimulationBox.tsx
+++ b/src/client/views/nodes/PhysicsSimulationBox.tsx
@@ -271,8 +271,8 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
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.startPosX = this.dataDoc.startPosX ?? 50;
+ this.dataDoc.startPosY = this.dataDoc.startPosY ?? 50;
this.dataDoc.stepNumber = this.dataDoc.stepNumber ?? 0;
this.dataDoc.updateDisplay = this.dataDoc.updateDisplay ?? false;
this.dataDoc.updatedForces = this.dataDoc.updatedForces ?? [this.forceOfGravity];
@@ -345,8 +345,8 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
/>
)}
</div>
- {/* <div>
- {this.dataDoc.wallPositions.map((element: { length: number; xPos: number; yPos: number; angleInDegrees: number; }, index: React.Key | null | undefined) => {
+ <div>
+ {(this.dataDoc.wallPositions ?? []).map((element: { length: number; xPos: number; yPos: number; angleInDegrees: number; }, index: React.Key | null | undefined) => {
return (
<div key={index}>
<Wall
@@ -358,7 +358,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
</div>
);
})}
- </div> */}
+ </div>
</div>
</div>
<div style = {{width: this.layoutDoc._width+'px', height: this.layoutDoc._height+'px'}}>
@@ -468,11 +468,13 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
this.addWedge()
this.setToWedgeDefault()
this.dataDoc.simulationType = "Inclined Plane"
+ this.dataDoc.elasticCollisions = false
}
else if (!this.dataDoc.pendulum && this.dataDoc.wedge) {
this.setToPendulumDefault()
this.addPendulum()
this.dataDoc.simulationType = "Pendulum"
+ this.dataDoc.elasticCollisions = false
}
else {
this.setToWeightDefault()
diff --git a/src/client/views/nodes/PhysicsSimulationWedge.tsx b/src/client/views/nodes/PhysicsSimulationWedge.tsx
index c5a186f18..6134a6bc0 100644
--- a/src/client/views/nodes/PhysicsSimulationWedge.tsx
+++ b/src/client/views/nodes/PhysicsSimulationWedge.tsx
@@ -49,11 +49,9 @@ export default class Wedge extends React.Component<IWedgeProps, IState> {
}
componentDidUpdate(prevProps: Readonly<IWedgeProps>, prevState: Readonly<IState>, snapshot?: any): void {
- if (prevState.coordinates != this.state.coordinates) {
- this.updateCoordinates();
- }
if (prevProps.startHeight != this.props.startHeight || prevProps.startWidth != this.props.startWidth) {
this.setState({angleInRadians: Math.atan(this.props.startHeight / this.props.startWidth)});
+ this.updateCoordinates();
}
}
diff --git a/src/client/views/nodes/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsSimulationWeight.tsx
index 9aa5a6aab..39b3249e8 100644
--- a/src/client/views/nodes/PhysicsSimulationWeight.tsx
+++ b/src/client/views/nodes/PhysicsSimulationWeight.tsx
@@ -518,86 +518,86 @@ export default class Weight extends React.Component<IWeightProps, IState> {
<div>
<div
className="weightContainer"
- onPointerDown={(e) => {
- if (this.draggable) {
- e.preventDefault();
- this.props.dataDoc['simulationPaused'] = true;
- this.setState({dragging: true});
- this.setState({clickPositionX: e.clientX})
- this.setState({clickPositionY: e.clientY})
- }
- }}
- onPointerMove={(e) => {
- e.preventDefault();
- if (this.state.dragging) {
- let newY = this.state.yPosition + e.clientY - this.state.clickPositionY;
- if (newY > this.props.yMax - 2 * this.props.radius) {
- newY = this.props.yMax - 2 * this.props.radius;
- }
-
- let newX = this.state.xPosition + e.clientX - this.state.clickPositionX;
- if (newX > this.props.xMax - 2 * this.props.radius) {
- newX = this.props.xMax - 2 * this.props.radius;
- } else if (newX < 0) {
- newX = 0;
- }
- this.setState({xPosition: newX})
- this.setState({yPosition: newY})
- this.setState({updatedStartPosX: newX})
- this.setState({updatedStartPosY: newY})
- this.props.dataDoc['positionYDisplay'] = Math.round((this.props.yMax - 2 * this.props.radius - newY + 5) * 100) / 100;
- this.setState({clickPositionX: e.clientX})
- this.setState({clickPositionY: e.clientY})
- this.setDisplayValues();
- }
- }}
- onPointerUp={(e) => {
- if (this.state.dragging) {
- e.preventDefault();
- if (!this.props.dataDoc['pendulum']) {
- this.resetEverything();
- }
- this.setState({dragging: false});
- let newY = this.state.yPosition + e.clientY - this.state.clickPositionY;
- if (newY > this.props.yMax - 2 * this.props.radius) {
- newY = this.props.yMax - 2 * this.props.radius;
- }
-
- let newX = this.state.xPosition + e.clientX - this.state.clickPositionX;
- if (newX > this.props.xMax - 2 * this.props.radius) {
- newX = this.props.xMax - 2 * this.props.radius;
- } else if (newX < 0) {
- newX = 0;
- }
- if (this.props.dataDoc['pendulum']) {
- const x = this.props.xMax / 2 - newX - this.props.radius;
- const y = newY + this.props.radius + 5;
- let angle = (Math.atan(y / x) * 180) / Math.PI;
- if (angle < 0) {
- angle += 180;
- }
- let oppositeAngle = 90 - angle;
- if (oppositeAngle < 0) {
- oppositeAngle = 90 - (180 - angle);
- }
-
- const pendulumLength = Math.sqrt(x * x + y * y);
- this.props.dataDoc['pendulumAngle'] = oppositeAngle;
- this.props.dataDoc['pendulumLength'] = Math.sqrt(x * x + y * y);
- const mag = 9.81 * Math.cos((oppositeAngle * Math.PI) / 180);
- const forceOfTension: IForce = {
- description: "Tension",
- magnitude: mag,
- directionInDegrees: angle,
- };
- this.setState({kineticFriction: false})
- this.setState({xVelocity: this.props.startVelX ?? 0})
- this.setState({yVelocity: this.props.startVelY ?? 0})
- this.setDisplayValues();
- this.props.dataDoc['updatedForces'] = ([this.forceOfGravity, forceOfTension]);
- }
- }
- }}
+ // onPointerDown={(e) => {
+ // if (this.draggable) {
+ // e.preventDefault();
+ // this.props.dataDoc['simulationPaused'] = true;
+ // this.setState({dragging: true});
+ // this.setState({clickPositionX: e.clientX})
+ // this.setState({clickPositionY: e.clientY})
+ // }
+ // }}
+ // onPointerMove={(e) => {
+ // e.preventDefault();
+ // if (this.state.dragging) {
+ // let newY = this.state.yPosition + e.clientY - this.state.clickPositionY;
+ // if (newY > this.props.yMax - 2 * this.props.radius) {
+ // newY = this.props.yMax - 2 * this.props.radius;
+ // }
+
+ // let newX = this.state.xPosition + e.clientX - this.state.clickPositionX;
+ // if (newX > this.props.xMax - 2 * this.props.radius) {
+ // newX = this.props.xMax - 2 * this.props.radius;
+ // } else if (newX < 0) {
+ // newX = 0;
+ // }
+ // this.setState({xPosition: newX})
+ // this.setState({yPosition: newY})
+ // this.setState({updatedStartPosX: newX})
+ // this.setState({updatedStartPosY: newY})
+ // this.props.dataDoc['positionYDisplay'] = Math.round((this.props.yMax - 2 * this.props.radius - newY + 5) * 100) / 100;
+ // this.setState({clickPositionX: e.clientX})
+ // this.setState({clickPositionY: e.clientY})
+ // this.setDisplayValues();
+ // }
+ // }}
+ // onPointerUp={(e) => {
+ // if (this.state.dragging) {
+ // e.preventDefault();
+ // if (!this.props.dataDoc['pendulum']) {
+ // this.resetEverything();
+ // }
+ // this.setState({dragging: false});
+ // let newY = this.state.yPosition + e.clientY - this.state.clickPositionY;
+ // if (newY > this.props.yMax - 2 * this.props.radius) {
+ // newY = this.props.yMax - 2 * this.props.radius;
+ // }
+
+ // let newX = this.state.xPosition + e.clientX - this.state.clickPositionX;
+ // if (newX > this.props.xMax - 2 * this.props.radius) {
+ // newX = this.props.xMax - 2 * this.props.radius;
+ // } else if (newX < 0) {
+ // newX = 0;
+ // }
+ // if (this.props.dataDoc['pendulum']) {
+ // const x = this.props.xMax / 2 - newX - this.props.radius;
+ // const y = newY + this.props.radius + 5;
+ // let angle = (Math.atan(y / x) * 180) / Math.PI;
+ // if (angle < 0) {
+ // angle += 180;
+ // }
+ // let oppositeAngle = 90 - angle;
+ // if (oppositeAngle < 0) {
+ // oppositeAngle = 90 - (180 - angle);
+ // }
+
+ // const pendulumLength = Math.sqrt(x * x + y * y);
+ // this.props.dataDoc['pendulumAngle'] = oppositeAngle;
+ // this.props.dataDoc['pendulumLength'] = Math.sqrt(x * x + y * y);
+ // const mag = 9.81 * Math.cos((oppositeAngle * Math.PI) / 180);
+ // const forceOfTension: IForce = {
+ // description: "Tension",
+ // magnitude: mag,
+ // directionInDegrees: angle,
+ // };
+ // this.setState({kineticFriction: false})
+ // this.setState({xVelocity: this.props.startVelX ?? 0})
+ // this.setState({yVelocity: this.props.startVelY ?? 0})
+ // this.setDisplayValues();
+ // this.props.dataDoc['updatedForces'] = ([this.forceOfGravity, forceOfTension]);
+ // }
+ // }
+ // }}
>
<div className="weight" style={this.weightStyle}>
<p className="weightLabel">{this.props.mass} kg</p>