Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Interactive Projectile Motion Simulation

An educational physics simulation for exploring projectile motion concepts through interactive visualizations and hands-on experimentation.

Projectile Motion Simulation

Features

๐ŸŽฏ Interactive Simulation

  • Real-time projectile motion visualization using p5.js
  • Adjustable parameters: initial speed (0-50 m/s), launch angle (0-90ยฐ), initial height (0-10 m)
  • Vector visualization showing velocity components
  • Trajectory path tracing
  • Live variable table with physics calculations

๐Ÿ“Š Educational Tools

  • Challenge Mode: Hide variables and test student predictions
  • Assessment System: Star-based scoring with 2% error tolerance for 3 stars
  • Progress Tracking: Save student progress locally
  • Real-time Calculations: All physics values updated every frame

๐Ÿ“ฑ Responsive Design

  • Optimized for Canvas LMS embedding (800ร—600 iframe)
  • Mobile-friendly responsive layout
  • Accessible controls and clear visual hierarchy
  • Works on desktop, tablet, and mobile devices

๐Ÿงฎ Accurate Physics

  • Professional-grade kinematic equations
  • Proper gravitational acceleration (-9.8 m/sยฒ)
  • Range, maximum height, and flight time calculations
  • World-to-screen coordinate conversion (1m = 50px)

Quick Start

1. Direct Browser Use

# Clone the repository
git clone https://github.com/your-username/projectile-motion-sim.git
cd projectile-motion-sim

# Serve locally (Python 3)
python3 -m http.server 8000

# Or with Python 2
python -m SimpleHTTPServer 8000

# Open http://localhost:8000 in your browser

2. GitHub Pages Deployment

  1. Fork this repository
  2. Enable GitHub Pages in repository settings
  3. Set source to "Deploy from a branch" โ†’ main โ†’ / (root)
  4. Access at: https://your-username.github.io/projectile-motion-sim/

3. Canvas LMS Integration

<iframe 
    src="https://your-username.github.io/projectile-motion-sim/" 
    width="800" 
    height="600" 
    style="border: 1px solid #ccc;">
</iframe>

Project Structure

projectile-motion-sim/
โ”œโ”€โ”€ index.html              # Main HTML page
โ”œโ”€โ”€ css/
โ”‚   โ””โ”€โ”€ styles.css          # Responsive CSS with custom properties
โ”œโ”€โ”€ js/
โ”‚   โ”œโ”€โ”€ main.js             # p5.js sketch and main simulation loop
โ”‚   โ”œโ”€โ”€ physics.js          # Physics calculations and helper functions
โ”‚   โ”œโ”€โ”€ ui.js               # UI controls and state management
โ”‚   โ””โ”€โ”€ assessment.js       # Challenge mode and progress tracking
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ physics.test.js     # Jest test suite for physics functions
โ”œโ”€โ”€ package.json            # NPM configuration and scripts
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ .github/
    โ””โ”€โ”€ copilot-instructions.md # GitHub Copilot customization

Physics Implementation

Core Equations

// Horizontal position: x = vโ‚€โ‚“ ร— t
export function horizPos(v0x, t) { return v0x * t; }

// Vertical position: y = yโ‚€ + vโ‚€แตงร—t + ยฝgtยฒ
export function vertPos(y0, v0y, t) { return y0 + v0y*t + 0.5*g*t*t; }

// Vertical velocity: vแตง = vโ‚€แตง + gt
export function vertVel(v0y, t) { return v0y + g*t; }

Calculated Values

  • Range: Horizontal distance traveled
  • Maximum Height: Peak altitude reached
  • Flight Time: Total time in air
  • Velocity Components: vโ‚“ and vแตง throughout flight

Educational Modules

โœ… Module 1: Horizontal Launch (Implemented)

  • Projectiles launched horizontally from a height
  • Focus on x-y motion independence
  • Challenge problems with range and flight time predictions

โœ… Module 2: Angled Launch (Implemented)

  • Full 2D projectile motion with launch angles
  • Optimal angle exploration (45ยฐ for maximum range)
  • Vector analysis and trajectory visualization

๐Ÿšง Module 3: Advanced Scenarios (TODO)

  • Air resistance effects
  • Variable gravity environments
  • Multiple projectile comparisons
  • Target practice mode

๐Ÿšง Module 4: Data Analysis (TODO)

  • Export trajectory data
  • Statistical analysis tools
  • Collaborative problem solving
  • Teacher dashboard

Testing

Run the comprehensive Jest test suite:

# Install dependencies
npm install

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

Test Coverage

  • โœ… All physics helper functions
  • โœ… Coordinate system conversions
  • โœ… Edge cases and error conditions
  • โœ… Integration tests for complete motion
  • โœ… Energy conservation verification

API Reference

Physics Functions

import { horizPos, vertPos, range, maxHeight } from './js/physics.js';

// Calculate range for 30ยฐ launch at 25 m/s from 5m height
const totalRange = range(25, 30, 5); // Returns distance in meters

// Get velocity components
const { vx, vy } = velocityComponents(20, 45); // 20 m/s at 45ยฐ

UI State Management

import { getCurrentState, updateVariableTable } from './js/ui.js';

// Get current simulation parameters
const state = getCurrentState();
console.log(state.speed, state.angle, state.height);

// Update the live variable display
updateVariableTable({
    time: 2.5,
    x: 35.4,
    y: 12.1,
    vx: 14.1,
    vy: -10.5
});

Assessment System

import { startChallenge, submitAnswer } from './js/assessment.js';

// Start an easy challenge
startChallenge(1); // Level 1 = Easy

// Submit student answer
const result = submitAnswer(42.5);
console.log(result.stars); // 0-3 stars based on accuracy

Browser Compatibility

  • โœ… Chrome 60+
  • โœ… Firefox 55+
  • โœ… Safari 12+
  • โœ… Edge 79+
  • โœ… Mobile browsers (iOS Safari, Chrome Mobile)

Deployment Options

GitHub Pages (Recommended)

  1. Automatic: Push to main branch
  2. Custom Domain: Configure in repository settings
  3. HTTPS: Automatically enabled

Alternative Hosting

  • Netlify: Drag and drop deployment
  • Vercel: Git integration
  • Canvas LMS: Direct file upload
  • Google Sites: Embed via iframe

Contributing

Development Setup

git clone https://github.com/your-username/projectile-motion-sim.git
cd projectile-motion-sim
npm install
npm run serve

Code Standards

  • ES6+ modules with JSDoc comments
  • Responsive CSS with custom properties
  • Comprehensive Jest testing
  • Accessible HTML semantic structure

Future Enhancements

  • Air resistance toggle
  • Multi-projectile comparisons
  • Data export functionality
  • Teacher analytics dashboard
  • Sound effects and animations
  • Collaborative features

License

MIT License - see LICENSE file for details.

Support


Built with โค๏ธ for physics education

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages