Planet v0.1.1 GEOF.Planet.Field

Functions for handling an individual Field on a Planet.

Link to this section Summary

Types

Provides the indexes of Fields that are adjacent to this Field, organized by specific relative positions relevant to the way the Sphere is organized

A Field’s index uniquely identifies it on a Sphere and it’s used to identify its position and which Fields are adjacent

Functions

Provides a map of indexes for a field’s adjacent fields

Determines the 1-dimensional integer index of a Field given its index and the Sphere’s number of divisions

Stringifies a Field index

Provides a map of indexes for a field’s adjacent fields

Link to this section Types

Link to this type adjacents_map()
adjacents_map() ::
  %{nw: index(), w: index(), sw: index(), se: index(), e: index()}
  | %{
      nw: index(),
      w: index(),
      sw: index(),
      se: index(),
      e: index(),
      ne: index()
    }

Provides the indexes of Fields that are adjacent to this Field, organized by specific relative positions relevant to the way the Sphere is organized.

For pentagonal fields, all located at a vertex of the icosahedron, no ne adjacent Field is defined.

Link to this type index()
index() ::
  :north
  | :south
  | {:sxy, non_neg_integer(), non_neg_integer(), non_neg_integer()}

A Field’s index uniquely identifies it on a Sphere and it’s used to identify its position and which Fields are adjacent.

If the Field is not one of the poles, it’s defined by its SXY coordinates, where S is the section 0..4, X is 0..divisions * 2, Y is 0..divisions.

Link to this section Functions

Link to this function adjacents(field_index, divisions)

Provides a map of indexes for a field’s adjacent fields.

Link to this function flatten_index(field_index, divisions)

Determines the 1-dimensional integer index of a Field given its index and the Sphere’s number of divisions.

Link to this function index_to_string(field_index)
index_to_string(index()) :: String.t()

Stringifies a Field index.

Link to this function is_pentagon(field_index, divisions)
is_pentagon(index(), GEOF.Planet.Sphere.divisions()) :: boolean()

Provides a map of indexes for a field’s adjacent fields.