Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function XY = task5 (C1, C2)
- wrapper = @(x) g(x, C1, C2);
- # если они вообще пересекаются
- A = -2 * (C2(1) - C1(1));
- B = -2 * (C2(2) - C1(2));
- C = (C2(1) - C1(1))^2 + (C2(2) - C1(2))^2 + C1(3)^2 - C2(3)^2;
- R = C1(3);
- D = A^2 + B^2;
- hold on;
- grid on;
- phi = -2*pi():0.01:2*pi();
- plot(C1(1) + C1(3) * cos(phi), C1(2) + C1(3) * sin(phi));
- plot(C2(1) + C2(3) * cos(phi), C2(2) + C2(3) * sin(phi));
- # честно спжно с e-maxx
- if (C^2 - R^2 * D <= 0)
- # 2 одинаковые точки же не ошибка? типа, потом можно удалить ненужные
- XY = [ fsolve(wrapper, [C1(1) - C2(3), C1(2) - C1(3)]); fsolve(wrapper, [C1(1) + C1(3), C1(2) + C1(3)]) ].';
- plot(XY(1, :), XY(2, :), "p");
- endif
- endfunction
- function y = g (x, C1, C2)
- y(1) = (x(1) - C1(1))^2 + (x(2) - C1(2))^2 - C1(3)^2;
- y(2) = (x(1) - C2(1))^2 + (x(2) - C2(2))^2 - C2(3)^2;
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement