フィルターのクリア

Generating points on flattened sphere

1 回表示 (過去 30 日間)
Ghulam Murtaza
Ghulam Murtaza 2016 年 8 月 27 日
コメント済み: John D'Errico 2016 年 8 月 28 日
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 Center および File Exchange2-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