%-----------------------------------------------------------
% Carlos Cabral 2003 - Dep.UA

% onde se resolve as equaçoes de triangulaçao segundo o modelo predefinido
%-----------------------------------------------------------

clc, clear all

syms x y r1 r2 x1 x2 y1 y2


% solve( '(x-x1)^2+(y-y1)^2-r1^2=0' , '(x-x2)^2+(y-y2)^2-r2^2=0' )


%---------------------------------------------------------------------
% Modelo 1 - Caso 3    ( o o ) distanciados 5400
    
    %x1=0;
    %y1=14400;
    %x2=0;
    %y2=19800;

    %[x y]=solve( '(0-x)^2+(14400-y)^2-r1^2=0' , '(0-x)^2+(19800-y)^2-r2^2=0' )

    %Resultado OBTIDO
    %x =
    %[  1/10800*(-r1^4-850305600000000+58320000*r1^2+58320000*r2^2+2*r1^2*r2^2-r2^4)^(1/2)]
    %[ -1/10800*(-r1^4-850305600000000+58320000*r1^2+58320000*r2^2+2*r1^2*r2^2-r2^4)^(1/2)]
    %y =
    %[ 17100+1/10800*r1^2-1/10800*r2^2]
    %[ 17100+1/10800*r1^2-1/10800*r2^2]

%---------------------------------------------------------------------

%---------------------------------------------------------------------
% Modelo 1 - Caso 3 MODIFICADO   ( o o ) distanciados 5400
    
    %x1=0;
    %y1=5400;
    %x2=0;
    %y2=10800;

    %[x y]=solve( '(0-x)^2+(5400-y)^2-r1^2=0' , '(0-x)^2+(10800-y)^2-r2^2=0' )

    %Resultado OBTIDO     
	%x =
	%[  1/10800*(-r1^4-850305600000000+58320000*r1^2+58320000*r2^2+2*r1^2*r2^2-r2^4)^(1/2)]
	%[ -1/10800*(-r1^4-850305600000000+58320000*r1^2+58320000*r2^2+2*r1^2*r2^2-r2^4)^(1/2)] 
	%y =
	%[ 8100+1/10800*r1^2-1/10800*r2^2]
	%[ 8100+1/10800*r1^2-1/10800*r2^2]


%---------------------------------------------------------------------


%---------------------------------------------------------------------
% Modelo 1 - Caso 2    ( o o ) distanciados 3600
    
    %x1=0;
    %y1=10800;
    %x2=0;
    %y2=14400;

    %[x y]=solve( '(x-0)^2+(y-10800)^2-r1^2=0' , '(x-0)^2+(y-14400)^2-r2^2=0' )

    %Resultado OBTIDO
    %x =
    %[  1/7200*(-r1^4-167961600000000+25920000*r1^2+25920000*r2^2+2*r1^2*r2^2-r2^4)^(1/2)]
    %[ -1/7200*(-r1^4-167961600000000+25920000*r1^2+25920000*r2^2+2*r1^2*r2^2-r2^4)^(1/2)]
    %y =
    %[ 12600+1/7200*r1^2-1/7200*r2^2]
    %[ 12600+1/7200*r1^2-1/7200*r2^2]

%---------------------------------------------------------------------


