-1

Sorry for boring you. After reading some answers in TEX stack exchange, it poses no problem to draw a regular cuboid. But, I am wandering someone knows how to draw a curved 'cuboid' as shown in the following fig (in red window). enter image description here Thank you very much for taking a look.

2 Answers2

3

It is fairly straightforward to draw something of this sort, but you'll have to draw additional features in the right order, or to switch to asymptote.

\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{70}{50}
\begin{tikzpicture}[tdplot_main_coords,font=\sffamily]
% Uncomment these lines if you want to know where x, y and z point to
% \draw[-latex] (-7.5,0,0) -- (7.5,0,0)  node[above right]  {$x$};
% \draw[-latex] (0,-7.5,0) -- (0,7.5,0)  node[below] {$y$};
% \draw[-latex] (0,0,-7.5) -- (0,0,7.5)  node[above left]  {$z$};
\tdplotsetrotatedcoords{90}{90}{90}
\begin{scope}[tdplot_rotated_coords]
% Uncomment these lines if you want to know where x', y' and z' point to
% \draw[-latex,blue] (-7.5,0,0) -- (7.5,0,0)  node[above right]  {$x'$};
% \draw[-latex,blue] (0,-7.5,0) -- (0,7.5,0)  node[below] {$y'$};
% \draw[-latex,blue] (0,0,-7.5) -- (0,0,7.5)  node[above left]  {$z'$};
\draw[thick,fill=gray!10] plot[variable=\x,domain={-6:6},samples=120] 
({\x},{4+0.25*\x-0.6*exp(\x-6)},-1) --
plot[variable=\x,domain={6:-6},samples=120] 
({\x},{4+0.25*\x-0.6*exp(\x-6)},1) -- cycle;
\draw[thick,fill=gray!30] (-6,2.5,-1) -- (-6,2.5,1) -- (-5.5,0.5,1) 
--(-5.5,0.5,-1) -- cycle;
\draw[thick,fill=gray!20] plot[variable=\x,domain={-6:6},samples=120] 
({\x},{4+0.25*\x-0.6*exp(\x-6)},-1) --
 plot[variable=\x,domain={6:-6},samples=120] 
({(5.5/6)*\x},{2+0.25*\x-0.6*exp((5.5/6)*\x-6)},-1) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

1

TikZ offers support for 3D coordinates in cartesian (and per example in the manual, cylindrical) coordinates and allows to create your own coordinate system with relative ease. In this question, a spherical coordinate system was implemented, including showing ways of drawing lines and (pseudo-) 3D effects. If you intent to draw your picture, consider a proper coordinate system, set up the projection thereof onto the 2D canvas (can't find the command in the manual right now, but is possible) and then start drawing. For a free-form, it probably best to parse a series of coordinates to a plot operation (can be read from file). If you can describe your points through a mathematical function, consider drawing them with a foreach operation, give them node names and then use line to operations to join up the nodes.

Overall, it is probably better/easier to just parse your image in a svg editor like inkscape and import the svg to tikz. (Inkscape also offers limited LaTeX math support and proper scaling thereof.)

However, given that you already have an image ready, why not just use that? It is accepted practice to put pictures from other programs into articles, books and other documents. No need to spend >6h day drawing coordinates in TeX or >1h redrawing the image in an editor. (Mileage may vary)

Huang_d
  • 1,797