Flight Sun Tracker
An interactive TypeScript and Canvas visualization tool computing solar elevation relative to aircraft passenger seating, helping travelers choose direct sunlight or cool shade.
Executive Summary: Flight Sun Tracker is an open-source TypeScript and HTML5 Canvas application that calculates the sun's azimuth and altitude relative to an aircraft's heading along great-circle routes. It solves the traveler dilemma of window seat glare versus shade by delivering instant seat-specific solar exposure breakdowns.
Problem: Window Seat Sun Glare vs Scenic Shade
Selecting a window seat on a long-haul commercial flight is typically guesswork. On morning eastbound flights, passengers on the right side face blinding solar glare and overheating cabins, while the left side stays comfortably shaded. On transatlantic or transpacific routes, seasonal variations in solar declination can flip sunlight exposure mid-flight.
Flight Sun Tracker eliminates guesswork by modeling solar positions deterministically across the entire route duration, calculating exact sun angles relative to the airplane's longitudinal axis.
Technical Architecture & Solar Calculations
The core engine computes astronomical and geodesic coordinates entirely client-side without relying on rate-limited third-party solar APIs:
- Great-Circle Route Interpolation: Computes waypoints between origin and destination airport pairs using spherical trigonometry (Haversine and spherical law of cosines) to calculate the aircraft's instantaneous true heading.
- Sub-Solar Point Modeling: Calculates solar declination and the Greenwich Hour Angle (GHA) for each flight segment timestamp using Jean Meeus astronomical algorithms.
- Relative Azimuth Transformation: Projects the sun's coordinates into the aircraft's local coordinate frame, determining whether sunlight strikes port (left / A-seats) or starboard (right / F-K seats).
Key Architectural Decisions
| Design Vector | Flight Sun Tracker Choice | Alternative Considered | Technical Rationale |
|---|---|---|---|
| Visualization | HTML5 Canvas 2D | Heavy 3D WebGL (Three.js) | Zero bundle bloat, instant rendering on mobile browsers, 60 FPS animation. |
| Calculation Engine | Local TypeScript Math | External REST Ephemeris APIs | Zero network latency, offline capability, 100% deterministic results. |
| Seat Mapping | Relative Angle Vectors | Binary Left/Right Classification | Allows calculating exact cabin glare duration, sunrise/sunset golden hours, and twilight. |
Source Code & Verification
The code is fully open-source and maintained on GitHub. Explore the repository and implementation details:
- Live Interactive Application: flight-sun-tracker-shivam-mahajans-projects.vercel.app ↗
- GitHub Repository: github.com/smresponsibilities/flight-sun-tracker ↗
- Author Portfolio: Return to Shivam Mahajan's Portfolio
- Full Projects Catalog: Explore All Software Projects