Desenhando uma curva parabólica lateral em tikz

Desenhando uma curva parabólica lateral em tikz

Sou capaz de desenhar curvas parabólicas no tikz usando \draweparabola bend

\begin{tikzpicture}
        \draw (-3,4) parabola bend (0,-.5) (3,4);
\end{tikzpicture}

No entanto, gostaria de desenhar esta parábola espelhada na reta y=x. Tentei inserir o que pareciam pontos sensatos:

\begin{tikzpicture}
        \draw (4,-3) parabola bend (-.5,0) (4,3);
\end{tikzpicture}

No entanto, isto cria uma curva quebrada e é bastante claro que o tikz não se destina a receber informações desta forma. Existe alguma maneira de obter uma curva parabólica lateral \drawde maneira semelhante à forma como obtive a primeira curva?

Responder1

O parabolacomando path cria apenas parábolas do tipo y=a*x+b, mas você está livre para girar, dimensionar, inclinar ou qualquer outra coisa. Então você quer espelhar, a questão permanece:Podemos espelhar uma parte no tikz?Ah, sim, podemos:

insira a descrição da imagem aqui

MWE

\documentclass{standalone}
\usepackage{tikz}

% Code from user Qrrbrbirlbel (https://tex.stackexchange.com/a/142491/81905)
\usetikzlibrary{backgrounds}
\makeatletter
\tikzset{
    mirror/.code={\pgfutil@in@{--}{#1}\ifpgfutil@in@\tikz@trans@mirror#1\@nil
        \else\tikz@scan@one@point\pgftransformmirror#1\relax\fi},
    ymirror/.code={\pgfutil@ifnextchar(\tikz@trans@ymirror@coordinate\tikz@trans@ymirror@simple#1\@nil},
    xmirror/.code={\pgfutil@ifnextchar(\tikz@trans@xmirror@coordinate\tikz@trans@xmirror@simple#1\@nil}}
\def\tikz@trans@mirror#1--#2\@nil{%
    \pgfextract@process\pgf@trans@mirror@A{\tikz@scan@one@point\pgfutil@firstofone#1}%
    \pgfextract@process\pgf@trans@mirror@B{\tikz@scan@one@point\pgfutil@firstofone#2}%
    \pgftransformMirror{\pgf@trans@mirror@A}{\pgf@trans@mirror@B}}
\def\pgftransformxmirror#1{\pgfmathparse{2*(#1)}\pgftransformcm{-1}{0}{0}{1}{\pgfqpoint{+\pgfmathresult pt}{+0pt}}}
\def\pgftransformymirror#1{\pgfmathparse{2*(#1)}\pgftransformcm{1}{0}{0}{-1}{\pgfqpoint{+0pt}{+\pgfmathresult pt}}}
\def\tikz@trans@ymirror@simple#1\@nil{
    \pgfmathparse{#1}\let\tikz@temp\pgfmathresult
    \ifpgfmathunitsdeclared
    \pgftransformymirror{\tikz@temp pt}%
    \else
    \pgf@process{\pgfpointxy{0}{\tikz@temp}}%
    \pgftransformymirror{+\the\pgf@y}%
    \fi}
\def\tikz@trans@xmirror@simple#1\@nil{
    \pgfmathparse{#1}\let\tikz@temp\pgfmathresult
    \ifpgfmathunitsdeclared
    \pgftransformxmirror{\tikz@temp pt}%
    \else
    \pgf@process{\pgfpointxy{\tikz@temp}{0}}%
    \pgftransformxmirror{+\the\pgf@x}%
    \fi}
\def\tikz@trans@xmirror@coordinate#1\@nil{\tikz@scan@one@point\pgfutil@firstofone#1\pgftransformxmirror{+\the\pgf@x}}
\def\tikz@trans@ymirror@coordinate#1\@nil{\tikz@scan@one@point\pgfutil@firstofone#1\pgftransformymirror{+\the\pgf@y}}
\def\pgftransformmirror#1{%
    \pgfpointnormalised{#1}%
    \pgf@xa=\pgf@sys@tonumber\pgf@y\pgf@x
    \pgf@xb=\pgf@sys@tonumber\pgf@x\pgf@x
    \pgf@yb=\pgf@sys@tonumber\pgf@y\pgf@y
    \multiply\pgf@xa2\relax
    \pgf@xc=-\pgf@yb\advance\pgf@xc\pgf@xb
    \pgf@yc=-\pgf@xb\advance\pgf@yc\pgf@yb
    \edef\pgf@temp{{\the\pgf@xc}{+\the\pgf@xa}{+\the\pgf@xa}{+\the\pgf@yc}}%
    \expandafter\pgf@transformcm\pgf@temp{\pgfpointorigin}}
\def\pgftransformMirror#1#2{%
    \pgfextract@process\pgf@trans@mirror@A{#1}%
    \pgfextract@process\pgf@trans@mirror@B{#2}%
    \pgfextract@process\pgf@trans@mirror@g{\pgfpointdiff{\pgf@trans@mirror@A}{\pgf@trans@mirror@B}}%
    \pgftransformshift{\pgf@trans@mirror@A}%
    \pgftransformmirror{\pgf@trans@mirror@g}%
    \pgftransformshift{\pgfpointscale{-1}{\pgf@trans@mirror@A}}}
\makeatother
%End of code from Qrrbrbirlbel

\begin{document}
\begin{tikzpicture}
\draw (-3,4) parabola bend (0,-.5) (3,4);
\draw[thick, <->] (-3,0) -- (3,0);
\draw[thick, <->] (0,-3) -- (0,4);
\coordinate (1) at (-3,-3);
\coordinate (2) at (3,3);
\draw[dashed,very thin] (1)--(2);
\draw[mirror=(1)--(2),red] (-3,4) parabola bend (0,-.5) (3,4);
\end{tikzpicture}
\end{document}

Responder2

Uma solução simples a considerar:

\begin{tikzpicture}
        \draw[rotate=-90] (-3,4) parabola bend (0,-.5) (3,4);
\end{tikzpicture}

informação relacionada