%% Circle to circle intersection
%% More details at https://lucidar.me/en/mathematics/how-to-calculate-the-intersection-points-of-two-circles
close all;
clear all;
clc;

%% Parameters of the circles
P1=[3;4]; r1=3.4;
P2=[-1;2]; r2=2.6;

%% Draw circles
drawCircle = @(C,R,color) plot ( C(1) + R*cos([0:0.01:2*pi]) , C(2) + R*sin([0:0.01:2*pi]), color );
figure;
hold on;
grid on;
axis square equal;
drawCircle(P1, r1, 'r');
drawCircle(P2, r2, 'g');

%% Intersection points
[I1, I2] = circlesIntersectionPoints(P1, r1, P2, r2);


plot (I1(1), I1(2), 'o');
plot (I2(1), I2(2), 'o');