tikz-3dplot:填充 3d 剖面图

tikz-3dplot:填充 3d 剖面图
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{70}{70} 
\begin{tikzpicture}[tdplot_main_coords, scale=2]

    %define coordinates 
    \coordinate (O) at (0,0,0);
    \coordinate (A) at (-0.15,0,-0.1);
    \coordinate (B) at (0.15,0,-0.1);
    \coordinate (C) at (0.15,0,0.1);
    \coordinate (D) at (-0.15,0,0.1);
    \coordinate (E) at (-0.15,0.6,-0.1);
    \coordinate (F) at (0.15,0.6,-0.1);
    \coordinate (G) at (0.15,0.6,0.1);
    \coordinate (H) at (-0.15,0.6,0.1);

    %draw straight-profile
    \draw (A) -- (B) -- (C) -- (D) -- cycle;
    \draw (E) -- (F) -- (G) -- (H) -- cycle;
    \draw (A) -- (E);
    \draw (B) -- (F);
    \draw (C) -- (G);
    \draw (D) -- (H);

    %fill the straight-profile
    \draw[fill=blue, opacity = 0.1] (A) -- (E) -- (H) -- (D);
    \draw[fill=blue, opacity = 0.1] (B) -- (F) -- (G) -- (C);
    \draw[fill=blue, opacity = 0.1] (C) -- (G) -- (H) -- (D);
    \draw[fill=blue, opacity = 0.1] (A) -- (B) -- (F) -- (E);

    %draw bend-profile 
    \tdplotsetrotatedcoords{90}{90}{90}
    \coordinate (bend) at (0,1.1,0.5);
    \tdplotsetrotatedcoordsorigin{(bend)}
    \draw[canvas is zy plane at x = 0.15](-0.1,0.6) arc (0:-90:-0.6);
    \draw[canvas is zy plane at x = -0.15](-0.1,0.6) arc (0:-90:-0.6);
    \draw[canvas is zy plane at x = 0.15](0.1,0.6) arc (0:-90:-0.4);
    \draw[canvas is zy plane at x = -0.15](0.1,0.6) arc (0:-90:-0.4);
    \draw[tdplot_rotated_coords] (-0.15,0,-0.1) -- (0.15,0,-0.1) -- (0.15,0,0.1) -- (-0.15,0,0.1) -- (-0.15,0,-0.1);

    %fill the bend-profile
    %...?

\end{tikzpicture}
\end{document}

在此处输入图片描述

你好,

我遇到了以下问题。我希望黑色弯曲轮廓像直轮廓一样填充蓝色。有人能帮我解决这个问题吗?

谢谢,尼科

答案1

像这样?但它并不像想象的那么整洁……

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{70}
\begin{tikzpicture}
  [
    tdplot_main_coords,
    scale=2,
    my fill/.style={fill=blue, fill opacity=.1}
  ]
  %define coordinates
  \coordinate (O) at (0,0,0);
  \coordinate (A) at (-0.15,0,-0.1);
  \coordinate (B) at (0.15,0,-0.1);
  \coordinate (C) at (0.15,0,0.1);
  \coordinate (D) at (-0.15,0,0.1);
  \coordinate (E) at (-0.15,0.6,-0.1);
  \coordinate (F) at (0.15,0.6,-0.1);
  \coordinate (G) at (0.15,0.6,0.1);
  \coordinate (H) at (-0.15,0.6,0.1);
  % fill and draw the straight-profile
  \draw [my fill] (A) -- (B) -- (F) -- (E) -- cycle;
  \draw [my fill] (A) -- (E) -- (H) -- (D) -- cycle;
  \draw [my fill] (C) -- (G) -- (H) -- (D) -- cycle;
  \draw [my fill] (B) -- (F) -- (G) -- (C) -- cycle;
  % draw bend-profile
  \tdplotsetrotatedcoords{90}{90}{90}
  \coordinate (bend) at (0,1.1,0.5);
  \tdplotsetrotatedcoordsorigin{(bend)}
  % get first coordinate
  \path [canvas is zy plane at x = -0.15] (E) arc (0:-90:-0.6) coordinate (a);
  % draw and fill bend-profile
  \draw [canvas is zy plane at x = -0.15, my fill] (H) arc (0:-90:-0.4) coordinate (d) -- (a) arc (-90:0:-0.6) -- cycle;
  \draw [canvas is zy plane at x = 0.15, my fill] (F) arc (0:-90:-0.6) coordinate (b) -- (a) arc (-90:0:-0.6) -- cycle;
  \draw [canvas is zy plane at x = 0.15, my fill] (G) arc (0:-90:-0.4) coordinate (c) -- (d) arc (-90:0:-.4) -- cycle;
  \draw [canvas is zy plane at x = 0.15, my fill] (G) arc (0:-90:-0.4) coordinate (c) -- (b) arc (-90:0:-.6) -- cycle;
\end{tikzpicture}
\end{document}

3D 填充

相关内容