Open in playproj

playproj

GuidePerspectiveCones and cylindersSight and shadeSpilhausGlobals and interruptedsPeeling the orangeDistortionEllipsoidGeoidOrthorectifications2 cellsH3 hexagonsL3 binsModel gridsIndex spaceMGRS and Sentinel-2AAT gridTiles and overviewsRectilinear chunksIcechunk and ZarrRasterizeAffineRegular in what?Convex hullCatastrophesTexture mappingPenguin datumFor exampleHomageVicGridNuyinaRhumb linesFrameTime and depthCutawayVoxels

Click the terrain to move the spot. Distance 0 puts the eye on the spot; the far end of the slider is infinity, the sun.

How it works

A viewshed is the ground an eye can see. Project the terrain through the eye onto a plane: that is the gnomonic, the pinhole camera. Straight lines in 3D stay straight, so each terrain triangle lands as a triangle. Split the view round the eye into four 90 degree wedges (north, east, south and west), each its own gnomonic image, and in each one height in the image grows with elevation angle: higher in the image is higher in the view.

Now add the triangles nearest first. Everything drawn so far covers the image from the bottom up to a horizon line, the upper envelope of the triangles' projected edges. A piece of ground is visible exactly where it rises above that horizon, and then it raises it. On a grid no sort is needed: anything that can hide a square lies in a square fewer rows plus columns from the eye. The horizon left at the end is the skyline at the spot (the orange line).

A cast shadow is the same question asked of the sun. Drag the distance out: the eye moves away from the spot towards the light, the wedges narrow onto the terrain and the sight lines turn parallel. At infinity the eye is the sun and the projection is orthographic: the lit ground is the sun's viewshed. These are the two ends of the point of light on the perspective page, pointed at a landscape instead of a globe.

The terrain is synthetic, 160 x 160 squares of 30 m, each split into two triangles. Visibility here is decided for every vertex and checked against marching every line of sight (in test/check-sight.mjs, better than 99.8% agreement; the rest are grazing). Earth curvature and refraction are left out: at 5 km they lower the far ground by about 2 m.

  • Object-space visibility on triangulated terrain: L. De Floriani and P. Magillo (1994), Visibility algorithms on triangulated digital terrain models, IJGIS 8(1).
  • Six gnomonic faces as a cube map: N. Greene (1986), Environment mapping and other applications of world projections, IEEE CG&A 6(11).
  • Horizon and sky view factor by ray tracing: Steger, Steger and Schär (2022), HORAYZON v1.2, GMD 15.
  • A wedge-and-horizon viewshed with exact visible polygons: lunashade, docs/viewshed.md.
Source and contributing