Maintainer | diagrams-discuss@googlegroups.com |
---|---|

Safe Haskell | None |

`diagrams-core`

defines the core library of primitives
forming the basis of an embedded domain-specific language for
describing and rendering diagrams.

The `Trace`

module defines a data type and type class for
"traces", aka functional boundaries, essentially corresponding to
embedding a raytracer with each diagram.

- newtype Trace v = Trace {}
- inTrace :: ((Point v -> v -> PosInf (Scalar v)) -> Point v -> v -> PosInf (Scalar v)) -> Trace v -> Trace v
- mkTrace :: (Point v -> v -> PosInf (Scalar v)) -> Trace v
- class (Ord (Scalar (V a)), VectorSpace (V a)) => Traced a where
- traceV :: Traced a => Point (V a) -> V a -> a -> Maybe (V a)
- traceP :: Traced a => Point (V a) -> V a -> a -> Maybe (Point (V a))
- maxTraceV :: Traced a => Point (V a) -> V a -> a -> Maybe (V a)
- maxTraceP :: Traced a => Point (V a) -> V a -> a -> Maybe (Point (V a))

# Traces

Every diagram comes equipped with a *trace*. Intuitively, the
trace for a diagram is like a raytracer: given a line
(represented as a base point and a direction), the trace computes
the distance from the base point along the line to the first
intersection with the diagram. The distance can be negative if
the intersection is in the opposite direction from the base
point, or infinite if the ray never intersects the diagram.
Note: to obtain the distance to the *furthest* intersection
instead of the *closest*, just negate the direction vector and
then negate the result.

Note that the output should actually be interpreted not as an
absolute distance, but as a multiplier relative to the input
vector. That is, if the input vector is `v`

and the returned
scalar is `s`

, the distance from the base point to the
intersection is given by `s * magnitude v`

.

Action Name (Trace v) | |

Show (Trace v) | |

Ord (Scalar v) => Monoid (Trace v) | |

Ord (Scalar v) => Semigroup (Trace v) | |

VectorSpace v => HasOrigin (Trace v) | |

HasLinearMap v => Transformable (Trace v) | |

(Ord (Scalar v), VectorSpace v) => Traced (Trace v) | |

Newtype (QDiagram b v m) (DUALTree (DownAnnots v) (UpAnnots b v m) () (Prim b v)) |

inTrace :: ((Point v -> v -> PosInf (Scalar v)) -> Point v -> v -> PosInf (Scalar v)) -> Trace v -> Trace vSource

# Traced class

class (Ord (Scalar (V a)), VectorSpace (V a)) => Traced a whereSource

`Traced`

abstracts over things which have a trace.

Traced b => Traced [b] | |

Traced b => Traced (Set b) | |

(Ord (Scalar v), VectorSpace v) => Traced (Point v) | The trace of a single point is the empty trace, |

Traced t => Traced (TransInv t) | |

(Ord (Scalar v), VectorSpace v) => Traced (Trace v) | |

(Traced a, Traced b, ~ * (V a) (V b)) => Traced (a, b) | |

Traced b => Traced (Map k b) | |

(Ord (Scalar v), VectorSpace v, HasLinearMap v) => Traced (Subdiagram b v m) | |

(HasLinearMap v, VectorSpace v, Ord (Scalar v)) => Traced (QDiagram b v m) |

# Computing with traces

traceV :: Traced a => Point (V a) -> V a -> a -> Maybe (V a)Source

Compute the vector from the given point to the boundary of the
given object in the given direction, or `Nothing`

if there is no
intersection.

traceP :: Traced a => Point (V a) -> V a -> a -> Maybe (Point (V a))Source

Given a base point and direction, compute the closest point on
the boundary of the given object, or `Nothing`

if there is no
intersection in the given direction.