function Zq=ylqvII(baasi0,S,x,lp,qz,EA,EJ)
#  loading vector for tuniformly distributed load of the second order 
#  analysis for a frame (Sign Convention 2), where
#  qz - uniformly distributed load along the z-axis,
#  EA - axial stiffness of the element
#  EJ - bending stiffness of the element
#  baasi0 - scaling multiplier for the displacements (i = EJ/l)
#  S - axial force
# [Up Wp Fip Sv Hp Mp] = ylfII*[Uv Wv Fiv Sv Hv Mv]
#
##=========================================================================
## This Program is written by Andres Lahe,   1998-05-22
##                    e-mail: andres.lahe@ttu.ee
## LAST MODIFIED: Andres Lahe,   2009-02-17
## Copyright (c)  1998 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
##==========
##
l=lp;
#lp=l;
   qx=0.0;
#
   EA=1.0;
#
  mark1='-'; mark2='+';
#
 if S>=0
    mark=mark2;
 end
 if S<0 
    mark=mark1;
 end
  eps1=0.000001; eps2=0.0000001;
     nu=tnnusarv(lp,S,EJ);
# compression
 if strcmp(mark1,mark) == 1
   if nu <=eps1
     nu=nu+eps1; 
     S=0.0;
     Zq=yzhqz(baasi0,x,qx,qz,EA,EJ);
   else
     cs=cos(nu*x/l);
     ss=sin(nu*x/l);
 Zq(1,1)=0;
 Zq(2,1)=baasi0*(qz*l^4/EJ)*(nu^2*x^2/(l^2)-2*(1-cs))/(2*nu^4);
 Zq(3,1)=baasi0*qz*l^3*(-nu*x/l+ss)/(nu^3*EJ);
 Zq(4,1)=0;
 Zq(5,1)=-qz*x;
 Zq(6,1)=qz*l^2*(-1+cs)/nu^2;
   end
 end
# tension
  if strcmp(mark2,mark) == 1
   if nu <=eps1
     nu=nu+eps1; 
     S=0.0;
     Zq=yzhqz(baasi0,x,qx,qz,EA,EJ);
   else
     cs=cosh(nu*x/l);
     ss=sinh(nu*x/l);
 Zq(1,1)=0;
 Zq(2,1)=baasi0*(qz*l^4/EJ)*(-nu^2*x^2/(l^2)-2*(1-cs))/(2*nu^4);
 Zq(3,1)=baasi0*qz*l^3*(nu*x/l-ss)/(nu^3*EJ);
 Zq(4,1)=0;
 Zq(5,1)=-qz*x;
 Zq(6,1)=qz*l^2*(1-cs)/nu^2;
   end
 end
# 
