# How to draw torsion prismatic beams in tikz?

I'm new in Tikz but I want to draw this objects:

Can anyone give some good advice, or help?

• Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. Apr 18, 2015 at 7:29
• not even sure if this is possible, crossing fingers for z buffer=sort to do the trick Apr 18, 2015 at 8:16

Using the assumption that cross-sections behave as rigid bodies:

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}[
declare function={squarex(\t) =
(\t < 0.25) ? 1 : (
(\t < 0.5) ? (1 - (\t-0.25) * 8) : (
(\t < 0.75) ? -1 : (-1 + (\t - 0.75) * 8)
)
;},
declare function={squarey(\t) =
(\t < 0.25) ? (-1 + \t*8) : (
(\t < 0.5) ? 1 : (
(\t < 0.75) ? (1 - (\t - 0.5) * 8) : -1
)
;}
]
\begin{axis}[
axis equal image,
z buffer=sort,
hide axis,
domain=0:1, y domain = 0:10, samples y = 25,
ylabel =y, xlabel=x,
clip=false
]

z buffer=none, domain=0:330, samples y=1,
ultra thick, black, -latex] (
-0.5,
{sin(x)*1.5},
{cos(x)*1.5}
);

y,
{squarex(x) * cos(y*9) - squarey(x) * sin(y*9)},
{squarex(x) * sin(y*9) + squarey(x) * cos(y*9)}
);

\addplot3 [z buffer=auto, fill=yellow!50, draw=black] table {
x y z
10 -1 -1
10 1 -1
10 1 1
10 -1 1
10 -1 -1
};

z buffer=auto, domain=-60:270, samples y=1,
ultra thick, black, latex-] (
10.5,
{sin(x)*1.5},
{cos(x)*1.5}
);
\end{axis}
\end{tikzpicture}
\end{document}

• Thanks, but how can with circle? Apr 18, 2015 at 12:57
• @Acatka: Replace squarex(x) with cos(x*360) and squarey(x) with sin(x*360).
– Jake
Apr 18, 2015 at 13:02
• How can I do with this code a wired model without shading Apr 23, 2015 at 14:14
• The figure looks great, but it's wrong since the cross section is not twisting (it remains rigid in the figure). It would be amazing to have that fixed. Check here. Aug 11, 2020 at 13:54
• @Jake How do you change the extremity as a circle (disc) too? Mar 5, 2023 at 21:01