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 Center および File ExchangeSignal Generation and Preprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by