From 728db020856e3ff5c11e7eabbb4fe48f10a9a490 Mon Sep 17 00:00:00 2001 From: brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> Date: Mon, 6 Feb 2023 19:41:25 -0500 Subject: code compiles and runs --- src/client/views/nodes/PhysicsSimulationApp.tsx | 10 ++++------ src/client/views/nodes/PhysicsSimulationWall.tsx | 3 +-- src/client/views/nodes/PhysicsSimulationWedge.tsx | 15 +++++++-------- src/client/views/nodes/PhysicsSimulationWeight.tsx | 22 ++++++++++------------ 4 files changed, 22 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/PhysicsSimulationApp.tsx b/src/client/views/nodes/PhysicsSimulationApp.tsx index 0536d0679..1dfa04a31 100644 --- a/src/client/views/nodes/PhysicsSimulationApp.tsx +++ b/src/client/views/nodes/PhysicsSimulationApp.tsx @@ -3,8 +3,6 @@ import "./PhysicsSimulationBox.scss"; import Weight, { IForce } from "./PhysicsSimulationWeight"; import Wall, { IWallProps } from "./PhysicsSimulationWall" import Wedge from "./PhysicsSimulationWedge" -import { props, any } from 'bluebird'; -import { render } from 'react-dom'; interface PhysicsVectorTemplate { top: number; @@ -70,8 +68,8 @@ export default class App extends React.Component<{}, IState> { }; xMin = 0; yMin = 0; - xMax = window.innerWidth * 0.7; - yMax = window.innerHeight * 0.8; + xMax = 300; + yMax = 300; color = `rgba(0,0,0,0.5)`; radius = 50 @@ -461,7 +459,7 @@ export default class App extends React.Component<{}, IState> { ); })} */} - {/* {this.state.weight && ( + {this.state.weight && ( { wedgeWidth={this.state.wedgeWidth} coefficientOfKineticFriction={this.state.coefficientOfKineticFriction} /> - )} */} + )} {this.state.wedge && ( { updateCoordinates() { const coordinatePair1 = - Math.round(this.state.left) + "," + Math.round(window.innerHeight * 0.8) + " "; + Math.round(this.state.left) + "," + Math.round(300 * 0.8) + " "; const coordinatePair2 = Math.round(this.state.left + this.props.startWidth) + "," + - Math.round(window.innerHeight * 0.8) + + Math.round(300 * 0.8) + " "; const coordinatePair3 = Math.round(this.state.left) + "," + - Math.round(window.innerHeight * 0.8 - this.props.startHeight); + Math.round(300 * 0.8 - this.props.startHeight); const coord = coordinatePair1 + coordinatePair2 + coordinatePair3; this.setState({coordinates: coord}); } @@ -59,8 +58,8 @@ export default class Wedge extends React.Component {
@@ -71,7 +70,7 @@ export default class Wedge extends React.Component { position: "absolute", zIndex: 500, left: Math.round(this.state.left + this.props.startWidth - 80) + "px", - top: Math.round(window.innerHeight * 0.8 - 40) + "px", + top: Math.round(300 * 0.8 - 40) + "px", }} > {Math.round(((this.state.angleInRadians * 180) / Math.PI) * 100) / 100}° diff --git a/src/client/views/nodes/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsSimulationWeight.tsx index 669aab67a..9ce740ae9 100644 --- a/src/client/views/nodes/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsSimulationWeight.tsx @@ -1,6 +1,4 @@ -import React from "react"; -import { useEffect, useState } from "react"; -import { render } from "react-dom"; +import React = require('react'); import { IWallProps } from "./PhysicsSimulationWall"; import Wedge from "./PhysicsSimulationWedge"; @@ -94,9 +92,9 @@ export default class Weight extends React.Component { magnitude: this.props.mass * 9.81, directionInDegrees: 270, }; - xMax = window.innerWidth * 0.7; + xMax = 300; xMin = 0; - yMax = window.innerHeight * 0.8; + yMax = 300; yMin = 0; // Helper function to go between display and real values @@ -352,11 +350,11 @@ export default class Weight extends React.Component { let collision = false; const minX = this.state.xPosition; const maxX = this.state.xPosition + 2 * this.props.radius; - const containerWidth = window.innerWidth; + const containerWidth = 300; if (this.state.xVelocity != 0) { this.props.walls.forEach((wall) => { if (wall.angleInDegrees == 90) { - const wallX = (wall.xPos / 100) * window.innerWidth; + const wallX = (wall.xPos / 100) * 300; if (wall.xPos < 0.35) { if (minX <= wallX) { if (this.props.elasticCollisions) { @@ -390,7 +388,7 @@ export default class Weight extends React.Component { if (this.state.yVelocity > 0) { this.props.walls.forEach((wall) => { if (wall.angleInDegrees == 0) { - const groundY = (wall.yPos / 100) * window.innerHeight; + const groundY = (wall.yPos / 100) * 300; if (maxY >= groundY) { if (this.props.elasticCollisions) { this.setState({yVelocity: -this.state.yVelocity}) @@ -602,7 +600,7 @@ export default class Weight extends React.Component { zIndex: -2, }} > - + { top: 0, }} > - + { top: 0, }} > - + { >