Skip to main content

icosalattice

This is a Python library which implements a lattice on the sphere (by this I mean the 2-sphere, which is the surface of a 3D sphere). The lattice is based on subdividing the edges and faces of an icosahedron to arbitrary precision.

What does it do? / What is it for?

The lattice provides a coordinate system for specifying points on the sphere. It is different from either 3D Cartesian coordinates or spherical coordinates.

Each point has a code, which is a string telling exactly where it is based on how it was generated from points in the previous iteration.

The iterative way in which the lattice is constructed also creates a natural graph of connections between points. There is a complicated but efficient "arithmetic" for determining the neighbors of a point based on its code. This makes it useful for simulating things spreading around on the sphere.

Why do this?

This lattice was originally conceived as a way to generate terrain for a made-up planet. I wanted a set of points roughly evenly spaced across the sphere. However, due to Gauss's Theorema Egregium, we cannot use lattices in latitude-longitude space for this because they will oversample near the poles. I decided to take the Platonic solid which is closest to a sphere and use that as the basis for a coordinate system. Since the faces of the icosahedron are triangles, this also results in all points except the original 12 vertices having 6 neighbors. Any area of the globe not including one of these vertices resembles a hexagonal/triangular lattice, which I find nicer than a square lattice.

How the lattice works

Place an icosahedron just inside the unit sphere such that one of its vertices lies at the sphere's north pole. The points on the sphere corresponding to this icosahedron's 12 vertices are labeled "A" through "L". The north pole is "A" and the south pole is "B".

The locations of the 12 original vertices

The remaining 10 vertices (at latitude +/- arctan(1/2)) are labeled by "peel". A peel is a vertical slice made of 4 faces of the icosahedron. There are 5 peels, each touching the north and south poles.

#TODO diagram of the peels, with vertices labeled on each and world map section in each triangle (might be a bit hard to do but should be possible) #TODO make clear which points on the edges of a peel belong to it and which don't, and that the north pole and south pole do not belong to any peels

Each vertex has 5 original neighbors, based on which other vertices it is connected to by the edges of the icosahedron.

This is iteration 0 of the lattice. To get the next iteration, we take all edges in the current lattice, bisect them, and draw lines to fill out the new triangular lattice on each local triangle.

#TODO diagram of this process

New points are created in a particular order. #TODO describe the point ordering

#TODO describe the concept of parent point and how this creates the point's code, and how north and south poles cannot be parent of anything

#TODO describe the concept of directional parent, with diagrams

#TODO describe the concept of watershed and directional watershed, with diagrams

#TODO describe the neighbor direction system, how to navigate among points within a triangular lattice region (no refraction across peel boundary)

#TODO describe how this is complicated by refraction across peel boundary

#TODO describe the arithmetic for getting neighbors

Working with spherical coordinates

#TODO describe how to get the nearest point code to a latlon within distance tolerance / iteration limit

#TODO describe how to get the latlon of a point code

Point numbers

#TODO describe birth number and lookup number systems, show some tables of how they correspond to point codes, make it very clear to reader which systems are for what and why they exist and why you'd use them (and if there is no such reason then get rid of that system, e.g. birth order might not be useful)

Metadata

Release files for icosalattice 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for icosalattice 0.0.4
File Size Uploaded
icosalattice-0.0.4.tar.gz 59.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for icosalattice 0.0.4
File Interpreter ABI Platform
icosalattice-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 120.1 kB

Release files / icosalattice-0.0.4.tar.gz

Download URL icosalattice-0.0.4.tar.gz
Size 59.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7d8ddca3abd5f33b372ba67b1b0482e2f53ffee7e8fbe8a3666c5bbe737f7461
BLAKE2b-256 checksum
How to use checksums
9c39eeb784e966fa2085225d8d0fa642fc54de12d0e9bec88c9806c78577e448
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / icosalattice-0.0.4-py3-none-any.whl

Download URL icosalattice-0.0.4-py3-none-any.whl
Size 60.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81dc7e6c1581baa17c352022afab9c56ed758c98c5ebe457a4c5415d20806175
BLAKE2b-256 checksum
How to use checksums
1adee2f478bb7472b9d48ddacab67fd1616bce1a4f951cc173f2060d109992ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page