Generating points on flattened sphere

2 次查看(过去 30 天)
hi i am new in matlab I have a flattened sphere x1^2+0.01*x2^2+x3^2=1; I have code but it does not give exact results.
function A = rand_pick_sphere(n,a,b,X,Y,Z)
% Uniform points in a shell of inner radius a, outer radius b and center at
% (X,Y,Z)
% [x,y,z] = rand_pick_sphere(300,.5,.6); % 300 points in shell between
% r = .5 and r = .6, with center at origin.
if nargin==3
X = 0;
Y = 0;
Z = 0;
end
r1 = (rand(n,1)*(b^3-a^3)+a^3).^(1/3);
phi1 = acos(-1 + 2*rand(n,1));
th1 = 2*pi*rand(n,1);
% Convert to cart.
x = r1.*sin(phi1).*sin(th1) + X
y = r1.*sin(phi1).*cos(th1) + Y
z = r1.*cos(phi1) + Z
A=[x y z];
how can generates points that lies on this sphere plz help me
  1 个评论
John D'Errico
John D'Errico 2016-8-28
Why do you think the code that you have is inadequate? Where is the problem?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by