aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-05-23 00:35:00 -0400
committerbobzel <zzzman@gmail.com>2023-05-23 00:35:00 -0400
commit90479323c4476c1c87f10ec2ca42339246414ca0 (patch)
treeabec52c30fb97e35f2c3ce5b6b22e602a823a928 /src
parentc43b5f144eef86bd07fbb447b7c8a7087f4d0cac (diff)
more physics cleanup
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts2
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx914
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx187
3 files changed, 551 insertions, 552 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 4ee3368ab..1a2409508 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -690,7 +690,7 @@ export namespace Docs {
{
data: '',
layout: { view: PhysicsSimulationBox, dataField: defaultDataKey },
- options: { _height: 100, position: '', velocity: '', acceleration: '', pendulum: '', simulation: '', review: '', show: '', start: '' },
+ options: { _height: 100, position: '', acceleration: '', pendulum: '', spring: '', wedge: '', simulation: '', review: '' },
},
],
]);
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<FieldViewP
super(props);
}
+ @computed get circularMotionRadius() {
+ return NumCast(this.dataDoc.circularMotionRadius, 150);
+ }
+ @computed get gravity() {
+ return NumCast(this.dataDoc.simulation_gravity, -9.81);
+ }
+
// Constants
xMin = 0;
yMin = 0;
@@ -95,65 +103,49 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
this.xMax = this.layoutDoc._width * 0.6;
this.yMax = this.layoutDoc._height * 0.9;
this.dataDoc.componentForces = this.dataDoc.componentForces ?? [];
- this.dataDoc.gravity = NumCast(this.dataDoc.gravity, -9.81);
- this.dataDoc.mass = NumCast(this.dataDoc.mass, 1);
- this.dataDoc.mode = 'Freeform';
- this.dataDoc.show_ComponentForces = this.dataDoc.show_ComponentForces ?? false;
- this.dataDoc.simulation_Speed = NumCast(this.dataDoc.simulation_Speed, 2);
- this.dataDoc.simulation_Type = StrCast(this.dataDoc.simulation_Type, 'Inclined Plane');
- this.dataDoc.start_Forces = this.dataDoc.start_Forces ?? [];
- this.dataDoc.start_PosX = this.dataDoc.start_PosX ?? Math.round((this.xMax * 0.5 - 200) * 10) / 10;
- this.dataDoc.start_PosY = this.dataDoc.start_PosY ?? this.getDisplayYPos((400 - 0.08 * this.layoutDoc._height) * Math.tan((26 * Math.PI) / 180) + Math.sqrt(26));
- this.dataDoc.stepNumber = NumCast(this.dataDoc.stepNumber);
- this.dataDoc.updatedForces = this.dataDoc.updatedForces ?? [];
+ this.dataDoc.simulation_gravity = NumCast(this.dataDoc.simulation_gravity, -9.81);
+ this.dataDoc.mass1 = NumCast(this.dataDoc.mass1, 1);
+ this.dataDoc.simulation_mode = 'Freeform';
+ this.dataDoc.simulation_showComponentForces = this.dataDoc.simulation_showComponentForces ?? false;
+ this.dataDoc.simulation_speed = NumCast(this.dataDoc.simulation_speed, 2);
+ this.dataDoc.simulation_type = StrCast(this.dataDoc.simulation_type, 'Inclined Plane');
+ this.dataDoc.mass1_forcesStart = this.dataDoc.mass1_forcesStart ?? [];
+ this.dataDoc.mass1_positionXstart = this.dataDoc.mass1_positionXstart ?? Math.round((this.xMax * 0.5 - 200) * 10) / 10;
+ this.dataDoc.mass1_positionYstart = this.dataDoc.mass1_positionYstart ?? this.getDisplayYPos((400 - 0.08 * this.layoutDoc._height) * Math.tan((26 * Math.PI) / 180) + Math.sqrt(26));
+ this.dataDoc.mass1_forcesUpdated = this.dataDoc.mass1_forcesUpdated ?? [];
// Used for review mode
// this.dataDoc.currentForceSketch = this.dataDoc.currentForceSketch ?? null;
// this.dataDoc.deleteMode = this.dataDoc.deleteMode ?? false;
// this.dataDoc.forceSketches = this.dataDoc.forceSketches ?? [];
this.dataDoc.answers = new List<number>();
- 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<FieldViewP
this.layoutDoc._height = Math.max(this.layoutDoc[HeightSym](), 600);
this.xMax = this.layoutDoc._width * 0.6;
this.yMax = this.layoutDoc._height * 0.9;
- this.setupSimulation(StrCast(this.dataDoc.simulation_Type), StrCast(this.dataDoc.mode));
+ this.setupSimulation(StrCast(this.dataDoc.simulation_type), StrCast(this.dataDoc.simulation_mode));
}
}
setupSimulation = (simulationType: string, mode: string) => {
- 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<FieldViewP
this.setupSuspension();
}
} else if (mode == 'Review') {
- this.dataDoc.show_ComponentForces = false;
- this.dataDoc.show_ForceMagnitudes = true;
- this.dataDoc.show_Acceleration = false;
- this.dataDoc.show_Velocity = false;
- this.dataDoc.show_Forces = true;
+ this.dataDoc.simulation_showComponentForces = false;
+ this.dataDoc.simulation_showForceMagnitudes = true;
+ this.dataDoc.simulation_showAcceleration = false;
+ this.dataDoc.simulation_showVelocity = false;
+ this.dataDoc.simulation_showForces = true;
this.generateNewQuestion();
if (simulationType == 'One Weight') {
// TODO - one weight review problems
@@ -242,8 +234,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
this.setupSpring();
// TODO - spring review problems
} else if (simulationType == 'Inclined Plane') {
- this.dataDoc.updatedForces = [];
- this.dataDoc.start_Forces = [];
+ this.dataDoc.mass1_forcesUpdated = [];
+ this.dataDoc.mass1_forcesStart = [];
} else if (simulationType == 'Pendulum') {
this.setupPendulum();
// TODO - pendulum review problems
@@ -258,78 +250,78 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
// TODO - suspension tutorial review problems
}
} else if (mode == 'Tutorial') {
- this.dataDoc.show_ComponentForces = false;
- this.dataDoc.stepNumber = 0;
- this.dataDoc.show_Acceleration = false;
- if (this.dataDoc.simulation_Type != 'Circular Motion') {
- this.dataDoc.velocity_XDisplay = 0;
- this.dataDoc.velocity_YDisplay = 0;
- this.dataDoc.show_Velocity = false;
+ this.dataDoc.simulation_showComponentForces = false;
+ this.dataDoc.tutorial_stepNumber = 0;
+ this.dataDoc.simulation_showAcceleration = false;
+ if (this.dataDoc.simulation_type != 'Circular Motion') {
+ this.dataDoc.mass1_velocityX = 0;
+ this.dataDoc.mass1_velocityY = 0;
+ this.dataDoc.simulation_showVelocity = false;
} else {
- this.dataDoc.velocity_XDisplay = 20;
- this.dataDoc.velocity_YDisplay = 0;
- this.dataDoc.show_Velocity = true;
+ this.dataDoc.mass1_velocityX = 20;
+ this.dataDoc.mass1_velocityY = 0;
+ this.dataDoc.simulation_showVelocity = true;
}
- if (this.dataDoc.simulation_Type == 'One Weight') {
- this.dataDoc.show_Forces = true;
- this.dataDoc.start_PosY = this.yMax - 100;
- this.dataDoc.start_PosX = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym]();
- this.dataDoc.selectedTutorial = tutorials.freeWeight;
- this.dataDoc.start_Forces = this.getForceFromJSON(tutorials.freeWeight.steps[0].forces);
- this.dataDoc.show_ForceMagnitudes = tutorials.freeWeight.steps[0].showMagnitude;
- } else if (this.dataDoc.simulation_Type == 'Spring') {
- this.dataDoc.show_Forces = true;
+ if (this.dataDoc.simulation_type == 'One Weight') {
+ this.dataDoc.simulation_showForces = true;
+ this.dataDoc.mass1_positionYstart = this.yMax - 100;
+ this.dataDoc.mass1_positionXstart = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym]();
+ this.dataDoc.tutorial = tutorials.freeWeight;
+ this.dataDoc.mass1_forcesStart = this.getForceFromJSON(tutorials.freeWeight.steps[0].forces);
+ this.dataDoc.simulation_showForceMagnitudes = tutorials.freeWeight.steps[0].showMagnitude;
+ } else if (this.dataDoc.simulation_type == 'Spring') {
+ this.dataDoc.simulation_showForces = true;
this.setupSpring();
- this.dataDoc.start_PosY = this.yMin + 200 + 19.62;
- this.dataDoc.start_PosX = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym]();
- this.dataDoc.selectedTutorial = tutorials.spring;
- this.dataDoc.start_Forces = this.getForceFromJSON(tutorials.spring.steps[0].forces);
- this.dataDoc.show_ForceMagnitudes = tutorials.spring.steps[0].showMagnitude;
- } else if (this.dataDoc.simulation_Type == 'Pendulum') {
- this.dataDoc.show_Forces = true;
+ this.dataDoc.mass1_positionYstart = this.yMin + 200 + 19.62;
+ this.dataDoc.mass1_positionXstart = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym]();
+ this.dataDoc.tutorial = tutorials.spring;
+ this.dataDoc.mass1_forcesStart = this.getForceFromJSON(tutorials.spring.steps[0].forces);
+ this.dataDoc.simulation_showForceMagnitudes = tutorials.spring.steps[0].showMagnitude;
+ } else if (this.dataDoc.simulation_type == 'Pendulum') {
+ this.dataDoc.simulation_showForces = true;
const length = 300;
const angle = 30;
const x = length * Math.cos(((90 - angle) * Math.PI) / 180);
const y = length * Math.sin(((90 - angle) * Math.PI) / 180);
const xPos = this.xMax / 2 - x - 0.08 * this.layoutDoc[HeightSym]();
const yPos = y - 0.08 * this.layoutDoc[HeightSym]() - 5;
- this.dataDoc.start_PosX = xPos;
- this.dataDoc.start_PosY = yPos;
- this.dataDoc.selectedTutorial = tutorials.pendulum;
- this.dataDoc.start_Forces = this.getForceFromJSON(tutorials.pendulum.steps[0].forces);
- this.dataDoc.show_ForceMagnitudes = tutorials.pendulum.steps[0].showMagnitude;
+ this.dataDoc.mass1_positionXstart = xPos;
+ this.dataDoc.mass1_positionYstart = yPos;
+ this.dataDoc.tutorial = tutorials.pendulum;
+ this.dataDoc.mass1_forcesStart = this.getForceFromJSON(tutorials.pendulum.steps[0].forces);
+ this.dataDoc.simulation_showForceMagnitudes = tutorials.pendulum.steps[0].showMagnitude;
this.dataDoc.pendulum_angle = 30;
this.dataDoc.pendulum_length = 300;
this.dataDoc.pendulum_angle_adjust = 30;
this.dataDoc.pendulum_length_adjust = 300;
- } else if (this.dataDoc.simulation_Type == 'Inclined Plane') {
- this.dataDoc.show_Forces = true;
- this.dataDoc.wedgeAngle = 26;
+ } else if (this.dataDoc.simulation_type == 'Inclined Plane') {
+ this.dataDoc.simulation_showForces = true;
+ this.dataDoc.wedge_angle = 26;
this.changeWedgeBasedOnNewAngle(26);
- this.dataDoc.selectedTutorial = tutorials.inclinePlane;
- this.dataDoc.start_Forces = this.getForceFromJSON(tutorials.inclinePlane.steps[0].forces);
- this.dataDoc.show_ForceMagnitudes = tutorials.inclinePlane.steps[0].showMagnitude;
- } else if (this.dataDoc.simulation_Type == 'Circular Motion') {
- this.dataDoc.show_Forces = true;
+ this.dataDoc.tutorial = tutorials.inclinePlane;
+ this.dataDoc.mass1_forcesStart = this.getForceFromJSON(tutorials.inclinePlane.steps[0].forces);
+ this.dataDoc.simulation_showForceMagnitudes = tutorials.inclinePlane.steps[0].showMagnitude;
+ } else if (this.dataDoc.simulation_type == 'Circular Motion') {
+ this.dataDoc.simulation_showForces = true;
this.setupCircular(40);
- this.dataDoc.selectedTutorial = tutorials.circular;
- this.dataDoc.start_Forces = this.getForceFromJSON(tutorials.circular.steps[0].forces);
- this.dataDoc.show_ForceMagnitudes = tutorials.circular.steps[0].showMagnitude;
- } else if (this.dataDoc.simulation_Type == 'Pulley') {
- this.dataDoc.show_Forces = true;
+ this.dataDoc.tutorial = tutorials.circular;
+ this.dataDoc.mass1_forcesStart = this.getForceFromJSON(tutorials.circular.steps[0].forces);
+ this.dataDoc.simulation_showForceMagnitudes = tutorials.circular.steps[0].showMagnitude;
+ } else if (this.dataDoc.simulation_type == 'Pulley') {
+ this.dataDoc.simulation_showForces = true;
this.setupPulley();
- this.dataDoc.selectedTutorial = tutorials.pulley;
- this.dataDoc.start_Forces = this.getForceFromJSON(tutorials.pulley.steps[0].forces);
- this.dataDoc.show_ForceMagnitudes = tutorials.pulley.steps[0].showMagnitude;
- } else if (this.dataDoc.simulation_Type == 'Suspension') {
- this.dataDoc.show_Forces = true;
+ this.dataDoc.tutorial = tutorials.pulley;
+ this.dataDoc.mass1_forcesStart = this.getForceFromJSON(tutorials.pulley.steps[0].forces);
+ this.dataDoc.simulation_showForceMagnitudes = tutorials.pulley.steps[0].showMagnitude;
+ } else if (this.dataDoc.simulation_type == 'Suspension') {
+ this.dataDoc.simulation_showForces = true;
this.setupSuspension();
- this.dataDoc.selectedTutorial = tutorials.suspension;
- this.dataDoc.start_Forces = this.getForceFromJSON(tutorials.suspension.steps[0].forces);
- this.dataDoc.show_ForceMagnitudes = tutorials.suspension.steps[0].showMagnitude;
+ this.dataDoc.tutorial = tutorials.suspension;
+ this.dataDoc.mass1_forcesStart = this.getForceFromJSON(tutorials.suspension.steps[0].forces);
+ this.dataDoc.simulation_showForceMagnitudes = tutorials.suspension.steps[0].showMagnitude;
}
- this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset;
+ this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
}
};
@@ -342,72 +334,71 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
};
// Update forces when coefficient of static friction changes in freeform mode
- updateForcesWithFriction = (coefficient: number, width: number = NumCast(this.dataDoc.wedgeWidth), height: number = NumCast(this.dataDoc.wedgeHeight)) => {
+ 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<FieldViewP
yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.52;
}
- this.dataDoc.start_PosX = this.xMax * 0.25;
- this.dataDoc.start_PosY = yPos;
- if (this.dataDoc.mode == 'Freeform') {
+ this.dataDoc.mass1_positionXstart = this.xMax * 0.25;
+ this.dataDoc.mass1_positionYstart = yPos;
+ if (this.dataDoc.simulation_mode == 'Freeform') {
this.updateForcesWithFriction(NumCast(this.dataDoc.coefficientOfStaticFriction), this.xMax * 0.5, Math.tan((angle * Math.PI) / 180) * this.xMax * 0.5);
}
};
// In review mode, update forces when coefficient of static friction changed
updateReviewForcesBasedOnCoefficient = (coefficient: number) => {
- 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<FieldViewP
if (isNaN(theta)) {
return;
}
- 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((theta * Math.PI) / 180);
+ this.dataDoc.review_NormalMagnitude = Math.abs(this.gravity) * Math.cos((theta * Math.PI) / 180);
this.dataDoc.review_NormalAngle = 90 - theta;
- let yForce = -Math.abs(NumCast(this.dataDoc.gravity));
- yForce += Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((theta * Math.PI) / 180) * Math.sin(((90 - theta) * Math.PI) / 180);
- yForce += coefficient * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((theta * Math.PI) / 180) * Math.sin(((180 - theta) * Math.PI) / 180);
- let friction = coefficient * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((theta * Math.PI) / 180);
+ let yForce = -Math.abs(this.gravity);
+ yForce += Math.abs(this.gravity) * Math.cos((theta * Math.PI) / 180) * Math.sin(((90 - theta) * Math.PI) / 180);
+ yForce += coefficient * Math.abs(this.gravity) * Math.cos((theta * Math.PI) / 180) * Math.sin(((180 - theta) * Math.PI) / 180);
+ let friction = coefficient * Math.abs(this.gravity) * Math.cos((theta * Math.PI) / 180);
if (yForce > 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<FieldViewP
// In review mode, update forces when wedge angle changed
updateReviewForcesBasedOnAngle = (angle: number) => {
- 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<FieldViewP
getAnswersToQuestion = (question: QuestionTemplate, questionVars: number[]) => {
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<FieldViewP
} else if (description == 'solve normal force angle from wedge angle') {
solutions.push(90 - theta);
} else if (description == 'solve normal force magnitude from wedge angle') {
- solutions.push(Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((theta / 180) * Math.PI));
+ solutions.push(Math.abs(this.gravity) * Math.cos((theta / 180) * Math.PI));
} else if (description == 'solve static force magnitude from wedge angle given equilibrium') {
- let normalForceMagnitude = Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((theta / 180) * Math.PI);
+ let normalForceMagnitude = Math.abs(this.gravity) * Math.cos((theta / 180) * Math.PI);
let normalForceAngle = 90 - theta;
let frictionForceAngle = 180 - theta;
- let frictionForceMagnitude = (-normalForceMagnitude * Math.sin((normalForceAngle * Math.PI) / 180) + Math.abs(NumCast(this.dataDoc.gravity))) / Math.sin((frictionForceAngle * Math.PI) / 180);
+ let frictionForceMagnitude = (-normalForceMagnitude * Math.sin((normalForceAngle * Math.PI) / 180) + Math.abs(this.gravity)) / Math.sin((frictionForceAngle * Math.PI) / 180);
solutions.push(frictionForceMagnitude);
} else if (description == 'solve static force angle from wedge angle given equilibrium') {
solutions.push(180 - theta);
} else if (description == 'solve minimum static coefficient from wedge angle given equilibrium') {
- let normalForceMagnitude = Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((theta / 180) * Math.PI);
+ let normalForceMagnitude = Math.abs(this.gravity) * Math.cos((theta / 180) * Math.PI);
let normalForceAngle = 90 - theta;
let frictionForceAngle = 180 - theta;
- let frictionForceMagnitude = (-normalForceMagnitude * Math.sin((normalForceAngle * Math.PI) / 180) + Math.abs(NumCast(this.dataDoc.gravity))) / Math.sin((frictionForceAngle * Math.PI) / 180);
+ let frictionForceMagnitude = (-normalForceMagnitude * Math.sin((normalForceAngle * Math.PI) / 180) + Math.abs(this.gravity)) / Math.sin((frictionForceAngle * Math.PI) / 180);
let frictionCoefficient = frictionForceMagnitude / normalForceMagnitude;
solutions.push(frictionCoefficient);
} else if (description == 'solve maximum wedge angle from coefficient of static friction given equilibrium') {
@@ -563,7 +554,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
error = true;
}
} else if (this.dataDoc.selectedQuestion.answerParts[i] == 'wedge angle') {
- if (Math.abs(NumCast(this.dataDoc.wedgeAngle) - this.dataDoc.selectedSolutions[i]) > 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<FieldViewP
}
if (showAlert) {
if (!error) {
- this.dataDoc.simulation_Paused = false;
+ this.dataDoc.simulation_paused = false;
setTimeout(() => {
- 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<FieldViewP
this.dataDoc.review_StaticMagnitude = 0;
this.dataDoc.review_StaticAngle = 0;
this.dataDoc.coefficientOfKineticFriction = 0;
- this.dataDoc.simulation_Paused = true;
+ this.dataDoc.simulation_paused = true;
};
// In review mode, reset problem variables and generate a new question
@@ -610,7 +601,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
const vars: number[] = [];
let question: QuestionTemplate = questions.inclinePlane[0];
- if (this.dataDoc.simulation_Type == 'Inclined Plane') {
+ if (this.dataDoc.simulation_type == 'Inclined Plane') {
if (this.dataDoc.questionNumber === questions.inclinePlane.length - 1) {
this.dataDoc.questionNumber = 0;
} else {
@@ -619,21 +610,21 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
question = questions.inclinePlane[NumCast(this.dataDoc.questionNumber)];
let coefficient = 0;
- let wedgeAngle = 0;
+ let wedge_angle = 0;
for (let i = 0; i < question.variablesForQuestionSetup.length; i++) {
if (question.variablesForQuestionSetup[i] == 'theta - max 45') {
let randValue = Math.floor(Math.random() * 44 + 1);
vars.push(randValue);
- wedgeAngle = randValue;
+ wedge_angle = randValue;
} else if (question.variablesForQuestionSetup[i] == 'coefficient of static friction') {
let randValue = Math.round(Math.random() * 1000) / 1000;
vars.push(randValue);
coefficient = randValue;
}
}
- this.dataDoc.wedgeAngle = wedgeAngle;
- this.changeWedgeBasedOnNewAngle(wedgeAngle);
+ this.dataDoc.wedge_angle = wedge_angle;
+ this.changeWedgeBasedOnNewAngle(wedge_angle);
this.dataDoc.coefficientOfStaticFriction = coefficient;
this.dataDoc.review_Coefficient = coefficient;
}
@@ -652,27 +643,27 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
this.dataDoc.questionPartOne = q;
this.dataDoc.questionPartTwo = question.question;
this.dataDoc.answers = new List<number>(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<FieldViewP
const y = length * Math.sin(((90 - angle) * Math.PI) / 180);
const xPos = this.xMax / 2 - x - 0.08 * this.layoutDoc[HeightSym]();
const yPos = y - 0.08 * this.layoutDoc[HeightSym]() - 5;
- this.dataDoc.start_PosX = xPos;
- this.dataDoc.start_PosY = yPos;
- const mag = NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.sin((60 * Math.PI) / 180);
+ this.dataDoc.mass1_positionXstart = xPos;
+ this.dataDoc.mass1_positionYstart = yPos;
+ const mag = NumCast(this.dataDoc.mass1) * Math.abs(this.gravity) * Math.sin((60 * Math.PI) / 180);
const forceOfTension: IForce = {
description: 'Tension',
magnitude: mag,
@@ -701,37 +692,37 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
};
const gravityParallel: IForce = {
description: 'Gravity Parallel Component',
- magnitude: NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.sin(((90 - angle) * Math.PI) / 180),
+ magnitude: NumCast(this.dataDoc.mass1) * Math.abs(this.gravity) * Math.sin(((90 - angle) * Math.PI) / 180),
directionInDegrees: -angle - 90,
component: true,
};
const gravityPerpendicular: IForce = {
description: 'Gravity Perpendicular Component',
- magnitude: NumCast(this.dataDoc.mass) * Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos(((90 - angle) * Math.PI) / 180),
+ magnitude: NumCast(this.dataDoc.mass1) * Math.abs(this.gravity) * Math.cos(((90 - angle) * Math.PI) / 180),
directionInDegrees: -angle,
component: true,
};
this.dataDoc.componentForces = [tensionComponent, gravityParallel, gravityPerpendicular];
- this.dataDoc.updatedForces = [
+ this.dataDoc.mass1_forcesUpdated = [
{
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,
},
forceOfTension,
];
- this.dataDoc.start_Forces = [
+ this.dataDoc.mass1_forcesStart = [
{
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,
},
forceOfTension,
];
- this.dataDoc.start_PendulumAngle = 30;
+ this.dataDoc.pendulum_angleStart = 30;
this.dataDoc.pendulum_angle = 30;
this.dataDoc.pendulum_length = 300;
this.dataDoc.pendulum_angle_adjust = 30;
@@ -740,32 +731,32 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
// Default setup for spring simulation
setupSpring = () => {
- 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<FieldViewP
};
const grav: 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,
};
- this.dataDoc.updatedForces = [tensionForce1, tensionForce2, grav];
- this.dataDoc.start_Forces = [tensionForce1, tensionForce2, grav];
- this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset;
+ this.dataDoc.mass1_forcesUpdated = [tensionForce1, tensionForce2, grav];
+ this.dataDoc.mass1_forcesStart = [tensionForce1, tensionForce2, grav];
+ this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
};
// Default setup for pulley simulation
setupPulley = () => {
- 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<FieldViewP
directionInDegrees: NumCast(this.dataDoc.review_StaticAngle),
component: false,
};
- this.dataDoc.start_Forces = [forceOfGravityReview, normalForceReview, staticFrictionForceReview];
- this.dataDoc.updatedForces = [forceOfGravityReview, normalForceReview, staticFrictionForceReview];
+ this.dataDoc.mass1_forcesStart = [forceOfGravityReview, normalForceReview, staticFrictionForceReview];
+ this.dataDoc.mass1_forcesUpdated = [forceOfGravityReview, normalForceReview, staticFrictionForceReview];
};
render() {
@@ -888,7 +879,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<div className="mechanicsSimulationContentContainer">
<div className="mechanicsSimulationButtonsAndElements">
<div className="mechanicsSimulationButtons">
- {!this.dataDoc.simulation_Paused && (
+ {!this.dataDoc.simulation_paused && (
<div
style={{
position: 'fixed',
@@ -907,94 +898,94 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
wallPositions={this.wallPositions}
adjustPendulumAngle={NumCast(this.dataDoc.pendulum_angle_adjust)}
adjustPendulumLength={NumCast(this.dataDoc.pendulum_length_adjust)}
- gravity={NumCast(this.dataDoc.gravity)}
- circularMotionRadius={NumCast(this.dataDoc.circularMotionRadius)}
+ gravity={this.gravity}
+ circularMotionRadius={this.circularMotionRadius}
componentForces={this.dataDoc.componentForces}
- showComponentForces={BoolCast(this.dataDoc.show_ComponentForces)}
+ showComponentForces={BoolCast(this.dataDoc.simulation_showComponentForces)}
color={'red'}
coefficientOfKineticFriction={NumCast(this.dataDoc.coefficientOfKineticFriction)}
- displayXVelocity={NumCast(this.dataDoc.velocity_XDisplay)}
- displayYVelocity={NumCast(this.dataDoc.velocity_YDisplay)}
+ displayXVelocity={NumCast(this.dataDoc.mass1_velocityX)}
+ displayYVelocity={NumCast(this.dataDoc.mass1_velocityY)}
elasticCollisions={BoolCast(this.dataDoc.elasticCollisions)}
- mass={NumCast(this.dataDoc.mass)}
- mode={StrCast(this.dataDoc.mode)}
+ mass={NumCast(this.dataDoc.mass1)}
+ simulationMode={StrCast(this.dataDoc.simulation_mode)}
noMovement={BoolCast(this.dataDoc.noMovement)}
- paused={BoolCast(this.dataDoc.simulation_Paused)}
+ paused={BoolCast(this.dataDoc.simulation_paused)}
pendulumAngle={NumCast(this.dataDoc.pendulum_angle)}
pendulumLength={NumCast(this.dataDoc.pendulum_length)}
radius={0.08 * this.layoutDoc[HeightSym]()}
- reset={BoolCast(this.dataDoc.simulation_Reset)}
- simulationSpeed={NumCast(this.dataDoc.simulation_Speed)}
- startPendulumAngle={NumCast(this.dataDoc.start_PendulumAngle)}
- showAcceleration={BoolCast(this.dataDoc.show_Acceleration)}
- showForceMagnitudes={BoolCast(this.dataDoc.show_ForceMagnitudes)}
- showForces={BoolCast(this.dataDoc.show_Forces)}
- showVelocity={BoolCast(this.dataDoc.show_Velocity)}
- simulationType={StrCast(this.dataDoc.simulation_Type)}
- springConstant={NumCast(this.dataDoc.springConstant)}
- springStartLength={NumCast(this.dataDoc.springStartLength)}
- springRestLength={NumCast(this.dataDoc.springRestLength)}
- startForces={this.dataDoc.start_Forces}
- startPosX={NumCast(this.dataDoc.start_PosX)}
- startPosY={NumCast(this.dataDoc.start_PosY)}
- startVelX={NumCast(this.dataDoc.start_VelX)}
- startVelY={NumCast(this.dataDoc.start_VelY)}
+ reset={BoolCast(this.dataDoc.simulation_reset)}
+ simulationSpeed={NumCast(this.dataDoc.simulation_speed)}
+ startPendulumAngle={NumCast(this.dataDoc.pendulum_angleStart)}
+ showAcceleration={BoolCast(this.dataDoc.simulation_showAcceleration)}
+ showForceMagnitudes={BoolCast(this.dataDoc.simulation_showForceMagnitudes)}
+ showForces={BoolCast(this.dataDoc.simulation_showForces)}
+ showVelocity={BoolCast(this.dataDoc.simulation_showVelocity)}
+ simulationType={StrCast(this.dataDoc.simulation_type)}
+ springConstant={NumCast(this.dataDoc.spring_constant)}
+ springStartLength={NumCast(this.dataDoc.spring_lengthStart)}
+ springRestLength={NumCast(this.dataDoc.spring_lengthRest)}
+ startForces={this.dataDoc.mass1_forcesStart}
+ startPosX={NumCast(this.dataDoc.mass1_positionXstart)}
+ startPosY={NumCast(this.dataDoc.mass1_positionYstart)}
+ startVelX={NumCast(this.dataDoc.mass1_velocityXstart)}
+ startVelY={NumCast(this.dataDoc.mass1_velocityYstart)}
timestepSize={0.05}
- updateXDisplay={NumCast(this.dataDoc.display_xChange)}
- updateYDisplay={NumCast(this.dataDoc.display_yChange)}
- updatedForces={this.dataDoc.updatedForces}
- wedgeHeight={NumCast(this.dataDoc.wedgeHeight)}
- wedgeWidth={NumCast(this.dataDoc.wedgeWidth)}
+ updateXmass={NumCast(this.dataDoc.mass1_xChange)}
+ updateYmass={NumCast(this.dataDoc.mass1_yChange)}
+ forcesUpdated={this.dataDoc.mass1_forcesUpdated}
+ wedgeHeight={NumCast(this.dataDoc.wedge_height)}
+ wedgeWidth={NumCast(this.dataDoc.wedge_width)}
xMax={this.xMax}
xMin={this.xMin}
yMax={this.yMax}
yMin={this.yMin}
/>
- {this.dataDoc.simulation_Type == 'Pulley' && (
+ {this.dataDoc.simulation_type == 'Pulley' && (
<Weight
dataDoc={this.dataDoc}
layoutDoc={this.layoutDoc}
wallPositions={this.wallPositions}
adjustPendulumAngle={NumCast(this.dataDoc.pendulum_angle_adjust)}
adjustPendulumLength={NumCast(this.dataDoc.pendulum_length_adjust)}
- circularMotionRadius={NumCast(this.dataDoc.circularMotionRadius)}
- gravity={NumCast(this.dataDoc.gravity)}
+ circularMotionRadius={this.circularMotionRadius}
+ gravity={this.gravity}
componentForces={this.dataDoc.componentForces}
- showComponentForces={BoolCast(this.dataDoc.show_ComponentForces)}
+ showComponentForces={BoolCast(this.dataDoc.simulation_showComponentForces)}
color={'blue'}
coefficientOfKineticFriction={NumCast(this.dataDoc.coefficientOfKineticFriction)}
- displayXVelocity={NumCast(this.dataDoc.velocity_XDisplay)}
- displayYVelocity={NumCast(this.dataDoc.velocity_YDisplay)}
+ displayXVelocity={NumCast(this.dataDoc.mass1_velocityX)}
+ displayYVelocity={NumCast(this.dataDoc.mass1_velocityY)}
elasticCollisions={BoolCast(this.dataDoc.elasticCollisions)}
mass={NumCast(this.dataDoc.mass2)}
- mode={StrCast(this.dataDoc.mode)}
+ simulationMode={StrCast(this.dataDoc.simulation_mode)}
noMovement={BoolCast(this.dataDoc.noMovement)}
- paused={BoolCast(this.dataDoc.simulation_Paused)}
+ paused={BoolCast(this.dataDoc.simulation_paused)}
pendulumAngle={NumCast(this.dataDoc.pendulum_angle)}
pendulumLength={NumCast(this.dataDoc.pendulum_length)}
radius={0.08 * this.layoutDoc[HeightSym]()}
- reset={BoolCast(this.dataDoc.simulation_Reset)}
- simulationSpeed={NumCast(this.dataDoc.simulation_Speed)}
- startPendulumAngle={NumCast(this.dataDoc.start_PendulumAngle)}
- showAcceleration={BoolCast(this.dataDoc.show_Acceleration)}
- showForceMagnitudes={BoolCast(this.dataDoc.show_ForceMagnitudes)}
- showForces={BoolCast(this.dataDoc.show_Forces)}
- showVelocity={BoolCast(this.dataDoc.show_Velocity)}
- simulationType={this.dataDoc.simulation_Type}
- springConstant={NumCast(this.dataDoc.springConstant)}
- springStartLength={NumCast(this.dataDoc.springStartLength)}
- springRestLength={NumCast(this.dataDoc.springRestLength)}
- startForces={this.dataDoc.start_Forces2}
- startPosX={NumCast(this.dataDoc.start_PosX2)}
- startPosY={NumCast(this.dataDoc.start_PosY2)}
- startVelX={NumCast(this.dataDoc.start_VelX)}
- startVelY={NumCast(this.dataDoc.start_VelY)}
+ reset={BoolCast(this.dataDoc.simulation_reset)}
+ simulationSpeed={NumCast(this.dataDoc.simulation_speed)}
+ startPendulumAngle={NumCast(this.dataDoc.pendulum_angleStart)}
+ showAcceleration={BoolCast(this.dataDoc.simulation_showAcceleration)}
+ showForceMagnitudes={BoolCast(this.dataDoc.simulation_showForceMagnitudes)}
+ showForces={BoolCast(this.dataDoc.simulation_showForces)}
+ showVelocity={BoolCast(this.dataDoc.simulation_showVelocity)}
+ simulationType={this.dataDoc.simulation_type}
+ springConstant={NumCast(this.dataDoc.spring_constant)}
+ springStartLength={NumCast(this.dataDoc.spring_lengthStart)}
+ springRestLength={NumCast(this.dataDoc.spring_lengthRest)}
+ startForces={this.dataDoc.mass2_forcesStart}
+ startPosX={NumCast(this.dataDoc.mass2_positionXstart)}
+ startPosY={NumCast(this.dataDoc.mass2_positionYstart)}
+ startVelX={NumCast(this.dataDoc.mass1_velocityXstart)}
+ startVelY={NumCast(this.dataDoc.mass1_velocityYstart)}
timestepSize={0.05}
- updateXDisplay={NumCast(this.dataDoc.display_xChange2)}
- updateYDisplay={NumCast(this.dataDoc.display_yChange2)}
- updatedForces={this.dataDoc.updatedForces2}
- wedgeHeight={NumCast(this.dataDoc.wedgeHeight)}
- wedgeWidth={NumCast(this.dataDoc.wedgeWidth)}
+ updateXmass={NumCast(this.dataDoc.mass2_xChange)}
+ updateYmass={NumCast(this.dataDoc.mass2_yChange)}
+ forcesUpdated={this.dataDoc.mass2_forcesUpdated}
+ wedgeHeight={NumCast(this.dataDoc.wedge_height)}
+ wedgeWidth={NumCast(this.dataDoc.wedge_width)}
xMax={this.xMax}
xMin={this.xMin}
yMax={this.yMax}
@@ -1003,7 +994,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
)}
</div>
<div>
- {(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 <Wall key={index} length={element.length} xPos={element.xPos} yPos={element.yPos} angleInDegrees={element.angleInDegrees} />;
@@ -1014,26 +1005,26 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<div className="mechanicsSimulationEquationContainer">
<div className="mechanicsSimulationControls">
<Stack direction="row" spacing={1}>
- {this.dataDoc.simulation_Paused && this.dataDoc.mode != 'Tutorial' && (
+ {this.dataDoc.simulation_paused && this.dataDoc.simulation_mode != 'Tutorial' && (
<IconButton
onClick={() => {
- this.dataDoc.simulation_Paused = false;
+ this.dataDoc.simulation_paused = false;
}}>
<PlayArrowIcon />
</IconButton>
)}
- {!this.dataDoc.simulation_Paused && this.dataDoc.mode != 'Tutorial' && (
+ {!this.dataDoc.simulation_paused && this.dataDoc.simulation_mode != 'Tutorial' && (
<IconButton
onClick={() => {
- this.dataDoc.simulation_Paused = true;
+ this.dataDoc.simulation_paused = true;
}}>
<PauseIcon />
</IconButton>
)}
- {this.dataDoc.simulation_Paused && this.dataDoc.mode != 'Tutorial' && (
+ {this.dataDoc.simulation_paused && this.dataDoc.simulation_mode != 'Tutorial' && (
<IconButton
onClick={() => {
- this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset;
+ this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
}}>
<ReplayIcon />
</IconButton>
@@ -1041,10 +1032,10 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</Stack>
<div className="dropdownMenu">
<select
- value={StrCast(this.dataDoc.simulation_Type)}
+ value={StrCast(this.dataDoc.simulation_type)}
onChange={event => {
- this.dataDoc.simulation_Type = event.target.value;
- this.setupSimulation(event.target.value, StrCast(this.dataDoc.mode));
+ this.dataDoc.simulation_type = event.target.value;
+ this.setupSimulation(event.target.value, StrCast(this.dataDoc.simulation_mode));
}}
style={{ height: '2em', width: '100%', fontSize: '16px' }}>
<option value="One Weight">Projectile</option>
@@ -1058,10 +1049,10 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</div>
<div className="dropdownMenu">
<select
- value={StrCast(this.dataDoc.mode)}
+ value={StrCast(this.dataDoc.simulation_mode)}
onChange={event => {
- 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' }}>
<option value="Tutorial">Tutorial Mode</option>
@@ -1070,13 +1061,13 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</select>
</div>
</div>
- {this.dataDoc.mode == 'Review' && this.dataDoc.simulation_Type != 'Inclined Plane' && (
+ {this.dataDoc.simulation_mode == 'Review' && this.dataDoc.simulation_type != 'Inclined Plane' && (
<div className="wordProblemBox">
- <p>{this.dataDoc.simulation_Type} review problems in progress!</p>
+ <p>{this.dataDoc.simulation_type} review problems in progress!</p>
<hr />
</div>
)}
- {this.dataDoc.mode == 'Review' && this.dataDoc.simulation_Type == 'Inclined Plane' && (
+ {this.dataDoc.simulation_mode == 'Review' && this.dataDoc.simulation_type == 'Inclined Plane' && (
<div>
{!this.dataDoc.hintDialogueOpen && (
<IconButton
@@ -1136,7 +1127,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
unit={'N'}
upperBound={50}
value={NumCast(this.dataDoc.review_GravityMagnitude)}
- showIcon={BoolCast(this.dataDoc.show_Icon)}
+ showIcon={BoolCast(this.dataDoc.simulation_showIcon)}
correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('force of gravity')]}
labelWidth={'7em'}
/>
@@ -1152,7 +1143,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={360}
value={NumCast(this.dataDoc.review_GravityAngle)}
radianEquivalent={true}
- showIcon={BoolCast(this.dataDoc.show_Icon)}
+ showIcon={BoolCast(this.dataDoc.simulation_showIcon)}
correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('angle of gravity')]}
labelWidth={'7em'}
/>
@@ -1167,7 +1158,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
unit={'N'}
upperBound={50}
value={NumCast(this.dataDoc.review_NormalMagnitude)}
- showIcon={BoolCast(this.dataDoc.show_Icon)}
+ showIcon={BoolCast(this.dataDoc.simulation_showIcon)}
correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('normal force')]}
labelWidth={'7em'}
/>
@@ -1183,7 +1174,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={360}
value={NumCast(this.dataDoc.review_NormalAngle)}
radianEquivalent={true}
- showIcon={BoolCast(this.dataDoc.show_Icon)}
+ showIcon={BoolCast(this.dataDoc.simulation_showIcon)}
correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('angle of normal force')]}
labelWidth={'7em'}
/>
@@ -1198,7 +1189,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
unit={'N'}
upperBound={50}
value={NumCast(this.dataDoc.review_StaticMagnitude)}
- showIcon={BoolCast(this.dataDoc.show_Icon)}
+ showIcon={BoolCast(this.dataDoc.simulation_showIcon)}
correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('force of static friction')]}
labelWidth={'7em'}
/>
@@ -1214,7 +1205,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={360}
value={NumCast(this.dataDoc.review_StaticAngle)}
radianEquivalent={true}
- showIcon={BoolCast(this.dataDoc.show_Icon)}
+ showIcon={BoolCast(this.dataDoc.simulation_showIcon)}
correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('angle of static friction')]}
labelWidth={'7em'}
/>
@@ -1234,7 +1225,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={1}
value={NumCast(this.dataDoc.coefficientOfStaticFriction)}
effect={this.updateReviewForcesBasedOnCoefficient}
- showIcon={BoolCast(this.dataDoc.show_Icon)}
+ showIcon={BoolCast(this.dataDoc.simulation_showIcon)}
correctValue={NumListCast(this.dataDoc.answers)[this.dataDoc.selectedQuestion.answerParts.indexOf('coefficient of static friction')]}
/>
)}
@@ -1243,17 +1234,17 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
label={<Box>&theta;</Box>}
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<FieldViewP
</div>
</div>
)}
- {this.dataDoc.mode == 'Tutorial' && (
+ {this.dataDoc.simulation_mode == 'Tutorial' && (
<div className="wordProblemBox">
<div className="question">
<h2>Problem</h2>
- <p>{this.dataDoc.selectedTutorial.question}</p>
+ <p>{this.dataDoc.tutorial.question}</p>
</div>
<div
style={{
@@ -1275,40 +1266,40 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
}}>
<IconButton
onClick={() => {
- 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}>
<ArrowLeftIcon />
</IconButton>
<div>
<h3>
- 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}
</h3>
- <p>{this.dataDoc.selectedTutorial.steps[NumCast(this.dataDoc.stepNumber)].content}</p>
+ <p>{this.dataDoc.tutorial.steps[NumCast(this.dataDoc.tutorial_stepNumber)].content}</p>
</div>
<IconButton
onClick={() => {
- 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}>
<ArrowRightIcon />
</IconButton>
</div>
<div>
- {(this.dataDoc.simulation_Type == 'One Weight' || this.dataDoc.simulation_Type == 'Inclined Plane' || this.dataDoc.simulation_Type == 'Pendulum') && <p>Resources</p>}
- {this.dataDoc.simulation_Type == 'One Weight' && (
+ {(this.dataDoc.simulation_type == 'One Weight' || this.dataDoc.simulation_type == 'Inclined Plane' || this.dataDoc.simulation_type == 'Pendulum') && <p>Resources</p>}
+ {this.dataDoc.simulation_type == 'One Weight' && (
<ul>
<li>
<a
@@ -1336,7 +1327,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</li>
</ul>
)}
- {this.dataDoc.simulation_Type == 'Inclined Plane' && (
+ {this.dataDoc.simulation_type == 'Inclined Plane' && (
<ul>
<li>
<a
@@ -1364,7 +1355,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</li>
</ul>
)}
- {this.dataDoc.simulation_Type == 'Pendulum' && (
+ {this.dataDoc.simulation_type == 'Pendulum' && (
<ul>
<li>
<a
@@ -1383,7 +1374,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</div>
</div>
)}
- {this.dataDoc.mode == 'Review' && this.dataDoc.simulation_Type == 'Inclined Plane' && (
+ {this.dataDoc.simulation_mode == 'Review' && this.dataDoc.simulation_type == 'Inclined Plane' && (
<div
style={{
display: 'flex',
@@ -1396,16 +1387,16 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
textDecoration: 'underline',
cursor: 'pointer',
}}
- onClick={() => (this.dataDoc.mode = 'Tutorial')}>
+ onClick={() => (this.dataDoc.simulation_mode = 'Tutorial')}>
{' '}
Go to walkthrough{' '}
</p>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<Button
onClick={() => {
- this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset;
+ this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
this.checkAnswers();
- this.dataDoc.show_Icon = true;
+ this.dataDoc.simulation_showIcon = true;
}}
variant="outlined">
<p>Submit</p>
@@ -1413,7 +1404,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<Button
onClick={() => {
this.generateNewQuestion();
- this.dataDoc.show_Icon = false;
+ this.dataDoc.simulation_showIcon = false;
}}
variant="outlined">
<p>New question</p>
@@ -1421,37 +1412,41 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</div>
</div>
)}
- {this.dataDoc.mode == 'Freeform' && (
+ {this.dataDoc.simulation_mode == 'Freeform' && (
<div className="vars">
<FormControl component="fieldset">
<FormGroup>
- {this.dataDoc.simulation_Type == 'One Weight' && (
+ {this.dataDoc.simulation_type == 'One Weight' && (
<FormControlLabel
control={<Checkbox checked={BoolCast(this.dataDoc.elasticCollisions)} onChange={() => (this.dataDoc.elasticCollisions = !this.dataDoc.elasticCollisions)} />}
label="Make collisions elastic"
labelPlacement="start"
/>
)}
- <FormControlLabel control={<Checkbox checked={BoolCast(this.dataDoc.show_Forces)} onChange={() => (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') && (
+ <FormControlLabel
+ control={<Checkbox checked={BoolCast(this.dataDoc.simulation_showForces)} onChange={() => (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') && (
<FormControlLabel
- control={<Checkbox checked={BoolCast(this.dataDoc.show_Forces)} onChange={() => (this.dataDoc.show_ComponentForces = !this.dataDoc.show_ComponentForces)} />}
+ control={<Checkbox checked={BoolCast(this.dataDoc.simulation_showForces)} onChange={() => (this.dataDoc.simulation_showComponentForces = !this.dataDoc.simulation_showComponentForces)} />}
label="Show component force vectors"
labelPlacement="start"
/>
)}
<FormControlLabel
- control={<Checkbox checked={BoolCast(this.dataDoc.show_Acceleration)} onChange={() => (this.dataDoc.show_Acceleration = !this.dataDoc.show_Acceleration)} />}
+ control={<Checkbox checked={BoolCast(this.dataDoc.simulation_showAcceleration)} onChange={() => (this.dataDoc.simulation_showAcceleration = !this.dataDoc.simulation_showAcceleration)} />}
label="Show acceleration vector"
labelPlacement="start"
/>
<FormControlLabel
- control={<Checkbox checked={BoolCast(this.dataDoc.show_Velocity)} onChange={() => (this.dataDoc.show_Velocity = !this.dataDoc.show_Velocity)} />}
+ control={<Checkbox checked={BoolCast(this.dataDoc.simulation_showVelocity)} onChange={() => (this.dataDoc.simulation_showVelocity = !this.dataDoc.simulation_showVelocity)} />}
label="Show velocity vector"
labelPlacement="start"
/>
- <InputField label={<Box>Speed</Box>} 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' && (
+ <InputField label={<Box>Speed</Box>} 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' && (
<InputField
label={<Box>Gravity</Box>}
lowerBound={-30}
@@ -1460,46 +1455,46 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
step={0.01}
unit={'m/s2'}
upperBound={0}
- value={NumCast(this.dataDoc.gravity, -9.81)}
+ value={NumCast(this.dataDoc.simulation_gravity, -9.81)}
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' && (
<InputField
label={<Box>Mass</Box>}
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' && (
<InputField
label={<Box>Red mass</Box>}
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' && (
<InputField
label={<Box>Blue mass</Box>}
lowerBound={1}
@@ -1510,12 +1505,12 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={5}
value={NumCast(this.dataDoc.mass2) ?? 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 == 'Circular Motion' && (
+ {this.dataDoc.simulation_paused && this.dataDoc.simulation_type == 'Circular Motion' && (
<InputField
label={<Box>Rod length</Box>}
lowerBound={100}
@@ -1524,28 +1519,28 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
step={5}
unit={'m'}
upperBound={250}
- value={NumCast(this.dataDoc.circularMotionRadius) ?? 100}
+ value={this.circularMotionRadius}
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'}
/>
)}
</FormGroup>
</FormControl>
- {this.dataDoc.simulation_Type == 'Spring' && this.dataDoc.simulation_Paused && (
+ {this.dataDoc.simulation_type == 'Spring' && this.dataDoc.simulation_paused && (
<div>
<InputField
label={<Typography color="inherit">Spring stiffness</Typography>}
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 ViewBoxAnnotatableComponent<FieldViewP
label={<Typography color="inherit">Rest length</Typography>}
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<FieldViewP
/>
<InputField
label={<Typography color="inherit">Starting displacement</Typography>}
- 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<FieldViewP
/>
</div>
)}
- {this.dataDoc.simulation_Type == 'Inclined Plane' && this.dataDoc.simulation_Paused && (
+ {this.dataDoc.simulation_type == 'Inclined Plane' && this.dataDoc.simulation_paused && (
<div>
<InputField
label={<Box>&theta;</Box>}
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<FieldViewP
if (val < NumCast(this.dataDoc.coefficientOfKineticFriction)) {
this.dataDoc.soefficientOfKineticFriction = val;
}
- this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset;
+ this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
}}
mode={'Freeform'}
labelWidth={'2em'}
@@ -1643,28 +1638,28 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={NumCast(this.dataDoc.coefficientOfStaticFriction)}
value={NumCast(this.dataDoc.coefficientOfKineticFriction) ?? 0}
effect={(val: number) => {
- this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset;
+ this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
}}
mode={'Freeform'}
labelWidth={'2em'}
/>
</div>
)}
- {this.dataDoc.simulation_Type == 'Inclined Plane' && !this.dataDoc.simulation_Paused && (
+ {this.dataDoc.simulation_type == 'Inclined Plane' && !this.dataDoc.simulation_paused && (
<Typography>
- &theta;: {Math.round(NumCast(this.dataDoc.wedgeAngle) * 100) / 100}° ≈ {Math.round(((NumCast(this.dataDoc.wedgeAngle) * Math.PI) / 180) * 100) / 100} rad
+ &theta;: {Math.round(NumCast(this.dataDoc.wedge_angle) * 100) / 100}° ≈ {Math.round(((NumCast(this.dataDoc.wedge_angle) * Math.PI) / 180) * 100) / 100} rad
<br />
&mu; <sub>s</sub>: {this.dataDoc.coefficientOfStaticFriction}
<br />
&mu; <sub>k</sub>: {this.dataDoc.coefficientOfKineticFriction}
</Typography>
)}
- {this.dataDoc.simulation_Type == 'Pendulum' && !this.dataDoc.simulation_Paused && (
+ {this.dataDoc.simulation_type == 'Pendulum' && !this.dataDoc.simulation_paused && (
<Typography>
&theta;: {Math.round(NumCast(this.dataDoc.pendulum_angle) * 100) / 100}° ≈ {Math.round(((NumCast(this.dataDoc.pendulum_angle) * Math.PI) / 180) * 100) / 100} rad
</Typography>
)}
- {this.dataDoc.simulation_Type == 'Pendulum' && this.dataDoc.simulation_Paused && (
+ {this.dataDoc.simulation_type == 'Pendulum' && this.dataDoc.simulation_paused && (
<div>
<InputField
label={<Box>Angle</Box>}
@@ -1676,9 +1671,9 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={59}
value={NumCast(this.dataDoc.pendulum_angle, 30)}
effect={value => {
- 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<FieldViewP
};
const gravityParallel: IForce = {
description: 'Gravity Parallel Component',
- magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * Math.cos((value * Math.PI) / 180),
+ magnitude: Math.abs(this.gravity) * Math.cos((value * Math.PI) / 180),
directionInDegrees: 270 - value,
component: true,
};
const gravityPerpendicular: IForce = {
description: 'Gravity Perpendicular Component',
- magnitude: Math.abs(NumCast(this.dataDoc.gravity)) * Math.sin((value * Math.PI) / 180),
+ magnitude: Math.abs(this.gravity) * Math.sin((value * Math.PI) / 180),
directionInDegrees: -value,
component: true,
};
@@ -1711,22 +1706,22 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
const y = length * Math.sin(((90 - value) * Math.PI) / 180);
const xPos = this.xMax / 2 - x - NumCast(this.dataDoc.radius);
const yPos = y - NumCast(this.dataDoc.radius) - 5;
- this.dataDoc.start_PosX = xPos;
- this.dataDoc.start_PosY = yPos;
+ this.dataDoc.mass1_positionXstart = xPos;
+ this.dataDoc.mass1_positionYstart = yPos;
- 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,
},
forceOfTension,
];
- this.dataDoc.updatedForces = [
+ 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,
},
@@ -1734,7 +1729,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
];
this.dataDoc.componentForces = [tensionComponent, gravityParallel, gravityPerpendicular];
this.dataDoc.pendulum_angle_adjust = value;
- (this.dataDoc.pendulum_length_adjust = this.dataDoc.pendulum_length), (this.dataDoc.simulation_Reset = !this.dataDoc.simulation_Reset);
+ this.dataDoc.pendulum_length_adjust = this.dataDoc.pendulum_length;
+ this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
}
}}
radianEquivalent={true}
@@ -1751,10 +1747,10 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={400}
value={Math.round(NumCast(this.dataDoc.pendulum_length))}
effect={value => {
- 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<FieldViewP
</div>
)}
<div className="mechanicsSimulationEquation">
- {this.dataDoc.mode == 'Freeform' && (
+ {this.dataDoc.simulation_mode == 'Freeform' && (
<table>
<tbody>
<tr>
- <td>{this.dataDoc.simulation_Type == 'Pulley' ? 'Red Weight' : ''}</td>
+ <td>{this.dataDoc.simulation_type == 'Pulley' ? 'Red Weight' : ''}</td>
<td>X</td>
<td>Y</td>
</tr>
@@ -1785,34 +1781,34 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
>
<Box>Position</Box>
</td>
- {(!this.dataDoc.simulation_Paused || this.dataDoc.simulation_Type == 'Inclined Plane' || this.dataDoc.simulation_Type == 'Circular Motion' || this.dataDoc.simulation_Type == 'Pulley') && (
- <td style={{ cursor: 'default' }}>{this.dataDoc.position_XDisplay} m</td>
+ {(!this.dataDoc.simulation_paused || this.dataDoc.simulation_type == 'Inclined Plane' || this.dataDoc.simulation_type == 'Circular Motion' || this.dataDoc.simulation_type == 'Pulley') && (
+ <td style={{ cursor: 'default' }}>{this.dataDoc.mass1_positionX} m</td>
)}{' '}
- {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' && (
<td
style={{
cursor: 'default',
}}>
<InputField
- lowerBound={this.dataDoc.simulation_Type == 'Projectile' ? 1 : (this.xMax + this.xMin) / 4 - this.radius - 15}
+ lowerBound={this.dataDoc.simulation_type == 'Projectile' ? 1 : (this.xMax + this.xMin) / 4 - this.radius - 15}
dataDoc={this.dataDoc}
- prop="position_XDisplay"
+ prop="mass1_positionX"
step={1}
unit={'m'}
- upperBound={this.dataDoc.simulation_Type == 'Projectile' ? this.xMax - 110 : (3 * (this.xMax + this.xMin)) / 4 - this.radius / 2 - 15}
- value={NumCast(this.dataDoc.position_XDisplay)}
+ upperBound={this.dataDoc.simulation_type == 'Projectile' ? this.xMax - 110 : (3 * (this.xMax + this.xMin)) / 4 - this.radius / 2 - 15}
+ value={NumCast(this.dataDoc.mass1_positionX)}
effect={value => {
- 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<FieldViewP
};
const grav: 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,
};
- this.dataDoc.updatedForces = [tensionForce1, tensionForce2, grav];
+ this.dataDoc.mass1_forcesUpdated = [tensionForce1, tensionForce2, grav];
}
}}
small={true}
@@ -1842,10 +1838,10 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
/>
</td>
)}{' '}
- {(!this.dataDoc.simulation_Paused || this.dataDoc.simulation_Type == 'Inclined Plane' || this.dataDoc.simulation_Type == 'Circular Motion' || this.dataDoc.simulation_Type == 'Pulley') && (
- <td style={{ cursor: 'default' }}>{`${NumCast(this.dataDoc.position_YDisplay)} m`}</td>
+ {(!this.dataDoc.simulation_paused || this.dataDoc.simulation_type == 'Inclined Plane' || this.dataDoc.simulation_type == 'Circular Motion' || this.dataDoc.simulation_type == 'Pulley') && (
+ <td style={{ cursor: 'default' }}>{`${NumCast(this.dataDoc.mass1_positionY)} m`}</td>
)}{' '}
- {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' && (
<td
style={{
cursor: 'default',
@@ -1853,23 +1849,23 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<InputField
lowerBound={1}
dataDoc={this.dataDoc}
- prop="position_YDisplay"
+ prop="mass1_positionY"
step={1}
unit={'m'}
upperBound={this.yMax - 110}
- value={NumCast(this.dataDoc.position_YDisplay)}
+ value={NumCast(this.dataDoc.mass1_positionY)}
effect={value => {
- 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<FieldViewP
};
const grav: 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,
};
- this.dataDoc.updatedForces = [tensionForce1, tensionForce2, grav];
+ this.dataDoc.mass1_forcesUpdated = [tensionForce1, tensionForce2, grav];
}
}}
small={true}
@@ -1911,10 +1907,10 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
>
<Box>Velocity</Box>
</td>
- {(!this.dataDoc.simulation_Paused || (this.dataDoc.simulation_Type != 'One Weight' && this.dataDoc.simulation_Type != 'Circular Motion')) && (
- <td style={{ cursor: 'default' }}>{`${NumCast(this.dataDoc.velocity_XDisplay)} m/s`}</td>
+ {(!this.dataDoc.simulation_paused || (this.dataDoc.simulation_type != 'One Weight' && this.dataDoc.simulation_type != 'Circular Motion')) && (
+ <td style={{ cursor: 'default' }}>{`${NumCast(this.dataDoc.mass1_velocityX)} m/s`}</td>
)}{' '}
- {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') && (
<td
style={{
cursor: 'default',
@@ -1922,22 +1918,22 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<InputField
lowerBound={-50}
dataDoc={this.dataDoc}
- prop="velocity_XDisplay"
+ prop="mass1_velocityX"
step={1}
unit={'m/s'}
upperBound={50}
- value={this.dataDoc.velocity_XDisplay}
+ value={this.dataDoc.mass1_velocityX}
effect={value => {
- 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'}
/>
</td>
)}{' '}
- {(!this.dataDoc.simulation_Paused || this.dataDoc.simulation_Type != 'One Weight') && <td style={{ cursor: 'default' }}>{this.dataDoc.velocity_YDisplay} m/s</td>}{' '}
- {this.dataDoc.simulation_Paused && this.dataDoc.simulation_Type == 'One Weight' && (
+ {(!this.dataDoc.simulation_paused || this.dataDoc.simulation_type != 'One Weight') && <td style={{ cursor: 'default' }}>{this.dataDoc.mass1_velocityY} m/s</td>}{' '}
+ {this.dataDoc.simulation_paused && this.dataDoc.simulation_type == 'One Weight' && (
<td
style={{
cursor: 'default',
@@ -1945,15 +1941,15 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<InputField
lowerBound={-50}
dataDoc={this.dataDoc}
- prop="velocity_YDisplay"
+ prop="mass1_velocityY"
step={1}
unit={'m/s'}
upperBound={50}
- value={this.dataDoc.velocity_YDisplay}
+ value={this.dataDoc.mass1_velocityY}
effect={value => {
- 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 ViewBoxAnnotatableComponent<FieldViewP
<Box>Acceleration</Box>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.acceleration_XDisplay} m/s<sup>2</sup>
+ {this.dataDoc.mass1_accelerationX} m/s<sup>2</sup>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.acceleration_YDisplay} m/s<sup>2</sup>
+ {this.dataDoc.mass1_accelerationY} m/s<sup>2</sup>
</td>
</tr>
<tr>
<td>
<Box>Momentum</Box>
</td>
- <td>{Math.round(this.dataDoc.velocity_XDisplay * this.dataDoc.mass * 10) / 10} kg*m/s</td>
- <td>{Math.round(this.dataDoc.velocity_YDisplay * this.dataDoc.mass * 10) / 10} kg*m/s</td>
+ <td>{Math.round(NumCast(this.dataDoc.mass1_velocityX) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s</td>
+ <td>{Math.round(NumCast(this.dataDoc.mass1_velocityY) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s</td>
</tr>
</tbody>
</table>
)}
- {this.dataDoc.mode == 'Freeform' && this.dataDoc.simulation_Type == 'Pulley' && (
+ {this.dataDoc.simulation_mode == 'Freeform' && this.dataDoc.simulation_type == 'Pulley' && (
<table>
<tbody>
<tr>
@@ -2001,39 +1997,39 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<td>
<Box>Position</Box>
</td>
- <td style={{ cursor: 'default' }}>{`${this.dataDoc.position_XDisplay2} m`}</td>
- <td style={{ cursor: 'default' }}>{`${this.dataDoc.position_YDisplay2} m`}</td>
+ <td style={{ cursor: 'default' }}>{`${this.dataDoc.mass2_positionX} m`}</td>
+ <td style={{ cursor: 'default' }}>{`${this.dataDoc.mass2_positionY} m`}</td>
</tr>
<tr>
<td>
<Box>Velocity</Box>
</td>
- <td style={{ cursor: 'default' }}>{`${this.dataDoc.position_XDisplay2} m/s`}</td>
- <td style={{ cursor: 'default' }}>{`${this.dataDoc.position_YDisplay2} m/s`}</td>
+ <td style={{ cursor: 'default' }}>{`${this.dataDoc.mass2_positionX} m/s`}</td>
+ <td style={{ cursor: 'default' }}>{`${this.dataDoc.mass2_positionY} m/s`}</td>
</tr>
<tr>
<td>
<Box>Acceleration</Box>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.acceleration_XDisplay2} m/s<sup>2</sup>
+ {this.dataDoc.mass2_accelerationX} m/s<sup>2</sup>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.acceleration_YDisplay2} m/s<sup>2</sup>
+ {this.dataDoc.mass2_accelerationY} m/s<sup>2</sup>
</td>
</tr>
<tr>
<td>
<Box>Momentum</Box>
</td>
- <td>{Math.round(NumCast(this.dataDoc.velocity_XDisplay2) * NumCast(this.dataDoc.mass) * 10) / 10} kg*m/s</td>
- <td>{Math.round(NumCast(this.dataDoc.velocity_YDisplay2) * NumCast(this.dataDoc.mass) * 10) / 10} kg*m/s</td>
+ <td>{Math.round(NumCast(this.dataDoc.mass2_velocityX) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s</td>
+ <td>{Math.round(NumCast(this.dataDoc.mass2_velocityY) * NumCast(this.dataDoc.mass1) * 10) / 10} kg*m/s</td>
</tr>
</tbody>
</table>
)}
</div>
- {this.dataDoc.simulation_Type != 'Pendulum' && this.dataDoc.simulation_Type != 'Spring' && (
+ {this.dataDoc.simulation_type != 'Pendulum' && this.dataDoc.simulation_type != 'Spring' && (
<div>
<p>Kinematic Equations</p>
<ul>
@@ -2050,7 +2046,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</ul>
</div>
)}
- {this.dataDoc.simulation_Type == 'Spring' && (
+ {this.dataDoc.simulation_type == 'Spring' && (
<div>
<p>Harmonic Motion Equations: Spring</p>
<ul>
@@ -2079,7 +2075,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</ul>
</div>
)}
- {this.dataDoc.simulation_Type == 'Pendulum' && (
+ {this.dataDoc.simulation_type == 'Pendulum' && (
<div>
<p>Harmonic Motion Equations: Pendulum</p>
<ul>
@@ -2114,7 +2110,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
top: this.yMax - 120 + 40 + 'px',
left: this.xMin + 90 - 80 + 'px',
}}>
- {this.dataDoc.simulation_Type == 'Circular Motion' ? 'Z' : 'Y'}
+ {this.dataDoc.simulation_type == 'Circular Motion' ? 'Z' : 'Y'}
</p>
<p
style={{
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
index a2883e825..1d980ebf4 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
@@ -2,6 +2,7 @@ import { Doc, HeightSym, WidthSym } from '../../../../fields/Doc';
import React = require('react');
import './PhysicsSimulationBox.scss';
import { NumCast } from '../../../../fields/Types';
+import { computed } from 'mobx';
interface IWallProps {
length: number;
@@ -29,7 +30,7 @@ export interface IWeightProps {
elasticCollisions: boolean;
gravity: number;
mass: number;
- mode: string;
+ simulationMode: string;
noMovement: boolean;
paused: boolean;
pendulumAngle: number;
@@ -55,7 +56,7 @@ export interface IWeightProps {
timestepSize: number;
updateXDisplay: number;
updateYDisplay: number;
- updatedForces: IForce[];
+ forcesUpdated: IForce[];
wallPositions: IWallProps[];
wedgeHeight: number;
wedgeWidth: number;
@@ -117,7 +118,9 @@ export default class Weight extends React.Component<IWeightProps, IState> {
}
// Constants
- draggable = this.props.dataDoc.simulation_Type != 'Inclined Plane' && this.props.dataDoc.simulation_Type != 'Pendulum' && this.props.dataDoc.mode == 'Freeform';
+ @computed get draggable() {
+ return this.props.simulationType != 'Inclined Plane' && this.props.simulationType != 'Pendulum' && this.props.simulationMode == 'Freeform';
+ }
epsilon = 0.0001;
labelBackgroundColor = `rgba(255,255,255,0.5)`;
@@ -151,30 +154,30 @@ export default class Weight extends React.Component<IWeightProps, IState> {
setYPosDisplay = (yPos: number) => {
const displayPos = this.getDisplayYPos(yPos);
if (this.props.color == 'red') {
- this.props.dataDoc.position_YDisplay = Math.round(displayPos * 100) / 100;
+ this.props.dataDoc.mass1_positionY = Math.round(displayPos * 100) / 100;
} else {
- this.props.dataDoc.position_YDisplay2 = Math.round(displayPos * 100) / 100;
+ this.props.dataDoc.mass2_positionY = Math.round(displayPos * 100) / 100;
}
};
setXPosDisplay = (xPos: number) => {
if (this.props.color == 'red') {
- this.props.dataDoc.position_XDisplay = Math.round(xPos * 100) / 100;
+ this.props.dataDoc.mass1_positionX = Math.round(xPos * 100) / 100;
} else {
- this.props.dataDoc.position_XDisplay2 = Math.round(xPos * 100) / 100;
+ this.props.dataDoc.mass2_positionX = Math.round(xPos * 100) / 100;
}
};
setYVelDisplay = (yVel: number) => {
if (this.props.color == 'red') {
- this.props.dataDoc.velocity_YDisplay = (-1 * Math.round(yVel * 100)) / 100;
+ this.props.dataDoc.mass1_velocityY = (-1 * Math.round(yVel * 100)) / 100;
} else {
- this.props.dataDoc.velocity_YDisplay2 = (-1 * Math.round(yVel * 100)) / 100;
+ this.props.dataDoc.mass2_velocityY = (-1 * Math.round(yVel * 100)) / 100;
}
};
setXVelDisplay = (xVel: number) => {
if (this.props.color == 'red') {
- this.props.dataDoc.velocity_XDisplay = Math.round(xVel * 100) / 100;
+ this.props.dataDoc.mass1_velocityX = Math.round(xVel * 100) / 100;
} else {
- this.props.dataDoc.velocity_XDisplay2 = Math.round(xVel * 100) / 100;
+ this.props.dataDoc.mass2_velocityX = Math.round(xVel * 100) / 100;
}
};
@@ -185,15 +188,15 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.setYVelDisplay(yVel);
this.setXVelDisplay(xVel);
if (this.props.color == 'red') {
- this.props.dataDoc.acceleration_YDisplay = (-1 * Math.round(this.getNewAccelerationY(this.props.updatedForces) * 100)) / 100;
- this.props.dataDoc.acceleration_XDisplay = Math.round(this.getNewAccelerationX(this.props.updatedForces) * 100) / 100;
+ this.props.dataDoc.mass1_accelerationY = (-1 * Math.round(this.getNewAccelerationY(this.props.forcesUpdated) * 100)) / 100;
+ this.props.dataDoc.mass1_accelerationX = Math.round(this.getNewAccelerationX(this.props.forcesUpdated) * 100) / 100;
} else {
- this.props.dataDoc.acceleration_YDisplay2 = (-1 * Math.round(this.getNewAccelerationY(this.props.updatedForces) * 100)) / 100;
- this.props.dataDoc.acceleration_XDisplay2 = Math.round(this.getNewAccelerationX(this.props.updatedForces) * 100) / 100;
+ this.props.dataDoc.mass2_accelerationY = (-1 * Math.round(this.getNewAccelerationY(this.props.forcesUpdated) * 100)) / 100;
+ this.props.dataDoc.mass2_accelerationX = Math.round(this.getNewAccelerationX(this.props.forcesUpdated) * 100) / 100;
}
- this.setState({ xAccel: Math.round(this.getNewAccelerationX(this.props.updatedForces) * 100) / 100 });
- this.setState({ yAccel: (-1 * Math.round(this.getNewAccelerationY(this.props.updatedForces) * 100)) / 100 });
+ this.setState({ xAccel: Math.round(this.getNewAccelerationX(this.props.forcesUpdated) * 100) / 100 });
+ this.setState({ yAccel: (-1 * Math.round(this.getNewAccelerationY(this.props.forcesUpdated) * 100)) / 100 });
};
componentDidUpdate(prevProps: Readonly<IWeightProps>, prevState: Readonly<IState>, snapshot?: any): void {
@@ -221,9 +224,9 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.setState({ updatedStartPosX: x });
this.setState({ xPosition: x });
if (this.props.color == 'red') {
- this.props.dataDoc.position_XDisplay = x;
+ this.props.dataDoc.mass1_positionX = x;
} else {
- this.props.dataDoc.position_XDisplay2 = x;
+ this.props.dataDoc.mass2_positionX = x;
}
}
@@ -235,9 +238,9 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.setState({ updatedStartPosY: coordinatePosition });
this.setState({ yPosition: coordinatePosition });
if (this.props.color == 'red') {
- this.props.dataDoc.position_YDisplay = y;
+ this.props.dataDoc.mass1_positionY = y;
} else {
- this.props.dataDoc.position_YDisplay2 = y;
+ this.props.dataDoc.mass2_positionY = y;
}
}
@@ -245,9 +248,9 @@ export default class Weight extends React.Component<IWeightProps, IState> {
let x = this.props.displayXVelocity;
this.setState({ xVelocity: x });
if (this.props.color == 'red') {
- this.props.dataDoc.velocity_XDisplay = x;
+ this.props.dataDoc.mass1_velocityX = x;
} else {
- this.props.dataDoc.velocity_XDisplay2 = x;
+ this.props.dataDoc.mass2_velocityX = x;
}
}
@@ -255,9 +258,9 @@ export default class Weight extends React.Component<IWeightProps, IState> {
let y = this.props.displayYVelocity;
this.setState({ yVelocity: -y });
if (this.props.color == 'red') {
- this.props.dataDoc.velocity_YDisplay = y;
+ this.props.dataDoc.mass1_velocityY = y;
} else {
- this.props.dataDoc.velocity_YDisplay2 = y;
+ this.props.dataDoc.mass2_velocityY = y;
}
}
}
@@ -271,7 +274,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Make sure weight doesn't go above max height
if ((prevState.updatedStartPosY != this.state.updatedStartPosY || prevProps.startVelY != this.props.startVelY) && !isNaN(this.state.updatedStartPosY) && !isNaN(this.props.startVelY)) {
- if (this.props.dataDoc.simulation_Type == 'One Weight') {
+ if (this.props.simulationType == 'One Weight') {
let maxYPos = this.state.updatedStartPosY;
if (this.props.startVelY != 0) {
maxYPos -= (this.props.startVelY * this.props.startVelY) / (2 * Math.abs(this.props.gravity));
@@ -288,12 +291,12 @@ export default class Weight extends React.Component<IWeightProps, IState> {
if (prevState.timer != this.state.timer) {
if (!this.props.noMovement) {
let collisions = false;
- if (this.props.dataDoc.simulation_Type == 'One Weight' || this.props.dataDoc.simulation_Type == 'Inclined Plane') {
+ if (this.props.simulationType == 'One Weight' || this.props.simulationType == 'Inclined Plane') {
const collisionsWithGround = this.checkForCollisionsWithGround();
const collisionsWithWalls = this.checkForCollisionsWithWall();
collisions = collisionsWithGround || collisionsWithWalls;
}
- if (this.props.dataDoc.simulation_Type == 'Pulley') {
+ if (this.props.simulationType == 'Pulley') {
if (this.state.yPosition <= this.props.yMin + 100 || this.state.yPosition >= this.props.yMax - 100) {
collisions = true;
}
@@ -313,7 +316,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Convert from static to kinetic friction if/when weight slips on inclined plane
if (prevState.xVelocity != this.state.xVelocity) {
- if (this.props.dataDoc.simulation_Type == 'Inclined Plane' && Math.abs(this.state.xVelocity) > 0.1 && this.props.dataDoc.mode != 'Review' && !this.state.kineticFriction) {
+ if (this.props.simulationType == 'Inclined Plane' && Math.abs(this.state.xVelocity) > 0.1 && this.props.simulationMode != 'Review' && !this.state.kineticFriction) {
this.setState({ kineticFriction: true });
const normalForce: IForce = {
description: 'Normal Force',
@@ -367,10 +370,10 @@ export default class Weight extends React.Component<IWeightProps, IState> {
component: false,
};
if (this.props.coefficientOfKineticFriction != 0) {
- this.props.dataDoc.updatedForces = [gravityForce, normalForce, frictionForce];
+ this.props.dataDoc.mass1_forcesUpdated = [gravityForce, normalForce, frictionForce];
this.props.dataDoc.componentForces = [frictionForceComponent, normalForceComponent, gravityParallel, gravityPerpendicular];
} else {
- this.props.dataDoc.updatedForces = [gravityForce, normalForce];
+ this.props.dataDoc.mass1_forcesUpdated = [gravityForce, normalForce];
this.props.dataDoc.componentForces = [normalForceComponent, gravityParallel, gravityPerpendicular];
}
}
@@ -379,7 +382,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Add/remove walls when simulation type changes
if (prevProps.simulationType != this.props.simulationType) {
let w: IWallProps[] = [];
- if (this.props.dataDoc.simulation_Type == 'One Weight' || this.props.dataDoc.simulation_Type == 'Inclined Plane') {
+ if (this.props.simulationType == 'One Weight' || this.props.simulationType == 'Inclined Plane') {
w = this.props.wallPositions;
}
this.setState({ walls: w });
@@ -438,27 +441,27 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.setState({ kineticFriction: false });
this.setState({ xPosition: this.state.updatedStartPosX });
this.setState({ yPosition: this.state.updatedStartPosY });
- this.setState({ xVelocity: this.props.startVelX ?? 0 });
- this.setState({ yVelocity: this.props.startVelY ?? 0 });
- this.props.dataDoc.pendulum_angle = this.props.dataDoc.start_PendulumAngle;
- this.props.dataDoc.updatedForces = this.props.dataDoc.start_Forces;
- this.props.dataDoc.updatedForces2 = this.props.dataDoc.start_Forces2;
+ this.setState({ xVelocity: this.props.startVelX });
+ this.setState({ yVelocity: this.props.startVelY });
+ this.props.dataDoc.pendulum_angle = this.props.startPendulumAngle;
+ this.props.dataDoc.mass1_forcesUpdated = this.props.dataDoc.mass1_forcesStart;
+ this.props.dataDoc.mass2_forcesUpdated = this.props.dataDoc.mass2_forcesStart;
if (this.props.color == 'red') {
- this.props.dataDoc.position_XDisplay = this.state.updatedStartPosX;
- this.props.dataDoc.position_YDisplay = this.state.updatedStartPosY;
- this.props.dataDoc.velocity_XDisplay = this.props.startVelX ?? 0;
- this.props.dataDoc.velocity_YDisplay = this.props.startVelY ?? 0;
- this.props.dataDoc.acceleration_XDisplay = 0;
- this.props.dataDoc.acceleration_YDisplay = 0;
+ this.props.dataDoc.mass1_positionX = this.state.updatedStartPosX;
+ this.props.dataDoc.mass1_positionY = this.state.updatedStartPosY;
+ this.props.dataDoc.mass1_velocityX = this.props.startVelX;
+ this.props.dataDoc.mass1_velocityY = this.props.startVelY;
+ this.props.dataDoc.mass1_accelerationX = 0;
+ this.props.dataDoc.mass1_accelerationY = 0;
} else {
- this.props.dataDoc.position_XDisplay2 = this.state.updatedStartPosX;
- this.props.dataDoc.position_YDisplay2 = this.state.updatedStartPosY;
- this.props.dataDoc.velocity_XDisplay2 = this.props.startVelX ?? 0;
- this.props.dataDoc.velocity_YDisplay2 = this.props.startVelY ?? 0;
- this.props.dataDoc.acceleration_XDisplay2 = 0;
- this.props.dataDoc.acceleration_YDisplay2 = 0;
+ this.props.dataDoc.mass2_positionX = this.state.updatedStartPosX;
+ this.props.dataDoc.mass2_positionY = this.state.updatedStartPosY;
+ this.props.dataDoc.mass2_velocityX = this.props.startVelX;
+ this.props.dataDoc.mass2_velocityY = this.props.startVelY;
+ this.props.dataDoc.mass2_accelerationX = 0;
+ this.props.dataDoc.mass2_accelerationY = 0;
}
- this.setState({ angleLabel: Math.round(NumCast(this.props.dataDoc.pendulum_angle) ?? 0 * 100) / 100 });
+ this.setState({ angleLabel: Math.round(this.props.pendulumAngle * 100) / 100 });
};
// Compute x acceleration from forces, F=ma
@@ -618,7 +621,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.setState({ yVelocity: -this.state.yVelocity });
} else {
this.setState({ yVelocity: 0 });
- if (this.props.dataDoc.simulation_Type != 'Two Weights') {
+ if (this.props.simulationType != 'Two Weights') {
const forceOfGravity: IForce = {
description: 'Gravity',
magnitude: Math.abs(this.props.gravity) * this.props.mass,
@@ -631,8 +634,8 @@ export default class Weight extends React.Component<IWeightProps, IState> {
directionInDegrees: wall.angleInDegrees + 90,
component: false,
};
- this.props.dataDoc.updatedForces = [forceOfGravity, normalForce];
- if (this.props.dataDoc.simulation_Type == 'Inclined Plane') {
+ this.props.dataDoc.mass1_forcesUpdated = [forceOfGravity, normalForce];
+ if (this.props.simulationType == 'Inclined Plane') {
const forceOfGravityC: IForce = {
description: 'Gravity',
magnitude: Math.abs(this.props.gravity) * this.props.mass,
@@ -681,12 +684,12 @@ export default class Weight extends React.Component<IWeightProps, IState> {
const newYVel = currentYVel + deltaYVel * dt;
const newDeltaXPos = newXVel;
const newDeltaYPos = newYVel;
- let forces = this.props.updatedForces;
- if (this.props.dataDoc.simulation_Type == 'Pendulum') {
+ let forces = this.props.forcesUpdated;
+ if (this.props.simulationType == 'Pendulum') {
forces = this.getNewPendulumForces(newXPos, newYPos, newXVel, newYVel);
- } else if (this.props.dataDoc.simulation_Type == 'Spring') {
+ } else if (this.props.simulationType == 'Spring') {
forces = this.getNewSpringForces(newYPos);
- } else if (this.props.dataDoc.simulation_Type == 'Circular Motion') {
+ } else if (this.props.simulationType == 'Circular Motion') {
forces = this.getNewCircularMotionForces(newXPos, newYPos);
}
const newDeltaXVel = this.getNewAccelerationX(forces);
@@ -711,12 +714,12 @@ export default class Weight extends React.Component<IWeightProps, IState> {
let yPos = this.state.yPosition;
let xVel = this.state.xVelocity;
let yVel = this.state.yVelocity;
- let forces: IForce[] = this.props.dataDoc.updatedForces;
- if (this.props.dataDoc.simulation_Type == 'Pendulum') {
+ let forces: IForce[] = this.props.dataDoc.mass1_forcesUpdated;
+ if (this.props.simulationType == 'Pendulum') {
forces = this.getNewPendulumForces(xPos, yPos, xVel, yVel);
- } else if (this.props.dataDoc.simulation_Type == 'Spring') {
+ } else if (this.props.simulationType == 'Spring') {
forces = this.getNewSpringForces(yPos);
- } else if (this.props.dataDoc.simulation_Type == 'Circular Motion') {
+ } else if (this.props.simulationType == 'Circular Motion') {
forces = this.getNewCircularMotionForces(xPos, yPos);
}
const xAcc = this.getNewAccelerationX(forces);
@@ -733,7 +736,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
yPos += ((this.props.timestepSize * 1.0) / 6.0) * (k1.deltaYPos + 2 * (k2.deltaYPos + k3.deltaYPos) + k4.deltaYPos);
}
// make sure harmonic motion maintained and errors don't propagate
- if (this.props.dataDoc.simulation_Type == 'Spring') {
+ if (this.props.simulationType == 'Spring') {
if (startYVel < 0 && yVel > 0 && yPos < this.props.springRestLength) {
let equilibriumPos = this.props.springRestLength + (this.props.mass * Math.abs(this.props.gravity)) / this.props.springConstant;
let amplitude = Math.abs(equilibriumPos - this.props.springStartLength);
@@ -744,7 +747,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
yPos = equilibriumPos + amplitude;
}
}
- if (this.props.dataDoc.simulation_Type == 'Pendulum') {
+ if (this.props.simulationType == 'Pendulum') {
let startX = this.state.updatedStartPosX;
if (startXVel <= 0 && xVel > 0) {
xPos = this.state.updatedStartPosX;
@@ -760,7 +763,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
yPos = this.props.startPosY;
}
}
- if (this.props.dataDoc.simulation_Type == 'One Weight') {
+ if (this.props.simulationType == 'One Weight') {
if (yPos < this.state.maxPosYConservation) {
yPos = this.state.maxPosYConservation;
}
@@ -769,18 +772,18 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.setState({ yVelocity: yVel });
this.setState({ xPosition: xPos });
this.setState({ yPosition: yPos });
- let forcesn = this.props.dataDoc.updatedForces;
- if (this.props.dataDoc.simulation_Type == 'Pendulum') {
+ let forcesn = this.props.dataDoc.mass1_forcesUpdated;
+ if (this.props.simulationType == 'Pendulum') {
forcesn = this.getNewPendulumForces(xPos, yPos, xVel, yVel);
- } else if (this.props.dataDoc.simulation_Type == 'Spring') {
+ } else if (this.props.simulationType == 'Spring') {
forcesn = this.getNewSpringForces(yPos);
- } else if (this.props.dataDoc.simulation_Type == 'Circular Motion') {
+ } else if (this.props.simulationType == 'Circular Motion') {
forcesn = this.getNewCircularMotionForces(xPos, yPos);
}
- this.props.dataDoc.updatedForces = forcesn;
+ this.props.dataDoc.mass1_forcesUpdated = forcesn;
// set component forces if they change
- if (this.props.dataDoc.simulation_Type == 'Pendulum') {
+ if (this.props.simulationType == 'Pendulum') {
let x = this.props.xMax / 2 - xPos - this.props.radius;
let y = yPos + this.props.radius + 5;
let angle = (Math.atan(y / x) * 180) / Math.PI;
@@ -851,7 +854,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
} else if (newX < 10) {
newX = 10;
}
- if (this.props.dataDoc.simulation_Type == 'Suspension') {
+ if (this.props.simulationType == 'Suspension') {
if (newX < (this.props.xMax + this.props.xMin) / 4 - this.props.radius - 15) {
newX = (this.props.xMax + this.props.xMin) / 4 - this.props.radius - 15;
} else if (newX > (3 * (this.props.xMax + this.props.xMin)) / 4 - this.props.radius / 2 - 15) {
@@ -860,13 +863,13 @@ export default class Weight extends React.Component<IWeightProps, IState> {
}
this.setState({ yPosition: newY });
- this.props.dataDoc.position_YDisplay = Math.round((this.props.yMax - 2 * this.props.radius - newY + 5) * 100) / 100;
- if (this.props.dataDoc.simulation_Type != 'Pulley') {
+ this.props.dataDoc.mass1_positionY = Math.round((this.props.yMax - 2 * this.props.radius - newY + 5) * 100) / 100;
+ if (this.props.simulationType != 'Pulley') {
this.setState({ xPosition: newX });
- this.props.dataDoc.position_XDisplay = newX;
+ this.props.dataDoc.mass1_positionX = newX;
}
- if (this.props.dataDoc.simulation_Type != 'Suspension') {
- if (this.props.dataDoc.simulation_Type != 'Pulley') {
+ if (this.props.simulationType != 'Suspension') {
+ if (this.props.simulationType != 'Pulley') {
this.setState({ updatedStartPosX: newX });
}
this.setState({ updatedStartPosY: newY });
@@ -878,7 +881,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
}}
onPointerUp={e => {
if (this.state.dragging) {
- if (this.props.dataDoc.simulation_Type != 'Pendulum' && this.props.dataDoc.simulation_Type != 'Suspension') {
+ if (this.props.simulationType != 'Pendulum' && this.props.simulationType != 'Suspension') {
this.resetEverything();
}
this.setState({ dragging: false });
@@ -895,10 +898,10 @@ export default class Weight extends React.Component<IWeightProps, IState> {
} else if (newX < 10) {
newX = 10;
}
- if (this.props.dataDoc.simulation_Type == 'Spring') {
- this.props.dataDoc.springStartLength = newY;
+ if (this.props.simulationType == 'Spring') {
+ this.props.dataDoc.spring_lengthStart = newY;
}
- if (this.props.dataDoc.simulation_Type == 'Suspension') {
+ if (this.props.simulationType == 'Suspension') {
let x1rod = (this.props.xMax + this.props.xMin) / 2 - this.props.radius - this.props.yMin - 200;
let x2rod = (this.props.xMax + this.props.xMin) / 2 + this.props.yMin + 200 + this.props.radius;
let deltaX1 = this.state.xPosition + this.props.radius - x1rod;
@@ -928,7 +931,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
directionInDegrees: 270,
component: false,
};
- this.props.dataDoc.updatedForces = [tensionForce1, tensionForce2, grav];
+ this.props.dataDoc.mass1_forcesUpdated = [tensionForce1, tensionForce2, grav];
}
}
}}>
@@ -936,7 +939,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
<p className="weightLabel">{this.props.mass} kg</p>
</div>
</div>
- {this.props.dataDoc.simulation_Type == 'Spring' && (
+ {this.props.simulationType == 'Spring' && (
<div
className="spring"
style={{
@@ -967,7 +970,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
</div>
)}
- {this.props.dataDoc.simulation_Type == 'Pulley' && (
+ {this.props.simulationType == 'Pulley' && (
<div
className="rod"
style={{
@@ -981,7 +984,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
</svg>
</div>
)}
- {this.props.dataDoc.simulation_Type == 'Pulley' && (
+ {this.props.simulationType == 'Pulley' && (
<div
className="wheel"
style={{
@@ -995,7 +998,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
</svg>
</div>
)}
- {this.props.dataDoc.simulation_Type == 'Suspension' && (
+ {this.props.simulationType == 'Suspension' && (
<div
className="rod"
style={{
@@ -1060,7 +1063,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
</p>
</div>
)}
- {this.props.dataDoc.simulation_Type == 'Circular Motion' && (
+ {this.props.simulationType == 'Circular Motion' && (
<div
className="rod"
style={{
@@ -1081,7 +1084,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
</svg>
</div>
)}
- {this.props.dataDoc.simulation_Type == 'Pendulum' && (
+ {this.props.simulationType == 'Pendulum' && (
<div
className="rod"
style={{
@@ -1118,7 +1121,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
)}
</div>
)}
- {this.props.dataDoc.simulation_Type == 'Inclined Plane' && (
+ {this.props.simulationType == 'Inclined Plane' && (
<div>
<div style={{ position: 'absolute', left: '0', top: '0' }}>
<svg width={this.props.xMax + 'px'} height={this.props.yMax + 'px'}>
@@ -1154,8 +1157,8 @@ export default class Weight extends React.Component<IWeightProps, IState> {
<line
x1={this.state.xPosition + this.props.radius}
y1={this.state.yPosition + this.props.radius}
- x2={this.state.xPosition + this.props.radius + this.getNewAccelerationX(this.props.updatedForces) * 15}
- y2={this.state.yPosition + this.props.radius + this.getNewAccelerationY(this.props.updatedForces) * 15}
+ x2={this.state.xPosition + this.props.radius + this.getNewAccelerationX(this.props.forcesUpdated) * 15}
+ y2={this.state.yPosition + this.props.radius + this.getNewAccelerationY(this.props.forcesUpdated) * 15}
stroke={'green'}
strokeWidth="5"
markerEnd="url(#accArrow)"
@@ -1282,8 +1285,8 @@ export default class Weight extends React.Component<IWeightProps, IState> {
})}
{!this.state.dragging &&
this.props.showForces &&
- this.props.updatedForces &&
- this.props.updatedForces.map((force, index) => {
+ this.props.forcesUpdated &&
+ this.props.forcesUpdated.map((force, index) => {
if (force.magnitude < this.epsilon) {
return;
}