diff options
author | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2023-05-04 21:02:38 -0400 |
---|---|---|
committer | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2023-05-04 21:02:38 -0400 |
commit | bfc445334a5aeee27256ea59cb9f958ef844397d (patch) | |
tree | 537207f6dbd03ede9484eebb05dceba1cbd109c7 | |
parent | fbc3750dcfb124411965420bed6e04e36be18d09 (diff) |
debug pulley
-rw-r--r-- | src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx | 23 | ||||
-rw-r--r-- | src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx | 59 |
2 files changed, 50 insertions, 32 deletions
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<Fi this.dataDoc.mode = this.dataDoc.mode ?? "Freeform"; this.dataDoc.positionXDisplay = this.dataDoc.positionXDisplay ?? 0; this.dataDoc.positionYDisplay = this.dataDoc.positionYDisplay ?? 0; - this.dataDoc.resetAll = this.dataDoc.resetAll ?? true; this.dataDoc.showAcceleration = this.dataDoc.showAcceleration ?? false; this.dataDoc.showComponentForces = this.dataDoc.showComponentForces ?? false; this.dataDoc.showForces = this.dataDoc.showForces ?? true; @@ -506,17 +505,17 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi } else if (angle >= 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<Fi upperBound={0} value={this.dataDoc.gravity ?? -9.81} effect={(val: number) => { - 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<Fi upperBound={5} value={this.dataDoc.mass ?? 1} effect={(val: number) => { - 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<Fi upperBound={5} value={this.dataDoc.mass ?? 1} effect={(val: number) => { - 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<Fi upperBound={5} value={this.dataDoc.mass2 ?? 1} effect={(val: number) => { - 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<Fi upperBound={250} value={this.dataDoc.circularMotionRadius ?? 100} effect={(val: number) => { - 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<IWeightProps, IState> { // 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<IWeightProps, IState> { 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<IWeightProps, IState> { 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<IWeightProps, IState> { 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<IWeightProps, IState> { ) / 100} ° </p> - </div> - )} - {this.props.dataDoc['simulationType'] == "Suspension" && ( - <div - className="rod" - style={{ - pointerEvents: "none", - position: "absolute", - left: 0, - top: 0, - }} - > <svg width={this.props.xMax + "px"} height={this.props.layoutDoc._height + "px"}> <line x1={this.state.xPosition + this.props.radius} |