User Tools

Site Tools


latex:tikz:balconydrop



balconydrop.tex
\documentclass[border=3pt,tikz]{standalone}
\usepackage{amsmath,amssymb}
\usepackage{bm} % math bold
 
\usepackage{tikz}
\usetikzlibrary{patterns}
\tikzset{>=latex}
 
\begin{document}
 
% EXERCISE 1 setup without axes
\def\setup{
  \def\N{20}
  \def\depth{0.25}
  \def\h{6} % height balcony
  \def\w{2} % width ground
  \def\wb{\depth*3} % width balcony
  \def\xland{(\w-\wb*0.8)} % x component of landing position
  \def\xmin{-\depth*3}
  \def\xmax{\w+\depth*3.0}
  \def\ymin{-\depth*3}
  \def\ymax{\h*1.2}
  \def\tmin{0}
  \def\tmax{\xland}
  \def\a{-4.0} % parabola amplitude
  \def\c{(\xland-\h/\xland/\a)} % parabola parameter
 
  % ground, wall, balcony
  \draw[draw=none,pattern color=black!70!white,pattern=north east lines]
    (0,0) -- (0,-\depth) -- (\w+\depth,-\depth) 
      -- (\w+\depth,\h*1.1) -- (\w,\h*1.1) -- (\w,0) -- cycle;
  \draw[thick,black!70!white]
    (0,0) -- (\w,0) -- (\w,\h*1.1);
  \draw[thick,black!70!white,pattern color=black!70!white,pattern=north east lines]
    (\w-\wb,\h-\depth*4) rectangle (\w,\h);
 
  % parabola
  \draw[very thick,black!40!blue,variable=\t,domain=0:\tmax,samples=\N,smooth]
    plot (\t,{\a*\t*(\t-\c)});
}
 
% EXERCISE 1 setup with axes
\begin{tikzpicture}[scale=0.8]
  \setup % axes
  \draw[thick,->] (\xmin,0) -- (\xmax,0) node[anchor=north]       {$x\,[\text{m}]$};
  \draw[thick,->] (0,\ymin) -- (0,\ymax) node[anchor=north east]  {$y\,[\text{m}]$};
  \fill (0,0) circle[radius=2.5pt] node[below left=-1pt] {0};
  \draw[thick]    (+\depth/2,\h) -- (-\depth/2,\h) node[left] {$h$};
\end{tikzpicture}
 
\end{document}
latex/tikz/balconydrop.txt · Last modified: 2018/06/23 13:01 by iwn