ianTPE/tetra-unfold
About
Seamless tetrahedral world map with a multi-stop flight trip planner in 9 languages. Also unfolds 360° photos for AI vision and drone attitude. 四面體世界地圖與出差航線規劃。
Design & MediaMeasured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originaltetra-unfold
English | 繁體中文 | 简体中文 | 日本語 | 한국어 | Deutsch | Français | Español | Русский
Beijing to London: which countries and cities does the route pass?

The map shows the shortest great-circle route between the two cities, not an actual flight track.
China → Mongolia → Russia → Finland → Sweden → Denmark → United Kingdom, 8,154 km in all. The route passes near Ulaanbaatar, Krasnoyarsk, Surgut, Stockholm and Gothenburg. The bend in the line is a fold of the map, not a turn. Open this route.
Plan a business trip, compare layovers or see where a flight goes: this world map does all three. Check that a route makes sense on the map, then compare fares. Open the map; there is nothing to install.
For example, Taipei to London is 9,783 km direct, 9,918 km via Shanghai (only 135 km more) and 12,160 km via Doha (2,377 km more).
To make the map, the whole sphere is unfolded onto a regular tetrahedron, then flattened into a rectangle that tiles the plane seamlessly.
The demo uses a world map and is inspired by the AuthaGraph world map by Hajime Narukawa. It is not an implementation of AuthaGraph: that algorithm is patented and unpublished, so this project uses its own approximation. The same method can also be applied to 360° camera images, so that an AI model can see the entire sphere in a single flat image.

Demos
Try it online: https://iantpe.github.io/tetra-unfold/
The map is available in 繁體中文, 简体中文, English, 日本語, 한국어, Deutsch, Français, Español and Русский. It picks your browser's language automatically; use the menu in the panel to switch, or add ?lang= to the address (zh-Hant, zh-Hans, en, ja, ko, de, fr, es, ru), for example https://iantpe.github.io/tetra-unfold/?lang=ja.
Your trip, distance range, rotation and settings are saved in the address as you work, so you can bookmark the page or send it to someone, and it opens exactly as you left it. Copy share link in the panel copies the address. For example, this link opens the Taipei → Tokyo → London → Singapore trip with a 5,000 km range around Taipei. Nothing is stored on a server; everything is in the address.
The map is a single HTML file plus i18n.js (interface text), tetra-map.js (projection and drawing), trip-order.js (the shortest-order calculation), airports.json and names/<language>.json (airport and city names). There is nothing to install or build. An internet connection is needed to load D3 and the country data.
| File | What it shows |
|---|---|
index.html · live |
Tetrahedral world map. One tetrahedron edge runs down the vertical centre line along 90°E, with corners at the top and bottom centre. By default the North Pole is on the top corner; dragging up and down slides the globe along that edge until the South Pole is on the bottom corner (the North Pole up and South Pole down buttons jump between the two). Dragging stops at these two positions; a checkbox removes the limit so the globe can keep turning. The other corners stay in the oceans in both positions. Seamless tiling, drag to rotate the globe, optional area correction, tetrahedron fold lines, and country names on hover. |
Controls:
- Drag: rotate the globe (in
index.html, Shift + drag pans the view) - Mouse wheel: zoom (
index.html) - Keyboard (all three pages): press Tab to focus the map, then use the arrow keys to rotate the globe, Shift + arrow keys to pan and + / - to zoom. In
index.html, Pan view mode swaps the arrow keys and Shift + arrow keys - Hover: show the country name and coordinates
- On a phone (
index.html): one finger rotates the globe; two fingers zoom and pan. Tap to see a name; to add an airport, tap it and press Add to trip. Settings and the trip are in the bar at the bottom of the screen: tap it or swipe up to open it
Planning a multi-stop trip (index.html)
The map is handy for checking flight directions: with area correction off (the default), each triangular face is a gnomonic projection, so a great-circle route is a straight line within a face and only bends where it crosses a fold line.
- Add airports by clicking the dots on the map, or by typing an IATA code, a city, an airport name or a country, in the selected language or in English (for example
TPE,London,ロンドン,Londres). When a city has several airports, the busiest one comes first. Zoom in to also see medium-sized airports. - Each leg is drawn as a great-circle route, with its distance and the trip total. Tick return to the start for a round trip.
- Find the smoothest order keeps the first stop as the starting point and finds the order of the others with the shortest total distance. A trip can have up to 30 stops: up to 16 the result is the true shortest; above that it is approximate and may not be the shortest.
- When part of the route is out of view, the map turns to keep the route together, with north staying up. This happens after you add a stop or find the order, and when you open a link that has no saved rotation. Centre the route does the same at any time. A trip that circles the globe can't avoid being cut: its start then appears at both edges of the map.
- Distances are great-circle distances on a sphere of radius 6,371 km. Real flight paths are usually somewhat longer.
Checking fares with an AI browser assistant
The map finds the order with the shortest distance, but not the cheapest or fastest flights. An AI assistant that can use your browser, such as Claude in Chrome or ChatGPT's agent, can do that part: it reads the order from the map, searches each leg on a flight search site such as Google Flights, and compares the combinations. For example:
Open https://iantpe.github.io/tetra-unfold/ and plan a trip from Taipei (TPE) to Tokyo, Singapore and London, returning to Taipei. Compare the order the map finds with the other orders. Then search one-way economy fares on Google Flights for 1, 4, 7 and 10 December, and list the total fare and total travel time for each order.
In a test with exactly this trip (fares as shown in November 2026, one adult, economy, one-way tickets including taxes):
| Visiting order (back to Taipei) | Great-circle distance | Flights found | Total fare | Total travel time |
|---|---|---|---|---|
| Tokyo → Singapore → London | 28,206 km | London leg via Shanghai | NT$49,198 | 47 h 30 min |
| Tokyo → Singapore → London | 28,206 km | London leg via Doha | NT$50,509 | 44 h 05 min |
| Tokyo → London → Singapore (the map's order) | 25,878 km | Via Shanghai and Munich | NT$50,779 | 45 h 50 min |
- The shortest order is not always the cheapest. The map's order saved 2,328 km (8.3%), but with these dates its flights cost slightly more. Fares depend mostly on which airlines fly each route.
- The connection can matter as much as the order. Changing the Singapore–London connection from Shanghai to Doha cost NT$1,311 more but saved 3 h 25 min.
- Overnight flights shorten your stays, which the map cannot show.
So use the map to rule out orders that double back, and let the assistant compare fares for the few orders that are left. The assistant only searches; book and pay yourself. Fares change constantly, and a multi-city ticket can be cheaper than separate one-way tickets, so ask the assistant to check that as well.
Distance range circles (index.html)
Pick a centre (an airport code or city, or the first stop of your trip) and a radius in kilometres or flight hours. The map shades every place within that great-circle distance and lists the cities with large airports inside the circle, nearest first. Hover anywhere to see its distance from the centre.
On the globe the range is a circle, but on this map it is not: within one face it is a smooth oval, and it bends where it crosses a fold line. For example, a 5,000 km circle around Taipei reaches Delhi (4,373 km) and Darwin (4,298 km) but stops just short of Mumbai (5,002 km). Flight hours are converted at an average of 800 km/h, so treat them as a rough guide.
Flight replay (launch.html)
launch.html · live replays Starship Flight 11 on the tetrahedral map, with time, altitude, speed, an altitude chart and the same route on an ordinary map. The central edge stays vertical in the middle of the screen, so north and south stay easy to read. This is a reconstruction for illustration, not measured telemetry. It was rebuilt from the launch site, the splashdown point, a public timeline and Earth's rotation; altitude and speed during the ascent and entry are assumed. The page only plays a data file and does not calculate trajectories.
The page also replays a measured long-range flight: NASA's Global Hawk on 6–7 September 2012, from Dryden, California to Wallops, Virginia, around the east side of Hurricane Leslie (19.2 hours, 11,576 km). flights/global-hawk-hs3.json keeps one row a minute from NASA's navigation files. Gaps of 12 and 4 minutes are joined by straight lines. This file follows NASA's data terms, not this repository's licence. Citation: Sorenson, C. (2025). Hurricane and Severe Storm Sentinel (HS3) Global Hawk Navigation [Data set]. NASA GHRC DAAC. https://doi.org/10.5067/HS3/NAV/DATA201
To show another flight, add a data file to flights/ (use flights/starship-11.json as a template) and add it to FLIGHTS in launch.html. rows holds one array per column: t (seconds after liftoff), lat, lon (degrees), alt (km), speed (km/h) and dist (ground distance in km). The page fills in the values between rows. The same file holds the title, labels, events, sources and map direction.
To set the map direction for a new route, change only view in the data file. The zoom is worked out for you.
- Open the page, press Whole route, and drag the map until the route looks right.
- In the browser console, enter
[state.yaw, state.pitch]. - Put the two numbers in
viewasyawandpitch.
yaw is the longitude on the central line minus 90 (add 360 if the result is below −180). pitch runs from 0 to 70.5, and a route further south usually needs a larger value. Keep the route away from the coloured corner dots, or it folds into a sharp V.
Short-wave great-circle paths (radio.html)
radio.html · live shows the short and long path between Taipei and London as one nearly straight great circle, with the distance, the antenna bearing from each end and which share of each path is in darkness at a chosen UTC time. It shows geometry only and does not predict propagation. To use other places, change A, B and CIRCLE_VIEW at the top of the file; CIRCLE_VIEW works like view in the flight replay.
Use it with Claude Code, Codex or Antigravity
The repository includes two skills that coding agents can use. Clone it and start Claude Code or Codex in its folder, or open the folder in Antigravity, then ask in your own words:
git clone https://github.com/ianTPE/tetra-unfold
cd tetra-unfold
claude # or: codex
| Skill | Example request | Needs |
|---|---|---|
plan-route |
Plan the shortest trip from Taipei to Tokyo, Singapore and London, and give me the map link | Node.js |
plan-route |
Find real flights and the total price for this trip on Google Flights, leaving December 7 and staying 3 days at each stop | Node.js, a browser the agent can control |
unfold-360 |
Unfold photo.jpg | Python, pip install numpy pillow |
The skills only load when the agent is working in this repository. You can also run the route tool without an agent: node plan_route.js TPE Tokyo Singapore London. It gives great-circle distances, not fares or flight availability. The agent looks up real flights and fares on Google Flights in the browser, and it does not book anything.
How it works
Why it tiles seamlessly
The plane is covered by a lattice of equilateral triangles with side length 1. Grouping the lattice points (i, j) by the parity of i and j gives exactly 4 classes, one for each vertex of the tetrahedron, and every small triangle becomes one face of the tetrahedron.
Three faces meet at each vertex of a regular tetrahedron, so the total angle around a vertex is 3 × 60° = 180°. This means the whole plane is the tetrahedron's surface repeated by 180° rotations about every lattice point. The rectangle [0, 2] × [0, √3/2] holds exactly one complete map. Neighbouring rows are rotated by 180°, so copies of the map tile infinitely in every direction. index.html turns this lattice by 90° so that one edge is vertical: its map is the √3 × 1 rectangle with a corner at the midpoint of each side and none inside, which is also exactly one complete map.
From the plane to the sphere
Each pixel is computed as follows:
- Find the small triangle that contains the pixel and compute its barycentric coordinates.
- Use the barycentric coordinates to pick a point on the matching face of the tetrahedron.
- Push that point onto the sphere, in one of two modes:
- Uncorrected (gnomonic): project straight out from the centre of the sphere. Each face looks like an ultra-wide pinhole camera image, and straight lines stay straight.
- Area-corrected: redistribute distances along each ray from the face centre so that areas on the map are roughly proportional to areas on the sphere.
- Apply the rotation matrix to get longitude and latitude, then sample the colour from an equirectangular texture.
Because every pixel is looked up in reverse, there is no polygon clipping to deal with, and tiling and rotation come almost for free.
Corner distortion is unavoidable
A tetrahedron vertex has only 180° around it, but every point on a sphere has 360°. The area near each of the 4 vertices must therefore be stretched by about 2×, whatever formula is used. AuthaGraph has the same distortion and places its corners in the oceans.
Application: 360° cameras, AI recognition and drone attitude
360° cameras usually export equirectangular images (2:1 panoramas). That is the same format as the world map texture used here, so the method works by swapping the texture for a 360° photo.
Compared with common formats:
- Equirectangular: objects are cut at the left and right edges, and the poles are heavily stretched.
- Cubemap (6 faces): each face looks like an ordinary photo, but there are many seams, and objects across seams need extra handling.
- Tetrahedral unfolding: one rectangular image of the whole sphere with no cuts, which can be fed directly to standard image models. The drawback is distortion near the 4 corners.
Horizon layout
unfold360.py uses the same √3 × 1 net as index.html (one tetrahedron edge runs vertically down the centre), turned so that when the camera is level:
- The horizontal centre line is the horizon. The top half of the image is entirely sky and the bottom half entirely ground, each exactly half of the sphere.
- The centre of the image looks straight ahead. Straight behind is at the four corners, and the horizon continues along the left and right edges.
- The zenith is at 1/4 and 3/4 of the top edge, and the nadir at the same places on the bottom edge.
- The 4 tetrahedron corners are at the top and bottom centre (54.7° above and below the horizon, straight ahead) and at the midpoints of the left and right edges (on the horizon, 125.3° to either side).
Because the corner distortion cannot be avoided, the image can be unfolded twice in two orientations, and each direction is read from whichever image keeps it farther from a corner. B is A rotated 180° about the vertical axis. A's 4 corners are symmetric above and below the horizon, so after the rotation B's corners land exactly opposite A's corners, at the centre of each of A's faces, where A has the least distortion. The sky stays at the top in both images. Every direction is then at least 35.3° from a corner in one of the two images, including every point on the horizon:
| B rotated by | Worst direction, distance from a corner |
|---|---|
| 180° | 35.3° |
| 150° | 20.3° |
| 90° | 9.8° |
| 0° | 0° (both images identical) |
pip install numpy pillow
python unfold360.py photo.jpg out/
Drone attitude: telling sky from ground
A drone knows which way is up from its IMU (gyroscope and accelerometer). But the accelerometer measures gravity plus the drone's own acceleration, so during gusts, collisions, tumbling or hard manoeuvres the "down" it reports is wrong, and the gyroscope on its own drifts over time. The magnetometer is also easily upset by electromagnetic interference.
The boundary between sky and ground in a 360° image is an independent reference: it is not affected by electromagnetic interference or by the drone's acceleration. The idea is to combine it with the IMU: use the IMU normally, and when the drone is disturbed and the accelerometer cannot be trusted, correct the attitude with the up direction seen in the image. This matters most for drones that must keep flying under interference.
The horizon layout suits this:
- One seamless image covers the whole sphere, so the sky is never split across image borders, however the drone is turned.
- When the drone is level, the top half is sky and the bottom half is ground, which makes labels for training a sky/ground segmentation model simple.
- In area-corrected mode every pixel covers the same solid angle, so pixel directions can be averaged directly.
Test
drone_attitude.py simulates a drone in 300 random attitudes per photo, including upside down. For each one it unfolds the 360° image in the drone's own frame (128 × 74 pixels, area-corrected) and estimates "up" with a deliberately simple rule:
- Bright, bluish pixels are sky. The threshold is chosen automatically for each image (Otsu's method).
- Black "no data" areas are ignored.
- The up direction is the average direction of sky pixels minus that of ground pixels.
It was run on six aerial 360° panoramas from Wikimedia Commons (by Gunther Tschuch, CC BY-SA 4.0):
| Terrain | Upside down | Error (median) | Error (90%) | Worst | Estimate step (excludes unfolding) |
|---|---|---|---|---|---|
| Farmland (Sebnitz) | 0 / 300 | 5.4° | 8.5° | 10.7° | 0.9 ms |
| Town (Bad Karlshafen) | 0 / 300 | 6.6° | 10.7° | 13.9° | 0.9 ms |
| River valley town (Hirschhorn) | 0 / 300 | 7.6° | 11.4° | 16.7° | 0.9 ms |
| Island coast (Skye) | 0 / 300 | 11.1° | 16.1° | 20.5° | 0.9 ms |
| Lake (Loch Tay) | 0 / 300 | 11.5° | 16.2° | 18.4° | 0.9 ms |
| Coast and mountains (Mull) | 0 / 300 | 13.6° | 18.1° | 22.3° | 0.9 ms |
| Level | Tilted 70° | Turned back level using the estimate |
|---|---|---|
![]() |
![]() |
![]() |
What we found:
- In 1,800 random attitudes the sky and ground were never swapped. The direction was off by 5–14° (median) and at most 22°. In Python on a desktop CPU, the estimate step took about 1 ms; unfolding a 2048 × 1024 image adds about 12 ms, for about 13 ms per frame in total.
- Water that reflects the sky (lakes, coasts) gives the largest errors.
- The camera must be able to see the sky. These panoramas are black above about 25° elevation, because the camera hangs under the drone. Before the black areas were excluded, most attitudes came out upside down. A drone using this needs cameras covering the upper hemisphere too, for example a 360° camera with lenses above and below the body.
- Panoramas taken from the ground (1.5 m) are not representative of a flying drone: trees and buildings hide much of the sky.
Limitations:
- The tumbling is simulated by rotating a still panorama. Motion blur, sudden exposure changes, propellers in view and sun glare are not tested.
- The brightness rule fails at night, over snow and above clouds. A trained sky/ground segmentation model would be needed, and should also reduce the 5–14° error.
- Combining the estimate with the IMU is not implemented.
Numerical checks
The projection code has been checked with Node.js:
- Tiling error after translation and 180° rotation is about 10⁻¹⁵ (the edges match exactly), and the map is not mirrored.
- Round-trip error between map coordinates and sphere coordinates is below 10⁻¹² in both modes.
- Area distortion (map area ÷ true area):
| Mode | Range |
|---|---|
| Uncorrected | 0.13× – 3.3× |
| Area-corrected | 0.55× – 1.4× |
- Shape distortion (ratio of maximum to minimum stretch) in uncorrected mode: about 2.4× within 10° of a corner, and 1.5× or less beyond 35°.
Related projections
Unfolding the globe onto a tetrahedron is not new. The closest earlier work:
- Lee's conformal tetrahedral projection (L. P. Lee, 1965). It also maps the globe onto a regular tetrahedron and tiles the plane, and its tile can be rearranged into the same
√3 × 1rectangle. The original is centred on the South Pole, which sits on a vertex. It is conformal (local shapes are right), so great circles are curved. It is available in D3 asd3.geoTetrahedralLee, usually drawn as a triangle with the pole at its centre. - Doug McIlroy's tetrahedral map card (1983) uses Lee's projection with the poles at the midpoints of two opposite edges and all four vertices in the oceans.
- AuthaGraph (Hajime Narukawa) is a rectangular, seamlessly tiling tetrahedral map with its corners in the oceans. Its algorithm is patented and unpublished.
What this project does differently:
- One edge runs vertically down the centre of the map, and dragging slides the globe along it between the North Pole on the top corner and the South Pole on the bottom corner.
- Each face is a gnomonic projection, so great-circle flight routes are straight within a face.
- It includes a trip planner on top of the map: airport search in nine languages, routes, distances and the shortest visiting order.
Related tools for trip planning
Other web tools also draw multi-stop flight routes and add up great-circle distances:
| What you see | Routes | Good for | |
|---|---|---|---|
| Great Circle Map | A 3D globe you can turn (a Mercator map is also available); the globe shows only half the Earth at a time | Correct great-circle arcs; distances on the ellipsoid | One leg or a few legs |
| RapidToolset Multi-City Flight Planner | The whole world on a conventional flat map | Arcs between stops; high-latitude routes are stretched, so their real direction is hard to judge | Adding up distances |
| This map | The whole world on one flat, seamlessly tiling map | Straight within each face, bending only at fold lines | Planning the order of a complex multi-country trip |
A globe shows directions correctly but never the whole trip at once; a conventional map shows the whole trip but with misleading directions. This map shows the whole trip with directions that stay close to true, and can find the shortest visiting order.
Distances here use a sphere (radius 6,371 km). They differ from ellipsoid distances, such as Great Circle Map's, by less than 0.4% (for example Taipei–London: 9,783 km vs 9,802 km). That is far smaller than the gap between different visiting orders, so it does not change which order is shortest.
Credits
- D3.js 7.9.0: equirectangular projection and border rendering
- TopoJSON 3.0.2
- world-atlas 2.0.2: country boundaries derived from Natural Earth (1:50m)
- OurAirports: airport list (
airports.json, airports with scheduled service and an IATA code), public domain - Wikidata: airport and city names in Chinese, Japanese, Korean, German, French, Spanish and Russian, and passenger counts used for ranking search results, CC0. Chinese names were converted to Traditional (Taiwan usage) or Simplified script with OpenCC; Traditional Chinese names were then checked for Taiwan-standard transliterations. Country names come from the browser's built-in translations (
Intl.DisplayNames) - Wikimedia Commons: aerial 360° panoramas by Gunther Tschuch (PaulT), CC BY-SA 4.0, used for the drone test: Sebnitz Ottendorf, Kassel Bad Karlshafen, Hirschhorn (Neckar), Skye Dun Beag, Perth and Kinross Loch Tay, Mull Lochbuie.
examples/aerial_*.jpgare adapted from the Sebnitz Ottendorf panorama and are licensed CC BY-SA 4.0 - AuthaGraph is the work and registered trademark of Hajime Narukawa. This project is not affiliated with it.
License
PolyForm Noncommercial 1.0.0. Personal use, study, research, hobby projects, and use by schools, charities, public research and government organisations are free.
Commercial use needs a separate paid license. Contact [email protected].
- The license covers the code in this repository. The libraries and data listed above (D3, TopoJSON, world-atlas / Natural Earth, OurAirports, Wikidata) keep their own licenses.
examples/aerial_*.jpgare licensed CC BY-SA 4.0 (see Credits).
Explore related projects
Loading…


