Representation of Gabriel's Horn
3 views (last 30 days)
Show older comments
Athanasios Paraskevopoulos
on 22 Jul 2024
Answered: Star Strider
on 23 Jul 2024
By reading the following very interesting paper An Understanding of a Solid with Finite Volume and Infinite Surface Area. I tried to create a code in matlab to give me the same result as in the image above. How could I have a sharper visualization of the trumpet especially where it opens ?
% Define the function for Gabriel's Horn
gabriels_horn = @(x) 1 ./ x;
% Create a range of x values
x = linspace(1, 40, 4000); % Increase the number of points for better accuracy
y = gabriels_horn(x);
% Create the meshgrid
theta = linspace(0, 2 * pi, 6000); % Increase theta points for a smoother surface
[X, T] = meshgrid(x, theta);
Y = gabriels_horn(X) .* cos(T);
Z = gabriels_horn(X) .* sin(T);
% Plot the surface of Gabriel's Horn
figure('Position', [200, 100, 1200, 900]);
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.9);
hold on;
% Plot the central axis
plot3(x, zeros(size(x)), zeros(size(x)), 'r', 'LineWidth', 2);
% Set labels
xlabel('x');
ylabel('y');
zlabel('z');
% Adjust colormap and axis properties
colormap('gray');
shading interp; % Smooth shading
% Adjust the view
view(3);
axis tight;
grid on;
% Add formulas as text annotations
dim1 = [0.4 0.7 0.3 0.2];
annotation('textbox',dim1,'String',{'$$V = \pi \int_{1}^{a} \left( \frac{1}{x} \right)^2 dx = \pi \left( 1 - \frac{1}{a} \right)$$', ...
'', ... % Add an empty line for larger gap
'$$\lim_{a \to \infty} V = \lim_{a \to \infty} \pi \left( 1 - \frac{1}{a} \right) = \pi$$'}, ...
'Interpreter','latex','FontSize',12, 'EdgeColor','none', 'FitBoxToText', 'on');
dim2 = [0.4 0.5 0.3 0.2];
annotation('textbox',dim2,'String',{'$$A = 2\pi \int_{1}^{a} \frac{1}{x} \sqrt{1 + \left( -\frac{1}{x^2} \right)^2} dx > 2\pi \int_{1}^{a} \frac{dx}{x} = 2\pi \ln(a)$$', ...
'', ... % Add an empty line for larger gap
'$$\lim_{a \to \infty} A \geq \lim_{a \to \infty} 2\pi \ln(a) = \infty$$'}, ...
'Interpreter','latex','FontSize',12, 'EdgeColor','none', 'FitBoxToText', 'on');
% Add Gabriel's Horn label
dim3 = [0.3 0.9 0.3 0.1];
annotation('textbox',dim3,'String','Gabriel''s Horn', ...
'Interpreter','latex','FontSize',14, 'EdgeColor','none', 'HorizontalAlignment', 'center');
hold off;
0 Comments
Accepted Answer
Star Strider
on 23 Jul 2024
If you want it to look more like the image you posted in your question, one option is to use the daspect function.. It allows you to specify the ratios of the three axes lengths. Adding calls to view, lightangle and lighting rotates tthe plot and produces the light reflection effect.
Try this —
% Define the function for Gabriel's Horn
gabriels_horn = @(x) 1 ./ x;
% Create a range of x values
x = linspace(1, 40, 4000); % Increase the number of points for better accuracy
y = gabriels_horn(x);
% Create the meshgrid
theta = linspace(0, 2 * pi, 6000); % Increase theta points for a smoother surface
[X, T] = meshgrid(x, theta);
Y = gabriels_horn(X) .* cos(T);
Z = gabriels_horn(X) .* sin(T);
% Plot the surface of Gabriel's Horn
figure('Position', [200, 100, 1200, 900]);
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.9);
hold on;
% Plot the central axis
plot3(x, zeros(size(x)), zeros(size(x)), 'r', 'LineWidth', 2);
% Set labels
xlabel('x');
ylabel('y');
zlabel('z');
% Adjust colormap and axis properties
colormap('gray');
shading interp; % Smooth shading
% Adjust the view
view(3);
axis tight;
grid on;
% Add formulas as text annotations
dim1 = [0.4 0.7 0.3 0.2];
annotation('textbox',dim1,'String',{'$$V = \pi \int_{1}^{a} \left( \frac{1}{x} \right)^2 dx = \pi \left( 1 - \frac{1}{a} \right)$$', ...
'', ... % Add an empty line for larger gap
'$$\lim_{a \to \infty} V = \lim_{a \to \infty} \pi \left( 1 - \frac{1}{a} \right) = \pi$$'}, ...
'Interpreter','latex','FontSize',12, 'EdgeColor','none', 'FitBoxToText', 'on');
dim2 = [0.4 0.5 0.3 0.2];
annotation('textbox',dim2,'String',{'$$A = 2\pi \int_{1}^{a} \frac{1}{x} \sqrt{1 + \left( -\frac{1}{x^2} \right)^2} dx > 2\pi \int_{1}^{a} \frac{dx}{x} = 2\pi \ln(a)$$', ...
'', ... % Add an empty line for larger gap
'$$\lim_{a \to \infty} A \geq \lim_{a \to \infty} 2\pi \ln(a) = \infty$$'}, ...
'Interpreter','latex','FontSize',12, 'EdgeColor','none', 'FitBoxToText', 'on');
% Add Gabriel's Horn label
dim3 = [0.3 0.9 0.3 0.1];
annotation('textbox',dim3,'String','Gabriel''s Horn', ...
'Interpreter','latex','FontSize',14, 'EdgeColor','none', 'HorizontalAlignment', 'center');
hold off
daspect([3.5 1 1]) % daspect([x y z])
view(-27, 15)
lightangle(-50,0)
lighting('gouraud')
Make appropriate changes to get the result you want.
.
0 Comments
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!