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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Generation and Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!