S2 Geometry
s2geometry.io
s2geometry.io
If I remember him correctly, this project started off as a 20% time project of just one employee. The more amazing part was it sounded like that employee had been working on the problem, largely by himself, for near a decade.
And now this project, started by one guy, is in production use for an application hundreds of millions (if not billions) of people use daily. All because he just kept working on it. Inspiring.
Yes, it was mostly one employee, but it wasn't an ordinary one.
http://graphics.stanford.edu/papers/veach_thesis/
(I forgot: he was also behind jump consistent hashing)
Almost all modern ray-tracing engines (e.g. Indigo) rely on that technique these days.
And yeah, all the other things he did at Google.
Not your run of the mill engineer, by a very large margin.
MLT is actually not much used in modern ray tracers, it has some undesirable properties that rule it out for most "final frame" use.
However, Veach's thesis still laid the foundation for all modern rendering, in particular MIS and BDPT.
Google Presentation on S2: https://docs.google.com/presentation/d/1Hl4KapfAENAOf4gv-pSn...
Christian Perone's blog post on it: http://blog.christianperone.com/2015/08/googles-s2-geometry-...
Google Code Archive: https://code.google.com/archive/p/s2-geometry-library/
Java Implementation: https://github.com/rschreijer/s2-geometry-library-java
I didn't know much about S2 geometry before I discovered the library. It was a lot of fun to dive in and learn how it all worked.
Nice to see that it's all open sourced now.
For less distortion, it uses hexagons.
While the hexagon has less distortion - we loose some of the nice child <> parent guarantees that S2 offers in my experience.
With S2 cells there are two different distances to neighbors at the corners vs the sides and the neighbors at the sites have long borders and neighbors at the corners have vertice borders.
Both S3 and H3 are useful, but for different reasons. It's worth knowing the benefits and tradeoffs of both and choosing the solution that fits your particular problem.
H3 uses Buckminster Fuller's Dymaxion project and puts the 20 pentagonal vertices all in the ocean. I'm not sure the impact of this for maritime usage and I'm not sure if there is yet a different orientation that puts all vertices on land, so you can use it for maritime usage without having to concern yourself with these vertices.
Technically, in spherical geometry this isn't true. It's actually not possible to tile the sphere with regular hexagons (even after including those 12 pentagons). Unlike a planar tiling, some hexagons end up bigger or smaller than others, the internal angles aren't all equal to each other, and the internal angles sum to more than 360 degrees.
This page has some good diagrams where this effect is readily visible: https://en.wikipedia.org/wiki/Goldberg_polyhedron
Now ignoring some cheats, like just putting 6 vertices on the equator and calling both hemisphere a hexagon, a shape consisting solely of 'h' hexagons and 'p' pentagons will have (h+p) faces, (6h+5p)/2 edges and at most (6h+5p)/3 vertices (we're forbidding the construction where you just cut an edge into two and claim you've created a vertex, so each vertex is part of at least 3 faces). This gives an Euler characeristic of at most:
(6h+5p)/3 - (6h+5p)/2 + (h+p) = (6h+5p)/6 - (h+p) = (1/6) p.
Since a sphere has a characteristic of 2 you need at least twelve pentagons. And apparently you can achieve this lower bound by subdividing the triangular faces of an icosahedron, leaving you with 12 pentagons at the corners of the icosahedron.
Well done.
> A unique feature of the S2 library is that unlike traditional geographic information systems, which represent data as flat two-dimensional projections (similar to an atlas), the S2 library represents all data on a three-dimensional sphere (similar to a globe).
(S^2 if the superscript character doesn't show up for you.)
Somewhere there's an older doc/presentation that goes into the reasons for the cube in more detail, and if I remember where it is, I'll post it here later.
Consistent uniform cell size, minimizing distortions and relegating them to remote parts of the ocean, grouping land masses together (one cube side is almost pure ocean), optimizing for geodesics, and making it easy to index and reason about were some of the considerations in the design decision. It's been a while so I'm little fuzzy on all the reasoning, but I'm sure someone else on here can provide ptrs or fill in the details.
Edit: it may also be easier to figure out which squares are adjacent when using a grid based on a cube.
The geographic database may have no singularities but the coordinate system used does. The coordinate system has a singularity at the origin since it is just an equivalence class on R^3 / {0} but probably (I don't know the domain well) this never comes up in practice.
The related blog post is at https://medium.com/sidewalk-talk/s2-cells-and-space-filling-...
In practice, we use s2 for in memory location indexing.
Remember a couple weeks (months?) ago when google changed their maps from being a flat Cartesian style to having a more polar spherical look to them as you actually moved away from the surface of the earth? This is the library responsible for that.
As far as I know, the map tiles google serves are still in mercator projection -- it's just that mercator was always designed to be projected onto a sphere, not a plane, so now it looks better.
What S2 is, is a better way of representing sets of coordinates within GIS systems, such that searching for features that are close to each other, or within a complex polygon, can be performed much quicker than with other coordinate reference systems ie. floating point latitude/longitude pairs. They're storing points on a 3D sphere (unit vectors) as easily subdivisible 64-bit integers which have a logical order which is much faster to index / iterate over nearby areas.
Makes sense for applications like google maps; "find local businesses near point X,Y" etc.
If I remember correctly, he also mentioned something about the same project being responsible for better stitching and less overlaps/voids in the map.
Thanks for explaining though, helped me understand things a bit better.
Honestly, it's one of the best abstractions I've ever used.
Also, I'm not a mathematician and everything I know about computer science (and most of math for that matter) I've taught myself or learned on the job. So... maybe I'm using the wrong terminology?
I'm 98% certain the library is the same one currently used on google maps web app.
I assume that was done ironically?