Implementation to IEEE Vis 2016 paper

Glyphs for General Second-Order 2D Tensors

This is an implementation of the construction of 2d glyphs presented in the SciVis 2016 paper Glyphs for General Second-Order 2D and 3D Tensors.


You require an installation of the Julia language v0.5 (current release). In Julia, use


For updating the package use



Basic usage

Render a glyph for a tensor J

using TensorGlyph2D   # use the package
J=(rand(2,2)-0.5)*2   # create some tensor
glyph(J)              # render the glyph

The glyph function can take additional options


# default options:
myopts = Options(:show_quadric => false,
                 :show_ellipse => false,
                 :show_modified_ellipse=> false,
                 :show_controlpolygons => false,
                 :filllinewidth => 1.0,
                 :position => [0;0]


Options with prefix :show_ illustrate the construction (if set true) as presented in the paper:

  • :show_quadric and :show_ellipse show the characteristic ellipse before modification (as implicit and piecewise rational quadratic curves w/ eigenvectors/left singular vectors).
  • :show_modified_ellipse shows the characteristic ellipse after modification (e.g., discontinuities).
  • :show_controlpolygons shows the control polygons of the rational pieces for any ellipse that is shown.

The other options affect the rendering

  • :filllinewidth determines the line width for the filled curves. Use 0.0 for vector graphics export! For details see documentation of matplotlib.
  • :position is defines the origin, i.e., the center of the glyph. This option is ignored for any of the :show_ options!


Sample a tensor J from (γ,r)-space, provide context as a quiver plot and render the glyph. (Assume J is the Jacobian matrix of a flow field, and show local context as flow samples v=J*x.)

γ,r = π/8,0.7                  # input
J = GammaR.compose(γ,r)        # get tensor from (γ,r)
TensorGlyph2D.quiver_flow(J)   # show context
glyph(J)                       # draw glyph (over arrow plot)
PyPlot.axis([-1.5,1.5,-1.5,1.5])      # in (γ,r) space, norm(J,2)<=1

The animate function takes either γ or r as linspace of samples and generates an animation. The loop=N option "loops" N times going forth and back. The show_param option visualizes the current point (γ,r) in a second plot.

# vary angle γ with context as quiver plot

# vary radius r and loop animation forth and back

# We can have (γ,r) moving on an arbitrary curve,
# e.g., an Archimedian spiral ("clamped" to the unit circle):
TensorGlyph2D.animate(linspace(0,6π,100);show_param=true) do s

Sample the (γ,r)-space on Cartesian grid.

# require options to set :position below
opts = Options(:filllinewidth => 1.0)

N = 22              # take N×N samples in [0,1]×[0,1]

for x in linspace(-1,1,N), y in linspace(-1,1,N)
  let c=x+y*im, r=abs(c), γ=angle(c)
    if 0<r<=1       # discard invalid samples


Here is the result (click to enlarge):



The implementation does not treat the case r=1/2 (i.e., det(J)==0) special. As required, the glyph "degenerates" to a line. At some point when r approaches 0.5 and the filled shape gets thinner and thinner, [PyPlot] will generate an empty plot. Although this behavior is correct, using a special case with minimum shape dimensions may be preferable.


The main construction if found in TensorGlyph2D.jl with steps as presented in the paper. You can use Options to visualize intermediate steps, e.g., the characteristic ellipse before and after modification and control polygons of the rational quadratic pieces.

gammar.jl provides tools for sampling the (γ,r)-space of tensors (with constrained 2-norm and "factored" domain rotations). In contrast to the original proposal of (γ,r)-parametrization, this present implementation (and its motivation) is based on singular value decomposition and polar decomposition.

The color scheme is defined in colors.jl.

The files quadratics.jl, rationalcurves.jl, piecewise.jl, utilities.jl and animate.jl provide various building blocks and utilities for the construction and for plotting with PyPlot.jl.


  author  = {T. Gerrits and C. R{\"o}ssl and H. Theisel},
  title   = {Glyphs for General Second-Order 2D and 3D Tensors},
  journal = {IEEE Transactions on Visualization and Computer Graphics (Proc. SciVis)},
  year    = {2016},
  pages   = {preprint}