TransWikia.com

LaTeX: Visualize a roundabout

TeX - LaTeX Asked by LaTeX User. on September 2, 2021

Would it be possible to visualize a roundabout in LaTeX?
There has been a car crash in a roundabout and i would like to visualize it for presenting it very clearly, is this possible? its a two lane roundabout and i would only need to visualize two cars

One Answer

There are multiple ways to approach this, a very simple and straightforward approach is to make use of the polar coordinate system in TikZ together with the relative coordinates. Polar coordinates are given in the form (-10:1.75) where -10 is the angle and 1.75 is the distance from (0,0). Arcs can be drawn by stating arc (290:360:0.2) where 290 is the starting angle, 360 is the ending angle and 0.2 is the radius of the arc.

My basic idea is then to have the center of the roundabout at (0,0) and draw everything around it. The three arms of the roundabout could be located anywhere, therefore it is the easiest to always use the outer circle of the roundabout as the starting point, then draw relatively from there. More sophisticated ways are possible, if you would need this multiple times.

Car and bus symbols are taken from fontawesome, but of course it would be possible to draw them as TikZ pics and then refer to them anytime, if you need them frequently, they could even be configurable shapes in color and type. So here is a very basic way of doing it, that didn't take more than 10 minutes of drawing time:

documentclass[tikz,border=5mm]{standalone}

usepackage{fontawesome}

begin{document}
    begin{tikzpicture}
    draw (0,0) circle (1);
    draw[dashed] (0,0) circle (1.5);
    draw (20:2) arc (20:70:2) arc (250:180:0.2) -- ++(0,1);
    draw (20:2) arc (200:270:0.2) -- ++(1,0);
    draw[dashed] (0,2) -- (0,3);
    draw (-2,0) arc (180:110:2) arc (290:360:0.2) -- ++(0,1);
    draw (-2,0) arc (180:250:2) arc (70:0:0.2) -- ++(0,-1);
    draw[dashed] (0,-2) -- (0,-3);
    draw (-20:2) arc (160:90:0.2) -- ++(1,0);
    draw[dashed] (2,0) -- (3,0);
    draw (-20:2) arc (-20:-70:2) arc (-250:-180:0.2) -- ++(0,-1);
    
    node(mycar) at (-10:1.75){faCar};
    node(accidentbus) at (2.5,0.25){faBus};
    draw[->] (mycar) -- ++(80:0.5);
    draw[->] (accidentbus) -- ++(180:0.5);
    end{tikzpicture}
end{document}

The results looks like this:

enter image description here

Answered by TobiBS on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP