aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-05-23 12:49:24 -0400
committerbobzel <zzzman@gmail.com>2023-05-23 12:49:24 -0400
commit18e458603d1c672b412c18237be73f6581d58137 (patch)
treeb69a88256e09e613b488119266360a2ce248038c /src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
parent4832bb8e9589a786ac08d24b6e55bb23d19ce855 (diff)
more physics fixes
Diffstat (limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx')
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx66
1 files changed, 40 insertions, 26 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
index 9d75944f4..35e9c189f 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
@@ -19,7 +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';
+import { computed, trace } from 'mobx';
interface IWallProps {
length: number;
@@ -920,8 +920,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
startVelX={NumCast(this.dataDoc.mass1_velocityXstart)}
startVelY={NumCast(this.dataDoc.mass1_velocityYstart)}
timestepSize={0.05}
- updateXDisplay={NumCast(this.dataDoc.mass1_xChange)}
- updateYDisplay={NumCast(this.dataDoc.mass1_yChange)}
+ updateMassPosX={NumCast(this.dataDoc.mass1_xChange)}
+ updateMassPosY={NumCast(this.dataDoc.mass1_yChange)}
forcesUpdated={this.forcesUpdated1}
setForcesUpdated={this.setForcesUpdated1}
wedgeHeight={NumCast(this.dataDoc.wedge_height)}
@@ -972,8 +972,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
startVelX={NumCast(this.dataDoc.mass2_velocityXstart)}
startVelY={NumCast(this.dataDoc.mass2_velocityYstart)}
timestepSize={0.05}
- updateXDisplay={NumCast(this.dataDoc.mass2_xChange)}
- updateYDisplay={NumCast(this.dataDoc.mass2_yChange)}
+ updateMassPosX={NumCast(this.dataDoc.mass2_xChange)}
+ updateMassPosY={NumCast(this.dataDoc.mass2_yChange)}
forcesUpdated={this.forcesUpdated2}
setForcesUpdated={this.setForcesUpdated2}
wedgeHeight={NumCast(this.dataDoc.wedge_height)}
@@ -1055,7 +1055,9 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
</div>
{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>
)}
@@ -1437,7 +1439,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
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'} />
+ <InputField label={<Box>Speed</Box>} lowerBound={1} dataDoc={this.dataDoc} prop="simulation_speed" step={1} unit={'x'} upperBound={10} value={NumCast(this.dataDoc.simulation_speed, 2)} labelWidth={'5em'} />
{this.dataDoc.simulation_paused && this.dataDoc.simulation_type != 'Circular Motion' && (
<InputField
label={<Box>Gravity</Box>}
@@ -1639,11 +1641,13 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
)}
{this.dataDoc.simulation_type == 'Inclined Plane' && !this.dataDoc.simulation_paused && (
<Typography>
- &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}
+ <>
+ &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 && (
@@ -1774,7 +1778,9 @@ 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.mass1_positionX} m</td>
+ <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' && (
<td
@@ -1791,7 +1797,6 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
value={NumCast(this.dataDoc.mass1_positionX)}
effect={value => {
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;
@@ -1822,7 +1827,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
directionInDegrees: 270,
component: false,
};
- this.dataDoc.mass1_forcesUpdated = [tensionForce1, tensionForce2, grav];
+ this.dataDoc.mass1_forcesUpdated = JSON.stringify([tensionForce1, tensionForce2, grav]);
}
}}
small={true}
@@ -1847,7 +1852,6 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
upperBound={this.yMax - 110}
value={NumCast(this.dataDoc.mass1_positionY)}
effect={value => {
- 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;
@@ -1879,7 +1883,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
directionInDegrees: 270,
component: false,
};
- this.dataDoc.mass1_forcesUpdated = [tensionForce1, tensionForce2, grav];
+ this.dataDoc.mass1_forcesUpdated = JSON.stringify([tensionForce1, tensionForce2, grav]);
}
}}
small={true}
@@ -1914,7 +1918,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
step={1}
unit={'m/s'}
upperBound={50}
- value={this.dataDoc.mass1_velocityX}
+ value={NumCast(this.dataDoc.mass1_velocityX)}
effect={value => {
this.dataDoc.mass1_velocityXstart = value;
this.dataDoc.simulation_reset = !this.dataDoc.simulation_reset;
@@ -1924,7 +1928,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
/>
</td>
)}{' '}
- {(!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' }}>
+ <>{this.dataDoc.mass1_velocityY} m/s</>
+ </td>
+ )}{' '}
{this.dataDoc.simulation_paused && this.dataDoc.simulation_type == 'One Weight' && (
<td
style={{
@@ -1937,11 +1945,9 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
step={1}
unit={'m/s'}
upperBound={50}
- value={this.dataDoc.mass1_velocityY}
+ value={NumCast(this.dataDoc.mass1_velocityY)}
effect={value => {
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'}
@@ -1961,10 +1967,14 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<Box>Acceleration</Box>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.mass1_accelerationX} m/s<sup>2</sup>
+ <>
+ {this.dataDoc.mass1_accelerationX} m/s<sup>2</sup>
+ </>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.mass1_accelerationY} m/s<sup>2</sup>
+ <>
+ {this.dataDoc.mass1_accelerationY} m/s<sup>2</sup>
+ </>
</td>
</tr>
<tr>
@@ -2004,10 +2014,14 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewP
<Box>Acceleration</Box>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.mass2_accelerationX} m/s<sup>2</sup>
+ <>
+ {this.dataDoc.mass2_accelerationX} m/s<sup>2</sup>
+ </>
</td>
<td style={{ cursor: 'default' }}>
- {this.dataDoc.mass2_accelerationY} m/s<sup>2</sup>
+ <>
+ {this.dataDoc.mass2_accelerationY} m/s<sup>2</sup>
+ </>
</td>
</tr>
<tr>