diff --git a/frontend/src/pages/scenario.jsx b/frontend/src/pages/scenario.jsx index cf1d594..74c41dd 100644 --- a/frontend/src/pages/scenario.jsx +++ b/frontend/src/pages/scenario.jsx @@ -5,7 +5,7 @@ import axios from 'axios'; const EARTH_RADIUS_KM = 6371; // Earth's radius in kilometers const EARTH_DISPLAY_SCALE = 0.01; // Display scale for Earth -const ASTEROID_DISPLAY_SCALE = 0.3; // Display scale for asteroids +const ASTEROID_DISPLAY_SCALE = 0.4; // Display scale for asteroids const G = 1e-8; // Gravitational constant for simulation const EARTH_MASS = 5.972e6; // Scaled down mass of Earth for simulation const ASTEROID_DENSITY = 2000; // Density in kg/m^3 @@ -16,7 +16,7 @@ const EARTH_X = CANVAS_WIDTH - 100; const EARTH_Y = CANVAS_HEIGHT / 2; const SIMULATION_AREA_MULTIPLIER = 2; // Extend the simulation area const ROCKET_SPEED = 0.025; // Reduced speed of the rocket - +const ROCKET_RADIUS = 10; function Scenario() { const [asteroid, setAsteroid] = useState({ name: '', @@ -213,7 +213,7 @@ function Scenario() { setRocketDistance(rocketDistance); - if (rocketDistance <= asteroid.size * ASTEROID_DISPLAY_SCALE && !collisionOccurred) { + if (rocketDistance <= (asteroid.size * ASTEROID_DISPLAY_SCALE+ROCKET_RADIUS) && !collisionOccurred) { setSimulationResult('Rocket intercepted the asteroid!'); setIsSimulating(false); return; @@ -257,7 +257,7 @@ function Scenario() { return ( <> - + Asteroid Collision Scenario @@ -266,6 +266,7 @@ function Scenario() { onChange={handleAsteroidSelect} displayEmpty fullWidth + style={{ color: 'white' }} > {asteroidsData.current.map((ast, index) => ( @@ -280,6 +281,7 @@ function Scenario() { onChange={(e) => setStrategy(e.target.value)} displayEmpty fullWidth + style={{ color: 'white' }} > Select Deflection Strategy Nuclear Detonation @@ -296,21 +298,21 @@ function Scenario() { {simulationResult && ( - Simulation Result - {simulationResult} + Simulation Result + {simulationResult} )} {asteroid.name && ( - Asteroid Information - Name: {asteroid.name} - Size: {asteroid.size.toFixed(3)} kilometers - Speed: {(asteroid.speed * 1000).toFixed(3)} km/s - Mass: {asteroid.mass.toExponential(3)} kg + Asteroid Information + Name: {asteroid.name} + Size: {asteroid.size.toFixed(3)} kilometers + Speed: {(asteroid.speed * 1000).toFixed(3)} km/s + Mass: {asteroid.mass.toExponential(3)} kg )} - Time Step: {timeStep} + Time Step: {timeStep} - Initial Angle: {(asteroid.angle * 180 / Math.PI).toFixed(2)}° + Initial Angle: {(asteroid.angle * 180 / Math.PI).toFixed(2)}° - - - - {trajectoryPoints.length > 0 && ( - - )} + + + {forecastPoints.length > 0 && ( - + + )} + + {trajectoryPoints.length > 0 && ( + )} - {rocket.active && ( - + + {( + )} {rocket.trajectory.length > 0 && ( - + )}