plotting a 3d surface on the screen of an oscilloscope

조회 수: 1 (최근 30일)
EMMANUEL VIRATEL
EMMANUEL VIRATEL 2021년 1월 31일
Hello everyone,
I'm Emmanuel, a student from Toulouse (France). I've found this exemple on mathworks
and it works but i want to get the coordonates in a plan 2D in order to send it to the soundcard of my computer and drawing it on my oscilloscope. I want to get the most beautiful figure. I've made a script (after the original script, it use the function viewmtx), but i'm not satisfy by the result. Pleased would you help me!!!
my email: viratelemmanuel@yahoo.fr
The original script from mathworks
theta = 0:pi/40:pi; % polar angle
phi = 0:pi/20:2*pi; % azimuth angle
[phi,theta] = meshgrid(phi,theta); % define the grid
degree = 6;
order = 1;
amplitude = 90;
radius = 5;
Ymn = legendre(degree,cos(theta(:,1)));
Ymn = Ymn(order+1,:)';
yy = Ymn;
for kk = 2: size(theta,1)
yy = [yy Ymn];
end
yy = yy.*cos(order*phi);
order = max(max(abs(yy)));
rho = radius + amplitude*yy/order;
r = rho.*sin(theta); % convert to Cartesian coordinates
x = r.*cos(phi);
y = r.*sin(phi);
z = rho.*cos(theta);
figure
s = surf(x,y,z);
light % add a light
lighting gouraud % preferred lighting for a curved surface
% axis equal off % set axis equal and remove axis
% view(40,-10) % set viewpoint
camzoom(1.5) % zoom into scene
scale = [ linspace(1,-1,40)]; % surface scaling (0 to 1 to -1)
while true
for ii = 1:length(scale)
rho = scale(ii)*amplitude;
% r = rho.*sin(theta);
% x = r.*cos(phi);
% y = r.*sin(phi);
% z = rho.*cos(theta);
%
% s.XData = x; % replace surface x values
% s.YData = y; % replace surface y values
% s.ZData = z; % replace surface z values
view(rho,rho);
pause(0.05) % pause to control animation speed
end
end
My script with viewmtx and a projection
theta = 0:pi/40:pi; % polar angle
phi = 0:pi/20:2*pi; % azimuth angle
[phi,theta] = meshgrid(phi,theta); % define the grid
degree = 6;
order = 1;
amplitude = 90;
radius = 5;
Ymn = legendre(degree,cos(theta(:,1)));
Ymn = Ymn(order+1,:)';
yy = Ymn;
for kk = 2: size(theta,1)
yy = [yy Ymn];
end
yy = yy.*cos(order*phi);
order = max(max(abs(yy)));
rho = radius + amplitude*yy/order;
r = rho.*sin(theta); % convert to Cartesian coordinates
x = r.*cos(phi);
y = r.*sin(phi);
z = rho.*cos(theta);
scale = [ linspace(1,-1,40)];
for ii = 1:length(scale)
rho = scale(ii)*amplitude;
%A = viewmtx(-37.5,30);
A = viewmtx(rho,rho);
r=x(23,:);
b=y(20,:);
c=z(20,:);
m=41;
n=1;
x4d = [r;b;c;ones(n,m )];
x2d = A*x4d;
x2 = zeros(m,n); y2 = zeros(m,n);
x2(:) = x2d(1,:);
y2(:) = x2d(2,:);
plot(x2,y2);
% ones(m*n,1)
% plot(y(:,t),z(:,t));
pause (0.5)
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Physical and Time Unit Conversions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by