From 90479323c4476c1c87f10ec2ca42339246414ca0 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 23 May 2023 00:35:00 -0400 Subject: more physics cleanup --- .../nodes/PhysicsBox/PhysicsSimulationBox.tsx | 914 ++++++++++----------- 1 file changed, 455 insertions(+), 459 deletions(-) (limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx') diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx index db15c9a5c..0f5bdf316 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx @@ -19,6 +19,7 @@ import Weight from './PhysicsSimulationWeight'; import React = require('react'); import { BoolCast, NumCast, StrCast } from '../../../../fields/Types'; import { List } from '../../../../fields/List'; +import { computed } from 'mobx'; interface IWallProps { length: number; @@ -79,6 +80,13 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent(); - this.dataDoc.show_Icon = false; - this.dataDoc.hintDialogueOpen = false; - this.dataDoc.noMovement = false; - this.dataDoc.questionNumber = 0; this.dataDoc.questionPartOne = ''; this.dataDoc.questionPartTwo = ''; - this.dataDoc.review_GravityAngle = 0; - this.dataDoc.review_GravityMagnitude = 0; - this.dataDoc.review_NormalAngle = 0; - this.dataDoc.review_NormalMagnitude = 0; - this.dataDoc.review_StaticAngle = 0; - this.dataDoc.review_StaticMagnitude = 0; this.dataDoc.selectedSolutions = []; this.dataDoc.selectedQuestion = this.dataDoc.selectedQuestion ?? questions.inclinePlane[0]; // this.dataDoc.sketching = this.dataDoc.sketching ?? false; // Used for tutorial mode - this.dataDoc.selectedTutorial = this.dataDoc.selectedTutorial ?? tutorials.inclinePlane; - - // Used for uniform circular motion - this.dataDoc.circularMotionRadius = this.dataDoc.circularMotionRadius ?? 150; + this.dataDoc.tutorial = this.dataDoc.tutorial ?? tutorials.inclinePlane; // Used for spring simulation - this.dataDoc.springConstant = NumCast(this.dataDoc.springConstant, 0.5); - this.dataDoc.springRestLength = NumCast(this.dataDoc.springRestLength, 200); - this.dataDoc.springStartLength = NumCast(this.dataDoc.springStartLength, 200); + this.dataDoc.spring_constant = NumCast(this.dataDoc.spring_constant, 0.5); + this.dataDoc.spring_lengthRest = NumCast(this.dataDoc.spring_lengthRest, 200); + this.dataDoc.spring_lengthStart = NumCast(this.dataDoc.spring_lengthStart, 200); // Used for pendulum simulation this.dataDoc.pendulum_length = NumCast(this.dataDoc.pendulum_length, 300); // Used for wedge simulation - this.dataDoc.wedgeAngle = NumCast(this.dataDoc.wedgeAngle, 26); - this.dataDoc.wedgeHeight = NumCast(this.dataDoc.wedgeHeight, Math.tan((26 * Math.PI) / 180) * this.xMax * 0.5); - this.dataDoc.wedgeWidth = NumCast(this.dataDoc.wedgeWidth, this.xMax * 0.5); + this.dataDoc.wedge_angle = NumCast(this.dataDoc.wedge_angle, 26); + this.dataDoc.wedge_height = NumCast(this.dataDoc.wedge_height, Math.tan((26 * Math.PI) / 180) * this.xMax * 0.5); + this.dataDoc.wedge_width = NumCast(this.dataDoc.wedge_width, this.xMax * 0.5); // Used for pulley simulation - this.dataDoc.start_Forces2 = this.dataDoc.start_Forces2 ?? []; - this.dataDoc.updatedForces2 = this.dataDoc.updatedForces2 ?? []; this.dataDoc.mass2 = NumCast(this.dataDoc.mass2, 1); // Setup simulation - this.setupSimulation(StrCast(this.dataDoc.simulation_Type), StrCast(this.dataDoc.mode)); + this.setupSimulation(StrCast(this.dataDoc.simulation_type), StrCast(this.dataDoc.simulation_mode)); // Create walls let walls = []; @@ -170,49 +162,49 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.simulation_Paused = true; + this.dataDoc.simulation_paused = true; if (simulationType != 'Circular Motion') { - this.dataDoc.start_VelX = 0; - this.dataDoc.setStartVelY = 0; - this.dataDoc.velocity_XDisplay = 0; - this.dataDoc.velocity_YDisplay = 0; + this.dataDoc.mass1_velocityXstart = 0; + this.dataDoc.mass1_velocityYstart = 0; + this.dataDoc.mass1_velocityX = 0; + this.dataDoc.mass1_velocityY = 0; } if (mode == 'Freeform') { - this.dataDoc.show_ForceMagnitudes = true; + this.dataDoc.simulation_showForceMagnitudes = true; if (simulationType == 'One Weight') { - this.dataDoc.show_ComponentForces = false; - this.dataDoc.start_PosY = this.yMin + 0.08 * this.layoutDoc[HeightSym](); - this.dataDoc.start_PosX = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym](); - this.dataDoc.position_YDisplay = this.getDisplayYPos(this.yMin + 0.08 * this.layoutDoc[HeightSym]()); - this.dataDoc.position_XDisplay = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym](); - this.dataDoc.updatedForces = [ + this.dataDoc.simulation_showComponentForces = false; + this.dataDoc.mass1_positionYstart = this.yMin + 0.08 * this.layoutDoc[HeightSym](); + this.dataDoc.mass1_positionXstart = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym](); + this.dataDoc.mass1_positionY = this.getDisplayYPos(this.yMin + 0.08 * this.layoutDoc[HeightSym]()); + this.dataDoc.mass1_positionX = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym](); + this.dataDoc.mass1_forcesUpdated = [ { description: 'Gravity', - magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * NumCast(this.dataDoc.mass), + magnitude: Math.abs(this.gravity) * NumCast(this.dataDoc.mass1), directionInDegrees: 270, component: false, }, ]; - this.dataDoc.start_Forces = [ + this.dataDoc.mass1_forcesStart = [ { description: 'Gravity', - magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * NumCast(this.dataDoc.mass), + magnitude: Math.abs(this.gravity) * NumCast(this.dataDoc.mass1), directionInDegrees: 270, component: false, }, ]; - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; } else if (simulationType == 'Inclined Plane') { this.changeWedgeBasedOnNewAngle(26); - this.dataDoc.start_Forces = [ + this.dataDoc.mass1_forcesStart = [ { description: 'Gravity', - magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * NumCast(this.dataDoc.mass), + magnitude: Math.abs(this.gravity) * NumCast(this.dataDoc.mass1), directionInDegrees: 270, component: false, }, @@ -230,11 +222,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { + updateForcesWithFriction = (coefficient: number, width: number = NumCast(this.dataDoc.wedge_width), height: number = NumCast(this.dataDoc.wedge_height)) => { const normalForce: IForce = { description: 'Normal Force', - magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos(Math.atan(height / width)) * NumCast(this.dataDoc.mass), + magnitude: Math.abs(this.gravity) * Math.cos(Math.atan(height / width)) * NumCast(this.dataDoc.mass1), directionInDegrees: 180 - 90 - (Math.atan(height / width) * 180) / Math.PI, component: false, }; let frictionForce: IForce = { description: 'Static Friction Force', - magnitude: coefficient * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos(Math.atan(height / width)) * NumCast(this.dataDoc.mass), + magnitude: coefficient * Math.abs(this.gravity) * Math.cos(Math.atan(height / width)) * NumCast(this.dataDoc.mass1), directionInDegrees: 180 - (Math.atan(height / width) * 180) / Math.PI, component: false, }; // reduce magnitude or friction force if necessary such that block cannot slide up plane - let yForce = -Math.abs(NumCast(this.dataDoc.gravity)) * NumCast(this.dataDoc.mass); + let yForce = -Math.abs(this.gravity) * NumCast(this.dataDoc.mass1); yForce += normalForce.magnitude * Math.sin((normalForce.directionInDegrees * Math.PI) / 180); yForce += frictionForce.magnitude * Math.sin((frictionForce.directionInDegrees * Math.PI) / 180); if (yForce > 0) { - frictionForce.magnitude = - (-normalForce.magnitude * Math.sin((normalForce.directionInDegrees * Math.PI) / 180) + Math.abs(NumCast(this.dataDoc.gravity)) * NumCast(this.dataDoc.mass)) / Math.sin((frictionForce.directionInDegrees * Math.PI) / 180); + frictionForce.magnitude = (-normalForce.magnitude * Math.sin((normalForce.directionInDegrees * Math.PI) / 180) + Math.abs(this.gravity) * NumCast(this.dataDoc.mass1)) / Math.sin((frictionForce.directionInDegrees * Math.PI) / 180); } const frictionForceComponent: IForce = { description: 'Static Friction Force', - magnitude: coefficient * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos(Math.atan(height / width)), + magnitude: coefficient * Math.abs(this.gravity) * Math.cos(Math.atan(height / width)), directionInDegrees: 180 - (Math.atan(height / width) * 180) / Math.PI, component: true, }; const normalForceComponent: IForce = { description: 'Normal Force', - magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos(Math.atan(height / width)), + magnitude: Math.abs(this.gravity) * Math.cos(Math.atan(height / width)), directionInDegrees: 180 - 90 - (Math.atan(height / width) * 180) / Math.PI, component: true, }; const gravityParallel: IForce = { description: 'Gravity Parallel Component', - magnitude: NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.sin(Math.PI / 2 - Math.atan(height / width)), + magnitude: NumCast(this.dataDoc.mass1) * Math.abs(this.gravity) * Math.sin(Math.PI / 2 - Math.atan(height / width)), directionInDegrees: 180 - 90 - (Math.atan(height / width) * 180) / Math.PI + 180, component: true, }; const gravityPerpendicular: IForce = { description: 'Gravity Perpendicular Component', - magnitude: NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos(Math.PI / 2 - Math.atan(height / width)), + magnitude: NumCast(this.dataDoc.mass1) * Math.abs(this.gravity) * Math.cos(Math.PI / 2 - Math.atan(height / width)), directionInDegrees: 360 - (Math.atan(height / width) * 180) / Math.PI, component: true, }; const gravityForce: IForce = { description: 'Gravity', - magnitude: NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)), + magnitude: NumCast(this.dataDoc.mass1) * Math.abs(this.gravity), directionInDegrees: 270, component: false, }; if (coefficient != 0) { - this.dataDoc.start_Forces = [gravityForce, normalForce, frictionForce]; - this.dataDoc.updatedForces = [gravityForce, normalForce, frictionForce]; + this.dataDoc.mass1_forcesStart = [gravityForce, normalForce, frictionForce]; + this.dataDoc.mass1_forcesUpdated = [gravityForce, normalForce, frictionForce]; this.dataDoc.componentForces = [frictionForceComponent, normalForceComponent, gravityParallel, gravityPerpendicular]; } else { - this.dataDoc.start_Forces = [gravityForce, normalForce]; - this.dataDoc.updatedForces = [gravityForce, normalForce]; + this.dataDoc.mass1_forcesStart = [gravityForce, normalForce]; + this.dataDoc.mass1_forcesUpdated = [gravityForce, normalForce]; this.dataDoc.componentForces = [normalForceComponent, gravityParallel, gravityPerpendicular]; } }; // Change wedge height and width and weight position to match new wedge angle changeWedgeBasedOnNewAngle = (angle: number) => { - this.dataDoc.wedgeWidth = this.xMax * 0.5; - this.dataDoc.wedgeHeight = Math.tan((angle * Math.PI) / 180) * this.xMax * 0.5; + this.dataDoc.wedge_width = this.xMax * 0.5; + this.dataDoc.wedge_height = Math.tan((angle * Math.PI) / 180) * this.xMax * 0.5; // update weight position based on updated wedge width/height let yPos = this.yMax - 0.08 * this.layoutDoc[HeightSym]() * 2 - Math.tan((angle * Math.PI) / 180) * this.xMax * 0.5; @@ -433,16 +424,16 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - let theta: number = NumCast(this.dataDoc.wedgeAngle); + let theta: number = NumCast(this.dataDoc.wedge_angle); let index = this.dataDoc.selectedQuestion.variablesForQuestionSetup.indexOf('theta - max 45'); if (index >= 0) { theta = NumListCast(this.dataDoc.questionVariables)[index]; @@ -450,16 +441,16 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent 0) { - friction = (-(Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((theta * Math.PI) / 180)) * Math.sin(((90 - theta) * Math.PI) / 180) + Math.abs(NumCast(this.dataDoc.gravity))) / Math.sin(((180 - theta) * Math.PI) / 180); + friction = (-(Math.abs(this.gravity) * Math.cos((theta * Math.PI) / 180)) * Math.sin(((90 - theta) * Math.PI) / 180) + Math.abs(this.gravity)) / Math.sin(((180 - theta) * Math.PI) / 180); } this.dataDoc.review_StaticMagnitude = friction; this.dataDoc.review_StaticAngle = 180 - theta; @@ -467,16 +458,16 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.review_GravityMagnitude = Math.abs(NumCast(this.dataDoc.gravity)); + this.dataDoc.review_GravityMagnitude = Math.abs(this.gravity); this.dataDoc.review_GravityAngle = 270; - this.dataDoc.review_NormalMagnitude = Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((angle * Math.PI) / 180); + this.dataDoc.review_NormalMagnitude = Math.abs(this.gravity) * Math.cos((angle * Math.PI) / 180); this.dataDoc.review_NormalAngle = 90 - angle; - let yForce = -Math.abs(NumCast(this.dataDoc.gravity)); - yForce += Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((angle * Math.PI) / 180) * Math.sin(((90 - angle) * Math.PI) / 180); - yForce += NumCast(this.dataDoc.review_Coefficient) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((angle * Math.PI) / 180) * Math.sin(((180 - angle) * Math.PI) / 180); - let friction = NumCast(this.dataDoc.review_Coefficient) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((angle * Math.PI) / 180); + let yForce = -Math.abs(this.gravity); + yForce += Math.abs(this.gravity) * Math.cos((angle * Math.PI) / 180) * Math.sin(((90 - angle) * Math.PI) / 180); + yForce += NumCast(this.dataDoc.review_Coefficient) * Math.abs(this.gravity) * Math.cos((angle * Math.PI) / 180) * Math.sin(((180 - angle) * Math.PI) / 180); + let friction = NumCast(this.dataDoc.review_Coefficient) * Math.abs(this.gravity) * Math.cos((angle * Math.PI) / 180); if (yForce > 0) { - friction = (-(Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((angle * Math.PI) / 180)) * Math.sin(((90 - angle) * Math.PI) / 180) + Math.abs(NumCast(this.dataDoc.gravity))) / Math.sin(((180 - angle) * Math.PI) / 180); + friction = (-(Math.abs(this.gravity) * Math.cos((angle * Math.PI) / 180)) * Math.sin(((90 - angle) * Math.PI) / 180) + Math.abs(this.gravity)) / Math.sin(((180 - angle) * Math.PI) / 180); } this.dataDoc.review_StaticMagnitude = friction; this.dataDoc.review_StaticAngle = 180 - angle; @@ -486,7 +477,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { const solutions: number[] = []; - let theta: number = NumCast(this.dataDoc.wedgeAngle); + let theta: number = NumCast(this.dataDoc.wedge_angle); let index = question.variablesForQuestionSetup.indexOf('theta - max 45'); if (index >= 0) { theta = questionVars[index]; @@ -504,20 +495,20 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent epsilon) { + if (Math.abs(NumCast(this.dataDoc.wedge_angle) - this.dataDoc.selectedSolutions[i]) > epsilon) { error = true; } } @@ -571,14 +562,14 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.simulation_Paused = true; + this.dataDoc.simulation_paused = true; }, 3000); } else { - this.dataDoc.simulation_Paused = false; + this.dataDoc.simulation_paused = false; setTimeout(() => { - this.dataDoc.simulation_Paused = true; + this.dataDoc.simulation_paused = true; }, 3000); } } @@ -600,7 +591,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent(this.getAnswersToQuestion(question, vars)); - //this.dataDoc.simulation_Reset = (!this.dataDoc.simulation_Reset); + //this.dataDoc.simulation_reset = (!this.dataDoc.simulation_reset); }; // Default setup for uniform circular motion simulation setupCircular = (value: number) => { - this.dataDoc.show_ComponentForces = false; - this.dataDoc.start_VelY = 0; - this.dataDoc.start_VelX = value; + this.dataDoc.simulation_showComponentForces = false; + this.dataDoc.mass1_velocityYstart = 0; + this.dataDoc.mass1_velocityXstart = value; let xPos = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym](); - let yPos = (this.yMax + this.yMin) / 2 + NumCast(this.dataDoc.circularMotionRadius) - 0.08 * this.layoutDoc[HeightSym](); - this.dataDoc.start_PosY = yPos; - this.dataDoc.start_PosX = xPos; + let yPos = (this.yMax + this.yMin) / 2 + this.circularMotionRadius - 0.08 * this.layoutDoc[HeightSym](); + this.dataDoc.mass1_positionYstart = yPos; + this.dataDoc.mass1_positionXstart = xPos; const tensionForce: IForce = { description: 'Centripetal Force', - magnitude: (this.dataDoc.start_VelX ** 2 * NumCast(this.dataDoc.mass)) / NumCast(this.dataDoc.circularMotionRadius), + magnitude: (this.dataDoc.mass1_velocityXstart ** 2 * NumCast(this.dataDoc.mass1)) / this.circularMotionRadius, directionInDegrees: 90, component: false, }; - this.dataDoc.updatedForces = [tensionForce]; - this.dataDoc.start_Forces = [tensionForce]; - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.mass1_forcesUpdated = [tensionForce]; + this.dataDoc.mass1_forcesStart = [tensionForce]; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }; // Default setup for pendulum simulation @@ -683,9 +674,9 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.show_ComponentForces = false; + this.dataDoc.simulation_showComponentForces = false; const gravityForce: IForce = { description: 'Gravity', - magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * NumCast(this.dataDoc.mass), + magnitude: Math.abs(this.gravity) * NumCast(this.dataDoc.mass1), directionInDegrees: 270, component: false, }; - this.dataDoc.updatedForces = [gravityForce]; - this.dataDoc.start_Forces = [gravityForce]; - this.dataDoc.start_PosX = this.xMax / 2 - 0.08 * this.layoutDoc[HeightSym](); - this.dataDoc.start_PosY = 200; - this.dataDoc.springConstant = 0.5; - this.dataDoc.springRestLength = 200; - this.dataDoc.springStartLength = 200; - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.mass1_forcesUpdated = [gravityForce]; + this.dataDoc.mass1_forcesStart = [gravityForce]; + this.dataDoc.mass1_positionXstart = this.xMax / 2 - 0.08 * this.layoutDoc[HeightSym](); + this.dataDoc.mass1_positionYstart = 200; + this.dataDoc.spring_constant = 0.5; + this.dataDoc.spring_lengthRest = 200; + this.dataDoc.spring_lengthStart = 200; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }; // Default setup for suspension simulation setupSuspension = () => { let xPos = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym](); let yPos = this.yMin + 200; - this.dataDoc.start_PosY = yPos; - this.dataDoc.start_PosX = xPos; - this.dataDoc.position_YDisplay = this.getDisplayYPos(yPos); - this.dataDoc.position_XDisplay = xPos; - let tensionMag = (NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity))) / (2 * Math.sin(Math.PI / 4)); + this.dataDoc.mass1_positionYstart = yPos; + this.dataDoc.mass1_positionXstart = xPos; + this.dataDoc.mass1_positionY = this.getDisplayYPos(yPos); + this.dataDoc.mass1_positionX = xPos; + let tensionMag = (NumCast(this.dataDoc.mass1) * Math.abs(this.gravity)) / (2 * Math.sin(Math.PI / 4)); const tensionForce1: IForce = { description: 'Tension', magnitude: tensionMag, @@ -780,59 +771,59 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.show_ComponentForces = false; - this.dataDoc.start_PosY = (this.yMax + this.yMin) / 2; - this.dataDoc.start_PosX = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.layoutDoc[HeightSym]()) - 5; - this.dataDoc.position_YDisplay = this.getDisplayYPos((this.yMax + this.yMin) / 2); - this.dataDoc.position_XDisplay = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.layoutDoc[HeightSym]()) - 5; - let a = (-1 * ((NumCast(this.dataDoc.mass) - NumCast(this.dataDoc.mass2)) * Math.abs(NumCast(this.dataDoc.gravity)))) / (NumCast(this.dataDoc.mass) + NumCast(this.dataDoc.mass2)); + this.dataDoc.simulation_showComponentForces = false; + this.dataDoc.mass1_positionYstart = (this.yMax + this.yMin) / 2; + this.dataDoc.mass1_positionXstart = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.layoutDoc[HeightSym]()) - 5; + this.dataDoc.mass1_positionY = this.getDisplayYPos((this.yMax + this.yMin) / 2); + this.dataDoc.mass1_positionX = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.layoutDoc[HeightSym]()) - 5; + let a = (-1 * ((NumCast(this.dataDoc.mass1) - NumCast(this.dataDoc.mass2)) * Math.abs(this.gravity))) / (NumCast(this.dataDoc.mass1) + NumCast(this.dataDoc.mass2)); const gravityForce1: IForce = { description: 'Gravity', - magnitude: NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)), + magnitude: NumCast(this.dataDoc.mass1) * Math.abs(this.gravity), directionInDegrees: 270, component: false, }; const tensionForce1: IForce = { description: 'Tension', - magnitude: NumCast(this.dataDoc.mass) * a + NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)), + magnitude: NumCast(this.dataDoc.mass1) * a + NumCast(this.dataDoc.mass1) * Math.abs(this.gravity), directionInDegrees: 90, component: false, }; a *= -1; const gravityForce2: IForce = { description: 'Gravity', - magnitude: NumCast(this.dataDoc.mass2) * Math.abs(NumCast(this.dataDoc.gravity)), + magnitude: NumCast(this.dataDoc.mass2) * Math.abs(this.gravity), directionInDegrees: 270, component: false, }; const tensionForce2: IForce = { description: 'Tension', - magnitude: NumCast(this.dataDoc.mass2) * a + NumCast(this.dataDoc.mass2) * Math.abs(NumCast(this.dataDoc.gravity)), + magnitude: NumCast(this.dataDoc.mass2) * a + NumCast(this.dataDoc.mass2) * Math.abs(this.gravity), directionInDegrees: 90, component: false, }; - this.dataDoc.updatedForces = [gravityForce1, tensionForce1]; - this.dataDoc.start_Forces = [gravityForce1, tensionForce1]; - this.dataDoc.start_PosY2 = (this.yMax + this.yMin) / 2; - this.dataDoc.start_PosX2 = (this.xMin + this.xMax) / 2 + 5; - this.dataDoc.position_YDisplay2 = this.getDisplayYPos((this.yMax + this.yMin) / 2); - this.dataDoc.position_XDisplay2 = (this.xMin + this.xMax) / 2 + 5; - this.dataDoc.updatedForces2 = [gravityForce2, tensionForce2]; - this.dataDoc.start_Forces2 = [gravityForce2, tensionForce2]; + this.dataDoc.mass1_forcesUpdated = [gravityForce1, tensionForce1]; + this.dataDoc.mass1_forcesStart = [gravityForce1, tensionForce1]; + this.dataDoc.mass2_positionYstart = (this.yMax + this.yMin) / 2; + this.dataDoc.mass2_positionXstart = (this.xMin + this.xMax) / 2 + 5; + this.dataDoc.mass2_positionY = this.getDisplayYPos((this.yMax + this.yMin) / 2); + this.dataDoc.mass2_positionX = (this.xMin + this.xMax) / 2 + 5; + this.dataDoc.mass2_forcesUpdated = [gravityForce2, tensionForce2]; + this.dataDoc.mass2_forcesStart = [gravityForce2, tensionForce2]; - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }; // Helper function used for tutorial and review mode @@ -877,8 +868,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
- {!this.dataDoc.simulation_Paused && ( + {!this.dataDoc.simulation_paused && (
- {this.dataDoc.simulation_Type == 'Pulley' && ( + {this.dataDoc.simulation_type == 'Pulley' && (
- {(this.dataDoc.simulation_Type == 'One Weight' || this.dataDoc.simulation_Type == 'Inclined Plane') && + {(this.dataDoc.simulation_type == 'One Weight' || this.dataDoc.simulation_type == 'Inclined Plane') && this.wallPositions && this.wallPositions.map((element, index) => { return ; @@ -1014,26 +1005,26 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
- {this.dataDoc.simulation_Paused && this.dataDoc.mode != 'Tutorial' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_mode != 'Tutorial' && ( { - this.dataDoc.simulation_Paused = false; + this.dataDoc.simulation_paused = false; }}> )} - {!this.dataDoc.simulation_Paused && this.dataDoc.mode != 'Tutorial' && ( + {!this.dataDoc.simulation_paused && this.dataDoc.simulation_mode != 'Tutorial' && ( { - this.dataDoc.simulation_Paused = true; + this.dataDoc.simulation_paused = true; }}> )} - {this.dataDoc.simulation_Paused && this.dataDoc.mode != 'Tutorial' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_mode != 'Tutorial' && ( { - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }}> @@ -1041,10 +1032,10 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
{ - this.dataDoc.mode = event.target.value; - this.setupSimulation(StrCast(this.dataDoc.simulation_Type), event.target.value); + this.dataDoc.simulation_mode = event.target.value; + this.setupSimulation(StrCast(this.dataDoc.simulation_type), event.target.value); }} style={{ height: '2em', width: '100%', fontSize: '16px' }}> @@ -1070,13 +1061,13 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
- {this.dataDoc.mode == 'Review' && this.dataDoc.simulation_Type != 'Inclined Plane' && ( + {this.dataDoc.simulation_mode == 'Review' && this.dataDoc.simulation_type != 'Inclined Plane' && (
-

{this.dataDoc.simulation_Type} review problems in progress!

+

{this.dataDoc.simulation_type} review problems in progress!


)} - {this.dataDoc.mode == 'Review' && this.dataDoc.simulation_Type == 'Inclined Plane' && ( + {this.dataDoc.simulation_mode == 'Review' && this.dataDoc.simulation_type == 'Inclined Plane' && (
{!this.dataDoc.hintDialogueOpen && ( @@ -1152,7 +1143,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent @@ -1167,7 +1158,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent @@ -1183,7 +1174,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent @@ -1198,7 +1189,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent @@ -1214,7 +1205,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent @@ -1234,7 +1225,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} @@ -1243,17 +1234,17 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponentθ} lowerBound={0} dataDoc={this.dataDoc} - prop="wedgeAngle" + prop="wedge_angle" step={1} unit={'°'} upperBound={49} - value={NumCast(this.dataDoc.wedgeAngle, 26)} + value={NumCast(this.dataDoc.wedge_angle, 26)} effect={(val: number) => { this.changeWedgeBasedOnNewAngle(val); this.updateReviewForcesBasedOnAngle(val); }} radianEquivalent={true} - showIcon={BoolCast(this.dataDoc.show_Icon)} + showIcon={BoolCast(this.dataDoc.simulation_showIcon)} correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('wedge angle')]} /> )} @@ -1261,11 +1252,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
)} - {this.dataDoc.mode == 'Tutorial' && ( + {this.dataDoc.simulation_mode == 'Tutorial' && (

Problem

-

{this.dataDoc.selectedTutorial.question}

+

{this.dataDoc.tutorial.question}

{ - let step = NumCast(this.dataDoc.stepNumber) - 1; + let step = NumCast(this.dataDoc.tutorial_stepNumber) - 1; step = Math.max(step, 0); - step = Math.min(step, this.dataDoc.selectedTutorial.steps.length - 1); - this.dataDoc.stepNumber = step; - this.dataDoc.start_Forces = this.getForceFromJSON(this.dataDoc.selectedTutorial.steps[step].forces); - this.dataDoc.updatedForces = this.getForceFromJSON(this.dataDoc.selectedTutorial.steps[step].forces); - this.dataDoc.show_ForceMagnitudes = this.dataDoc.selectedTutorial.steps[step].show_Magnitude; + step = Math.min(step, this.dataDoc.tutorial.steps.length - 1); + this.dataDoc.tutorial_stepNumber = step; + this.dataDoc.mass1_forcesStart = this.getForceFromJSON(this.dataDoc.tutorial.steps[step].forces); + this.dataDoc.mass1_forcesUpdated = this.getForceFromJSON(this.dataDoc.tutorial.steps[step].forces); + this.dataDoc.simulation_showForceMagnitudes = this.dataDoc.tutorial.steps[step].show_Magnitude; }} - disabled={this.dataDoc.stepNumber == 0}> + disabled={this.dataDoc.tutorial_stepNumber == 0}>

- Step {NumCast(this.dataDoc.stepNumber) + 1}: {this.dataDoc.selectedTutorial.steps[this.dataDoc.stepNumber].description} + Step {NumCast(this.dataDoc.tutorial_stepNumber) + 1}: {this.dataDoc.tutorial.steps[this.dataDoc.tutorial_stepNumber].description}

-

{this.dataDoc.selectedTutorial.steps[NumCast(this.dataDoc.stepNumber)].content}

+

{this.dataDoc.tutorial.steps[NumCast(this.dataDoc.tutorial_stepNumber)].content}

{ - let step = NumCast(this.dataDoc.stepNumber) + 1; + let step = NumCast(this.dataDoc.tutorial_stepNumber) + 1; step = Math.max(step, 0); - step = Math.min(step, this.dataDoc.selectedTutorial.steps.length - 1); - this.dataDoc.stepNumber = step; - this.dataDoc.start_Forces = this.getForceFromJSON(this.dataDoc.selectedTutorial.steps[step].forces); - this.dataDoc.updatedForces = this.getForceFromJSON(this.dataDoc.selectedTutorial.steps[step].forces); - this.dataDoc.show_ForceMagnitudes = this.dataDoc.selectedTutorial.steps[step].show_Magnitude; + step = Math.min(step, this.dataDoc.tutorial.steps.length - 1); + this.dataDoc.tutorial_stepNumber = step; + this.dataDoc.mass1_forcesStart = this.getForceFromJSON(this.dataDoc.tutorial.steps[step].forces); + this.dataDoc.mass1_forcesUpdated = this.getForceFromJSON(this.dataDoc.tutorial.steps[step].forces); + this.dataDoc.simulation_showForceMagnitudes = this.dataDoc.tutorial.steps[step].show_Magnitude; }} - disabled={this.dataDoc.stepNumber == this.dataDoc.selectedTutorial.steps.length - 1}> + disabled={this.dataDoc.tutorial_stepNumber == this.dataDoc.tutorial.steps.length - 1}>
- {(this.dataDoc.simulation_Type == 'One Weight' || this.dataDoc.simulation_Type == 'Inclined Plane' || this.dataDoc.simulation_Type == 'Pendulum') &&

Resources

} - {this.dataDoc.simulation_Type == 'One Weight' && ( + {(this.dataDoc.simulation_type == 'One Weight' || this.dataDoc.simulation_type == 'Inclined Plane' || this.dataDoc.simulation_type == 'Pendulum') &&

Resources

} + {this.dataDoc.simulation_type == 'One Weight' && ( )} - {this.dataDoc.simulation_Type == 'Inclined Plane' && ( + {this.dataDoc.simulation_type == 'Inclined Plane' && ( )} - {this.dataDoc.simulation_Type == 'Pendulum' && ( + {this.dataDoc.simulation_type == 'Pendulum' && (
)} - {this.dataDoc.mode == 'Review' && this.dataDoc.simulation_Type == 'Inclined Plane' && ( + {this.dataDoc.simulation_mode == 'Review' && this.dataDoc.simulation_type == 'Inclined Plane' && (
(this.dataDoc.mode = 'Tutorial')}> + onClick={() => (this.dataDoc.simulation_mode = 'Tutorial')}> {' '} Go to walkthrough{' '}

)} - {this.dataDoc.mode == 'Freeform' && ( + {this.dataDoc.simulation_mode == 'Freeform' && (
- {this.dataDoc.simulation_Type == 'One Weight' && ( + {this.dataDoc.simulation_type == 'One Weight' && ( (this.dataDoc.elasticCollisions = !this.dataDoc.elasticCollisions)} />} label="Make collisions elastic" labelPlacement="start" /> )} - (this.dataDoc.show_Forces = !this.dataDoc.show_Forces)} />} label="Show force vectors" labelPlacement="start" /> - {(this.dataDoc.simulation_Type == 'Inclined Plane' || this.dataDoc.simulation_Type == 'Pendulum') && ( + (this.dataDoc.simulation_showForces = !this.dataDoc.simulation_showForces)} />} + label="Show force vectors" + labelPlacement="start" + /> + {(this.dataDoc.simulation_type == 'Inclined Plane' || this.dataDoc.simulation_type == 'Pendulum') && ( (this.dataDoc.show_ComponentForces = !this.dataDoc.show_ComponentForces)} />} + control={ (this.dataDoc.simulation_showComponentForces = !this.dataDoc.simulation_showComponentForces)} />} label="Show component force vectors" labelPlacement="start" /> )} (this.dataDoc.show_Acceleration = !this.dataDoc.show_Acceleration)} />} + control={ (this.dataDoc.simulation_showAcceleration = !this.dataDoc.simulation_showAcceleration)} />} label="Show acceleration vector" labelPlacement="start" /> (this.dataDoc.show_Velocity = !this.dataDoc.show_Velocity)} />} + control={ (this.dataDoc.simulation_showVelocity = !this.dataDoc.simulation_showVelocity)} />} label="Show velocity vector" labelPlacement="start" /> - Speed} lowerBound={1} dataDoc={this.dataDoc} prop="simulation_Speed" step={1} unit={'x'} upperBound={10} value={this.dataDoc.simulation_Speed ?? 2} labelWidth={'5em'} /> - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type != 'Circular Motion' && ( + Speed} lowerBound={1} dataDoc={this.dataDoc} prop="simulation_speed" step={1} unit={'x'} upperBound={10} value={this.dataDoc.simulation_speed ?? 2} labelWidth={'5em'} /> + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type != 'Circular Motion' && ( Gravity} lowerBound={-30} @@ -1460,46 +1455,46 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.setupSimulation(StrCast(this.dataDoc.simulation_Type), StrCast(this.dataDoc.mode)); + this.setupSimulation(StrCast(this.dataDoc.simulation_type), StrCast(this.dataDoc.simulation_mode)); }} labelWidth={'5em'} /> )} - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type != 'Pulley' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type != 'Pulley' && ( Mass} lowerBound={1} dataDoc={this.dataDoc} - prop="mass" + prop="mass1" step={0.1} unit={'kg'} upperBound={5} - value={NumCast(this.dataDoc.mass) ?? 1} + value={NumCast(this.dataDoc.mass1) ?? 1} effect={(val: number) => { - this.setupSimulation(StrCast(this.dataDoc.simulation_Type), StrCast(this.dataDoc.mode)); + this.setupSimulation(StrCast(this.dataDoc.simulation_type), StrCast(this.dataDoc.simulation_mode)); }} labelWidth={'5em'} /> )} - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type == 'Pulley' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type == 'Pulley' && ( Red mass} lowerBound={1} dataDoc={this.dataDoc} - prop="mass" + prop="mass1" step={0.1} unit={'kg'} upperBound={5} - value={NumCast(this.dataDoc.mass) ?? 1} + value={NumCast(this.dataDoc.mass1) ?? 1} effect={(val: number) => { - this.setupSimulation(StrCast(this.dataDoc.simulation_Type), StrCast(this.dataDoc.mode)); + this.setupSimulation(StrCast(this.dataDoc.simulation_type), StrCast(this.dataDoc.simulation_mode)); }} labelWidth={'5em'} /> )} - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type == 'Pulley' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type == 'Pulley' && ( Blue mass} lowerBound={1} @@ -1510,12 +1505,12 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.setupSimulation(StrCast(this.dataDoc.simulation_Type), StrCast(this.dataDoc.mode)); + this.setupSimulation(StrCast(this.dataDoc.simulation_type), StrCast(this.dataDoc.simulation_mode)); }} labelWidth={'5em'} /> )} - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type == 'Circular Motion' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type == 'Circular Motion' && ( Rod length} lowerBound={100} @@ -1524,28 +1519,28 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.setupSimulation(StrCast(this.dataDoc.simulation_Type), StrCast(this.dataDoc.mode)); + this.setupSimulation(StrCast(this.dataDoc.simulation_type), StrCast(this.dataDoc.simulation_mode)); }} labelWidth={'5em'} /> )} - {this.dataDoc.simulation_Type == 'Spring' && this.dataDoc.simulation_Paused && ( + {this.dataDoc.simulation_type == 'Spring' && this.dataDoc.simulation_paused && (
Spring stiffness} lowerBound={0.1} dataDoc={this.dataDoc} - prop="springConstant" + prop="spring_constant" step={1} unit={'N/m'} upperBound={500} - value={NumCast(this.dataDoc.springConstant) ?? 0.5} + value={NumCast(this.dataDoc.spring_constant) ?? 0.5} effect={(val: number) => { - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }} radianEquivalent={false} mode={'Freeform'} @@ -1555,13 +1550,13 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponentRest length} lowerBound={10} dataDoc={this.dataDoc} - prop="springRestLength" + prop="spring_lengthRest" step={100} unit={''} upperBound={500} - value={NumCast(this.dataDoc.springRestLength) ?? 200} + value={NumCast(this.dataDoc.spring_lengthRest) ?? 200} effect={(val: number) => { - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }} radianEquivalent={false} mode={'Freeform'} @@ -1569,17 +1564,17 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent Starting displacement} - lowerBound={-(NumCast(this.dataDoc.springRestLength) - 10)} + lowerBound={-(NumCast(this.dataDoc.spring_lengthRest) - 10)} dataDoc={this.dataDoc} prop="" step={10} unit={''} - upperBound={NumCast(this.dataDoc.springRestLength)} - value={NumCast(this.dataDoc.springStartLength) - NumCast(this.dataDoc.springRestLength)} + upperBound={NumCast(this.dataDoc.spring_lengthRest)} + value={NumCast(this.dataDoc.spring_lengthStart) - NumCast(this.dataDoc.spring_lengthRest)} effect={(val: number) => { - this.dataDoc.start_PosY = NumCast(this.dataDoc.springRestLength) + val; - this.dataDoc.springStartLength = NumCast(this.dataDoc.springRestLength) + val; - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.mass1_positionYstart = NumCast(this.dataDoc.spring_lengthRest) + val; + this.dataDoc.spring_lengthStart = NumCast(this.dataDoc.spring_lengthRest) + val; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }} radianEquivalent={false} mode={'Freeform'} @@ -1587,20 +1582,20 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
)} - {this.dataDoc.simulation_Type == 'Inclined Plane' && this.dataDoc.simulation_Paused && ( + {this.dataDoc.simulation_type == 'Inclined Plane' && this.dataDoc.simulation_paused && (
θ} lowerBound={0} dataDoc={this.dataDoc} - prop="wedgeAngle" + prop="wedge_angle" step={1} unit={'°'} upperBound={49} - value={NumCast(this.dataDoc.wedgeAngle, 26)} + value={NumCast(this.dataDoc.wedge_angle, 26)} effect={(val: number) => { this.changeWedgeBasedOnNewAngle(val); - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }} radianEquivalent={true} mode={'Freeform'} @@ -1624,7 +1619,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }} mode={'Freeform'} labelWidth={'2em'} />
)} - {this.dataDoc.simulation_Type == 'Inclined Plane' && !this.dataDoc.simulation_Paused && ( + {this.dataDoc.simulation_type == 'Inclined Plane' && !this.dataDoc.simulation_paused && ( - θ: {Math.round(NumCast(this.dataDoc.wedgeAngle) * 100) / 100}° ≈ {Math.round(((NumCast(this.dataDoc.wedgeAngle) * Math.PI) / 180) * 100) / 100} rad + θ: {Math.round(NumCast(this.dataDoc.wedge_angle) * 100) / 100}° ≈ {Math.round(((NumCast(this.dataDoc.wedge_angle) * Math.PI) / 180) * 100) / 100} rad
μ s: {this.dataDoc.coefficientOfStaticFriction}
μ k: {this.dataDoc.coefficientOfKineticFriction}
)} - {this.dataDoc.simulation_Type == 'Pendulum' && !this.dataDoc.simulation_Paused && ( + {this.dataDoc.simulation_type == 'Pendulum' && !this.dataDoc.simulation_paused && ( θ: {Math.round(NumCast(this.dataDoc.pendulum_angle) * 100) / 100}° ≈ {Math.round(((NumCast(this.dataDoc.pendulum_angle) * Math.PI) / 180) * 100) / 100} rad )} - {this.dataDoc.simulation_Type == 'Pendulum' && this.dataDoc.simulation_Paused && ( + {this.dataDoc.simulation_type == 'Pendulum' && this.dataDoc.simulation_paused && (
Angle} @@ -1676,9 +1671,9 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - this.dataDoc.start_PendulumAngle = value; - if (this.dataDoc.simulation_Type == 'Pendulum') { - const mag = NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((value * Math.PI) / 180); + this.dataDoc.pendulum_angleStart = value; + if (this.dataDoc.simulation_type == 'Pendulum') { + const mag = NumCast(this.dataDoc.mass1) * Math.abs(this.gravity) * Math.cos((value * Math.PI) / 180); const forceOfTension: IForce = { description: 'Tension', @@ -1695,13 +1690,13 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - if (this.dataDoc.simulation_Type == 'Pendulum') { + if (this.dataDoc.simulation_type == 'Pendulum') { this.dataDoc.pendulum_angle_adjust = NumCast(this.dataDoc.pendulum_angle); this.dataDoc.pendulum_length_adjust = value; - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; } }} radianEquivalent={false} @@ -1766,11 +1762,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )}
- {this.dataDoc.mode == 'Freeform' && ( + {this.dataDoc.simulation_mode == 'Freeform' && ( - + @@ -1785,34 +1781,34 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent Position - {(!this.dataDoc.simulation_Paused || this.dataDoc.simulation_Type == 'Inclined Plane' || this.dataDoc.simulation_Type == 'Circular Motion' || this.dataDoc.simulation_Type == 'Pulley') && ( - + {(!this.dataDoc.simulation_paused || this.dataDoc.simulation_type == 'Inclined Plane' || this.dataDoc.simulation_type == 'Circular Motion' || this.dataDoc.simulation_type == 'Pulley') && ( + )}{' '} - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type != 'Inclined Plane' && this.dataDoc.simulation_Type != 'Circular Motion' && this.dataDoc.simulation_Type != 'Pulley' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type != 'Inclined Plane' && this.dataDoc.simulation_type != 'Circular Motion' && this.dataDoc.simulation_type != 'Pulley' && ( )}{' '} - {(!this.dataDoc.simulation_Paused || this.dataDoc.simulation_Type == 'Inclined Plane' || this.dataDoc.simulation_Type == 'Circular Motion' || this.dataDoc.simulation_Type == 'Pulley') && ( - + {(!this.dataDoc.simulation_paused || this.dataDoc.simulation_type == 'Inclined Plane' || this.dataDoc.simulation_type == 'Circular Motion' || this.dataDoc.simulation_type == 'Pulley') && ( + )}{' '} - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type != 'Inclined Plane' && this.dataDoc.simulation_Type != 'Circular Motion' && this.dataDoc.simulation_Type != 'Pulley' && ( + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type != 'Inclined Plane' && this.dataDoc.simulation_type != 'Circular Motion' && this.dataDoc.simulation_type != 'Pulley' && ( - {(!this.dataDoc.simulation_Paused || (this.dataDoc.simulation_Type != 'One Weight' && this.dataDoc.simulation_Type != 'Circular Motion')) && ( - + {(!this.dataDoc.simulation_paused || (this.dataDoc.simulation_type != 'One Weight' && this.dataDoc.simulation_type != 'Circular Motion')) && ( + )}{' '} - {this.dataDoc.simulation_Paused && (this.dataDoc.simulation_Type == 'One Weight' || this.dataDoc.simulation_Type == 'Circular Motion') && ( + {this.dataDoc.simulation_paused && (this.dataDoc.simulation_type == 'One Weight' || this.dataDoc.simulation_type == 'Circular Motion') && ( )}{' '} - {(!this.dataDoc.simulation_Paused || this.dataDoc.simulation_Type != 'One Weight') && }{' '} - {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type == 'One Weight' && ( + {(!this.dataDoc.simulation_paused || this.dataDoc.simulation_type != 'One Weight') && }{' '} + {this.dataDoc.simulation_paused && this.dataDoc.simulation_type == 'One Weight' && ( - - + +
{this.dataDoc.simulation_Type == 'Pulley' ? 'Red Weight' : ''}{this.dataDoc.simulation_type == 'Pulley' ? 'Red Weight' : ''} X Y
{this.dataDoc.position_XDisplay} m{this.dataDoc.mass1_positionX} m { - this.dataDoc.display_xChange = value; - this.dataDoc.display_yChange = this.dataDoc.position_YDisplay; - if (this.dataDoc.simulation_Type == 'Suspension') { + this.dataDoc.mass1_xChange = value; + this.dataDoc.mass1_yChange = this.dataDoc.mass1_positionY; + if (this.dataDoc.simulation_type == 'Suspension') { let x1rod = (this.xMax + this.xMin) / 2 - this.radius - this.yMin - 200; let x2rod = (this.xMax + this.xMin) / 2 + this.yMin + 200 + this.radius; let deltaX1 = value + this.radius - x1rod; let deltaX2 = x2rod - (value + this.radius); - let deltaY = this.getYPosFromDisplay(NumCast(this.dataDoc.position_YDisplay)) + this.radius; + let deltaY = this.getYPosFromDisplay(NumCast(this.dataDoc.mass1_positionY)) + this.radius; let dir1T = Math.PI - Math.atan(deltaY / deltaX1); let dir2T = Math.atan(deltaY / deltaX2); - let tensionMag2 = (NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity))) / ((-Math.cos(dir2T) / Math.cos(dir1T)) * Math.sin(dir1T) + Math.sin(dir2T)); + let tensionMag2 = (NumCast(this.dataDoc.mass1) * Math.abs(this.gravity)) / ((-Math.cos(dir2T) / Math.cos(dir1T)) * Math.sin(dir1T) + Math.sin(dir2T)); let tensionMag1 = (-tensionMag2 * Math.cos(dir2T)) / Math.cos(dir1T); dir1T = (dir1T * 180) / Math.PI; dir2T = (dir2T * 180) / Math.PI; @@ -1830,11 +1826,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent {`${NumCast(this.dataDoc.position_YDisplay)} m`}{`${NumCast(this.dataDoc.mass1_positionY)} m`} { - this.dataDoc.display_xChange = NumCast(this.dataDoc.position_XDisplay); - this.dataDoc.display_yChange = value; - if (this.dataDoc.simulation_Type == 'Suspension') { + this.dataDoc.mass1_xChange = NumCast(this.dataDoc.mass1_positionX); + this.dataDoc.mass1_yChange = value; + if (this.dataDoc.simulation_type == 'Suspension') { let x1rod = (this.xMax + this.xMin) / 2 - this.radius - this.yMin - 200; let x2rod = (this.xMax + this.xMin) / 2 + this.yMin + 200 + this.radius; - let deltaX1 = NumCast(this.dataDoc.position_XDisplay) + this.radius - x1rod; - let deltaX2 = x2rod - (NumCast(this.dataDoc.position_XDisplay) + this.radius); + let deltaX1 = NumCast(this.dataDoc.mass1_positionX) + this.radius - x1rod; + let deltaX2 = x2rod - (NumCast(this.dataDoc.mass1_positionX) + this.radius); let deltaY = this.getYPosFromDisplay(value) + this.radius; let dir1T = Math.PI - Math.atan(deltaY / deltaX1); let dir2T = Math.atan(deltaY / deltaX2); - let tensionMag2 = (NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity))) / ((-Math.cos(dir2T) / Math.cos(dir1T)) * Math.sin(dir1T) + Math.sin(dir2T)); + let tensionMag2 = (NumCast(this.dataDoc.mass1) * Math.abs(this.gravity)) / ((-Math.cos(dir2T) / Math.cos(dir1T)) * Math.sin(dir1T) + Math.sin(dir2T)); let tensionMag1 = (-tensionMag2 * Math.cos(dir2T)) / Math.cos(dir1T); dir1T = (dir1T * 180) / Math.PI; dir2T = (dir2T * 180) / Math.PI; @@ -1887,11 +1883,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent Velocity {`${NumCast(this.dataDoc.velocity_XDisplay)} m/s`}{`${NumCast(this.dataDoc.mass1_velocityX)} m/s`} { - this.dataDoc.start_VelX = value; - this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset; + this.dataDoc.mass1_velocityXstart = value; + this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset; }} small={true} mode={'Freeform'} /> {this.dataDoc.velocity_YDisplay} m/s{this.dataDoc.mass1_velocityY} m/s { - this.dataDoc.start_VelY = -value; - this.dataDoc.display_xChange = this.dataDoc.position_XDisplay; - this.dataDoc.display_yChange = this.dataDoc.position_YDisplay; + this.dataDoc.mass1_velocityYstart = -value; + this.dataDoc.mass1_xChange = this.dataDoc.mass1_positionX; + this.dataDoc.mass1_yChange = this.dataDoc.mass1_positionY; }} small={true} mode={'Freeform'} @@ -1973,23 +1969,23 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponentAcceleration - {this.dataDoc.acceleration_XDisplay} m/s2 + {this.dataDoc.mass1_accelerationX} m/s2 - {this.dataDoc.acceleration_YDisplay} m/s2 + {this.dataDoc.mass1_accelerationY} m/s2
Momentum {Math.round(this.dataDoc.velocity_XDisplay * this.dataDoc.mass * 10) / 10} kg*m/s{Math.round(this.dataDoc.velocity_YDisplay * this.dataDoc.mass * 10) / 10} kg*m/s{Math.round(NumCast(this.dataDoc.mass1_velocityX) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s{Math.round(NumCast(this.dataDoc.mass1_velocityY) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s
)} - {this.dataDoc.mode == 'Freeform' && this.dataDoc.simulation_Type == 'Pulley' && ( + {this.dataDoc.simulation_mode == 'Freeform' && this.dataDoc.simulation_type == 'Pulley' && ( @@ -2001,39 +1997,39 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent Position - - + + - - + + - - + +
{`${this.dataDoc.position_XDisplay2} m`}{`${this.dataDoc.position_YDisplay2} m`}{`${this.dataDoc.mass2_positionX} m`}{`${this.dataDoc.mass2_positionY} m`}
Velocity {`${this.dataDoc.position_XDisplay2} m/s`}{`${this.dataDoc.position_YDisplay2} m/s`}{`${this.dataDoc.mass2_positionX} m/s`}{`${this.dataDoc.mass2_positionY} m/s`}
Acceleration - {this.dataDoc.acceleration_XDisplay2} m/s2 + {this.dataDoc.mass2_accelerationX} m/s2 - {this.dataDoc.acceleration_YDisplay2} m/s2 + {this.dataDoc.mass2_accelerationY} m/s2
Momentum {Math.round(NumCast(this.dataDoc.velocity_XDisplay2) * NumCast(this.dataDoc.mass) * 10) / 10} kg*m/s{Math.round(NumCast(this.dataDoc.velocity_YDisplay2) * NumCast(this.dataDoc.mass) * 10) / 10} kg*m/s{Math.round(NumCast(this.dataDoc.mass2_velocityX) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s{Math.round(NumCast(this.dataDoc.mass2_velocityY) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s
)}
- {this.dataDoc.simulation_Type != 'Pendulum' && this.dataDoc.simulation_Type != 'Spring' && ( + {this.dataDoc.simulation_type != 'Pendulum' && this.dataDoc.simulation_type != 'Spring' && (

Kinematic Equations

    @@ -2050,7 +2046,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
)} - {this.dataDoc.simulation_Type == 'Spring' && ( + {this.dataDoc.simulation_type == 'Spring' && (

Harmonic Motion Equations: Spring

    @@ -2079,7 +2075,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
)} - {this.dataDoc.simulation_Type == 'Pendulum' && ( + {this.dataDoc.simulation_type == 'Pendulum' && (

Harmonic Motion Equations: Pendulum

    @@ -2114,7 +2110,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent - {this.dataDoc.simulation_Type == 'Circular Motion' ? 'Z' : 'Y'} + {this.dataDoc.simulation_type == 'Circular Motion' ? 'Z' : 'Y'}