From bfc445334a5aeee27256ea59cb9f958ef844397d Mon Sep 17 00:00:00 2001 From: brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> Date: Thu, 4 May 2023 21:02:38 -0400 Subject: debug pulley --- .../nodes/PhysicsBox/PhysicsSimulationBox.tsx | 23 ++++----- .../nodes/PhysicsBox/PhysicsSimulationWeight.tsx | 59 ++++++++++++++-------- 2 files changed, 50 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx index 58ea745ef..695b0733d 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx @@ -123,7 +123,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent= 15 && angle < 20) { yPos += 0.08*this.layoutDoc._height*0.26 } else if (angle >= 20 && angle < 25) { - yPos += 0.08*this.layoutDoc._height*0.32 + yPos += 0.08*this.layoutDoc._height*0.33 } else if (angle >= 25 && angle < 30) { - yPos += 0.08*this.layoutDoc._height*0.34 + yPos += 0.08*this.layoutDoc._height*0.35 } else if (angle >= 30 && angle < 35) { - yPos += 0.08*this.layoutDoc._height*0.37 + yPos += 0.08*this.layoutDoc._height*0.40 } else if (angle >= 35 && angle < 40) { - yPos += 0.08*this.layoutDoc._height*0.42 + yPos += 0.08*this.layoutDoc._height*0.45 } else if (angle >= 40 && angle < 45) { - yPos += 0.08*this.layoutDoc._height*0.44 + yPos += 0.08*this.layoutDoc._height*0.47 } else if (angle >= 45) { - yPos += 0.08*this.layoutDoc._height*0.46 + yPos += 0.08*this.layoutDoc._height*0.52 } @@ -1791,7 +1790,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.resetAll = (!this.dataDoc.resetAll); + this.setupSimulation(this.dataDoc.simulationType, this.dataDoc.mode) }} labelWidth={"5em"} /> @@ -1807,7 +1806,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.resetAll = (!this.dataDoc.resetAll); + this.setupSimulation(this.dataDoc.simulationType, this.dataDoc.mode) }} labelWidth={"5em"} /> @@ -1823,7 +1822,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.resetAll = (!this.dataDoc.resetAll); + this.setupSimulation(this.dataDoc.simulationType, this.dataDoc.mode) }} labelWidth={"5em"} /> @@ -1839,7 +1838,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.resetAll = (!this.dataDoc.resetAll); + this.setupSimulation(this.dataDoc.simulationType, this.dataDoc.mode) }} labelWidth={"5em"} /> @@ -1855,7 +1854,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.resetAll = (!this.dataDoc.resetAll); + this.setupSimulation(this.dataDoc.simulationType, this.dataDoc.mode) }} labelWidth={"5em"} /> diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx index 4e7d0e7e6..3ab78e339 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx @@ -151,16 +151,29 @@ export default class Weight extends React.Component { // Set display values based on real values setYPosDisplay = (yPos: number) => { const displayPos = this.getDisplayYPos(yPos); - this.props.dataDoc['positionYDisplay'] = Math.round(displayPos * 100) / 100 + if (this.props.color == 'red') { + this.props.dataDoc['positionYDisplay'] = Math.round(displayPos * 100) / 100 + } else { + this.props.dataDoc['positionYDisplay2'] = Math.round(displayPos * 100) / 100 + } }; setXPosDisplay = (xPos: number) => { - this.props.dataDoc['positionXDisplay'] = Math.round(xPos * 100) / 100; + if (this.props.color == 'red') { + this.props.dataDoc['positionXDisplay'] = Math.round(xPos * 100) / 100; + } else { + this.props.dataDoc['positionXDisplay2'] = Math.round(xPos * 100) / 100;} }; setYVelDisplay = (yVel: number) => { - this.props.dataDoc['velocityYDisplay'] = (-1 * Math.round(yVel * 100)) / 100; + if (this.props.color == 'red') { + this.props.dataDoc['velocityYDisplay'] = (-1 * Math.round(yVel * 100)) / 100; + } else { + this.props.dataDoc['velocityYDisplay2'] = (-1 * Math.round(yVel * 100)) / 100;} }; setXVelDisplay = (xVel: number) => { - this.props.dataDoc['velocityXDisplay'] = Math.round(xVel * 100) / 100; + if (this.props.color == 'red') { + this.props.dataDoc['velocityXDisplay'] = Math.round(xVel * 100) / 100; + } else { + this.props.dataDoc['velocityXDisplay2'] = Math.round(xVel * 100) / 100;} }; // Update display values when simulation updates @@ -213,7 +226,11 @@ export default class Weight extends React.Component { x = Math.min(x, this.props.xMax - 2 * this.props.radius); this.setState({updatedStartPosX: x}) this.setState({xPosition: x}) + if (this.props.color == 'red') { this.props.dataDoc['positionXDisplay'] = x + } else { + this.props.dataDoc['positionXDisplay2'] = x + } } if (this.props.updateDisplay.yDisplay != this.getDisplayYPos(this.state.yPosition)) { @@ -223,19 +240,31 @@ export default class Weight extends React.Component { let coordinatePosition = this.getYPosFromDisplay(y); this.setState({updatedStartPosY: coordinatePosition}) this.setState({yPosition: coordinatePosition}) + if (this.props.color == 'red') { this.props.dataDoc['positionYDisplay'] = y + } else { + this.props.dataDoc['positionYDisplay2'] = y + } } if (this.props.displayXVelocity != this.state.xVelocity) { let x = this.props.displayXVelocity; this.setState({xVelocity: x}) - this.props.dataDoc['velocityXDisplay'] = x + if (this.props.color == 'red') { + this.props.dataDoc['velocityXDisplay'] = x + } else { + this.props.dataDoc['velocityXDisplay2'] = x + } } if (this.props.displayYVelocity != -this.state.yVelocity) { let y = this.props.displayYVelocity; this.setState({yVelocity: -y}) - this.props.dataDoc['velocityYDisplay'] = y + if (this.props.color == 'red') { + this.props.dataDoc['velocityYDisplay'] = y + } else { + this.props.dataDoc['velocityYDisplay2'] = y + } } } @@ -474,18 +503,20 @@ export default class Weight extends React.Component { this.props.dataDoc['pendulumAngle'] = this.props.dataDoc['startPendulumAngle'] this.props.dataDoc['updatedForces'] = (this.props.dataDoc['startForces']) this.props.dataDoc['updatedForces2'] = (this.props.dataDoc['startForces2']) - this.props.dataDoc['accelerationXDisplay'] = 0 - this.props.dataDoc['accelerationYDisplay'] = 0 if (this.props.color == 'red') { this.props.dataDoc['positionXDisplay'] = this.state.updatedStartPosX this.props.dataDoc['positionYDisplay'] = this.state.updatedStartPosY this.props.dataDoc['velocityXDisplay'] = this.props.startVelX ?? 0 this.props.dataDoc['velocityYDisplay'] = this.props.startVelY ?? 0 + this.props.dataDoc['accelerationXDisplay'] = 0 + this.props.dataDoc['accelerationYDisplay'] = 0 } else { this.props.dataDoc['positionXDisplay2'] = this.state.updatedStartPosX this.props.dataDoc['positionYDisplay2'] = this.state.updatedStartPosY this.props.dataDoc['velocityXDisplay2'] = this.props.startVelX ?? 0 this.props.dataDoc['velocityYDisplay2'] = this.props.startVelY ?? 0 + this.props.dataDoc['accelerationXDisplay2'] = 0 + this.props.dataDoc['accelerationYDisplay2'] = 0 } this.setState({angleLabel: Math.round(this.props.dataDoc['pendulumAngle'] ?? 0 * 100) / 100}) }; @@ -1174,18 +1205,6 @@ export default class Weight extends React.Component { ) / 100} °

- - )} - {this.props.dataDoc['simulationType'] == "Suspension" && ( -