## Build a graduate dials with LaTeX

Discussion about creating 2d and 3d cockpits.

### Build a graduate dials with LaTeX

In the construction of the G91-R1B I met the need to make several graduated dials, some of which are quite complex and long to be realized with Inkscape. Not only that, but manual realization often involves problems when changing a dial, for example, if you use a too small font you need to do everything. Inkscape has a scripting language that automates the process, but I find it quite uncomfortable.
Then I would like to be able to include in the documentation, which accompanies most of the objects we make, even the program to make a graduated dial, so that anyone can modify it or use it for other models.
That's why it seemed to me a practical solution to using LaTeX to do this job, because there are many programs in LaTeX that do this job, then, eventually, you can "finish" work with a program like Inkscape and / or Gimp.

The LaTeX code is very simple and this demonstrates the power of this language:

Code: Select all
%POLAR COORDINATES%The print template for A4 paper (portrait)%Author: Zoran Nikolic\documentclass[12pt]{article}\usepackage[margin=0.5in,paper=a4paper]{geometry} %Shrinking margins to 0.5in\usepackage[x11names]{xcolor}                     %Additional colors% TikZ graphivc language is described in: http://cremeronline.com/LaTeX/minimaltikz.pdf\usepackage{tikz}% For the numeric value calculation look this link: https://tex.stackexchange.com/questions/337831/pgfmathparse-basic-usage \begin{document}\thispagestyle{empty} %Please, no page numbers or similar{\fontfamily{qhv}\selectfont  \begin{center}    \begin{tikzpicture}      %1° Rays      \foreach \a in {0, 2,...,340}   \draw[ultra thick] (\a:5.6) -- (\a:6);      %5° Rays      \foreach \a in {0, 10,...,340}   \draw[ultra thick] (\a:5.4) -- (\a:6);            %10° Rays      \foreach \a in {0, 20,...,340}   \draw[ultra thick] (\a:5.2) -- (\a:6);       %Angle labels        \foreach \a in {0, 20,...,340}        \pgfmathtruncatemacro\result{170-\a/2}   \draw (\a: 4.95) node {\rotatebox{90}{\rotatebox{\a}{\result}}};    \end{tikzpicture}  \end{center}}\end{document}

I admit that you have some knowledge of LaTeX and the program installed on your PC, I must point out that LaTeX is not a small program, its average size is about 1.5 GB!
If you do not think you can use LaTeX or its derivative Lyx (which I use as a rewrite) you can always run the program remotely via the link:

https://www.sharelatex.com?r=c988b15a&rm=d&rs=b (in: Test Graduate dials)

The site is very simple, asks only one email address and password to enter, then gives you a workspace where you can enter your text.
I just copied and pasted the code I put in this post and done it all, getting the same result as I get with LaTeX installed on my PC.

At the end of the job you can download the pdf and use it with gimp or Inkscape to modify it appropriately.

Some code notes:

\documentclass[12pt]{article}
Is the document format e font size. If you want a bigger fonts is necessary insert an option:

https://engineering.purdue.edu/ECN/Support/KB/Docs/LaTeXChangingTheFont

\fontfamily{qhv}

Defines the font family to use, LaTeX has many font families, probably there are those you need, if it were not, you need to convert it to LaTeX. Or you can use a PDF editor to edit fonts directly from your PC.

\foreach \a in {0, 2,...,340}
\draw[ultra thick] (\a:5.6) -- (\a:6);

It is the loop that produces the dashes, The loop says that starts from an angle 0, every 2 degrees runs in dash and this up to 340 degrees for 171 times. The second line indicates the smaller diameter (5.6) and the largest diameter (6) within which the dash is made.

[ultra thick]

The keyword [ultra thick] defines the dash thickness, according to LaTeX specifications. It may seem like a limitation, but I assure you that Latex specifications coincide almost always with reality!

\foreach \a in {0, 20,...,340}
\pgfmathtruncatemacro\result{170-\a/2}
\draw (\a: 4.95) node {\rotatebox{90}{\rotatebox{\a}{\result}}};

This specification is more complex as it first calculates the number to be inserted, which depends on the 20 degree step angle, but the value is divided by two and inverted with respect to the standard notation (170- \ a / 2). The value \a is the variable that contains the angle. Always following the code the number is inserted into a box rotated before 90 ° and then the corner. The box is positioned at 4.95 from the center.

