For the sake of convenience, I've written these small \def
and macro that should help to pretty print point coordinates.
\documentclass{minimal}
\pdfminorversion 7
\pdfobjcompresslevel 3
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{hobby,calc,intersections}
\begin{document}
\begin{tikzpicture}[scale=0.7]
\pgfkeys{/pgf/number format/.cd,fixed,precision=1,dec sep={,}}
\def\pttocm#1{\pgfmathparse{#1 / 19.93333
}\pgfmathprintnumber{\pgfmathresult}}
\newcommand{\printcoords}[1]{
\newdimen\posx
\pgfextractx{\posx}{\pgfpointanchor{#1}{center}}
\newdimen\posy
\pgfextracty{\posy}{\pgfpointanchor{#1}{center}}
(\pttocm\posx ; \pttocm\posy )
}
\draw [thick,->] (-4.3,0) -- (4.3,0) node[below] {$x$} ;
\draw [thick,->] (0,-2.3) -- (0,7.2) node[left] {$y$};
\draw [dotted] (-4.3,-2.3) grid (4.3,7.2) ;
\draw [name path=h,thick] plot [smooth] coordinates {(-4,-2)(-3,2)(-2,6)(0,2)
(2,-2)(3,4)} ;
\draw (0,0) node [below left] {0} ;
\draw (1,0) node [below] {1} ;
\draw (0,1) node [left] {1} ;
\foreach \i in {-4,-3,-2,-1,1,2,3,4}
{ \draw[very thick] (\i,0) -- (\i,-0.15) ; }
\foreach \i in {-2,-1,1,2,3,4,5}
{ \draw[very thick] (0,\i) -- (-0.15,\i) ; }
\foreach \i/\j in { -4/-2, 3/4 }
{ \draw (\i,\j) node[fill,circle, inner sep=1pt] {} ; }
\draw (-3,-1) node[xshift=-2mm,yshift=1mm] {${C}_h$} ;
\draw [name path=g,thick,red] plot[domain=-4.3:4.3]
(\x,{ -(\x-2)*2/3 }) ;
\draw [dashed,very thick,red] (2,0) -- (2,-2) -- (0,-2) ;
\draw [name path=eq,red] (-4.3,2) -- (4.3,2) ;
\path [name intersections ={of = h and eq }] ;
\coordinate (A) at (intersection-1) ;
\draw[red,thick] (A) node[draw,circle] {} ;
\draw[red] (A) node[below left] {\printcoords{A}} ;
\coordinate (B) at (intersection-2) ;
\draw[red,thick] (B) node[draw,circle] {} ;
\draw[red] (B) node[above right] {\printcoords{B}} ;
\coordinate (C) at (intersection-3) ;
\draw[red,thick] (C) node[draw,circle] {} ;
\draw[red] (C) node[above right] {\printcoords{C}} ;
\path [name intersections ={of = h and g }] ;
\coordinate (D) at (intersection-1) ;
\draw[red,thick] (D) node[draw,circle] {} ;
\draw[red] (D) node[above right] {\printcoords{D}} ;
\coordinate (E) at (intersection-2) ;
\draw[red,thick] (E) node[draw,circle] {} ;
\draw[red] (E) node [above right] {\printcoords{E}} ;
\coordinate (F) at (intersection-3) ;
\draw[red,thick] (F) node[draw,circle] {} ;
\draw[red] (F) node[above right] {\printcoords{F}} ;
\end{tikzpicture}
\end{document}
It even handles multiple intersection points, thanks to the intersection library.
let
operation looks like a good fit. You can just golet \p1 (3,4) in (\x1,0) -- (\x1,\y1)
then\x1
and\y1
will hold the3
and4
respectively. You can even do multiple points at once. All of this is within a\path
the TikZ manual discusses it on page 150.