clear all

% zname veliciny
omega=7.2*pi/180;
F=800*cos(omega);
a=399;
b=570;
e=120.1;
k=520.5;
l=489;
m=577;
p=111.8;
f=m;
alfa_carka=32.6*pi/180;
beta_carka=12.4*pi/180;
delta=69.056*pi/180;
ksi=80.3342*pi/180;
psi=30.6098*pi/180;
h=2.3;
L=175;
Rc=75;
tau=45*pi/180;

Fp=F*cos(tau);
Rp=(Fp*L/Rc);
F1_carka=Rp*sin(62.78*pi/180)/(sin(110.94*pi/180));
F2_carka=Rp*sin(6.28*pi/180)/(sin(110.94*pi/180));
% Reakce
Ra=F*(1-(a/(a+b))); 
Rb=(F*a)/(a+b);
Mc=Rb*e;
% Vnejsi ucinky
F1=((Ra*sin(psi))/(sin(delta))-F1_carka)/h;
F2=((Ra*sin(ksi))/(sin(delta))+F2_carka);
% x1
Fx1=F*sin(16*pi/180);
F1x1=F1*cos(27*pi/180);
% y2
Fy2=F*cos(3.6*pi/180);
F1y2=F1*sin(47*pi/180);
F2y2=F2*cos(34.2*pi/180);
% y3
Rby3=Rb*sin(45*pi/180);
Fy3=F*sin(41.4*pi/180);
F1y3=F1*cos(31.7342*pi/180);
F2y3=F2*sin(14*pi/180);

% Koeficienty
A1=((((l*l/2)-(p*l))*cos(beta_carka))+(((m*m/2)-(f*m))*cos(alfa_carka)));
A2=((k*k/2)+(((p*l)-(l*l/2))*sin(beta_carka))+(sin(alfa_carka)*((f*m)-(m*m/2))));
A3=-k-l-m;

B1=(cos(beta_carka)*cos(beta_carka)*((l*l*l/3)-(p*l*l)+(p*p*l)))+(cos(alfa_carka)*cos(alfa_carka)*((m*m*m/3)-(f*m*m)+(f*f*m)));
B2=(cos(beta_carka)*sin(beta_carka)*((l*l*l/3)-(p*l*l)+(p*p*l)))+(cos(alfa_carka)*sin(alfa_carka)*((m*m*m/3)-(f*m*m)+(f*f*m)));
B3=(cos(beta_carka)*((l*p)-(l*l/2)))+(cos(alfa_carka)*((m*f)-(m*m/2)));

C1=(cos(beta_carka)*sin(beta_carka)*((l*l*l/3)-(p*l*l)+(p*p*l)))+(cos(alfa_carka)*sin(alfa_carka)*((m*m*m/3)-(f*m*m)+(f*f*m)));
C2=(sin(beta_carka)*sin(beta_carka)*((l*l*l/3)-(p*l*l)+(p*p*l)))+(sin(alfa_carka)*sin(alfa_carka)*((m*m*m/3)-(f*m*m)+(f*f*m)));
C3=(k*k/2)+(sin(beta_carka)*((l*p)-(l*l/2)))+(sin(alfa_carka)*((m*f)-(m*m/2)));

D1=(cos(beta_carka)*(((l*l*l/3)*(Fy2+F2y2-F1y2))+((p*l*l)*((F2y2/2)-Fy2+F1y2))+((p*p*l)*(Fy2-F1y2)))+(cos(alfa_carka)*((Mc*(l*l/2))+(Mc*f*m)+((m*m*m/3)*(Rby3+Fy3-F2y3-F1y3))+((f*m*m)*((-Rby3/2)-Fy3+F1y3+F2y3))+((f*f*m)*(Fy3-F1y3-F2y3)))));
D2=((k*k*k/3)*(Fx1-F1x1))+(sin(beta_carka)*(((l*l*l/3)*(Fy2+F2y2-F1y2))+((p*l*l)*((F2y2/2)-Fy2+F1y2))+((p*p*l)*(Fy2-F1y2)))+(sin(alfa_carka)*((Mc*(l*l/2))+(Mc*f*m)+((m*m*m/3)*(Rby3+Fy3-F2y3-F1y3))+((f*m*m)*((-Rby3/2)-Fy3+F1y3+F2y3))+((f*f*m)*(Fy3-F1y3-F2y3)))));
D3=((k*k/2)*(-Fx1-F1x1))+(((l*l/2)*(Fy2-F2y2-F1y2))+((p*l)*(-Fy2+F1y2))+(-Mc*m)+((m*m/2)*(Rby3+Fy3-F2y3-F1y3))+((f*m)*(-Fy3+F1y3+F2y3)));

