Matlab code of mobius transform
Show older comments
I need to write a code to convert a series of lines into a series of circles, and here are the pictures I have. I know I should use Möbius transformation, and I have searched a lot but I don't understand what I should do. Could anyone help?

1 Comment
Rena Berman
on 4 Jan 2024
(Answers Dev) restored edit
Accepted Answer
More Answers (1)
Hi @SAAAA
I understand that you need to write a code to convert a series of lines into a series of circles. Here is the code you can start with:
% Define the grid of points
[x, y] = meshgrid(linspace(-2, 2, 1000), linspace(-2, 2, 1000));
z = x + 1i * y; % Convert the grid to complex numbers
% Define the Möbius transformation with a fixed point at the origin
a = 0;
b = 1;
c = 1;
d = 0;
f = @(z) (a * z + b) ./ (c * z + d);
% Define the range for the lines
line_range = linspace(-2, 2, 20);
% Plot the original grid
figure;
subplot(1, 2, 1);
hold on;
for k = line_range
plot(x(1, :), k * ones(size(x(1, :))), 'b'); % Horizontal lines
plot(k * ones(size(y(:, 1))), y(:, 1), 'r'); % Vertical lines
end
axis equal;
xlim([-2, 2]);
ylim([-2, 2]);
title('Original Grid');
% Plot the transformed grid
subplot(1, 2, 2);
hold on;
for k = line_range
% Apply the Möbius transformation to each horizontal line
horizontal_line = f(x(1, :) + 1i * k);
plot(real(horizontal_line), imag(horizontal_line), 'b'); % Transformed horizontal lines
% Apply the Möbius transformation to each vertical line
vertical_line = f(k + 1i * y(:, 1));
plot(real(vertical_line), imag(vertical_line), 'r'); % Transformed vertical lines
end
axis equal;
xlim([-1.5, 1.5]); % Adjust axis limits if necessary
ylim([-1.5, 1.5]); % Adjust axis limits if necessary
title('Transformed Grid');
% Make sure the plots hold their properties
hold off;
Thanks,
Ayush
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

