aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-05-03 13:06:09 -0400
committerbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-05-03 13:06:09 -0400
commit018077581b70483ac2f3453ba813b5f4adb61fd5 (patch)
tree43ef473356c7e4cc47296e1b59470f8d678f2ce7
parent30068f771a1a6e69c43097948439855dea896e83 (diff)
debugging
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx15
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationWall.tsx4
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx15
3 files changed, 21 insertions, 13 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
index 9a16c5c73..315e64e79 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx
@@ -106,11 +106,6 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
wallPositions: IWallProps[] = [];
componentDidMount() {
- this.wallPositions.push({ length: 70, xPos: 0, yPos: 0, angleInDegrees: 0 });
- this.wallPositions.push({ length: 70, xPos: 0, yPos: 70, angleInDegrees: 0 });
- this.wallPositions.push({ length: 80, xPos: 0, yPos: 0, angleInDegrees: 90 });
- this.wallPositions.push({ length: 80, xPos: 69.5, yPos: 0, angleInDegrees: 90 });
-
// Used throughout sims
this.layoutDoc._width = 1000;
this.layoutDoc._height = 1000;
@@ -211,6 +206,14 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
// Setup simulation
this.setupSimulation(this.dataDoc.simulationType, this.dataDoc.mode)
+
+ // Create walls
+ let walls = []
+ walls.push({ length: this.xMax / this.layoutDoc._width * 100, xPos: 0, yPos: 0, angleInDegrees: 0 });
+ walls.push({ length: this.xMax / this.layoutDoc._width * 100, xPos: 0, yPos: this.yMax / this.layoutDoc._height * 100, angleInDegrees: 0 });
+ walls.push({ length: this.yMax / this.layoutDoc._height * 100, xPos: 0, yPos: 0, angleInDegrees: 90 });
+ walls.push({ length: this.yMax / this.layoutDoc._height * 100, xPos: this.xMax / this.layoutDoc._width * 100, yPos: 0, angleInDegrees: 90 });
+ this.wallPositions = walls
}
componentDidUpdate() {
@@ -1283,6 +1286,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
<Weight
dataDoc={this.dataDoc}
layoutDoc={this.layoutDoc}
+ wallPositions={this.wallPositions}
adjustPendulumAngle={this.dataDoc.adjustPendulumAngle}
gravity={this.dataDoc.gravity}
circularMotionRadius={this.dataDoc.circularMotionRadius}
@@ -1332,6 +1336,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi
<Weight
dataDoc={this.dataDoc}
layoutDoc={this.layoutDoc}
+ wallPositions={this.wallPositions}
adjustPendulumAngle={this.dataDoc.adjustPendulumAngle}
circularMotionRadius={this.dataDoc.circularMotionRadius}
gravity={this.dataDoc.gravity}
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWall.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWall.tsx
index 83dff660a..8cc1d0fbf 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWall.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWall.tsx
@@ -18,8 +18,8 @@ export default class Wall extends React.Component<IWallProps> {
}
wallStyle = {
- width: this.props.angleInDegrees == 0 ? this.props.length + "%" : "1%",
- height: this.props.angleInDegrees == 0 ? "1%" : this.props.length + "%",
+ width: this.props.angleInDegrees == 0 ? this.props.length + "%" : "5px",
+ height: this.props.angleInDegrees == 0 ? "5px" : this.props.length + "%",
position: "absolute" as "absolute",
left: this.props.xPos + "%",
top: this.props.yPos + "%",
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
index c0bcd783a..597256d44 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
@@ -3,6 +3,12 @@ import React = require('react');
import { IWallProps } from "./PhysicsSimulationWall";
import "./PhysicsSimulationBox.scss";
+interface IWallProps {
+ length: number;
+ xPos: number;
+ yPos: number;
+ angleInDegrees: number;
+}
interface IForce {
description: string;
magnitude: number;
@@ -48,6 +54,7 @@ export interface IWeightProps {
timestepSize: number;
updateDisplay: { xDisplay: number; yDisplay: number };
updatedForces: IForce[];
+ wallPositions: IWallProps[];
wedgeHeight: number;
wedgeWidth: number;
xMax: number;
@@ -403,10 +410,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
console.log('walls')
let w: IWallProps[] = [];
if (this.props.dataDoc['simulationType'] == "One Weight" || this.props.dataDoc['simulationType'] == "Inclined Plane") {
- w.push({ length: 70, xPos: 0, yPos: 0, angleInDegrees: 0 });
- w.push({ length: 70, xPos: 0, yPos: 70, angleInDegrees: 0 });
- w.push({ length: 70, xPos: 0, yPos: 0, angleInDegrees: 90 });
- w.push({ length: 70, xPos: 69.5, yPos: 0, angleInDegrees: 90 });
+ w = this.props.wallPositions
}
this.setState({walls: w})
}
@@ -431,17 +435,16 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Update wedge coordinates
if (prevProps.wedgeWidth != this.props.wedgeWidth || prevProps.wedgeHeight != this.props.wedgeHeight) {
- console.log('wedge')
const left = this.props.xMax * 0.5 - 200;
const coordinatePair1 = Math.round(left) + "," + this.props.yMax + " ";
const coordinatePair2 = Math.round(left + this.props.wedgeWidth) + "," + this.props.yMax + " ";
const coordinatePair3 = Math.round(left) + "," + (this.props.yMax - this.props.wedgeHeight);
const coord = coordinatePair1 + coordinatePair2 + coordinatePair3;
+ console.log('coord ', coord)
this.setState({coordinates: coord})
}
if (this.state.xPosition != prevState.xPosition || this.state.yPosition != prevState.yPosition) {
- console.log('style')
this.weightStyle = {
alignItems: "center",
backgroundColor: this.props.color,