trace -package:matrix -package:ghc package:diagrams-lib

Lens onto the Trace of a QDiagram.
"Traces", aka embedded raytracers, for finding points on the edge of a diagram. See Diagrams.Core.Trace for internal implementation details.
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 vector), the trace computes a sorted list of signed distances from the base point to all intersections of the line with the boundary of the diagram. Note that the outputs are not absolute distances, but multipliers relative to the input vector. That is, if the base point is p and direction vector is v, and one of the output scalars is s, then there is an intersection at the point p .+^ (s *^ v).
Compute the "smallest" boundary point along the line determined by the given point p and vector v. The "smallest" boundary point is defined as the one given by p .+^ (s *^ v) for the smallest (most negative) value of s. Return Nothing if there is no such boundary point. See also traceV. See also rayTraceP which uses the smallest positive intersection, which is often more intuitive behavior.
Compute the vector from the given point p to the "smallest" boundary intersection along the given vector v. The "smallest" boundary intersection is defined as the one given by p .+^ (s *^ v) for the smallest (most negative) value of s. Return Nothing if there is no intersection. See also traceP. See also rayTraceV which uses the smallest positive intersection, which is often more intuitive behavior.
Traced abstracts over things which have a trace.
Use the trace from some object as the trace for a diagram, in place of the diagram's default trace.
Like traceP, but computes the "largest" boundary point instead of the smallest. (Note, however, the "largest" boundary point may still be in the opposite direction from the given vector, if all the boundary points are.)
Like traceV, but computes a vector to the "largest" boundary point instead of the smallest. (Note, however, the "largest" boundary point may still be in the opposite direction from the given vector, if all the boundary points are, as in the third example shown below.)
Replace the trace of a diagram.
Mark the trace of a diagram by placing 64 red dots 1/100th its size along the trace.
Mark the trace of a diagram, with control over colour and scale of marker dot and the number of points on the trace.