3

I'd like to draw a tangent curve from point (a) to point (b), intersecting point (c) (the center of the square). The curve should be stretched according to the gray lines (being a logarithmic scale). I've played around with controls, but I didn't get very far. Is there a better way than using controls?

My code so far:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[every node/.style = {draw, circle, fill=white, inner sep=.01cm}]

\draw (0, 1) -- (10, 1) -- (10, -1) -- (0, -1) -- cycle;
\node (a) at (0, -1) {a};   % south-west corner
\node (b) at (10, 1) {b};   % north-east corner
\node (c) at (5, 0) {c};    % center
\foreach \n in {1,...,50} \draw[gray, very thin]
        ({10/pow(2, \n/12)}, 1)
    --  ({10/pow(2, \n/12)}, -1);

\draw[cyan] (a) -- (b);

\end{tikzpicture}
\end{document}

The result: enter image description here

What I want to achieve is the following (although the left half of the curve should decrease more rapidly): enter image description here

  • 2
    Among your trials, have you come across this \draw (0,-1) .. controls (5,-1.0) and (5,1.0) .. (10,1); Further, you could try (5,-1.1) and (5,1.1) pairs too. – Jesse May 12 '14 at 11:50
  • 1
    I don't undersand the "logarithmic" nature of your curve. What is is supposed to increase logarithmically? The derivative of the curve? Then, how could it be tangent to (b)? – JLDiaz May 12 '14 at 12:23
  • 2
    Will this produce what you want? \draw[cyan] (a) to[out=0,in=180] (b); – Gonzalo Medina May 12 '14 at 12:26
  • 1
    Or what about this: \draw[cyan] (a) .. controls +(4, 0) and +(-.5, -.5) .. (c.center) .. controls +(.5,.5) and +(-2,0) .. (b); ? – JLDiaz May 12 '14 at 12:30
  • 1
    Hi, watain, just a thought: Continue searching \draw (0,-1) .. controls (6,-1.0) and (4,1.0) .. (10,1); (7,-1) and (3,1); (8,-1) and (2,1) or any pairs among them, should get one of your expected output. – Jesse May 12 '14 at 12:30
3

May be this comes some what closer?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[every node/.style = {draw, circle, fill=white, inner sep=.01cm}]

\draw (0, 1) -- (10, 1) -- (10, -1) -- (0, -1) -- cycle;
\node (a) at (0, -1) {a};   % south-west corner
\node (b) at (10, 1) {b};   % north-east corner
\node (c) at (5, 0) {c};    % center
\foreach \n in {1,...,50} \draw[gray, very thin]
        ({10/pow(2, \n/12)}, 1)
    --  ({10/pow(2, \n/12)}, -1);

\draw[thick,cyan] (a) to[out=0,in=270,looseness=0.55] (c.center) to[out=65,in=180,looseness=0.5] (b);

\end{tikzpicture}
\end{document}

enter image description here

  • At first I wasn't too keen about using the to[...] syntax, but it seems like it's really the easiest way. It pretty much matches what I needed. Thank you! – watain May 13 '14 at 6:49
2

This is what I get from your description in one of your comments. Was I close to your idea? If not, perhaps you could provide a hand-drawn mockup.

This?

\usetikzlibrary{calc}
\begin{tikzpicture}[every node/.style = {draw, circle, fill=white, inner sep=.01cm}]

\draw (0, 1) -- (10, 1) -- (10, -1) -- (0, -1) -- cycle;
\node (a) at (0, -1) {a};   % south-west corner
\node (b) at (10, 1) {b};   % north-east corner
\node (c) at (5, 0) {c};    % center
\foreach \n in {1,...,50} \draw[gray, very thin]
        ({10/pow(2, \n/12)}, 1)
    --  ({10/pow(2, \n/12)}, -1);

\draw[cyan] (a) .. controls +(5, 0) and +(-.5, -.5) .. (c.center) .. controls +(.5,.5) and +(-1,0) .. (b);
\end{tikzpicture}
  • Thanks for your answer, too bad I can't accept two correct answers - yours seems to be a good alternative to what Harish Kumar posted. – watain May 13 '14 at 6:50
  • 1
    Not worry about the acceptance. More important to me is, if I got it right. Was this the kind of slope you wanted? – JLDiaz May 13 '14 at 8:17
  • Yes, this is the kind of slope that I wanted. Your answer made me understand how controls really works. Harish Kumar's answer just seemed simpler to me, but both are correct. – watain May 13 '14 at 8:43

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.