close all
clear all

R=12;
L=25;
P=6;
C=18;
D=12;
%R*cos(fi)=P+L*cos(pi/2-fi)
Fi0 = (-2)*atan((L - (L^2 - P^2 + R^2)^(1/2))/(P + R));
disp(['Fi0 = ' num2str(0)])
disp(['Fi0 = ' num2str(Fi0*180/pi)])

servacomp(0,R,L,C,P,30,-1.95,2.45,0,0)
servacomp(0,R,L,C,P,30,0,0,2.3,-2.1)
servacomp(Fi0*180/pi,R,L,C,P,30,-4.05,0.25,0,0)
servacomp(Fi0*180/pi,R,L,C,P,30,0,0,5.75,-0.25)
servacykl(0,R,L,C,D,30,-1.95,2.45,0,0)
servacykl(0,R,L,C,D,30,0,0,2.3,-2.1)
servacykl(Fi0*180/pi,R,L,C,D,30,-4.05,0.25,0,0)
servacykl(Fi0*180/pi,R,L,C,D,30,0,0,5.75,-0.25)
%simple(solve('V=P*sin(pu)+T*sin(tu)-X*sin(xu)','L=-P*cos(pu)+X*cos(xu)+T*cos(tu)','xu'))

%solve('T*cos(x)=V+X*cos(arcsin((P*sin(u)+T*sin(x)-V)/X))-P*cos(u)','x')
%2*atan((2*L*X + (- L^4*tan(1/2*fi)^4 - 2*L^4*tan(1/2*fi)^2 - L^4 - 8*L^3*P*tan(1/2*fi)^3 - 8*L^3*P*tan(1/2*fi) - 2*L^2*P^2*tan(1/2*fi)^4 - 20*L^2*P^2*tan(1/2*fi)^2 - 2*L^2*P^2 - 4*L^2*P*V*tan(1/2*fi)^4 + 4*L^2*P*V + 2*L^2*T^2*tan(1/2*fi)^4 + 4*L^2*T^2*tan(1/2*fi)^2 + 2*L^2*T^2 - 2*L^2*V^2*tan(1/2*fi)^4 - 4*L^2*V^2*tan(1/2*fi)^2 - 2*L^2*V^2 + 2*L^2*X^2*tan(1/2*fi)^4 + 4*L^2*X^2*tan(1/2*fi)^2 + 2*L^2*X^2 - 8*L*P^3*tan(1/2*fi)^3 - 8*L*P^3*tan(1/2*fi) - 16*L*P^2*V*tan(1/2*fi)^3 + 16*L*P^2*V*tan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