From 9a5f2e9d098d0ad2db1be90818b6295390a60501 Mon Sep 17 00:00:00 2001 From: brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> Date: Wed, 22 Feb 2023 14:29:44 -0500 Subject: pendulum angle --- src/client/views/nodes/PhysicsSimulationBox.scss | 8 +-- src/client/views/nodes/PhysicsSimulationBox.tsx | 76 ++++++++++++++++------ src/client/views/nodes/PhysicsSimulationWeight.tsx | 3 +- 3 files changed, 61 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/PhysicsSimulationBox.scss b/src/client/views/nodes/PhysicsSimulationBox.scss index 7573f1472..0f05010b4 100644 --- a/src/client/views/nodes/PhysicsSimulationBox.scss +++ b/src/client/views/nodes/PhysicsSimulationBox.scss @@ -63,12 +63,10 @@ button { z-index: 1000; } -.mechanicsSimulationSettingsMenuColumn { +.mechanicsSimulationSettingsMenuRow { display: flex; - flex-direction: column; - width: 50%; } -.mechanicsSimulationSettingsMenuContents { - display: flex; +.mechanicsSimulationSettingsMenuRowDescription { + width: 50%; } \ No newline at end of file diff --git a/src/client/views/nodes/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsSimulationBox.tsx index 7eb9092bf..1a64ec795 100644 --- a/src/client/views/nodes/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsSimulationBox.tsx @@ -119,6 +119,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent {this.dataDoc.weight && (

Simulation Settings

-
-
-

Show forces

-

Show acceleration

-

Show velocity

- {this.dataDoc.simulationType == "Free Weight" &&

Elastic collisions

} -
-
-
{this.dataDoc.showForces = !this.dataDoc.showForces}}/>
-
{this.dataDoc.showAcceleration = !this.dataDoc.showAcceleration}}/>
-
{this.dataDoc.showVelocity = !this.dataDoc.showVelocity}}/>
- {this.dataDoc.simulationType == "Free Weight" &&
{this.dataDoc.elasticCollisions = !this.dataDoc.elasticCollisions}}/>
} -
+
+

Show forces

+
{this.dataDoc.showForces = !this.dataDoc.showForces}}/>
+
+
+

Show acceleration

+
{this.dataDoc.showAcceleration = !this.dataDoc.showAcceleration}}/>
+
+
+

Show velocity

+
{this.dataDoc.showVelocity = !this.dataDoc.showVelocity}}/>
+
+
+ {this.dataDoc.simulationType == "Free Weight" &&
+

Elastic collisions

+
{this.dataDoc.elasticCollisions = !this.dataDoc.elasticCollisions}}/>
+
} + {this.dataDoc.simulationType == "Pendulum" &&
+

Pendulum start angle

+
+ { + let angle = e.target.value; + if (angle > 35) { + angle = 35 + } + if (angle < 0) { + angle = 0 + } + let length = this.xMax*0.7; + let x = length * Math.cos(((90 - angle) * Math.PI) / 180); + let y = length * Math.sin(((90 - angle) * Math.PI) / 180); + let xPos = this.xMax / 2 - x - this.radius; + let yPos = y - this.radius; + this.dataDoc.startPosX = xPos; + this.dataDoc.startPosY = yPos; + let mag = 9.81 * Math.cos((angle * Math.PI) / 180); + this.dataDoc.pendulumAngle = angle; + this.dataDoc.pendulumLength = length; + this.dataDoc.startPendulumAngle = angle; + this.dataDoc.adjustPendulumAngle = !this.dataDoc.adjustPendulumAngle; + }} + /> +
+
} {/* {this.dataDoc.simulationType == "Inclined Plane" &&

Inclined plane angle

input field!

} */} - {/* {this.dataDoc.simulationType == "Pendulum" && -
-

Pendulum angle

-

input field!

-
- } */}
)} diff --git a/src/client/views/nodes/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsSimulationWeight.tsx index 66af645b5..9aa5a6aab 100644 --- a/src/client/views/nodes/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsSimulationWeight.tsx @@ -293,6 +293,7 @@ export default class Weight extends React.Component { this.setState({xVelocity: this.props.startVelX ?? 0}) this.setState({yVelocity: this.props.startVelY ?? 0}) this.props.dataDoc['updatedForces'] = (this.props.dataDoc['startForces']) + this.setState({angleLabel: Math.round(this.props.dataDoc['pendulumAngle']* 100) / 100}) this.setDisplayValues(); }; @@ -356,7 +357,7 @@ export default class Weight extends React.Component { magnitude: mag, directionInDegrees: angle, }; - this.setState({angleLabel: Math.round(oppositeAngle * 100) / 100}) + this.setState({angleLabel: Math.round(this.props.dataDoc['pendulumAngle']* 100) / 100}) return [this.forceOfGravity, forceOfTension]; }; -- cgit v1.2.3-70-g09d2