manifolds-0.2.3.0: Coordinate-free hypersurfaces

Copyright(c) Justus Sagemüller 2015
LicenseGPL v3
Maintainer(@) sagemueller $ geo.uni-koeln.de
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Manifold.TreeCover

Contents

Description

 

Synopsis

Shades

data Shade x Source

A Shade is a very crude description of a region within a manifold. It can be interpreted as either an ellipsoid shape, or as the Gaussian peak of a normal distribution (use http://hackage.haskell.org/package/manifold-random for actually sampling from that distribution).

For a precise description of an arbitrarily-shaped connected subset of a manifold, there is Region, whose implementation is vastly more complex.

Constructors

Shade 

Fields

_shadeCtr :: !(Interior x)
 
_shadeExpanse :: !(Metric' x)
 

pattern (:±) :: () => WithField Manifold x => x -> [Needle x] -> Shade x Source

Span a Shade from a center point and multiple deviation-vectors.

data Shade' x Source

A “co-shade” can describe ellipsoid regions as well, but unlike Shade it can be unlimited / infinitely wide in some directions. It does OTOH need to have nonzero thickness, which Shade needs not.

Constructors

Shade' 

Fields

_shade'Ctr :: !(Interior x)
 
_shade'Narrowness :: !(Metric x)
 

(|±|) :: WithField EuclidSpace x => x -> [Needle x] -> Shade' x Source

Similar to ':±', but instead of expanding the shade, each vector restricts it. Iff these form a orthogonal basis (in whatever sense applicable), then both methods will be equivalent.

Note that '|±|' is only possible, as such, in an inner-product space; in general you need reciprocal vectors (Needle') to define a Shade'.

class IsShade shade where Source

Methods

shadeCtr :: Lens' (shade x) (Interior x) Source

Access the center of a Shade or a Shade'.

occlusion :: (Manifold x, s ~ Scalar (Needle x), RealDimension s) => shade x -> x -> s Source

Check the statistical likelihood-density of a point being within a shade. This is taken as a normal distribution.

factoriseShade :: (Manifold x, RealDimension (Scalar (Needle x)), Manifold y, RealDimension (Scalar (Needle y))) => shade (x, y) -> (shade x, shade y) Source

coerceShade :: (Manifold x, Manifold y, LocallyCoercible x y) => shade x -> shade y Source

Lenses

shadeExpanse :: Lens' (Shade x) (Metric' x) Source

Construction

pointsShades :: WithField Manifold x => [x] -> [Shade x] Source

Attempt to find a Shade that describes the distribution of given points. At least in an affine space (and thus locally in any manifold), this can be used to estimate the parameters of a normal distribution from which some points were sampled. Note that some points will be “outside” of the shade, as happens for a normal distribution with some statistical likelyhood. (Use pointsCovers if you need to prevent that.)

For nonconnected manifolds it will be necessary to yield separate shades for each connected component. And for an empty input list, there is no shade! Hence the result type is a list.

pointsCovers :: forall x. WithField Manifold x => [x] -> [Shade x] Source

Like pointsShades, but ensure that all points are actually in the shade, i.e. if [Shade x₀ ex] is the result then metric (recipMetric ex) (p-x₀) ≤ 1 for all p in the list.

Evaluation

Misc

intersectShade's :: forall y. Refinable y => NonEmpty (Shade' y) -> Option (Shade' y) Source

class WithField Manifold y => Refinable y where Source

Class of manifolds which can use Shade' as a basic set type. This is easily possible for vector spaces with the default implementations.

Minimal complete definition

Nothing

Methods

subShade' :: Shade' y -> Shade' y -> Bool Source

a subShade' b ≡ True means a is fully contained in b, i.e. from minusLogOcclusion' a p < 1 follows also minusLogOcclusion' b p < 1.

refineShade' :: Shade' y -> Shade' y -> Option (Shade' y) Source

convolveShade' :: Shade' y -> Shade' (Needle y) -> Shade' y Source

If p is in a (red) and δ is in b (green), then p.+~^δ is in convolveShade' a b (blue).

Example: https://nbviewer.jupyter.org/github/leftaroundabout/manifolds/blob/master/test/ShadeCombinations.ipynb#shadeConvolutions

Instances

Shade trees

data ShadeTree x Source

Constructors

PlainLeaves [x] 
DisjointBranches !Int (NonEmpty (ShadeTree x)) 
OverlappingBranches !Int !(Shade x) (NonEmpty (DBranch x)) 

Instances

ImpliesMetric ShadeTree Source 
Generic (ShadeTree x) Source 
WithField Manifold x => Monoid (ShadeTree x) Source 
(NFData x, NFData (Needle' x)) => NFData (ShadeTree x) Source 
WithField Manifold x => Semigroup (ShadeTree x) Source

WRT union.

AffineManifold x => Semimanifold (ShadeTree x) Source

Experimental. There might be a more powerful instance possible.

type MetricRequirement ShadeTree x = WithField Manifold x Source 
type Rep (ShadeTree x) Source 
type Needle (ShadeTree x) = Diff x Source 
type Interior (ShadeTree x) = ShadeTree x 

fromLeafPoints :: forall x. WithField Manifold x => [x] -> ShadeTree x Source

Build a quite nicely balanced tree from a cloud of points, on any real manifold.

Example: https://nbviewer.jupyter.org/github/leftaroundabout/manifolds/blob/master/test/Trees-and-Webs.ipynb#pseudorandomCloudTree

onlyLeaves :: WithField Manifold x => ShadeTree x -> [x] Source

Left (and, typically, also right) inverse of fromLeafNodes.

indexShadeTree :: forall x. WithField Manifold x => ShadeTree x -> Int -> Either Int ([ShadeTree x], x) Source

The leaves of a shade tree are numbered. For a given index, this function attempts to find the leaf with that ID, within its immediate environment.

positionIndex Source

Arguments

:: WithField Manifold x 
=> Option (Metric x)

For deciding (at the lowest level) what “close” means; this is optional for any tree of depth >1.

-> ShadeTree x

The tree to index into

-> x

Position to look up

-> Option (Int, ([ShadeTree x], x))

Index of the leaf near to the query point, the “path” of environment trees leading down to its position (in decreasing order of size), and actual position of the found node.

“Inverse indexing” of a tree. This is roughly a nearest-neighbour search, but not guaranteed to give the correct result unless evaluated at the precise position of a tree leaf.

View helpers

onlyNodes :: WithField Manifold x => ShadeTree x -> Trees x Source

Imitate the specialised ShadeTree structure with a simpler, generic tree.

Auxiliary types

type SimpleTree = GenericTree Maybe [] Source

SimpleTree x ≅ Maybe (x, Trees x)

type Trees = GenericTree [] [] Source

Trees x ≅ [(x, Trees x)]

type NonEmptyTree = GenericTree NonEmpty [] Source

NonEmptyTree x ≅ (x, Trees x)

newtype GenericTree c b x Source

Constructors

GenericTree 

Fields

treeBranches :: c (x, GenericTree b b x)
 

Instances

Misc

sShSaw Source

Arguments

:: WithField Manifold x 
=> ShadeTree x

“Reference tree”, defines the cut regions. Must be at least one level of OverlappingBranches deep.

-> ShadeTree x

Tree to take the actual contents from.

-> Sawboneses x

All points within each region, plus those from the boundaries of each neighbouring region.

Saw a tree into the domains covered by the respective branches of another tree.

chainsaw :: WithField Manifold x => Cutplane x -> ShadeTree x -> Sawbones x Source

class HasFlatView f where Source

Associated Types

type FlatView f x Source

Methods

flatView :: f x -> FlatView f x Source

superFlatView :: f x -> [[x]] Source

shadesMerge Source

Arguments

:: WithField Manifold x 
=>

How near (inverse normalised distance, relative to shade expanse) two shades must be to be merged. If this is zero, any shades in the same connected region of a manifold are merged.

-> [Shade x]

A list of n shades.

-> [Shade x]

mn shades which cover at least the same area.

Attempt to reduce the number of shades to fewer (ideally, a single one). In the simplest cases these should guaranteed cover the same area; for non-flat manifolds it only works in a heuristic sense.

smoothInterpolate :: (WithField Manifold x, WithField LinearManifold y) => NonEmpty (x, y) -> x -> y Source

flexTwigsShading :: forall x y f. (WithField Manifold x, WithField Manifold y, Applicative f) => (Shade' (x, y) -> f (x, (Shade' y, LocalLinear x y))) -> (x `Shaded` y) -> f (x `Shaded` y) Source

data WithAny x y Source

Essentially the same as (x,y), but not considered as a product topology. The Semimanifold etc. instances just copy the topology of x, ignoring y.

Constructors

WithAny 

Fields

_untopological :: y
 
_topological :: !x
 

type Shaded x y = ShadeTree (x `WithAny` y) Source

This is to ShadeTree as Map is to Set.

fmapShaded :: (y -> υ) -> (x `Shaded` y) -> x `Shaded` υ Source

stiAsIntervalMapping :: (x ~ , y ~ ) => (x `Shaded` y) -> [(x, ((y, Diff y), Linear x y))] Source

spanShading :: forall x y. (WithField Manifold x, WithField Manifold y) => (Shade x -> Shade y) -> ShadeTree x -> x `Shaded` y Source

type DifferentialEqn x y = Shade (x, y) -> Shade' (LocalLinear x y) Source

propagateDEqnSolution_loc :: forall x y. (WithField Manifold x, Refinable y) => DifferentialEqn x y -> ((x, Shade' y), NonEmpty (Needle x, Shade' y)) -> NonEmpty (Shade' y) Source

Triangulation-builders

type TriangBuild t n x = TriangT t (S n) x (State (Map (SimplexIT t n x) (Metric x, ISimplex (S n) x))) Source

doTriangBuild :: KnownNat n => (forall t. TriangBuild t n x ()) -> [Simplex (S n) x] Source

singleFullSimplex :: forall t n x. (KnownNat n, WithField Manifold x) => ISimplex n x -> FullTriang t n x (SimplexIT t n x) Source

autoglueTriangulation :: forall t n n' n'' x. (KnownNat n'', WithField Manifold x, n ~ S n', n' ~ S n'') => (forall t'. TriangBuild t' n' x ()) -> TriangBuild t n' x () Source

BUGGY: this does connect the supplied triangulations, but it doesn't choose the right boundary simplices yet. Probable cause: inconsistent internal numbering of the subsimplices.

elementaryTriang :: forall n n' x. (KnownNat n', n ~ S n', WithField EuclidSpace x) => Simplex n x -> AutoTriang n x Source

breakdownAutoTriang :: forall n n' x. (KnownNat n', n ~ S n') => AutoTriang n x -> [Simplex n x] Source