Borrar filtros
Borrar filtros

Having two touching circles, find the third one so it's touching both

2 visualizaciones (últimos 30 días)
Mohamad Harb
Mohamad Harb el 19 de Nov. de 2021
Comentada: Mohamad Harb el 19 de Nov. de 2021
I gave it a try but I can't get the answer. any help please
function [] = circle()
x1=input('Enter the value of x1: ');
x2=input('Enter the value of x2: ');
y1=input('Enter the value of y1: ');
y2=input('Enter the value of y2: ');
r1=input('Enter the value of r1: ');
r2=input('Enter the value of r2: ');
%Consider the triangle C1C2C3
%BC3 = h = the altitude
%Pethagoran theorem: C3C1^2 - BC1^2=C3C2^2 - BC2^2 setting d=BC1
%(r3+r1)^2 - d^2 = (r3+r2)^2 - (r1+r2-d)^2
%d = (r1*(r3+r1)-r2*(r3-r1))/(r1+r2)
%h = sqrt((r3+r1)^2 - d^2)
%set vector u = C2-C1/r1+r2 (the unit vector that point from C1 to C2)
%set vector v = rot(u) = <-uy,ux> (vector u rotated 90 degrees
%counterclockwise)
%then C3 = C1 + du + hv
%C3 = C1 + (d/r1+r2)*(C2-C1) + (h/r1+r2)*rot(C2-C1) then use this equation
%for x3
syms r3 x3 y3
E1 = sqrt((x3-x1)^2 + (y3-y1)^2)-r1-r3==0;
E2 = sqrt((x3-x2)^2 + (y3-y2)^2)-r2-r3==0;
E3 = x1 - x3 + ((r1*(r3+r1)-r2*(r3-r1))/(r1+r2)^2)*(x2-x1) + ((sqrt((r3+r1)^2 - ((r1*(r3+r1)-r2*(r3-r1))/(r1+r2))^2))/(r1+r2))*(x2-x1) == 0;
S = solve(E1,E2,E3);
Center = [S.x3,S.y3];
disp(Center);
disp('radius = ') ,disp(S.r3)
end
  2 comentarios
DGM
DGM el 19 de Nov. de 2021
There are issues, but let's back up first. You're trying to solve for the center and location of a circle that's tangent to two others. There are an infinite number of circles that can do that. It's an underdefined problem.
Mohamad Harb
Mohamad Harb el 19 de Nov. de 2021
Could you help with writing a code about that problem. I know it's underdefined but I want to give it a try.

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by