Hi,
I am trying to create a hyperbolic paraboloid much like the one I have below, but instead of having a square region as shown, I would like to have an ellipse (to give an effect similar to the roof shape on the Calgary Olympic stadium).
My problem is that I have only used the "meshgrid" command in matlab to generate square/rectangular regions so I am unsure how to do this. I think I need to find an appropriate parametrization of an ellipse in order to produce the result I am after. I can see that if I wanted a circle I would use a parametrization of radius and the angle theta but for an ellipse where the radius is not constant I am pretty confused on how to achieve this.
Any help would be greatly appreciated,
Regards Elbarto
Code for images below
Code:%Hyperbolic paraboloid x = [-10:.5:10]; y=[-10:.5:10]; [X, Y] = meshgrid(x,y); Z = X.^2-Y.^2; surf(X,Y,Z) xlabel x ylabel y zlabel z
%================================================= =========================
%"I am trying to create a hyperbolic paraboloid much like the one I have
% below, but instead of having a square region as shown, I would like to
% have an ellipse (to give an effect similar to the roof shape on the
% Calgary Olympic stadium).
% My problem is that I have only used the "meshgrid" command in matlab
% to generate square/rectangular regions so I am unsure how to do this.
% I think I need to find an appropriate parametrization of an ellipse
% in order to produce the result I am after. I can see that if I wanted
% a circle I would use a parametrization of radius and the angle theta
% but for an ellipse where the radius is not constant I am pretty confused
% on how to achieve this."
% Any help would be greatly appreciated,
%
% Regards Elbarto
%
% ANSWER:
% Follow the answer to your question!
% Prof. Diomar Cesar Lobao PhD.
% www.professores.uff.br/diomar_cesar_lobao
%================================================= =========================
%
clear all; clc; close all;
%
%Hyperbolic paraboloid
figure(1)
%
a = 2.0; % major axis
b = 1.0; % minor axis
x = [-10:0.015:10];
y=[-10:0.015:10];
[X, Y] = meshgrid(x,y);
Z = X.^2-Y.^2;
surf(X,Y,Z)
xlabel x
ylabel y
zlabel z
%
figure(2)
%
%
[I,J] = find((X.^2/a^2 + Y.^2/b^2) <= 1); % Trick here!!!
%
for k=1:size(I,1)
tmy(I(k),J(k))=X(I(k),J(k));
tmz(I(k),J(k))=Y(I(k),J(k));
tmu(I(k),J(k))=(tmy(I(k),J(k))^2 - tmz(I(k),J(k))^2);
end
end
%
%
surf(tmy,tmz,tmu);
%