Page 1 of 1

Really Cool LaTeX usage

Posted: Tue Nov 14, 2017 4:04 pm
by IAHM-COL
Reposting from Curtis' Forum, a really awesome application:

https://forum.flightgear.org/viewtopic. ... 65#p322304

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}


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.

Image

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:

Code: Select all

\documentclass[12pt]{article}

Is the document format e font size. If you want a bigger fonts is necessary insert an option:



Do you look this link for more informations:
https://engineering.purdue.edu/ECN/Supp ... ingTheFont

Code: Select all

\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.

Code: Select all

\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.

Code: Select all

[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!

Code: Select all

\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:

Image

Re: Really Cool LaTeX usage

Posted: Tue Nov 14, 2017 5:52 pm
by LesterBoffo
Should be a boon for steam gauge makers, I'm wondering if the fonts include early 20th century text common on most instrument faces of that era.

Re: Really Cool LaTeX usage

Posted: Tue Nov 14, 2017 6:03 pm
by IAHM-COL
latex font packages collections are gigantic.

https://www.google.com/search?q=latex+f ... 19&bih=541

Re: Really Cool LaTeX usage

Posted: Tue Nov 14, 2017 10:50 pm
by Octal450
Will be awesome for my Canvas development!!!!!!!

Kind Regards,
Josh

Re: Really Cool LaTeX usage

Posted: Wed Nov 15, 2017 1:02 am
by jwocky
Image

This is not "medieval" but actually a font used in 15th and 16th century mostly. A little bit before the early 20th century ... but in the Latex catalog. So if they have that, they have also early 20th century, I am pretty sure of it.