create a script that can draw three tangent small circles inside a bigger one in matlab

main.m
% Define the radius of the big circle
r = 10;

% Define the radius of the small circles
r_small = 2;

% Define the center of the big circle
center = [0, 0];

% Create a figure
figure;
hold on;

% Plot the big circle
theta = linspace(0, 2*pi, 100);
x = r * cos(theta) + center(1);
y = r * sin(theta) + center(2);
plot(x, y, 'b');

% Define the centers of the small circles
center1 = [r_small/sqrt(3), 0];
center2 = [-r_small/(2*sqrt(3)), r_small/2];
center3 = [-r_small/(2*sqrt(3)), -r_small/2];

% Plot the small circles
theta = linspace(0, 2*pi, 100);
x1 = r_small * cos(theta) + center1(1);
y1 = r_small * sin(theta) + center1(2);
plot(x1, y1, 'r');

x2 = r_small * cos(theta) + center2(1);
y2 = r_small * sin(theta) + center2(2);
plot(x2, y2, 'r');

x3 = r_small * cos(theta) + center3(1);
y3 = r_small * sin(theta) + center3(2);
plot(x3, y3, 'r');

axis equal;
title('Three tangent circles inside a bigger circle');
920 chars
41 lines

This script creates a plot with a big circle and three small circles that are tangent to each other and the big circle.

related categories

gistlibby LogSnag