From d8fe4e0b9924b6f7f6f79da7745642d68bef5436 Mon Sep 17 00:00:00 2001 From: brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> Date: Tue, 16 May 2023 21:22:46 -0400 Subject: finish tutorial --- .../nodes/PhysicsBox/PhysicsSimulationBox.tsx | 80 ++++++++++++++++++++-- 1 file changed, 75 insertions(+), 5 deletions(-) (limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx') diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx index 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 { 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