TeX - LaTeX Asked on June 18, 2021
Regarding drawing internal force diagrams through the use of the Stanli package. The following parameters are required for 2D internal forces command:
In addition, the 3D internal forces commands uses the same parameters with 2 extra ones
How can I add an two additional optional parameters to hatch the area under diagram (Area between the parabola and the beam):
Such that if such patterns are not entered, no hatching is applied
MWE is shown below
documentclass{article}
usepackage{amsmath}
usepackage{stanli}
begin{document}
begin{center}
begin{tikzpicture}
draw[help lines,step=0.5](0,0) grid(15,24);
%%%%%%%%%%%%%%%%%%%%%%%%Loading%%%%%%%%%%%%%%%%
point{a-LD}{0}{22.5};
point{b-LD}{10}{22.5};
point{su-LD}{2}{22.5+1.5};
point{s-LD}{2}{22.5};
point{sl-LD}{2}{22.5-0.5};
point{TL-LD}{10}{22.5+2};
point{CAP-LD}{10/2}{22.5-2.5};
% Elements
beam{4}{a-LD}{b-LD};
%Supports
support {1}{a-LD};
support {2}{b-LD};
%Loads
lineload{1}{a-LD}{b-LD}[0][2][0.035]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%First diagram%%%%%%%%%%%%%%%%%%
point{a-FBD}{0}{22.5-6};
point{b-FBD}{10}{22.5-6};
point{TL-FBD}{2*10/3}{22.5-6};
point{TLA-FBD}{2*10/3}{22.5-6+1.75};
point{HR}{0-1.5}{22.5-6};
point{VRA}{0}{22.5-6-1};
point{VRB}{10}{22.5-6-1};
point{CAP-FBD}{10/2}{22.5-6-3.5};
% Elements
beam{4}{a-FBD}{b-FBD};
%%%%%%%%%%%%%%%%%Second diagram%%%%%%%%%%%%%%%%%%
internalforces{a-FBD}{b-FBD}{-3}{6}[0][red]%[0]
point{a-SFD}{0}{22.5-14};
point{b-SFD}{10}{22.5-14};
point{TL-SFD}{2*10/3}{22.5-14};
point{TLA-SFD}{2*10/3}{22.5-14+1.75};
point{VRA}{0}{22.5-14-1};
point{VRB}{10}{22.5-14-1};
point{CAP-SFD}{10/2}{22.5-14-3.5};
% Elements
beam{4}{a-SFD}{b-SFD};
internalforces{a-SFD}{b-SFD}{-3}{6}[3][red]%[0]
end{tikzpicture}
end{center}
newpage
begin{tikzpicture}[coords]
dpoint{a}{0}{0}{0};
dpoint{b}{0}{3}{-1};
dpoint{c}{1.5}{3}{ -1};
dbeam{1}{a}{b}[0][1];
dbeam{1}{b}{c};
dinternalforces{yz}{a}{b}{.5}{-1}[ -.4][blue];
dinternalforces{xz}{b}{c}{1}{0};
end{tikzpicture}
end{document}
This is the macro for the internal force command
% internalforces
%------------------------------------------------
% internalforces{initial point}{end point}{initial value}{end value}[parabola height][color][bend position]
% [parabola height][color][bend position] are optional
%
newcommandx{internalforces}[7][5=0,6=red,7=.6667]{%
coordinate (internalforcesVarA) at ($ (#1)!#3cm!-90:(#2) $);
coordinate (internalforcesVarB) at ($ (#2)!#4cm!90:(#1)$);
coordinate (internalforcesVarAB) at ($ (internalforcesVarA)!.5!(internalforcesVarB)$);
coordinate (internalforcesVarC) at ($ (internalforcesVarAB)+2*(0,#5)$);
coordinate (internalforcesVarAC) at ($ (internalforcesVarA)!#7!(internalforcesVarC)$);
coordinate (internalforcesVarBC) at ($ (internalforcesVarB)!#7!(internalforcesVarC)$);
ifthenelse{equal{#5}{0}}{
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) -- (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}
{
%draw [bigLine,color=#6](internalforcesVarA) parabola[parabola height=#5cm] (internalforcesVarB);
%draw [bigLine,color=#6](internalforcesVarA)--(internalforcesVarAC)--(internalforcesVarBC)--(internalforcesVarB);
%draw [bigLine,color=blue](internalforcesVarA)--(internalforcesVarB)
%(internalforcesVarAB) -- (internalforcesVarC);
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) .. (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}
}
Macro for points
%------------------------------------------------
% point
%------------------------------------------------
% point{name}{x-coordiante}{y-coordiante}
%
newcommandx{point}[3]{
node[coordinate][
shift={(#2*scalingParameter,#3*scalingParameter)}](#1){};
}
`````````````````````````````````````````````````
Macro for beam
`````````````````````````````````````````````````
%------------------------------------------------
% beam
%------------------------------------------------
% beam{type}{initial point}{end point}[rounded initial point][rounded end point]
newcommandx{beam}[5][4=0,5=0]{
ifthenelse{equal{#1}{1}}{ %
draw [hugeLine] (#2) -- (#3);
coordinate (barVarA) at ($ (#2)!barGap!-barAngle:(#3) $);
coordinate (barVarB) at ($ (#3)!barGap!barAngle:(#2) $);
draw [smallLine,dashed] (barVarA) -- (barVarB);
ifthenelse{equal{#4}{0}}{}
{fill (#2) circle (hugeLineWidth/2);}
ifthenelse{equal{#5}{0}}{}
{fill (#3) circle (hugeLineWidth/2);}
}{}
ifthenelse{equal{#1}{2}}{ %
draw [bigLine] (#2) -- (#3);
ifthenelse{equal{#4}{0}}{}
{fill (#2) circle (bigLineWidth/2);}
ifthenelse{equal{#5}{0}}{}
{fill (#3) circle (bigLineWidth/2);}
}{}
ifthenelse{equal{#1}{3}}{ %
draw [normalLine,dashed] (#2) -- (#3);
}{}
ifthenelse{equal{#1}{4}}{ %
draw [hugeLine] (#2) -- (#3);
ifthenelse{equal{#4}{0}}{}
{fill (#2) circle (hugeLineWidth/2);}
ifthenelse{equal{#5}{0}}{}
{fill (#3) circle (hugeLineWidth/2);}
}{}
}
%------------------------------------------------
MAcro for 3Dinternal forces command
``````````````````````````````````````````````
%------------------------------------------------
% 3dinternalforces
%------------------------------------------------
% dinternalforces{plane}[plane distance]{initial point}{end point}{initial value}{end value}[parabola height][color][bend position];
%
newcommandx{dinternalforces}[9][2=0,7=0,8=red,9=.6667]{
%
ifthenelse{equal{#1}{xy}}
{renewcommand{DhelpVarA}{z}}{}
ifthenelse{equal{#1}{yx}}
{renewcommand{DhelpVarA}{z}}{}
ifthenelse{equal{#1}{xz}}
{renewcommand{DhelpVarA}{y}}{}
ifthenelse{equal{#1}{zx}}
{renewcommand{DhelpVarA}{y}}{}
ifthenelse{equal{#1}{yz}}
{renewcommand{DhelpVarA}{x}}{}
ifthenelse{equal{#1}{zy}}
{renewcommand{DhelpVarA}{x}}{}
begin{scope}[canvas is #1 plane at DhelpVarA=#2]
subinternalforces{#3}{#4}{#5}{#6}[#7][#8][#9];
end{scope}
}
newcommandx{subinternalforces}[7][5=0,6=red,7=.6667]{%
coordinate (internalforcesVarA) at ($ (#1)!#3cm!-90:(#2) $);
coordinate (internalforcesVarB) at ($ (#2)!#4cm!90:(#1)$);
coordinate (internalforcesVarAB) at ($ (internalforcesVarA)!.5!(internalforcesVarB)$);
coordinate (internalforcesVarC) at ($ (internalforcesVarAB)+2*(0,#5)$);
coordinate (internalforcesVarAC) at ($ (internalforcesVarA)!#7!(internalforcesVarC)$);
coordinate (internalforcesVarBC) at ($ (internalforcesVarB)!#7!(internalforcesVarC)$);
ifthenelse{equal{#5}{0}}{
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) -- (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (DbigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (DbigLineWidth/2);
fill [color=#6] (#1) circle (DbigLineWidth/2);
fill [color=#6] (#2) circle (DbigLineWidth/2);
}
{
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) .. (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (DbigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (DbigLineWidth/2);
fill [color=#6] (#1) circle (DbigLineWidth/2);
fill [color=#6] (#2) circle (DbigLineWidth/2);
}
}
``````````````````````````````````````````````
[![enter image description here][1]][1]
[![enter image description here][2]][2]
[1]: https://i.stack.imgur.com/IQTkm.jpg
[2]: https://i.stack.imgur.com/m9li2.jpg
code 1: No arguments
documentclass[border=12mm]{standalone}
usepackage{stanli}
newcommandx{internalforcesx}[7][5=0,6=red,7=.6667]{%
coordinate (internalforcesVarA) at ($ (#1)!#3cm!-90:(#2) $);
coordinate (internalforcesVarB) at ($ (#2)!#4cm!90:(#1)$);
coordinate (internalforcesVarAB) at ($ (internalforcesVarA)!.5!(internalforcesVarB)$);
coordinate (internalforcesVarC) at ($ (internalforcesVarAB)+2*(0,#5)$);
coordinate (internalforcesVarAC) at ($ (internalforcesVarA)!#7!(internalforcesVarC)$);
coordinate (internalforcesVarBC) at ($ (internalforcesVarB)!#7!(internalforcesVarC)$);
ifthenelse{equal{#5}{0}}{
fill [pattern=north west lines,pattern color=blue] (#1) -- (internalforcesVarA) --(internalforcesVarB) -- (#2)--cycle;
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) -- (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}{
fill [pattern=north east lines,pattern color=blue] (#1) -- (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) ..(internalforcesVarB) -- (#2)--cycle;
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) .. (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}}
pagestyle{empty}
begin{document}
begin{tikzpicture}
draw[help lines,step=1](0,0) grid(11,20);
point{a-FBD}{0}{22.5-6};
point{b-FBD}{10}{22.5-6};
internalforcesx{a-FBD}{b-FBD}{-3}{6}[0][red]%[0]
beam{4}{a-FBD}{b-FBD};
%+++++++++++++++++++++++
point{a-SFD}{0}{22.5-14};
point{b-SFD}{10}{22.5-14};
internalforcesx{a-SFD}{b-SFD}{-3}{6}[3][red]%[0]
beam{4}{a-SFD}{b-SFD};
end{tikzpicture}
end{document}
code 2: def with arguments
note: Renamed , internalforces
to internalforcesx
newcommandx{internalforcesx}[9][5=0,6=red,7=.6667,8=north west lines,9=white]{%
coordinate (internalforcesVarA) at ($ (#1)!#3cm!-90:(#2) $);
coordinate (internalforcesVarB) at ($ (#2)!#4cm!90:(#1)$);
coordinate (internalforcesVarAB) at ($ (internalforcesVarA)!.5!(internalforcesVarB)$);
coordinate (internalforcesVarC) at ($ (internalforcesVarAB)+2*(0,#5)$);
coordinate (internalforcesVarAC) at ($ (internalforcesVarA)!#7!(internalforcesVarC)$);
coordinate (internalforcesVarBC) at ($ (internalforcesVarB)!#7!(internalforcesVarC)$);
ifthenelse{equal{#5}{0}}{
fill [pattern=#8,pattern color=#9] (#1) -- (internalforcesVarA) --(internalforcesVarB) -- (#2);
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) -- (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}{
fill [pattern=#8,pattern color=#9] (#1) -- (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) ..(internalforcesVarB) -- (#2);
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) .. (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}}
%+++++++++++++++++++++++++++++++++
documentclass[border=12mm]{standalone}
usepackage{stanli}
newcommandx{internalforcesx}[9][5=0,6=red,7=.6667,8=north west lines,9=white]{%
coordinate (internalforcesVarA) at ($ (#1)!#3cm!-90:(#2) $);
coordinate (internalforcesVarB) at ($ (#2)!#4cm!90:(#1)$);
coordinate (internalforcesVarAB) at ($ (internalforcesVarA)!.5!(internalforcesVarB)$);
coordinate (internalforcesVarC) at ($ (internalforcesVarAB)+2*(0,#5)$);
coordinate (internalforcesVarAC) at ($ (internalforcesVarA)!#7!(internalforcesVarC)$);
coordinate (internalforcesVarBC) at ($ (internalforcesVarB)!#7!(internalforcesVarC)$);
ifthenelse{equal{#5}{0}}{
fill [pattern=#8,pattern color=#9] (#1) -- (internalforcesVarA) --(internalforcesVarB) -- (#2);
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) -- (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}{
fill [pattern=#8,pattern color=#9] (#1) -- (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) ..(internalforcesVarB) -- (#2);
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) .. (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (bigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (bigLineWidth/2);
fill [color=#6] (#1) circle (bigLineWidth/2);
fill [color=#6] (#2) circle (bigLineWidth/2);
}}
pagestyle{empty}
begin{document}
begin{tikzpicture}
draw[help lines,step=1](0,0) grid(11,20);
point{a-FBD}{0}{22.5-6};
point{b-FBD}{10}{22.5-6};
internalforcesx{a-FBD}{b-FBD}{-3}{6}[0][red][.6667][north west lines][blue]
beam{4}{a-FBD}{b-FBD};
%+++++++++++++++++++++++
point{a-SFD}{0}{22.5-14};
point{b-SFD}{10}{22.5-14};
%internalforcesx{a-SFD}{b-SFD}{-3}{6}[3][red][.6667][north east lines][blue]
%internalforcesx{a-SFD}{b-SFD}{-3}{6}[3][red][.6667][dots][blue]
internalforcesx{a-SFD}{b-SFD}{-3}{6}[3][red][.6667][crosshatch dots light steel blue]%[blue]
%internalforcesx{a-SFD}{b-SFD}{-3}{6}[3][red][.6667][fivepointed stars][yellow]
beam{4}{a-SFD}{b-SFD};
end{tikzpicture}
end{document}
output:
for 3D: A maximum of 9 arguments can be written, see xargs.pdf or xargs.sty.
documentclass{article}
usepackage{stanli}
% dinternalforces{plane}[plane distance]{initial point}{end point}{initial value}{end value}[parabola height][color][bend position];
newcommandx{dinternalforcesx}[9][2=0,7=0,8=red,9=.6667]{
%
ifthenelse{equal{#1}{xy}}
{renewcommand{DhelpVarA}{z}}{}
ifthenelse{equal{#1}{yx}}
{renewcommand{DhelpVarA}{z}}{}
ifthenelse{equal{#1}{xz}}
{renewcommand{DhelpVarA}{y}}{}
ifthenelse{equal{#1}{zx}}
{renewcommand{DhelpVarA}{y}}{}
ifthenelse{equal{#1}{yz}}
{renewcommand{DhelpVarA}{x}}{}
ifthenelse{equal{#1}{zy}}
{renewcommand{DhelpVarA}{x}}{}
begin{scope}[canvas is #1 plane at DhelpVarA=#2]
subinternalforcesx{#3}{#4}{#5}{#6}[#7][#8][#9];
end{scope}
}
newcommandx{subinternalforcesx}[7][5=0,6=red,7=.6667]{%
coordinate (internalforcesVarA) at ($ (#1)!#3cm!-90:(#2) $);
coordinate (internalforcesVarB) at ($ (#2)!#4cm!90:(#1)$);
coordinate (internalforcesVarAB) at ($ (internalforcesVarA)!.5!(internalforcesVarB)$);
coordinate (internalforcesVarC) at ($ (internalforcesVarAB)+2*(0,#5)$);
coordinate (internalforcesVarAC) at ($ (internalforcesVarA)!#7!(internalforcesVarC)$);
coordinate (internalforcesVarBC) at ($ (internalforcesVarB)!#7!(internalforcesVarC)$);
ifthenelse{equal{#5}{0}}{
fill[pattern=north west lines,pattern color=green] (#1) -- (internalforcesVarA) -- (internalforcesVarB) -- (#2)--cycle;
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) -- (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (DbigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (DbigLineWidth/2);
fill [color=#6] (#1) circle (DbigLineWidth/2);
fill [color=#6] (#2) circle (DbigLineWidth/2);
}
{
fill [pattern=north west lines,pattern color=green] (#1) -- (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) .. (internalforcesVarB) -- (#2);
draw [bigLine,color=#6] (#1) -- (internalforcesVarA) (internalforcesVarA) .. controls (internalforcesVarAC) and (internalforcesVarBC) .. (internalforcesVarB) (internalforcesVarB) -- (#2);
fill [color=#6] (internalforcesVarA) circle (DbigLineWidth/2);
fill [color=#6] (internalforcesVarB) circle (DbigLineWidth/2);
fill [color=#6] (#1) circle (DbigLineWidth/2);
fill [color=#6] (#2) circle (DbigLineWidth/2);
}
}
begin{document}
begin{tikzpicture}[coords]
dpoint{a}{0}{0}{0};
dpoint{b}{0}{3}{-1};
dpoint{c}{1.5}{3}{ -1};
dinternalforcesx{yz}{a}{b}{.5}{-1}[ -.4][blue];
dinternalforcesx{xz}{b}{c}{1}{0};
dbeam{1}{a}{b}[0][1];
dbeam{1}{b}{c};
end{tikzpicture}
end{document}
Correct answer by M.Ahmadi on June 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP