# ESTSTKrmus.m
function Sj=ESTSTKrmus(xx,Li,Fjoud,qkoormus)
#
#  computed a loading vector for uniformly distributed load 
#  and point load (q + F) for a Gerber's beam
#
##=========================================================================
## This Program is written by Andres Lahe,    2006-02-25
##                    e-mail: andres.lahe@ttu.ee
## LAST MODIFIED: Andres Lahe,    2010-08-13
## Copyright (c)  2006  by Tallinn University of Technology 
##                Department of Mechanics
##                http://www.ttu.ee/
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
## http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
##========================================================================= 
#
#Li         # length of member
#Fjoud     # point load and distance of a load point  from start point
#qkoormus  # uniformly distributed load 
####
l=Li;
#==========
# Point load and distance of a load point  from start point
#       Fz    aF
#==========
#Fjoud=[0.0    0.0;	# force 1
#	 0.0    0.0;	# force 2
#	 0.0    0.0;	# force 3
#	 0.0    0.0;	# force 4
#	 0.0    0.0];	# force 5
#==========
#==========
# Uniformly distributed load and distances of start point and end point
#       qz     qA      qL    L
#==========
#qkoormus=[0.0   0.0   0.0  0.0;	# uniformly distributed load qz1
#          0.0   0.0   0.0  0.0;	# uniformly distributed load qz2
#          0.0   0.0   0.0  0.0];	# uniformly distributed load qz3
#==========
Fjoud;
qkoormus;
 eps1=0.000001;
FARV=size(Fjoud);
NFARV=FARV(1,1);
#
F1=Fjoud(1,1);
AF1=abs(F1);
FjouduS=size(Fjoud);
Fjoudu=FjouduS(1,1);
FZZZ=Fjoud(:,1);
FZZ=find(FZZZ);
FZY=size(FZZ);
Fjoudu=FZY(1,1);
##%http://www.network-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+vFz3+vFz4+vFz5;
##?otherwise
endswitch
else
# disp(' Koondatud force puudub  '); 
vFz=[0.0; 0.0];
endif

##%%%%%%%%%%%%%%%%%%%%
qzv=qkoormus(1,1);
Aq1=abs(qzv);
qZZZ=qkoormus(:,1);
qZZ=find(qZZZ);
qZY=size(qZZ);
qARV=qZY(1,1);
#
if (Aq1-eps1) > 0
switch (qARV)
case{1}
qz=qkoormus(1,1);
aqA=qkoormus(1,2);
Li=qkoormus(1,3); # aqL -kui koormus lõppeb enne lõppu
# Li=qkoormus(1,4); # varda lõpp (vaja kohendada)
if (xx-aqA) >= eps
xarv=xx-aqA;
vB=yzSThqz(xarv,qz);
else
vB(1,1)=0.0;
vB(2,1)=0.0;
##vB(1:2,1);
endif
#Zq0(1,1)=-qz*x;
#Zq0(2,1)=-qz*x^2/2;
#  vaja lisada juht kui koormus lõppeb enne lõppu
case{2}
qz1=qkoormus(1,1);
Li1=qkoormus(1,3);
vB1=yzSThqz(xx,qz1);
qz2=qkoormus(2,1);
Li2=qkoormus(2,3);
vB2=yzSThqz(xx,qz2);
vB=vB1+vB2;
case{3}
qz1=qkoormus(1,1);
Li1=qkoormus(1,3);
vB1=yzSThqz(xx,qz1);
qz2=qkoormus(2,1);
Li2=qkoormus(2,3);
vB2=yzSThqz(xx,qz2);
qz3=qkoormus(3,1);
Li3=qkoormus(3,3);
vB3=yzSThqz(xx,qz3);
vB=vB1+vB2+vB3;
case{4}
qz1=qkoormus(1,1);
Li1=qkoormus(1,3);
vB1=yzSThqz(xx,qz1);
qz2=qkoormus(2,1);
Li2=qkoormus(2,3);
vB2=yzSThqz(xx,qz2);
qz3=qkoormus(3,1);
Li3=qkoormus(3,3);
vB3=yzSThqz(xx,qz3);
qz4=qkoormus(4,1);
Li4=qkoormus(4,3);
vB4=yzSThqz(xx,qz4);
vB=vB1+vB2+vB3+vB4;
##?otherwise
endswitch
else
# disp(' Jaotatud koormus puudub  '); 
vB=[0.0; 0.0];
endif
##%%%%%%%%%%%%%%%%%%%%%%%
vBs=vB+vFz;
Sj=vBs;
#
endfunction
