2

I have two non linear lines. and i want create a (horizontal) line between them. I have tried to follow a section from the manual... but it doesn't like it works.

Example from the manual:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \path (30:1cm) node(p1) {$p_1$}   (75:1cm) node(p2) {$p_2$};
  \draw (-0.2,0) -- (1.2,0) node(xline)[right] {$q_1$};
  \draw (2,-0.2) -- (2,1.2) node(yline)[above] {$q_2$};
  \draw[->] (p1) -- (p1 |- xline);
  \draw[->] (p2) -- (p2 |- xline);
  \draw[->] (p1) -- (p1 -| yline);
  \draw[->] (p2) -- (p2 -| yline);
\end{tikzpicture}
\end{document}

Mine piece of code. And a picture of the result so far. The line should go from left to right for now on around (..., 1.5) between the two red lines, and just below the blue one. How can i do this? is this possible?

picture of the code so far

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}[scale=0.8]
    \draw[help lines] (-4,0) grid (4,4);
    \draw[thick] (-4,0) rectangle (4,4);
    \draw[blue, name path=line 1](-4,1.75) -- (4,1.75);
    \draw[red, thick, name path=line 2]  plot [smooth, tension=0.707] coordinates{(-4,0)  (-1.5,3) (4,4)};
    \fill[red,name intersections={of=line 1 and line 2,total=\t}]
    \foreach \s in {1,...,\t}{(intersection-\s) circle (2pt) node {\footnotesize\s}};
    \draw[red, thick, name path=line 3]  plot [smooth, tension=0.707] coordinates{(-4,0)  (1.5,1) (4,4)};
    \fill[red,name intersections={of=line 1 and line 3,total=\t}]
    \foreach \s in {1,...,\t}{(intersection-\s) circle (2pt) node {\footnotesize\s}};
    \draw[<->, green]  (0,1.5) -- (0,1.5 -| line 3); % this line failes
  \end{tikzpicture}
\end{document}
  • 1
    In (0,1.5-|line 3) you should use two coordinates and line 3 is a path. – Ignasi Apr 9 '17 at 19:07
0

Like this?

enter image description here

I'm not sure, between which points should be "green" line. I assume, that it show distance between points s1 and s2. Let me know, if you like to have it somewhere else.

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,intersections}

\begin{document}
    \begin{tikzpicture}
% grid
\draw[help lines] (-4,0) grid (4,4);
\draw[thick] (-4,0) rectangle (4,4);
% curve 1
\draw[red, thick, name path=line 1]  
        plot [smooth, tension=0.707] coordinates {(-4,0)  (-1.5,3) (4,4)};
% curve 2
\draw[red, thick, name path=line 2]  
        plot [smooth, tension=0.707] coordinates {(-4,0)  ( 1.5,1) (4,4)};
% path for determining of intersections
\draw[blue!50,name path=line 3] (-4,1.75) -- (4,1.75);
\fill[red,name intersections={of=line 1 and line 3, by={s1},}] (s1) circle (1pt);
\fill[red,name intersections={of=line 2 and line 3, by={s2},}] (s2) circle (1pt); 
% distancew between s1 and s2
\draw[Straight Barb-Straight Barb, teal]  (s1) -- (s2);
    \end{tikzpicture}
\end{document}
  • It was not exactly what i need but it gave some hints to what i need. Thanks – Jan-Bert Apr 10 '17 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.