Thinking of a DSL for generating landing pattern diagrams

Our chief glider instructor is writing a book. Currently it's a bunch of Word documents. I offered to typeset it for him (LaTeX). I also thought it would be nice if besides PDF, I could also generate ePub and nice looking web pages. The biggest obstacle he faces right now is making diagrams that look nice. He likes the kind of diagrams in the British Gliding Association Instructor Manual. An example would be page 14-2 at [1].

I already wrote some Racket code to generate diagram components based on runway lengths, pattern altitudes, glide ratio, wind vectors, ... It occurred to me it might be nice to make a DSL so he could experiment with his own diagram thoughts directly. I'm wondering what people's thoughts are, or if anyone has something like this. I do know about the basic drawing packages in Racket. On the Racket/LaTeX side, some of my experiments have been to have Racket functions write TikZ code for me.

A dream I have is to integrate the graphics with 3D imagery such as from Google Earth and to make it interactive. We already use some static images from Google Maps.

Geoff

[1] BGA Instructor Manual, section 3-14 - Pilot & Club Info

2 Likes

I just realized I should look at Pollen again.

I've used Racket to generate more than one dialect of TeX and a lot of HTML, and it works quite well. Actually, just about any time I write non-trivial TeX I end up generating it from Racket.

Pollen is definitely worth looking at. Even if you don't use it directly (I haven't, other than small experiments), it has some good ideas that can be imitated.

For diagrams, there are (at least) two strategies I would consider:

  1. You can create diagrams with pict, metapict, or other Racket libraries and use racket/draw to render them to SVG for HTML or to PDF, PostScript, or Encapsulated PostScript for use from TeX.
  2. If TeX-based libraries work out better for creating these diagrams (even if you are generating the TeX from a Racket front-end), you can convert them to SVG using dvisvgm, which is part of most TeX distributions.

For diagrams that involve text, a particular factor to consider is whether the pipeline preserves the textual data all the way to the final output or whether it converts text to mere vector shapes. In rare cases, if your target can't handle handle the text rendering you need or if there are problematic font issues, you may actually want to convert text to shapes. Usually, though, all other things being equal, it's preferable, to preserve the textual data: it lets Ctrl-F work on text in diagrams, and it can also produce much smaller files to share one reference to a font instead of several copies of letter shapes.

I'm not completely sure where things stand on this at the moment. I know PDFs generated by Slideshow (which uses pict), at least on systems where I've tried it, manage to preserve at least most text information. I can't recall off-hand having checked that this would be preserved in a TeX-generated PDF embedding the racket/draw-generated PDF as a figure, not with racket/draws PS and EPS renderers. I think racket/draw-generated SVGs convert text to shapes, but I haven't checked recently. The answers may depend on the underlying versions of Cairo, Pango, etc. and on what TeX engine you use.

I've used dvisvgm because the state-of-the-art system for typesetting medieval plainchant is essentially a DSL that compiles to LuaTeX. My understanding is that it now is possible to have dvisvgm preserve text data: however, I have not tried this myself yet because, the last time I was tinkering with the insides of my rendering pipeline, the version which added support specifically for LuaTeX native font definitions had not yet made it into the TeXLive distribution I was using. There are various documented caveats reflecting the complexity of the font situation in general, especially across different TeX engines. On the other hand, dvisvgm definitely is capable of rendering figures accurately by reducing text to shapes.

In case it's useful, on this page the modern notation (five-line staff, round noteheads, generated, unfortunately, with non-free software) preserves text as text, so e.g. "O come" is selectable, whereas further down the page the medieval notation (four-line staff, square notes, generated with an older dvisvgm) does not, so e.g. "et nunc et semper" is not selectable.

Incidentally, I've found latexmk useful to manage potentially needing to run LuaLaTeX several times.

For 3D diagrams in Racket, the only thing that comes to mind off-hand is pict3d. I don't remember what it provides by way of rendering or for inserting 3D imagery from elsewhere, though, and the build is currently failing (maybe just because the tests take too long?).

1 Like

I looked into Pict3D year or two ago, and decided it didn't match my needs.
It hs many of the operations needed for so-called "Constructive Solid Geometry", but not all od them.
It has a number of primitive geometric objects (like spheres, boxes, etc, the ability to take their union, choose colours, and apply various distortions and twists.

But what it lacks are:

  • any mechanism for appying textures to surfaces
  • and subtraction of one object from another, This is needed to cut a hole in an existing object, for example, to cut a window fron a wall.

It was not what I needed.

With enough understanding of its source code, someone might add these operations. But it doesn't look easy.

-- hendrik

@hendrikboom3

Ruckus has more 3d primitives.
It's supposed to be a procedural CAD, so I don't know whether it can be used for games.
Maybe it can be used to produce models, that can be used in anonther engine?

https://docs.racket-lang.org/ruckus/index.html

1 Like