%% BEGIN pst-stru.tex
%%
%% This extension try to deals with wavelength in optics.
%% Beginning with spectra
%%
%% COPYRIGHT by Giuseppe Mattarazzo, Manuel Luque
%%
%% 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.
%%
\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.13}%
\def\filedate{2015/10/08}%
\message{`PST-Stru v\fileversion, 
    \filedate\space (Giuseppe Matarazzo, Manuel Luque, hv)}%
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\pst@addfams{pst-stru}
%
\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{\pst@object{circput}}
\def\circput@i(#1)(#2)#3#4{{%
  \begin@SpecialObj
  \Pst@Pos=\psk@circuit@Pos pt%
  \multiply\Pst@Pos by 2
  \def\Position{\pst@number\Pst@Pos}
  \pst@getcoor{#1}\pst@tempA
  \pst@getcoor{#2}\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]{#1}{#2}
  \ncput[npos=\Position]{\pnode{Temp}}
  \pcline[linestyle=none,offset=\psk@Dipole@Offset](#1)(Temp)
  \lput{:U}{#3}
  \pcline[linestyle=none,offset=\psk@Label@Offset](#1)(Temp)
  \lput{\psk@Angle@Label}{#4}
  \end@SpecialObj
}\ignorespaces}
% 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{\pst@object{psArrow}}
\def\psArrow@i(#1)(#2)#3{{%
  \begin@SpecialObj
  \pst@getcoor{#1}\pst@tempA
  \pst@getcoor{#2}\pst@tempB
  \pnode(!%
    /stru@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 stru@length Angle cos mul add def
    /YE1 YM stru@length Angle sin mul add def
    XE1 YE1){E@}%
  \pnode(! XM YM){M@@}
  \psset{arrows=->}
  \psline(M@@)(E@)%
  \pcline[linestyle=none,offset=\psk@Label@Offset,arrows=-](M@@)(E@)
  \lput{\psk@Angle@Label}{#3}
  \end@SpecialObj
}\ignorespaces}

%
\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}{\def\psk@circ@RotArrows{#1}}
\psset{RotArrows=0}

\def\psArrowCivil{\pst@object{psArrowCivil}}
\def\psArrowCivil@i(#1)(#2)#3{%
%  \begin@SpecialObj
  \begingroup
  \use@par
  \pst@getcoor{#1}\pst@stru@tempA
  \pst@getcoor{#2}\pst@stru@tempB
  \pnode(!
    /stru@length \psk@circuit@Arrowlenght\space def
    /stru@K \psk@circuit@start\space def
    \pst@stru@tempA /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@stru@tempB /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /stru@XM X1 1 stru@K sub mul X2 stru@K mul add def
    /stru@YM Y1 1 stru@K sub mul Y2 stru@K mul add def
    \pst@stru@tempA /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@stru@tempB /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /stru@Angle Y2 Y1 sub X2 X1 sub Atan def
    /RotArrows 180 90 \psk@circ@RotArrows\space add stru@Angle add sub def
    /XC stru@XM stru@length RotArrows cos mul sub def
    /YC stru@YM stru@length RotArrows sin mul add def
    XC YC){C@}%
  \pnode(! stru@XM stru@YM){M@@}
  \psset{arrows=->}
  \psline(C@)(M@@)%
  \pcline[linestyle=none,offset=\psk@Label@Offset,arrows=-](C@)(M@@)
  %\lput{\psk@Angle@Label}{#3}
  \lput{:U}{#3}
%  \end@SpecialObj
  \endgroup
  \ignorespaces}
%%
%% 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{\pst@object{triload}}
\def\triload@i{{%
  \begin@SpecialObj
  \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.000+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)}
  \end@SpecialObj
}\ignorespaces}
\catcode`\@=\PstAtCode\relax
%%
%% End: Macro \triload %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% END: pst-stru.tex
