Effacer les filtres
Effacer les filtres

Generating points on flattened sphere

1 vue (au cours des 30 derniers jours)
Ghulam Murtaza
Ghulam Murtaza le 27 Août 2016
Commenté : John D'Errico le 28 Août 2016
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 commentaire
John D'Errico
John D'Errico le 28 Août 2016
Why do you think the code that you have is inadequate? Where is the problem?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by