aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx')
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx80
1 files changed, 75 insertions, 5 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
index 7bb5d0e98..9741ddc3e 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
@@ -2105,7 +2105,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
)}{" "}
{this.dataDoc.simulationPaused &&
this.dataDoc.simulationType != "Inclined Plane" &&
- this.dataDoc.simulationType != "Suspension" &&
this.dataDoc.simulationType != "Circular Motion" &&
this.dataDoc.simulationType != "Pulley" && (
<td
@@ -2114,18 +2113,54 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
}}
>
<InputField
- lowerBound={0}
+ lowerBound={this.dataDoc.simulationType == "Projectile" ? 1 : (this.xMax + this.xMin) / 4 - this.radius - 15}
dataDoc={this.dataDoc}
prop={'positionXDisplay'}
step={1}
unit={"m"}
- upperBound={this.xMax - 110}
+ upperBound={this.dataDoc.simulationType == "Projectile" ? this.xMax - 110 : (3 * (this.xMax + this.xMin)) / 4 - this.radius / 2 - 15}
value={this.dataDoc.positionXDisplay}
effect={(value) => {
this.dataDoc.displayChange = ({
xDisplay: value,
yDisplay: this.dataDoc.positionYDisplay,
});
+ if (this.dataDoc['simulationType'] == "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(this.dataDoc.positionYDisplay) + this.radius;
+ let dir1T = Math.PI - Math.atan(deltaY / deltaX1);
+ let dir2T = Math.atan(deltaY / deltaX2);
+ let tensionMag2 =
+ (this.dataDoc.mass * Math.abs(this.dataDoc.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;
+ const tensionForce1: IForce = {
+ description: "Tension",
+ magnitude: tensionMag1,
+ directionInDegrees: dir1T,
+ component: false,
+ };
+ const tensionForce2: IForce = {
+ description: "Tension",
+ magnitude: tensionMag2,
+ directionInDegrees: dir2T,
+ component: false,
+ };
+ const grav: IForce = {
+ description: "Gravity",
+ magnitude: this.dataDoc.mass * Math.abs(this.dataDoc.gravity),
+ directionInDegrees: 270,
+ component: false,
+ };
+ this.dataDoc['updatedForces'] = ([tensionForce1, tensionForce2, grav]);
+ }
}}
small={true}
mode={"Freeform"}
@@ -2143,7 +2178,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
)}{" "}
{this.dataDoc.simulationPaused &&
this.dataDoc.simulationType != "Inclined Plane" &&
- this.dataDoc.simulationType != "Suspension" &&
this.dataDoc.simulationType != "Circular Motion" &&
this.dataDoc.simulationType != "Pulley" && (
<td
@@ -2152,7 +2186,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
}}
>
<InputField
- lowerBound={0}
+ lowerBound={1}
dataDoc={this.dataDoc}
prop={'positionYDisplay'}
step={1}
@@ -2164,6 +2198,42 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
xDisplay: this.dataDoc.positionXDisplay,
yDisplay: value,
});
+ if (this.dataDoc['simulationType'] == "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 = this.dataDoc.positionXDisplay + this.radius - x1rod;
+ let deltaX2 = x2rod - (this.dataDoc.positionXDisplay + 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 =
+ (this.dataDoc.mass * Math.abs(this.dataDoc.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;
+ const tensionForce1: IForce = {
+ description: "Tension",
+ magnitude: tensionMag1,
+ directionInDegrees: dir1T,
+ component: false,
+ };
+ const tensionForce2: IForce = {
+ description: "Tension",
+ magnitude: tensionMag2,
+ directionInDegrees: dir2T,
+ component: false,
+ };
+ const grav: IForce = {
+ description: "Gravity",
+ magnitude: this.dataDoc.mass * Math.abs(this.dataDoc.gravity),
+ directionInDegrees: 270,
+ component: false,
+ };
+ this.dataDoc['updatedForces'] = ([tensionForce1, tensionForce2, grav]);
+ }
}}
small={true}
mode={"Freeform"}