3d Hemisphere transformation Problem from A to 90 degrees in Z axis to B direction

조회 수: 1 (최근 30일)
%code for A
N=500;
r = 6;
center = [2,1,3];
plot3(center(1),center(2),center(3),'ro')
hold on
P = zeros(N,3) ;
for i=1:N
x1 = rand;
x2 = rand;
Px = r*sqrt(x1*(2-x1))* cos(2*pi*x2);
Py = r*sqrt(x1*(2-x1))* sin(2*pi*x2);
Pz = r*(1-x1);
P(i,:) = [Px, Py, Pz]+center;
end
hold on
plot3(P(:,1), P(:,2), P(:,3),'.r')
to

채택된 답변

David Goodmanson
David Goodmanson 2019년 5월 5일
Hi Musa,
In the figure you don't say which axis is which, but I will assume +x axis out of the page toward the viewer, +y axis right, +z axis up. With the figure rotated as shown, the old z coordinates are along the +y axis and the old y coordinates are along the -z axis. It's possible to use rotation matrices for this, but in the 90 degree case it's easier to just change the coordinate labels as shown in plot 2 below.
N=1000;
r = 6;
center = [2,1,3];
figure(1)
plot3(center(1),center(2),center(3),'b*')
hold on
P = zeros(N,3) ;
for i=1:N
x1 = rand;
x2 = rand;
Px = r*sqrt(x1*(2-x1))* cos(2*pi*x2);
Py = -r*sqrt(x1*(2-x1))* sin(2*pi*x2);
Pz = r*(1-x1);
P(i,:) = [Px, Py, Pz]+center;
end
hold on
plot3(P(:,1), P(:,2), P(:,3),'.r')
axis equal
xlabel('x'); ylabel('y'); zlabel('z')
hold off
figure(2)
plot3(center(1),center(2),center(3),'b*')
hold on
P = zeros(N,3) ;
for i=1:N
x1 = rand;
x2 = rand;
Px = r*sqrt(x1*(2-x1))* cos(2*pi*x2);
Pz = -r*sqrt(x1*(2-x1))* sin(2*pi*x2);
Py = r*(1-x1);
P(i,:) = [Px, Py, Pz]+center;
end
hold on
plot3(P(:,1), P(:,2), P(:,3),'.r')
view([4 -1.2 .8])
xlabel('x'); ylabel('y'); zlabel('z')
axis equal
hold off
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by