It looks very complicated, but is well documented by the tikz package ( https://www.sharelatex.com/learn/TikZ_package ) Tikz is a very synthetic, but powerful, LaTeX package, perhaps one of the best 2D script languages ever made. With this package you can do everything and easily compose both graduated dials and other glass-cockpit objects.

This is the final result:

Last edited by abassign on Tue Nov 14, 2017 12:53 pm, edited 1 time in total.
abassign

Posts: 772
Joined: Mon Feb 27, 2012 5:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2018.3
OS: Linux Mint 19. x

### Re: Build a graduate dials with LaTeX

That's really cool. LaTeX is awesome, but I've never seen it used for this purpose before. Neat idea!

There is also svginstr (by Melchior Franz) which wraps some python helpers around svg. It allows similar scripted instrument construction ... output is svg which can then be converted to png. I've used this to develop several instruments for my UAS ground station. (Some of the instrument graphics in this image come out FlightGear, some are self generated with svginstr ... the panel is rendered in html5, data is fed through a web sockets link to the ground station which in turn is linked to the flying aircraft through a 115 kbaud radio modem.)

Aerospace Engineering and Mechanics
University of Minnesota
curt

Posts: 1173
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

### Re: Build a graduate dials with LaTeX

curt wrote in Tue Nov 14, 2017 12:39 pm:That's really cool. LaTeX is awesome, but I've never seen it used for this purpose before. Neat idea! ...

Thank you, I hope soon to make other dials for instruments the G91-R1B, I will publish them as an example so that others can use them and improve them for other aircraft. The advantage of using LaTeX is that it is very stable over time and can therefore be used for several generations of aircraft without having to make any special changes.
abassign

Posts: 772
Joined: Mon Feb 27, 2012 5:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2018.3
OS: Linux Mint 19. x

### Re: Build a graduate dials with LaTeX

The advantage of using LaTeX is that it is very stable over time

... or maybe several generations of developers!
Aerospace Engineering and Mechanics
University of Minnesota
curt

Posts: 1173
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

### Re: Build a graduate dials with LaTeX

Pretty cool guys, I'm the one who use to expend a lot of time in inkscape to make a dial. I thought should be a better method, now I realize that. So I expended hours loosing my time.

Want to have good ( easy to read ) 2d panels for FG like the ones shown by Curtis.

29.92

Michat

Posts: 958
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense

### Re: Build a graduate dials with LaTeX

There should be a variant of the C172 with a flat 2d panel very similar to the one shown. The tide flows towards detailed 3d cockpits, but for cockpit builders and a few other use cases, 2d cockpits are still pretty essential. My UAS panel is completely disconnected from FlightGear, but is very similar to some of Torsten D's work. The nice thing about a cockpit rendered in html5 is you can use just about any display device in the world ... from phones to tablets to laptops to desktops running any os ... all you need is a web browser. It is extra work to fire up a browser on the right machine and open the right url, but some of that can be automated too.
Aerospace Engineering and Mechanics
University of Minnesota
curt

Posts: 1173
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

### Re: Build a graduate dials with LaTeX

To demonstrate the simplicity of the method I had to expand the numbers because they were too small compared to the actual tool, so I modified the last draw command with a simple attribute: "\LARGE"... which means "very large character" .. and everything it worked well immediately!

First:
Code: Select all
\draw (\a: 4.95) node {\rotatebox{90}{\rotatebox{\a}{\result}}};

After:
Code: Select all
\draw (\a: 4.85) node {\LARGE\rotatebox{90}{\rotatebox{\a}{\result}}};

Result:

Of course I understand that for many LaTeX and Lyx (the most friendly version ...) may seem like extraterrestrial programming languages ... but they are absolutely powerful and synthetic, but not only is it easy to modify them without changing the code too much.
abassign

Posts: 772
Joined: Mon Feb 27, 2012 5:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2018.3
OS: Linux Mint 19. x

### Re: Build a graduate dials with LaTeX

And as a bonus, LaTeX allows you to do these kind of gauges:

Aerospace Engineering and Mechanics
University of Minnesota
curt

Posts: 1173
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

### Re: Build a graduate dials with LaTeX

Actually, you could do Hebrew ones. Or hieroglyphic ones. Or, if the Elves ever fly, tengwar ones. LaTeX is THE typesetting tool once you know how to handle it. There's pretty much no typesetting task it can't do professionally.

For the sake of completeness, for canvas displays I have a bit of code that generates such scales runtime, so no SVG images required at all, just enter the parameters and it pops out on display init. No fancy fonts though...
Thorsten

Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

### Re: Build a graduate dials with LaTeX

Pretty good job guys.
This is fresh air for 2d panels and classic gauges lovers of FG.

Bunch of digital Magenta things out there.

Thanks for sharing. Vivid readers at here.

Michat

Posts: 958
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense

### Re: Build a graduate dials with LaTeX

curt wrote in Tue Nov 14, 2017 4:41 pm:And as a bonus, LaTeX allows you to do these kind of gauges: ...

Fantastic!
abassign

Posts: 772
Joined: Mon Feb 27, 2012 5:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2018.3
OS: Linux Mint 19. x

### Re: Build a graduate dials with LaTeX

@Thorsten i am not surprise that we see an Flightdeck in Elves at the next fsweekend.
www2

Posts: 247
Joined: Thu Apr 16, 2009 1:58 pm

### Re: Build a graduate dials with LaTeX

@abassign: this could be turned into a howto/tutorial for the wiki - if in doubt, just add it to the newsletter. I am sure people will help you review your instructions.
A few more screenshots and/or youtube videos would be nice, though.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray

Posts: 11317
Joined: Tue Mar 25, 2008 8:40 am

### Re: Build a graduate dials with LaTeX

Hooray wrote in Sat Nov 18, 2017 3:22 pm:@abassign: this could be turned into a howto/tutorial for the wiki - if in doubt, just add it to the newsletter. I am sure people will help you review your instructions.
A few more screenshots and/or youtube videos would be nice, though.

Ok
I do it in order to have a reference point on the techniques. I find it very useful to insert some cases I'm using for the G91-R1B that can be useful for most analog gauges.
abassign

Posts: 772
Joined: Mon Feb 27, 2012 5:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2018.3
OS: Linux Mint 19. x

### Re: Build a graduate dials with LaTeX

Apart from that, there are actually dedicated Python/JavaScript libraries available for procedurally creating SVG/vector art - I think Thorsten mentioned already his shape drawing routines, which are serving the same purpose - just using native Canvas/OpenVG APIs instead of going through the SVG/svg.nas layer.

As a matter of fact, if you are interested in portability, that's actually the most reliable method for now - because the SVG parser is really simple and tiny, so you may quickly run into all sorts of issues due to missing features (not implemented), unless of course you export your artwork to a raster image and use that.

I actually once documented the whole process, i.e. covering how to extend the svg.nas module to make it support raster images, too: http://wiki.flightgear.org/Howto:Extend ... SVG_module
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray

Posts: 11317
Joined: Tue Mar 25, 2008 8:40 am

Next