tikz: curley brace in a non-parallel plane

by jakun   Last Updated July 12, 2019 12:23 PM - source

I am trying to denote some lengthes in a three dimensional tikz figure. But the result looks weird because the curley braces are not properly transformed. The transform shape option (which does the trick for the labels) has no effect on the braces. I have also tried to replace the brces by arrows but that is not much better because the arrow tips are not transformed either.

How can I draw curley braces or arrows in a plane which is not parallel to the paper?

\documentclass[border=.2cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{decorations.pathreplacing}

\usepackage{graphicx}
\newcommand{\mirror}{\scalebox{-1}[1]}

\tikzset{%
    % changing the axis to point in the directions that I am used to from school:
    % x-axis pointing toward the reader,
    % y-axis pointing right and
    % z-axis pointing up
    % using the same lengthes as TikZ' default settings specified in it's documentation on page 134
    3D/.style={
        x={(-3.85mm, -3.85mm)},
        y={(1cm, 0cm)},
        z={(0cm, 1cm)},
    },
}

\begin{document}
\begin{tikzpicture}[3D]
    \newcommand{\width}{2}
    \newcommand{\height}{1}

    \newcommand{\axislength}{2}
    \draw[gray, ->] (0,0,0) -- (\axislength,0,0) node[below left] {$x$};
    \draw[gray, ->] (0,0,0) -- (0,\axislength,0) node[right] {$y$};
    \draw[gray, ->] (0,0,0) -- (0,0,\axislength) node[above] {$z$};

    \begin{scope}[canvas is xz plane at y=0, transform shape]
        \newcommand{\distance}{.5em}
        \draw (0,0) rectangle ++(-\width, \height);
        \draw[decorate,decoration={brace}] (\distance, 0) -- node[right]{\mirror{$h$}} ++(0, \height);
        \draw[decorate,decoration={brace}] (0,0) ++(0, \height) ++(0, \distance) -- node[above]{\mirror{$w$}} ++(-\width, 0);
%       \draw[<->] (0,0) ++(.5em, 0) -- node[right]{\mirror{$h$}} ++(0, \height);
%       \draw[<->] (0,0) ++(0, \height) ++(0, .5em) -- node[above]{\mirror{$w$}} ++(-\width, 0);
    \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Tags : tikz-pgf tikz-3d


Related Questions




Drawing similar picture with tikz

Updated November 20, 2018 12:23 PM

Complicated curves interwined in the link figures

Updated December 17, 2018 22:23 PM

Complicated curves intertwined in the link figures (II)

Updated December 18, 2018 02:23 AM