clear all
close all
clc

% zadani 
y1=0.25; %[m]
x1=0.5; %[m]
h1=1; %[m]
h2=0.3; %[m]
b1=1.2; %[m]
r=0.2; %[m]

%poloha teziste
xt=(h1*b1*(x1+b1/2)+0.5*b1*h2*(x1+b1/3)-pi*r^2*(x1+b1/2))/(h1*b1+0.5*h2*b1-pi*r^2);
yt=(h1*b1*(y1+h1/2)+0.5*b1*h2*(y1+h1+h2/3)-pi*r^2*(y1+h1/2))/(h1*b1+0.5*h2*b1-pi*r^2);

Ixt=(b1*h1^3)/12+((y1+h1/2-yt)^2)*b1*h1+(b1*h2^3)/36+((y1+h1+h2/3-yt)^2)*0.5*b1*h2-(0.25*pi*r^4+((y1+h1/2-yt)^2)*pi*r^2);
Iyt=(b1^3*h1)/12+((x1+b1/2-xt)^2)*b1*h1+(b1^3*h2)/36+((x1+b1/3-xt)^2)*0.5*b1*h2-(0.25*pi*r^4+((x1+b1/2-xt)^2)*pi*r^2);

Dxtyt=0+abs((x1+b1/2-xt)*(y1+h1/2-yt))*b1*h1+((b1^2)*h2^2)/72+abs((x1+b1/3-xt)*(y1+h1+h2/3-yt))*0.5*b1*h2-abs((y1+h1/2-yt)*(x1+b1/2-xt)*pi*r^2);

% kvadraticke momenty k pootocenym osam
I1=0.5*(Ixt+Iyt)+0.5*sqrt((Ixt-Iyt)^2+4*Dxtyt^2);
I2=0.5*(Ixt+Iyt)-0.5*sqrt((Ixt-Iyt)^2+4*Dxtyt^2);
Imax=max(I1,I2);
Imin=min(I1,I2);

% uhel natoceni souradneho systemu
alpha=0.5*atan(2*Dxtyt/(Iyt-Ixt))*180/pi; %[stupne]

% polomery elipsy
imin=sqrt(Imin/(h1*b1+0.5*h2*b1-pi*r^2))
imax=sqrt(Imax/(h1*b1+0.5*h2*b1-pi*r^2))


