%%
%% This is file `pst-stru.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-stru.tex'
%%
%% Authors  : Giuseppe Matarazza <joematara@hotmail.com>
%%            Manuel LUQUE <Mluque5130@aol.com>
%%            Herbert Voss <voss@pstricks.de>    (pst-xkey)
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-stru' is a PSTricks package for civil engineers
%%
\csname PSTCircLoaded\endcsname
\let\PSTCircLoaded\endinput
% Require PSTricks and pst-node packages
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-plot.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey\fi
%
\def\fileversion{0.12}%
\def\filedate{2006/10/26}%
\message{`PST-Stru v\fileversion, \filedate\space (GM, ML)}%
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\pst@addfams{pst-stru}
%
\SpecialCoor
\psset{dimen=middle}
\newdimen\Start
\newdimen\debut
\newdimen\fin
\newdimen\Pst@Pos
\newcount\PAS
%
\define@boolkey[psset]{pst-stru}[Pst@]{node}[true]{}
\define@key[psset]{pst-stru}{position}{\def\psk@circuit@Pos{#1}}
\define@key[psset]{pst-stru}{OffsetLabel}{\def\psk@Label@Offset{#1}}
\define@key[psset]{pst-stru}{OffsetDipole}{\def\psk@Dipole@Offset{#1}}
\define@key[psset]{pst-stru}{AngleLabel}{\def\psk@Angle@Label{#1}}
\psset{position=0.5,node=false,OffsetLabel=0.70,OffsetDipole=0,AngleLabel=0}
%Commande permettant de placer un dipôle entre deux noeuds
%
\def\circput{\@ifnextchar[{\pst@circput}{\pst@circput[]}}
\def\pst@circput[#1](#2)(#3)#4#5{{%
\psset{#1}
\Pst@Pos=\psk@circuit@Pos pt
\multiply\Pst@Pos by 2
\def\Position{\pst@number\Pst@Pos}
\pst@getcoor{#2}\pst@tempa
\pst@getcoor{#3}\pst@tempb
\pnode(!%
    /k \psk@circuit@Pos\space def
    \pst@tempa /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@tempb /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /XM X1 1 k sub mul X2 k mul add def
    /YM Y1 1 k sub mul Y2 k mul add def
    /deno X2 X1 sub def
    /num Y2 Y1 sub def
    /angle num deno Atan def
    /XE1 XM 1 angle cos mul sub def
    /YE1 YM 1 angle sin mul sub def
    /XE2 XM 1 angle cos mul add def
    /YE2 YM 1 angle sin mul add def
    XM YM){M@}
\pnode(! XE1 YE1){E@1}
\pnode(! XE2 YE2){E@2}
\pcline(E@1)(#2)
\pcline(E@2)(#3)
\ncline[linestyle=none]{#2}{#3}
\ncput[npos=\Position]{\pnode{Temp}}
\pcline[linestyle=none,offset=\psk@Dipole@Offset](#2)(Temp)
\lput{:U}{#4}
\pcline[linestyle=none,offset=\psk@Label@Offset](#2)(Temp)
\lput{\psk@Angle@Label}{#5}
    }}
% Commande permettant de dessiner une flèche de longueur variable
% entre deux noeuds
\define@key[psset]{pst-stru}{length}{\edef\psk@circuit@Arrowlenght{#1}}
\define@key[psset]{pst-stru}{start}{\edef\psk@circuit@start{#1}}
\psset{length=1,start=0.5}
%
\def\psArrow{\@ifnextchar[{\pst@Arrow}{\pst@Arrow[]}}
\def\pst@Arrow[#1](#2)(#3)#4{{%
\psset{#1}
\pst@getcoor{#2}\pst@tempa
\pst@getcoor{#3}\pst@tempb
\pnode(!%
    /length \psk@circuit@Arrowlenght\space def
    /K \psk@circuit@start\space def
    \pst@tempa /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@tempb /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /XM X1 1 K sub mul X2 K mul add def
    /YM Y1 1 K sub mul Y2 K mul add def
    \pst@tempa /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@tempb /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /Angle Y2 Y1 sub X2 X1 sub Atan def
    /XE1 XM length Angle cos mul add def
    /YE1 YM length Angle sin mul add def
    XE1 YE1){E@}%
\pnode(! XM YM){M@@}
\psset{arrows=->}
\psline[#1](M@@)(E@)%
\pcline[linestyle=none,offset=\psk@Label@Offset,arrows=-](M@@)(E@)
\lput{\psk@Angle@Label}{#4}
}}

%
\def\node(#1){%
\pscircle*(#1){2\pslinewidth}
}
\def\arrow{%
    \psline[arrowinset=0,arrowscale=1.0,linewidth=0.75\pslinewidth]{->}(-2,0)(0,0)%
    }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                  Structural Engineering: MACROs
%   Updating:
%   7-10-2003   1) \def\fixedend
%   7-10-2003   2) macro \psArrowCivil
%   8-10-2003   3) macro \psArrowCivil: revised on loads label position
%  11-10-2003   4) \def\hinge, \def\roller, \def\guide, \interhinge,
%                  \def\clockCouple, \def\noclockCouple
%
%  25-10-2003   5) macro \triload for Parameterized Structure ps_01
%   2-11-2003   6) updating the above macro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\fixedend{%
    \psframe[fillstyle=vlines,linestyle=none,hatchwidth=0.5\pslinewidth](-0.5,0)(0.5,-0.2)
    \psline[linewidth=1.5\pslinewidth](-0.5,0)(0.5,0)
    }

\def\hinge{%
    \psframe[fillstyle=vlines,linestyle=none,hatchwidth=0.5\pslinewidth](-0.3,-0.45)(0.3,-0.3)
    \psline[linewidth=1.5\pslinewidth](-0.3,-0.3)(0.3,-0.3)
  \psline(0,0)(-0.3,-0.3)
  \psline(0,0)(0.3,-0.3)
    }

\def\interhinge{%
    \pscircle[fillstyle=solid](0,0){0.1}
    }

\def\guide{%
    \psframe[fillstyle=vlines,linestyle=none,hatchwidth=0.5\pslinewidth](-0.3,-0.3)(0.3,-0.1)
    \psline[linewidth=1.5\pslinewidth](-0.3,-0.1)(0.3,-0.1)
    \psline[linewidth=1.5\pslinewidth](-0.3,0.1)(0.3,0.1)
    \psframe[fillstyle=vlines,linestyle=none,hatchwidth=0.5\pslinewidth](-0.3,0.3)(0.3,0.1)
    }

\def\roller{%
    \psframe[fillstyle=vlines,linestyle=none,hatchwidth=0.5\pslinewidth](-0.3,-0.7)(0.3,-0.5)
    \psline[linewidth=1.5\pslinewidth](-0.3,-0.3)(0.3,-0.3)
  \psline(0,0)(-0.3,-0.3)
  \psline(0,0)(0.3,-0.3)
    \psline(-0.3,-0.5)(0.3,-0.5)
    \pscircle(-0.15,-0.4){0.1}
    \pscircle(0.15,-0.4){0.1}
    }

\def\noclockCouple{%
\psset{arrowsize=1.8mm}
 \psarc{->}(0,0){0.5}{280}{60}
    }

\def\clockCouple{%
\psset{arrowsize=1.8mm}
 \psarc{<-}(0,0){0.5}{120}{260}
    }

%% Macro \psArrowCivil
%% ===================
\define@key[psset]{pst-stru}{RotArrows}{\edef\psk@circ@RotArrows{#1}}
\psset{RotArrows=0}

\def\psArrowCivil{\@ifnextchar[{\pst@ArrowCivil}{\pst@ArrowCivil[]}}

\def\pst@ArrowCivil[#1](#2)(#3)#4{{%
\psset{#1}
\pst@getcoor{#2}\pst@tempa
\pst@getcoor{#3}\pst@tempb
\pnode(!%
    /length \psk@circuit@Arrowlenght\space def
    /K \psk@circuit@start\space def
    \pst@tempa /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@tempb /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /XM X1 1 K sub mul X2 K mul add def
    /YM Y1 1 K sub mul Y2 K mul add def
    \pst@tempa /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@tempb /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /Angle Y2 Y1 sub X2 X1 sub Atan def
    /RotArrows 180 90 \psk@circ@RotArrows\space add Angle add sub def
    /XC XM length RotArrows cos mul sub def
    /YC YM length RotArrows sin mul add def
    XC YC){C@}%
\pnode(! XM YM){M@@}
\psset{arrows=->}
\psline[#1](C@)(M@@)%
\pcline[linestyle=none,offset=\psk@Label@Offset,arrows=-](C@)(M@@)
%\lput{\psk@Angle@Label}{#4}
\lput{:U}{#4}
}}
%%
%% End: Macro \psArrowCivil %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Starting Macro \triload
%% =======================
%
\define@key[psset]{pst-stru}{K}{\edef\psk@triload@K{#1}}
\define@key[psset]{pst-stru}{L}{\edef\psk@triload@L{#1}}
\define@key[psset]{pst-stru}{P}{\edef\psk@triload@P{#1}}
\define@key[psset]{pst-stru}{scaleFactor}{\edef\psk@triload@F{#1}}
\psset{K=3,L=6,P=6,scaleFactor=0.15}
\def\triload{\@ifnextchar[{\pst@triload}{\pst@triload[]}}
\def\pst@triload[#1]{{%
\psset{#1}
\pnode(0,0){A}
\pnode(! /xB \psk@triload@L\space \psk@triload@K\space mul def xB 0){B}
\pnode(! /xC \psk@triload@K\space 1 add \psk@triload@L\space mul def xC 0){C}
%
\pnode(! /xB1 \psk@triload@L\space \psk@triload@K\space mul def xB1 -1){B1}
\pnode(! /xC1 \psk@triload@K\space 1 add \psk@triload@L\space mul def xC1 -1){C1}
%
\pnode(! /xB2 \psk@triload@L\space \psk@triload@K\space mul def xB2 -3){B2}
\pnode(! /xC2 \psk@triload@K\space 1 add \psk@triload@L\space mul def xC2 -3){C2}
%
\pnode(! /xC3 \psk@triload@K\space 1 add \psk@triload@L\space mul 0.25 add def xC3 0.5){C3}
%
\rput{0}(C){\hinge}
\rput{0}(B){\roller}
\psline[linecolor=red,fillcolor=yellow,fillstyle=solid](0,0)(!xC 0)(! xC 1)(0,0)
%
%
  \rput(1,-2){$k=\psk@triload@K\space \quad l=\psk@triload@L\space$}

  \rput(C3){\Large p}

  \rput(0,-0.4){\Large A}
  \rput(B1){\Large B}
  \rput(C1){\Large C}
%
\pcline[offset=0,linecolor=blue]{|-|}(0,-3)(B2)
\lput*{:U}{\bf $k\cdot l$}
\pcline[offset=0,linecolor=blue]{|-|}(B2)(C2)
\lput*{:U}{\bf $l$}

% --------- Triangular Distributed Load -------------------------
\multido{\nStart=1.00+0.025}{-37}{%
\psArrowCivil[RotArrows=0,length=\nStart,start=\nStart,%
       linecolor=magenta](A)(C){}}
% définir les fonctions ici
\pnode(! /func1 {\psk@triload@K\space 1 add \psk@triload@P\space exch div
               -6.0 div \psk@triload@L\space div x mul x mul x mul
                \psk@triload@F\space mul neg} def
         /func2 {\psk@triload@K\space 1 add \psk@triload@P\space exch div
                   -2.0 div \psk@triload@L\space div x mul x mul
                   \psk@triload@F\space mul} def
         /func3 {\psk@triload@K\space 1 add \psk@triload@P\space exch div
               -6.0 div \psk@triload@L\space div x mul x mul x mul
               \psk@triload@K\space \psk@triload@L\space mul neg x add
               \psk@triload@K\space 1 add mul
               \psk@triload@K\space 1 add mul
               \psk@triload@P\space mul 6.0 div \psk@triload@L\space mul add
               \psk@triload@F\space mul neg} def
         /func4 {\psk@triload@K\space 1 add \psk@triload@P\space exch div
                 -2.0 div \psk@triload@L\space div x mul x mul
                 \psk@triload@K\space 1 add
                 \psk@triload@K\space 1 add mul 6.0 div
                 \psk@triload@P\space mul \psk@triload@L\space mul add
                 \psk@triload@F\space mul} def
        0 0){Temp}

%----------- Bending Moment in span AB ----------------------
\pscustom[linecolor=blue,linewidth=1pt,fillstyle=hlines]{
\psplot{0}{xB}{func1}
\psline(B)(A)}
%----------- Shear in span AB ----------------------
\pscustom[linecolor=green,linewidth=1pt,fillstyle=crosshatch]{
    \psplot{0}{xB}{func2}
    \psline(B)(A)}
%
% ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
%
% ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
%
%----------- Bending Moment in span BC ----------------------
\pscustom[linecolor=blue,linewidth=1pt,fillstyle=hlines]{
\psplot{xB}{xC}{func3}
\psline(C)(B)}
%----------- Shear in span BC ----------------------
 \pscustom[linecolor=green,linewidth=1pt,fillstyle=crosshatch]{
 \psplot{xB}{xC}{func4}

% Closing Shear diagram in bearing B (right side)
 \psline(C)(B)(! xB /x xB def func4)}
}}
\catcode`\@=\PstAtCode\relax
%%
%% End: Macro \triload %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% END: pst-stru.tex