%---------------------------------------------------------------------
% % Modelo 1 - Caso 1    o   []

    % Lado direito

    %x1=0;
    %y1=5400;
    %x2=3300;
    %y2=5300;

    %[x y]=solve( '(0-x)^2+(5400-y)^2-r1^2=0' , '(3300-x)^2+(5300-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ 1650+33/218000*r1^2-33/218000*r2^2+1/218000*(-r1^4+21800000*r1^2+2*r2^2*r1^2-118810000000000+21800000*r2^2-r2^4)^(1/2)]
    %[ 1650+33/218000*r1^2-33/218000*r2^2-1/218000*(-r1^4+21800000*r1^2+2*r2^2*r1^2-118810000000000+21800000*r2^2-r2^4)^(1/2)]
    %y =
    %[ -1/218000*r1^2+5350+1/218000*r2^2+33/218000*(-r1^4+21800000*r1^2+2*r2^2*r1^2-118810000000000+21800000*r2^2-r2^4)^(1/2)]
    %[ -1/218000*r1^2+5350+1/218000*r2^2-33/218000*(-r1^4+21800000*r1^2+2*r2^2*r1^2-118810000000000+21800000*r2^2-r2^4)^(1/2)]
 
    
    % Lado esquerdo
    
    %x1=0;
    %y1=5400;
    %x2=-3300;
    %y2=5300;

    %[x y]=solve( '(0-x)^2+(5400-y)^2-r1^2=0' , '(-3300-x)^2+(5300-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ -1650+33/218000*r2^2-33/218000*r1^2-1/218000*(-r2^4+21800000*r2^2+2*r1^2*r2^2-118810000000000+21800000*r1^2-r1^4)^(1/2)]
    %[ -1650+33/218000*r2^2-33/218000*r1^2+1/218000*(-r2^4+21800000*r2^2+2*r1^2*r2^2-118810000000000+21800000*r1^2-r1^4)^(1/2)]
    %y =
    %[ 1/218000*r2^2+5350-1/218000*r1^2+33/218000*(-r2^4+21800000*r2^2+2*r1^2*r2^2-118810000000000+21800000*r1^2-r1^4)^(1/2)]
    %[ 1/218000*r2^2+5350-1/218000*r1^2-33/218000*(-r2^4+21800000*r2^2+2*r1^2*r2^2-118810000000000+21800000*r1^2-r1^4)^(1/2)]
%---------------------------------------------------------------------



%---------------------------------------------------------------------
% % Modelo 1 - Caso 4    o   []
    
    % Lado direito
    
    %x1=0;
    %y1=19800;
    %x2=3300;
    %y2=23300;

    %[x y]=solve( '(0-x)^2+(19800-y)^2-r1^2=0' , '(3300-x)^2+(23300-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ 1650+33/462800*r1^2-33/462800*r2^2-7/92560*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]
    %[ 1650+33/462800*r1^2-33/462800*r2^2+7/92560*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]
    %y =
    %[ 7/92560*r1^2+21550-7/92560*r2^2+33/462800*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]
    %[ 7/92560*r1^2+21550-7/92560*r2^2-33/462800*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]

    % Lado esquerdo
    
    %x1=0;
    %y1=19800;
    %x2=-3300;
    %y2=23300;

    %[x y]=solve( '(0-x)^2+(19800-y)^2-r1^2=0' , '(-3300-x)^2+(23300-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ -1650-33/462800*r1^2+33/462800*r2^2+7/92560*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]
    %[ -1650-33/462800*r1^2+33/462800*r2^2-7/92560*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]
    %y =
    %[ 7/92560*r1^2+21550-7/92560*r2^2+33/462800*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]
    %[ 7/92560*r1^2+21550-7/92560*r2^2-33/462800*(-r1^4+46280000*r1^2+2*r2^2*r1^2-535459600000000+46280000*r2^2-r2^4)^(1/2)]
     
%---------------------------------------------------------------------





%---------------------------------------------------------------------
% % Modelo 1 - Caso 5    o   []
    
    % Lado direito
    
    %x1=0;
    %y1=23400;
    %x2=3300;
    %y2=19700;

    %[x y]=solve( '(0-x)^2+(23400-y)^2-r1^2=0' , '(3300-x)^2+(19700-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ 1650+33/491600*r1^2-33/491600*r2^2+37/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]
    %[ 1650+33/491600*r1^2-33/491600*r2^2-37/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]
    %y =
    %[ -37/491600*r1^2+21550+37/491600*r2^2+33/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]
    %[ -37/491600*r1^2+21550+37/491600*r2^2-33/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]
    
    % Lado esquerdo
    
    %x1=0;
    %y1=23400;
    %x2=-3300;
    %y2=19700;

    %[x y]=solve( '(0-x)^2+(23400-y)^2-r1^2=0' , '(-3300-x)^2+(19700-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ -1650-33/491600*r1^2+33/491600*r2^2-37/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]
    %[ -1650-33/491600*r1^2+33/491600*r2^2+37/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]
    %y =
    %[ -37/491600*r1^2+21550+37/491600*r2^2+33/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]
    %[ -37/491600*r1^2+21550+37/491600*r2^2-33/491600*(-r1^4+49160000*r1^2+2*r2^2*r1^2-604176400000000+49160000*r2^2-r2^4)^(1/2)]

%---------------------------------------------------------------------


%---------------------------------------------------------------------
% % Modelo 1 - Caso 6    o   []
    
    % Lado direito
    
    %x1=0;
    %y1=0;
    %x2=3300;
    %y2=5300;

    %[x y]=solve( '(0-x)^2+(0-y)^2-r1^2=0' , '(3300-x)^2+(5300-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ 33/779600*r1^2+1650-33/779600*r2^2-53/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    %[ 33/779600*r1^2+1650-33/779600*r2^2+53/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    %y =
    %[ 53/779600*r1^2-53/779600*r2^2+2650+33/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    %[ 53/779600*r1^2-53/779600*r2^2+2650-33/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    
    % Lado esquerdo
    
    %x1=0;
    %y1=0;
    %x2=-3300;
    %y2=5300;

    %[x y]=solve( '(0-x)^2+(0-y)^2-r1^2=0' , '(-3300-x)^2+(5300-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ -33/779600*r1^2-1650+33/779600*r2^2+53/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    %[ -33/779600*r1^2-1650+33/779600*r2^2-53/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    %y =
    %[ 53/779600*r1^2-53/779600*r2^2+2650+33/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    %[ 53/779600*r1^2-53/779600*r2^2+2650-33/779600*(-r1^4+2*r1^2*r2^2+77960000*r1^2-r2^4+77960000*r2^2-1519440400000000)^(1/2)]
    
%---------------------------------------------------------------------


%---------------------------------------------------------------------
% % Modelo 1 - Caso 7    o   []
    
    % Lado direito
    
    %x1=0;
    %y1=5400;
    %x2=3300;
    %y2=0;

    %[x y]=solve( '(0-x)^2+(5400-y)^2-r1^2=0' , '(3300-x)^2+(0-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ 1650-11/267000*r2^2+11/267000*r1^2+3/44500*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]
    %[ 1650-11/267000*r2^2+11/267000*r1^2-3/44500*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]
    %y =
    %[ 3/44500*r2^2-3/44500*r1^2+2700+11/267000*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]
    %[ 3/44500*r2^2-3/44500*r1^2+2700-11/267000*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]

    % Lado esquerdo
    
    %x1=0;
    %y1=5400;
    %x2=-3300;
    %y2=0;

    %[x y]=solve( '(0-x)^2+(5400-y)^2-r1^2=0' , '(-3300-x)^2+(0-y)^2-r2^2=0' )

    % Resultado OBTIDO
    %x =
    %[ -1650+11/267000*r2^2-11/267000*r1^2-3/44500*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]
    %[ -1650+11/267000*r2^2-11/267000*r1^2+3/44500*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]
    %y =
    %[ 3/44500*r2^2-3/44500*r1^2+2700+11/267000*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]
    %[ 3/44500*r2^2-3/44500*r1^2+2700-11/267000*(-r2^4+2*r2^2*r1^2+80100000*r2^2-r1^4+80100000*r1^2-1604002500000000)^(1/2)]

%---------------------------------------------------------------------


%---------------------------------------------------------------------
% Modelo 1 - Caso 8    ( [] [] ) distanciados 3600
    
    %x1=3300;
    %y1=19700;
    %x2=3300;
    %y2=23300;

    %[x y]=solve( '(3300-x)^2+(19700-y)^2-r1^2=0' , '(3300-x)^2+(23300-y)^2-r2^2=0' )

    %Resultado OBTIDO
    %x =
    %[ 3300+1/7200*(-167961600000000+25920000*r1^2+25920000*r2^2-r2^4+2*r2^2*r1^2-r1^4)^(1/2)]
    %[ 3300-1/7200*(-167961600000000+25920000*r1^2+25920000*r2^2-r2^4+2*r2^2*r1^2-r1^4)^(1/2)]
    %y =
    %[ 21500-1/7200*r2^2+1/7200*r1^2]
    %[ 21500-1/7200*r2^2+1/7200*r1^2]

%---------------------------------------------------------------------

