[AJUDA] Tikz 3D

11 views
Skip to first unread message

Allexandre Fortes

unread,
May 3, 2022, 2:02:57 PMMay 3
to Latex-br
Olá! Tudo bem? Eu gostaria de plotar a seguinte figura usando o Tikz:

plot.png

entretanto, não consegui achar uma forma de escrevê-la. Usando o código abaixo, eu obtenho:
\begin{tikzpicture}
                                %eixos
                                \coordinate (O) at (0,0,0);
                               
                                \draw[very thick,->] (O) -- (7,0,0) node[anchor=north east]{$x_1$};
                                \draw[very thick,->] (O) -- (0,7,0) node[anchor=north east]{$f(x_1,x_2)$};
                                \draw[very thick,->] (O) -- (0,0,7) node[anchor=north east]{$x_2$};
                               
                                %função
                                \coordinate (C) at (2.5,6,2.5);
                               
                                \draw [red] (C) circle [radius=1];
                                \draw [blue, dashed](C) circle [radius=.8];
                                                              
                            \end{tikzpicture}
plot2.png
Desde já, muito obrigado

Manuel Castro Avila

unread,
May 3, 2022, 2:35:29 PMMay 3
to late...@googlegroups.com
Não é exatamente a resposta que procura,  porém, ao invés de criar a figura usando Tikz, talvez seja mais fácil desenhar a figura usando inkscape ou outra ferramenta similar, e exportar a figura no formato adequado. Usando Tikz me parece que daria mais trabalho.


--
Você recebeu essa mensagem porque está inscrito no grupo "Latex-br" dos Grupos do Google.
Para cancelar inscrição nesse grupo e parar de receber e-mails dele, envie um e-mail para latex-br+u...@googlegroups.com.
Para ver essa discussão na Web, acesse https://groups.google.com/d/msgid/latex-br/4165e3c4-64da-4aa3-836c-0d2cae60095dn%40googlegroups.com.


--



Emílio Kavamura

unread,
May 4, 2022, 7:57:36 AMMay 4
to Latex-br

Emílio Kavamura

unread,
May 4, 2022, 7:59:06 AMMay 4
to Latex-br
Esqueci de postar um exemplo:

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}
\usepackage[utf8]{inputenc}

\makeatletter
\def\tikz@td@retrieve@current@basis{%
\pgfmathsetmacro{\tikz@td@currentxx}{\pgf@xx/1cm}%
\pgfmathsetmacro{\tikz@td@currentxy}{\pgf@xy/1cm}%
\pgfmathsetmacro{\tikz@td@currentyx}{\pgf@yx/1cm}%
\pgfmathsetmacro{\tikz@td@currentyy}{\pgf@yy/1cm}%
\pgfmathsetmacro{\tikz@td@currentzx}{\pgf@zx/1cm}%
\pgfmathsetmacro{\tikz@td@currentzy}{\pgf@zy/1cm}%
\pgfmathsetmacro{\tikz@td@currentxz}{(\tikz@td@currentyx)*(\tikz@td@currentzy)-(\tikz@td@currentzx)*(\tikz@td@currentyy)}%
\pgfmathsetmacro{\tikz@td@currentyz}{(\tikz@td@currentzx)*(\tikz@td@currentxy)-(\tikz@td@currentxx)*(\tikz@td@currentzy)}%
\pgfmathsetmacro{\tikz@td@currentzz}{(\tikz@td@currentxx)*(\tikz@td@currentyy)-(\tikz@td@currentyx)*(\tikz@td@currentxy)}%
}
\tikzset{rotate about z axis/.code={%
\tikz@td@retrieve@current@basis
\pgfmathsetmacro{\newxx}{(\tikz@td@currentxx)*cos(#1)+(\tikz@td@currentxy)*sin(#1)}%
\pgfmathsetmacro{\newxy}{-1*(\tikz@td@currentxx)*sin(#1)+(\tikz@td@currentxy)*cos(#1)}%
\pgfmathsetmacro{\newyx}{(\tikz@td@currentyx)*cos(#1)+(\tikz@td@currentyy)*sin(#1)}%
\pgfmathsetmacro{\newyy}{-1*(\tikz@td@currentyx)*sin(#1)+(\tikz@td@currentyy)*cos(#1)}%
\tikzset{x={(\newxx cm,\newxy cm)},y={(\newyx cm,\newyy cm)},z={(\tikz@td@currentzx cm,\tikz@td@currentzy cm)}}%
},rotate about y axis/.code={%
\tikz@td@retrieve@current@basis
\pgfmathsetmacro{\newxx}{(\tikz@td@currentxx)*cos(#1)+(\tikz@td@currentxz)*sin(#1)}%
\pgfmathsetmacro{\newzx}{(\tikz@td@currentzx)*cos(#1)+(\tikz@td@currentzz)*sin(#1)}%
\tikzset{x={(\newxx cm,\tikz@td@currentxy cm)},
y={(\tikz@td@currentyx cm,\tikz@td@currentyy cm)},z={(\newzx cm,\newzy cm)}}%
},,rotate about x axis/.code={%
\tikz@td@retrieve@current@basis
\pgfmathsetmacro{\newyy}{(\tikz@td@currentyy)*cos(#1)+(\tikz@td@currentyz)*sin(#1)}%
\pgfmathsetmacro{\newzy}{(\tikz@td@currentzy)*cos(#1)+(\tikz@td@currentzz)*sin(#1)}%
\tikzset{x={(\tikz@td@currentxx cm,\tikz@td@currentxy cm)},
y={(\tikz@td@currentyx cm,\newyy cm)},z={(\tikz@td@currentzx cm,\newzy cm)}}%
}}
\makeatother



\begin{document}


\begin{tikzpicture}
           
            %eixos
            \coordinate (O) at (0,0,0);
           
            \draw[very thick,-stealth] (O) -- (7,0,0) node[anchor=north east]{$x_1$};
            \draw[very thick,-stealth] (O) -- (0,7,0) node[anchor=north east]{$f(x_1,x_2)$};
            \draw[very thick,-stealth] (O) -- (0,0,7) node[anchor=north east]{$x_2$};

           
            %função
            \coordinate (C) at (2.5,6,2.5);
           
            \draw [red] (C) circle [radius=1];
            \draw [blue, dashed](C) circle [radius=.8];
           
            \path (0,0,0) coordinate (O) (6,5,3) coordinate (O');
            \begin{scope}[rotate about x axis=-45,canvas is xy plane at z=0,shift={(O')}]
                %Circle in transformed xy plane at z=0
                \path[fill=red!20!white, draw=black, dashed] circle[radius=10mm];
            \end{scope}
            \draw [dotted](6,5,3) -- +(0,-5,0)-- +(0,-5,-3) ; \draw [dotted](6,0,3) -- +(-6,0,0);
               
                                                             
\end{tikzpicture}

\end{document}Screenshot from 2022-05-04 08-40-23.png
Reply all
Reply to author
Forward
0 new messages