% Vnitrni ucinky
M1=[A1 B1 C1;A2 B2 C2;A3 B3 C3];
K=[D1 D2 D3]';

N=M1\K;

Ma=N(1,1);
Na=N(2,1);
Ta=N(3,1);
    

disp('Vnitrni ucinky');
disp('Ma=');
disp(Ma);
disp('Na=');
disp(Na);
disp('Ta=');
disp(Ta);

% Vypocet momentu v mistech tenzometru

x1=134.5;
x2=350.5;
x3=118;
x4=340;
x5=140;
x6=450;
Nay2=Na*cos(beta_carka);
Tay2=Ta*sin(beta_carka);
Nay3=Na*cos(alfa_carka);
Tay3=Ta*sin(alfa_carka);

z=438;
t=577;
Mo1=Ma-Ta*x1-Fx1*x1+F1x1*x1;
Mo2=Ma-(Ta*x2)-(Fx1*x2)+(F1x1*x2);
Mo3=Ma-(F2y2*x3)+(Fy2*(x3-p))-(Nay2*(x3-p))-(Tay2*(x3-p))-(F1y2*(x3-p));
Mo4=Ma-(F2y2*x4)+(Fy2*(x4-p))-(Nay2*(x4-p))-(Tay2*(x4-p))-(F1y2*(x4-p));
Mo5=Ma-Mc+(Rby3*x5)+((+Fy3-Nay3+Tay3-F1y3)*(t-x5))+(F2y2*(z-x5));
Mo6=Ma-Mc+(Rby3*x6)+((+Fy3-Nay3+Tay3-F1y3)*(t-x6))+(F2y2*(z-x6));


disp('Momenty');
disp('Mo1=');
disp(Mo1);
disp('Mo2=');
disp(Mo2);
disp('Mo3=');
disp(Mo3);
disp('Mo4=');
disp(Mo4);
disp('Mo5=');
disp(Mo5);
disp('Mo6=');
disp(Mo6);

D1=34.3;
D2=34.3;
D3=38.0;
D4=48.0;
D5=48.0;
D6=48.0;
d1=31.8;
d2=31.8;
d3=35.0;
d4=43.0;
d5=45.0;
d6=45.0;

Wo1=(pi*D1*D1*D1/32)*(1-((d1*d1*d1*d1)/(D1*D1*D1*D1)));
Wo2=Wo1;
Wo3=((pi*D3*D3*D3)/32)*(1-((d3*d3*d3*d3)/(D3*D3*D3*D3)));
Wo4=(pi*D4*D4*D4/32)*(1-((d4*d4*d4*d4)/(D4*D4*D4*D4)));
Wo5=(pi*D5*D5*D5/32)*(1-((d5*d5*d5*d5)/(D5*D5*D5*D5)));
Wo6=Wo5;

sigma1=Mo1/Wo1;
sigma2=Mo2/Wo2;
sigma3=Mo3/(Wo3);
sigma4=Mo4/(Wo4);
sigma5=Mo5/Wo5;
sigma6=Mo6/Wo6;

E1=0.094;
E2=E1;
E3=0.081;
E4=E3;
E5=0.083;
E6=E5;

epsilon1=(sigma1/E1);
epsilon2=(sigma2/E2);
epsilon3=(sigma3/E3);
epsilon4=(sigma4/E4);
epsilon5=(sigma5/E5);
epsilon6=(sigma6/E6);

disp('Pomerne prodlouzeni');
disp('epsilon1=');
disp(epsilon1);
disp('epsilon2=');
disp(epsilon2);
disp('epsilon3=');
disp(epsilon3);
disp('epsilon4=');
disp(epsilon4);
disp('epsilon5=');
disp(epsilon5);
disp('epsilon6=');
disp(epsilon6);
