Music.Theory.Diagram.Path

Description

Functions to make path diagrams such as those in Fig. VIII-11 on I.Xenakis Formalized Music.

Synopsis

# Genera

parts :: [a] -> [([a], a, [a])]Source

Set of all (pre,element,post) triples of a sequence.

``` parts "abc" == [("",'a',"bc"),("a",'b',"c"),("ab",'c',"")]
```

parts' :: [a] -> [(a, [a])]Source

All (element,remainder) pairs for a sequence.

``` parts' "abc" == [('a',"bc"),('b',"ac"),('c',"ab")]
```

gather :: Ord a => [(a, i)] -> [(a, [i])]Source

Gather elements with equal keys.

``` gather (zip "abcba" [0..]) == [('a',[0,4]),('b',[1,3]),('c',[2])]
```

# Geometry

ln_on :: Ln R -> Ln R -> BoolSource

Does either endpoint of the lhs `Ln` lie on the rhs `Ln`.

``` ln_on (ln' (1/2,1/2) (1/2,1)) (ln' (0,0) (1,1)) == True
ln_on (ln' (1/2,0) (1/2,1)) (ln' (0,0) (1,1)) == False
```

overlap :: Ln R -> Ln R -> BoolSource

Do `Ln`s overlap in the particular sense of being `ln_parallel` and at least one endpoint of one line lying on the other.

includes :: Ln R -> Ln R -> BoolSource

Do both points of the rhs `Ln` lie on the lhs `Ln`.

`flip` `includes`.

pt_fn :: ((a, a) -> b) -> Pt a -> bSource

Apply f to x and y duple of `Pt`.

ln_fn :: (Num a, Eq a) => ((Pt a, Pt a) -> b) -> Ln a -> bSource

Apply f to start and end `Pt` duple of `Ln`.

ln_pt_fn :: (Num a, Eq a, Num b, Eq b) => (Pt a -> Pt b) -> Ln a -> Ln bSource

Apply f to start and end `Pt`s of `Ln` and construct `Ln`.

to_unit :: R -> [Ln R] -> [Ln R]Source

Scale set of `Ln` to lie in area given by (0,n).

# Orientation

data Orientation a Source

Enumeration of `Vertical`, `Horizontal` and `Diagonal`.

Constructors

 Vertical Horizontal Diagonal a

Instances

 Eq a => Eq (Orientation a) Show a => Show (Orientation a)

orientation :: (Fractional a, Eq a) => Ln a -> Orientation aSource

Calculate `Orientation` of `Ln`.

``` orientation (ln' (0,0) (0,1)) == Vertical
orientation (ln' (0,0) (1,0)) == Horizontal
orientation (ln' (0,0) (1,1)) == Diagonal 1
```

# Shift Map

type Shift_Map a = [(Pt a, [Orientation a])]Source

A table `Pt` and `Orientation` set pairs.

mk_shift_map :: [Ln R] -> Shift_Map RSource

Construct a `Shift_Map` from a set of `Ln`s.

Apply `Shift_Map` to a `Pt`.

Apply `Shift_Map` to a `Ln`.

# Shift table

type Shift_Table a = [(Pt a, Pt a)]Source

A table of `Pt` pairs.

mk_shift_tbl_m :: (Ln R, Bool) -> Maybe (Shift_Table R)Source

Make element of `Shift_Table`.

Make complete `Shift_Table`.

Apply `Shift_Table` to `Ln`.

# Collision table

type Collision_Table = [(Ln R, Bool)]Source

Table of `Ln`s indicating collisions.

Construct `Collision_Table` for a set of `Ln`.

Construct `Shift_Table` from `Collision_Table` and shift all `Ln`.

# Path diagram

type Path_Diagram = [(Int, Int)]Source

A diagram given as a set of `Int` pairs.

Construct set of `Ln` from `Path_Diagram`.

`Collision_Table` based resolution of `Path_Diagram`.

`Shift_Map` variant of `mk_path_ct`.