diff options
Diffstat (limited to 'src/client/views/nodes/PhysicsSimulationBox.tsx')
-rw-r--r-- | src/client/views/nodes/PhysicsSimulationBox.tsx | 194 |
1 files changed, 4 insertions, 190 deletions
diff --git a/src/client/views/nodes/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsSimulationBox.tsx index 3ea4fba9f..9d91adefb 100644 --- a/src/client/views/nodes/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsSimulationBox.tsx @@ -33,46 +33,6 @@ interface PhysicsVectorTemplate { weightY: number; } -interface IState { - accelerationXDisplay: number, - accelerationYDisplay: number, - adjustPendulumAngle: {angle: number, length: number}, - coefficientOfKineticFriction: number, - coefficientOfStaticFriction: number, - currentForceSketch: PhysicsVectorTemplate | null, - deleteMode: boolean, - displayChange: {xDisplay: number, yDisplay: number}, - elasticCollisions: boolean, - forceSketches: PhysicsVectorTemplate[], - pendulum: boolean, - pendulumAngle: number, - pendulumLength: number, - positionXDisplay: number, - positionYDisplay: number, - showAcceleration: boolean, - showForceMagnitudes: boolean, - showForces: boolean, - showVelocity: boolean, - simulationPaused: boolean, - simulationReset: boolean, - simulationType: "Inclined Plane", - sketching: boolean, - startForces: IForce[], - startPendulumAngle: number, - startPosX: number, - startPosY: number, - stepNumber: number, - timer: number, - updatedForces: IForce[], - velocityXDisplay: number, - velocityYDisplay: number, - wallPositions: IWallProps[], - wedge: boolean, - wedgeAngle: number, - wedgeHeight: number, - wedgeWidth: number, - weight: boolean, -} @observer export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { @@ -96,7 +56,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi super(props); this.dataDoc.accelerationXDisplay = 0; this.dataDoc.accelerationYDisplay = 0; - this.dataDoc.adjustPendulumAngle = {angle: 0, length: 0}; + this.dataDoc.adjustPendulumAngle = true; this.dataDoc.coefficientOfKineticFriction = 0; this.dataDoc.coefficientOfStaticFriction = 0; this.dataDoc.currentForceSketch = []; @@ -181,7 +141,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi this.dataDoc.startForces = [this.forceOfGravity, forceOfTension]; this.dataDoc.pendulumAngle = angle; this.dataDoc.pendulumLength = length; - this.dataDoc.adjustPendulumAngle = {angle: angle, length: length}; + this.dataDoc.adjustPendulumAngle = !this.dataDoc.adjustPendulumAngle; this.removeWalls(); }; @@ -329,166 +289,20 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi return ( <div> <div className="mechanicsSimulationContainer"> - <div - className="mechanicsSimulationContentContainer" - onPointerMove={(e) => { - // if (sketching) { - // x1 = positionXDisplay + 50; - // y1 = yMax - positionYDisplay - 2 * 50 + 5 + 50; - // x2 = e.clientX; - // y2 = e.clientY; - // height = Math.abs(y1 - y2) + 120; - // width = Math.abs(x1 - x2) + 120; - // top = Math.min(y1, y2) - 60; - // left = Math.min(x1, x2) - 60; - // x1Updated = x1 - left; - // x2Updated = x2 - left; - // y1Updated = y1 - top; - // y2Updated = y2 - top; - // setCurrentForceSketch({ - // top: top, - // left: left, - // width: width, - // height: height, - // x1: x1Updated, - // y1: y1Updated, - // x2: x2Updated, - // y2: y2Updated, - // weightX: positionXDisplay, - // weightY: positionYDisplay, - // }); - // } - }} - onPointerDown={(e) => { - // if (sketching && currentForceSketch) { - // setSketching(false); - // sketches = forceSketches; - // sketches.push(currentForceSketch); - // setForceSketches(sketches); - // setCurrentForceSketch(null); - // } - }} - > + <div className="mechanicsSimulationContentContainer"> <div className="mechanicsSimulationButtonsAndElements"> <div className="mechanicsSimulationElements"> - {/* {showForces && currentForceSketch && simulationPaused && ( - <div - style={{ - position: "fixed", - top: currentForceSketch.top, - left: currentForceSketch.left, - }} - > - <svg - width={currentForceSketch.width + "px"} - height={currentForceSketch.height + "px"} - > - <defs> - <marker - id="sketchArrow" - markerWidth="10" - markerHeight="10" - refX="0" - refY="2" - orient="auto" - markerUnits="strokeWidth" - > - <path d="M0,0 L0,4 L6,2 z" fill={color} /> - </marker> - </defs> - <line - x1={currentForceSketch.x1} - y1={currentForceSketch.y1} - x2={currentForceSketch.x2} - y2={currentForceSketch.y2} - stroke={color} - strokeWidth="10" - markerEnd="url(#sketchArrow)" - /> - </svg> - </div> - )} */} - {/* {showForces && - forceSketches.length > 0 && - simulationPaused && - forceSketches.map((element: PhysicsVectorTemplate, index) => { - return ( - <div - key={index} - style={{ - position: "fixed", - top: element.top + (positionYDisplay - element.weightY), - left: - element.left + (positionXDisplay - element.weightX), - }} - > - <svg - width={element.width + "px"} - height={element.height + "px"} - > - <defs> - <marker - id="sketchArrow" - markerWidth="10" - markerHeight="10" - refX="0" - refY="2" - orient="auto" - markerUnits="strokeWidth" - > - <path d="M0,0 L0,4 L6,2 z" fill={color} /> - </marker> - </defs> - <line - x1={element.x1} - y1={element.y1} - x2={element.x2} - y2={element.y2} - stroke={color} - strokeWidth="10" - markerEnd="url(#sketchArrow)" - onClick={() => { - if (deleteMode) { - deleteForce(element); - } else { - editForce(element); - } - }} - /> - </svg> - </div> - ); - })} */} {this.dataDoc.weight && ( <Weight - adjustPendulumAngle={this.dataDoc.adjustPendulumAngle} color={"red"} - displayXPosition={this.dataDoc.positionXDisplay} - displayXVelocity={this.dataDoc.velocityXDisplay} - displayYPosition={this.dataDoc.positionYDisplay} - displayYVelocity={this.dataDoc.velocityYDisplay} - elasticCollisions={this.dataDoc.elasticCollisions} - incrementTime={this.dataDoc.timer} + dataDoc={this.dataDoc} mass={1} - paused={this.dataDoc.simulationPaused} pendulum={this.dataDoc.pendulum} pendulumAngle={this.dataDoc.pendulumAngle} pendulumLength={this.dataDoc.pendulumLength} radius={this.radius} reset={this.dataDoc.simulationReset} showForceMagnitudes={this.dataDoc.showForceMagnitudes} - setSketching={(val: boolean) => {this.dataDoc.sketching = val}} - setDisplayXAcceleration={(val: number) => {this.dataDoc.accelerationXDisplay = val}} - setDisplayXPosition={(val: number) => {this.dataDoc.positionXDisplay = val}} - setDisplayXVelocity={(val: number) => {this.dataDoc.velocityXDisplay = val}} - setDisplayYAcceleration={(val: number) => {this.dataDoc.accelerationYDisplay = val}} - setDisplayYPosition={(val: number) => {this.dataDoc.positionYDisplay = val}} - setDisplayYVelocity={(val: number) => {this.dataDoc.velocityYDisplay = val}} - setPaused={(val: boolean) => {this.dataDoc.simulationPaused = val}} - setPendulumAngle={(val: number) => {this.dataDoc.pendulumAngle = val}} - setPendulumLength={(val: number) => {this.dataDoc.pendulumLength = val}} - setStartPendulumAngle={(val: number) => {this.dataDoc.startPendulumAngle = val}} - setUpdatedForces={(val: IForce[]) => {this.dataDoc.updatedForces = val}} showAcceleration={this.dataDoc.showAcceleration} showForces={this.dataDoc.showForces} showVelocity={this.dataDoc.showVelocity} |