numhask-space
Safe HaskellNone
LanguageGHC2024

NumHask.Space.Chart

Description

Coordinate charts and coordinate patches.

A Chart is the differential-geometric notion of a homeomorphism from an open subset of a manifold m to an open subset of a model space of coordinates c. In this library the coordinate patch is represented by a Space (typically a Rect for 2-D coordinates), so the existing SpaceRectPoint machinery becomes the chart infrastructure for free.

Synopsis

Charts

data Chart m c where Source #

A coordinate chart on a manifold/model type m with coordinates c.

The coordinate patch is any Space whose elements have type c. This is usually a Rect for 2-D coordinates (Point a) or a Range for 1-D coordinates a.

Constructors

Chart 

Fields

  • :: forall s c m. (Space s, Element s ~ c)
     
  • => s

    coordinate-domain patch

  • -> (c -> m)

    forward map: coordinates -> manifold point

  • -> (m -> c)

    inverse map: manifold point -> coordinates

  • -> Chart m c
     

data SomeSpace c where Source #

An existential space whose elements have type c.

Constructors

SomeSpace :: forall s c. (Space s, Element s ~ c) => s -> SomeSpace c 

chartMap :: Chart m c -> c -> m Source #

Extract the forward map from a chart.

chartInverse :: Chart m c -> m -> c Source #

Extract the inverse map from a chart.

chartDomain :: Chart m c -> SomeSpace c Source #

Extract the coordinate-domain patch from a chart.

inverseChart :: (Space s, Element s ~ m) => s -> Chart m c -> Chart c m Source #

Invert a chart, supplying the codomain patch for the inverse.

transition :: Chart m c2 -> Chart m c1 -> c1 -> c2 Source #

Transition map from the first chart to the second.

Both charts must cover (at least overlap on) the same manifold. The result is φ₂ ∘ φ₁⁻¹.

>>> let polar = polarChart (Rect 0.1 5 (-pi) pi)
>>> let cartesian = affineChart (Rect (-5) 5 (-5) 5) (Rect 0 1 0 1)
>>> transition cartesian polar (Point 1 0)
Point 0.6 0.5

Common charts

affineChart :: (Field a, Ord a) => Rect a -> Rect a -> Chart (Point a) (Point a) Source #

An affine chart between two rectangular patches.

>>> let c = affineChart (Rect 0 1 0 1) (Rect 0 2 0 2)
>>> chartMap c (Point 0.5 0.5)
Point 1.0 1.0

polarChart :: (TrigField a, ExpField a, Ord a) => Rect a -> Chart (Point a) (Point a) Source #

Polar coordinates (r, θ) to cartesian points (x, y).

>>> let c = polarChart (Rect 0.1 5 (-pi) pi)
>>> chartMap c (Point 1 0)
Point 1.0 0.0